Some Fun with Delay

As the director of the Christopher Newport University Electronic Music Ensemble, I am always looking for interesting electronic music to perform.  I also enjoy arranging experimental pieces for electronics.  Once piece I was arranging, I decided to add different random delay times to everyones live parts.  The effect was great and really added a nice amount of unpredictability to the composition.  I was looking at using Demand Ugens and triggering different times using amplitude tracking.  The following code illustrates components of doing this.

Server.local.options.memSize = some number // the number allocates ram.  Higher delay time more ram needed

SynthDef(“test”, { arg att = 1, rel = 0.4, mdel = 2;
var thresh, al, list, b, de, delay, mix, in;
in = SoundIn.ar(0);
thresh = Amplitude.kr(in, att, rel, 1).poll;
al = (thresh > 0.02);
list =( (0 .. 1000).collect({|n| n})/500);// change the 500 to change the randomized amount of delay.
b = Dxrand(list, inf) ; //to be a maximum of 2 seconds
de = Demand.kr(al, 0, b);
delay = DelayN.ar(in, mdel, de, 0.5); // the mdel is max delay time in seconds
mix = Mix.ar([in, delay]);
Out.ar(0, mix);
}).play

I am then using the Amplitude.kr with a very short attack and release to monitor the live input signal coming from a microphone.  the thresh > 0.02 triggers Demand.kr to “demand” a value from DXrand which gets its value from list

Finally, the number selected is given to the DelayN.ar Ugen to delay the signal.  This little synthdef is a lot of fun to play around with and I plan on developing it further to add feedback factors and spatialization.

Leave a comment