rot

clean-up #3:

beat rotation as described here...
http://music.columbia.edu/~douglas/strange_things/?p=78
implemented as a method for SequenceableCollection. some test code...

s.boot
(
SynthDef(\segMono, {|out= 0, buffer, amp= 0.5, rate= 1, offset= 0, atk= 0.01, rel= 0.1, gate= 1|
        var env= EnvGen.ar(Env.asr(atk, amp, rel), gate, doneAction:2);
        var src= PlayBuf.ar(1, buffer, rate*BufRateScale.ir(buffer), 1, offset*BufFrames.ir(buffer));
        OffsetOut.ar(out, Pan2.ar(src*env));
}).add;
SynthDef(\segStereo, {|out= 0, buffer, amp= 0.5, rate= 1, offset= 0, atk= 0.01, rel= 0.1, gate= 1|
        var env= EnvGen.ar(Env.asr(atk, amp, rel), gate, doneAction:2);
        var src= PlayBuf.ar(2, buffer, rate*BufRateScale.ir(buffer), 1, offset*BufFrames.ir(buffer));
        OffsetOut.ar(out, src*env);
}).add;
)

b= Buffer.read(s, "sounds/amen.wav")
b.numChannels           //use instrument \segStereo for 2 channel files and instrument \segMono for 1 channel files

60/(b.duration/16)      //calculate tempo in bpm. 16 is the number of beats in the file

c= TempoClock(1/(b.duration/16));       //create a tempo clock in the tempo of the file
Pdef(\test).play(c, quant:1)
(       //rot example 1 - shuffle
Pdef(\test, Pbind(
        \instrument, \segStereo,
        \buffer, b,
        \dur, 1,
        \amp, 0.75,
        \offset, Pseq((0..15).rot(2, 1, 0, 4)/16, inf)
))
)
(       //rot example 2 - double tempo
Pdef(\test, Pbind(
        \instrument, \segStereo,
        \buffer, b,
        \dur, 0.5,
        \amp, 0.75,
        \offset, Pseq((0..15).rot(2, 1, 1, 4)/16, inf)
))
)
(       //rot example 3 - double and triple tempo
Pdef(\test, Pbind(
        \instrument, \segStereo,
        \buffer, b,
        \dur, Pseq([0.5, 0.25, 0.25], inf),
        \amp, 0.75,
        \offset, Pseq((0..15).rot(0, 1, 1, 8)/16, inf)
))
)
(       //rot example 4 - subdivide into 32 segments
Pdef(\test, Pbind(
        \instrument, \segStereo,
        \buffer, b,
        \dur, Pseq([0.5, 0.25, 0.25], inf),
        \amp, 0.75,
        \offset, Pseq((0..31).rot(1, 1, 1, 4)/32, inf)
))
)
(       //rot example 5 - back to original
Pdef(\test, Pbind(
        \instrument, \segStereo,
        \buffer, b,
        \dur, 1,
        \amp, 0.75,
        \offset, Pseq((0..15).rot(0, 0, 0, 4)/16, inf)
))
)
Pdef(\test).stop
b.free;

in the mp3 recording of the above code, each rotation example gets to play for 16 beats.


AttachmentSize
Package icon extSequenceableCollection-rot.sc_.zip924 bytes