2023-04-24 05:54:24 +00:00
|
|
|
|
2023-09-23 05:05:08 +00:00
|
|
|
|
2023-04-24 05:54:24 +00:00
|
|
|
(
|
|
|
|
~modes = [
|
|
|
|
[ "saw", \pos_saw ],
|
|
|
|
[ "reverse", \pos_reverse ],
|
|
|
|
[ "sine", \pos_sine ],
|
|
|
|
[ "step", \pos_step ],
|
|
|
|
[ "random", \pos_random ]
|
|
|
|
];
|
|
|
|
|
2023-09-23 05:05:08 +00:00
|
|
|
~outputDir = Platform.recordingsDir +/+ "GrainBuffers";
|
|
|
|
|
|
|
|
|
2023-04-24 06:49:36 +00:00
|
|
|
~grainsb = Bus.audio(s, 2);
|
|
|
|
|
2023-04-24 05:54:24 +00:00
|
|
|
~granulators = Array.new(4);
|
|
|
|
~posb = Array.new(4);
|
2023-09-17 00:11:31 +00:00
|
|
|
~rectriggerb = Array.new(4);
|
2023-04-24 05:54:24 +00:00
|
|
|
~possynths = Array.new(4);
|
2023-09-17 00:11:31 +00:00
|
|
|
~triggersynths = Array.new(4);
|
|
|
|
|
|
|
|
// create the control busses
|
2023-04-24 05:54:24 +00:00
|
|
|
|
|
|
|
(0..3).do({
|
2023-09-17 00:11:31 +00:00
|
|
|
var ps;
|
|
|
|
~posb.add(Bus.control(s, 1));
|
|
|
|
~rectriggerb.add(Bus.control(s, 1));
|
2023-04-24 05:54:24 +00:00
|
|
|
});
|
|
|
|
|
2023-09-17 00:11:31 +00:00
|
|
|
// start the granulators
|
2023-04-24 05:54:24 +00:00
|
|
|
|
|
|
|
(0..3).do({ |i|
|
2023-09-17 00:11:31 +00:00
|
|
|
var pb = ~posb[i], rtb = ~rectriggerb[i];
|
|
|
|
~granulators.add(Granulator.new(~buflen, ~infxb, ~grainsb, pb, rtb));
|
2023-04-24 05:54:24 +00:00
|
|
|
});
|
|
|
|
|
2023-09-17 00:11:31 +00:00
|
|
|
|
|
|
|
// launch the pos synths and triggers to sync the buffer recorders
|
|
|
|
|
|
|
|
(0..3).do({ |i|
|
|
|
|
var pb = ~posb[i], rtb = ~rectriggerb[i];
|
|
|
|
~possynths.add(Synth(\pos_saw, [ \out, pb, \speed, 1 / ~buflen ]));
|
|
|
|
~triggersynths.add(Synth(\trigger, [ \out, rtb ]));
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO - retrigger the buffer records when changing the length etc
|
|
|
|
|
2023-04-24 05:54:24 +00:00
|
|
|
~setmode = {
|
|
|
|
arg track, mode;
|
|
|
|
var synth = ~modes[mode][1];
|
|
|
|
~possynths[track].get(\speed, { | speed |
|
|
|
|
~possynths[track].free;
|
2023-09-17 00:11:31 +00:00
|
|
|
~triggersynths[track].free;
|
2023-04-24 05:54:24 +00:00
|
|
|
~possynths[track] = Synth(synth, [\out, ~posb[track], \speed, speed]);
|
2023-09-17 00:11:31 +00:00
|
|
|
~triggersynths[track] = Synth(\trigger, [ \out, ~rectriggerb[track] ]);
|
2023-04-24 05:54:24 +00:00
|
|
|
});
|
|
|
|
~granulators[track].mode_(mode);
|
|
|
|
};
|
|
|
|
|
2023-09-23 05:05:08 +00:00
|
|
|
~dumpbuffers = { |prefix|
|
|
|
|
(0..3).do({|i|
|
|
|
|
var filename = ~outputDir +/+ prefix ++ 'buffer' ++ i.asString ++ '.aiff';
|
|
|
|
~granulators[i].buffer.write(filename);
|
|
|
|
});
|
|
|
|
}
|
2023-04-24 06:49:36 +00:00
|
|
|
)
|