Concat Concatenative Cross-Synthesis on Live Streams 


Concat.ar(control, source, storesize, seektime, seekdur, matchlength, freezestore, zcr, lms, sc, st)


Implementation of concatenative sound synthesis based on matching four features from a control input to the database generated from a source input. The control determines which frames of the source get played back, and you can change the weighting of features to refine your matching criteria (ie, make rms the most heavily weighted to have amplitude as the most important criteria).  You can also modulate the match length, being the amount of source played back for a match, the feature weightings, and freeze the database collection to work with a collected sample from the source. 


Refs- see the publications of Schwarz, Sturm, Casey amongst others. 


control- audio rate input, acts as control 

source- audio rate input, source for cross-synthesis 

storesize- size of source store sample buffer in seconds

seektime- Time in seconds into the past to start searching for matches  

seekdur- Time in seconds from seektime towards the present to test matches

matchlength- Match length in seconds (this will be rounded to the nearest FFT frame) 

freezestore- Stop collecting novel source input, keep store (database) fixed

zcr- Weight for zero crossing rate feature

lms- Weight for log mean square amplitude feature

sc- Weight for spectral centroid feature

st- Weight for spectral tilt feature



//examples


b = Buffer.read(s,"sounds/a11wlk01.wav");



//match only on amplitude from audio in

(

SynthDef(\concat1, {arg bufnum, matchlength=0.01, freeze=0;

var concat, control, input;


control= SoundIn.ar;


input=PlayBuf.ar(1,bufnum,BufRateScale.kr(bufnum), loop:1); 


concat= Concat.ar(control,input,1.0,1.0,1.0,matchlength,freeze,0.0,1.0,0.0,0.0);


Out.ar(0,Pan2.ar(concat,0.0))}).add;

)


a=Synth(\concat1,[\bufnum, b.bufnum]);


a.set(\freeze, 0);


a.set(\matchlength, 0.01);








//synthesis controls audio in- beat box, then the synth drives bits of audio rhythmically

(

{

var concat, control, input;


control= SinOsc.ar(0.5)*Saw.ar(SinOsc.kr(LFNoise0.kr(MouseY.kr(0.01,1),3,4.5),0,50,MouseY.kr(120,500)));


input=SoundIn.ar; 


concat= Concat.ar(control,input,4.0,4.0,4.0,MouseX.kr(0.0,0.5),0,0.5,1.0,0.5,0.0);


Out.ar(0,Pan2.ar(concat,0.0))}.play

)




//audio in controls synthesis, low latency, match by ZCR and spec centroid

(

{

var concat, control, input, amp;


input= SinOsc.ar(2)*

Mix(Gendy3.ar(3,5,1.0,1.0,(Array.fill(5,{LFNoise0.kr(1.3.rand,1,2)})*MouseY.kr(100,3780,'exponential')),MouseY.kr(0.01,0.05),MouseY.kr(0.001,0.016),5,mul:0.1));


control=SoundIn.ar; 


amp=Amplitude.ar(control);


concat= Concat.ar(control,input,1.0,1.0,1.0,MouseX.kr(0.0,0.1),0,1.0,0.0,1.0,1.0);


Out.ar(0,Pan2.ar(10*concat*amp,0.0))}.play

)




//granulator

(

{

var concat, control, input;


control= Saw.ar(SinOsc.kr(LFNoise0.kr(MouseY.kr(0.01,1),3,4.5),0,10,MouseY.kr(12,100)));


input=PlayBuf.ar(1,b.bufnum,BufRateScale.kr(b.bufnum), loop:1); 


concat= Concat.ar(control,input,2.0,2.0,2.0,MouseX.kr(0.01,0.1),0,MouseY.kr(0.0,1.0),1.0,0.5);


Out.ar(0,Pan2.ar(concat,0.0))}.play

)






b = Buffer.read(s,"sounds/break2");



//beat resynthesis match by ZCR and spec centroid

(

SynthDef(\concatexample2, {arg bufnum, freeze=0;

var concat, control, input, amp;


input= SoundIn.ar;


control=PlayBuf.ar(1,bufnum,BufRateScale.kr(bufnum), loop:1); 


amp=Amplitude.ar(control);


concat= Concat.ar(control,input,5.0,5.0,5.0,MouseX.kr(0.0,0.1),freeze,MouseY.kr(0.0,1.0),0.0,1.0);


Out.ar(0,Pan2.ar(10*concat*amp,0.0))

}).add;

)



a=Synth(\concatexample2,[\bufnum, b.bufnum]);


a.set(\freeze, 1); //set this on or off to stay with a set of collected sounds


a.set(\freeze, 0); //set this on or off to stay with a set of collected sounds