rot
2010-11-17 23:55
supercollider
clean-up #3:
Beat rotation as described here...
music.columbia.edu/~douglas/strange_things/?p=78 (archive.org)
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, "/Users/asdf/soundfiles/amen.wav") //***edit to match***
b.numChannels //use instrument \segStereo for 2 channel files and instrument \segMono for 1 channel files
~bpm= 60/(b.duration/16) //calculate tempo in bpm. 16 is the number of beats in the file. ***edit to match***
c= TempoClock(~bpm/60); //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, //***edit to match***
\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.
Attachments: | |
---|---|
extSequenceableCollection-rot.sc_.zip |