liveconv — Partitioned convolution with dynamically reloadable impulse response
Plugin opcode in liveconv.
Computationally efficient, partitioned convolution, using a function table as impulse response (IR) source, similar to the ftconv opcode. The liveconv opcode allows dynamic reload of IR data at any time while the convolution is running, controlled by the kupdate parameter. Due to the manner in which the IR is updated, the operation can be done without audio artifacts in the convolution output.
The IR table is read partition by partition after signalling an update. The first ksmps samples must be available when the update flag is set. The rest of the table can be continuously filled in consecutive passes. There may be a new update for every partition, allowing as many as ftlen/iplen simultaneous updates (ftlen is the length of the IR table).
The low-latency, dynamic behavior of liveconv makes it ideal for convolution with live sampled impulse responses, and/or real-time impulse response transformations and modifications.
ift -- table number for storing the impulse response (IR) for convolution. The table may be filled with new data at any time while the convolution is running.
iplen -- length of impulse response partition in samples; must be an integer power of two. Lower settings allow for shorter output delay, but will increase CPU usage.
ain -- input signal.
ares -- output signal.
kupdate -- flag indicating whether the IR table should be updated. If kupdate=1 the IR table ift is loaded partition by partition, starting with the next partition. If kupdate=-1 the IR table ift is unloaded (cleared to zero) partition by partition, starting with the next partition. Other values have no effect.
kclear -- flag for clearing all internal buffers. If kclear has any value != zero, the internal buffers are cleared immediately. This operation is not free of artifacts.
Here is an example of the liveconv opcode. It uses the file liveconv.csd.
Example 523. Example of the liveconv opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> -odac ;realtime audio out </CsOptions> <CsInstruments> sr = 44100 nchnls = 2 0dbfs = 1 ; empty IR table giIR_record ftgen 0, 0, 131072, 2, 0 ; Record impulse response instr 13 p3 = ftlen(giIR_record)/sr iskip = p4 irlen = p5 a1 diskin2 "fox.wav", 1, iskip ; Fill IR table with segment from audio file amp linseg 0, 0.1, 1, irlen, 1, 0.1, 0, 1, 0 andx_IR line 0, 1, 1/(ftlen(giIR_record)/sr) tablew a1*amp, andx_IR, giIR_record, 1 outch 1, a1*amp ; output the IR ktrig init 1 if ktrig > -1 then chnset ktrig, "conv_update" ktrig -= 1 endif endin ; The convolver instr 14 ain diskin2 "drumsMlp.wav", 1, 0, 1 kupdate chnget "conv_update" aconv liveconv ain, giIR_record, 2048, kupdate, 0 outch 2, aconv*0.009 ; output the convolution response endin </CsInstruments> <CsScore> ; record impulse response ; skip IR_dur i13 0 1 0.0 0.5 i13 2 1 0.5 0.5 i13 4 1 1.0 0.5 i13 6 1 1.5 0.5 i13 8 1 2.0 0.75 i13 10 1 2.38 0.25 ; convolve i14 0.0 11.65 e </CsScore> </CsoundSynthesizer>