I am trying to wrap my head around Ctk and reached a stumbling point here:
I would like to generate a score which streams audio files from disk, one at a time, but many different files for a very long time. I can see how to make a CtkBuffer to do this once, but I can’t figure out how to schedule it to re-cue itself at a certain time in the score…
(
var audioPath = "/Users/ericsluyter/mono.wav";
var score = CtkScore();
var stream = CtkNoteObject(
SynthDef(\stream, {
var buf = \buf.kr(0);
var sig = VDiskIn.ar(1, buf, 1);
var amp = \amp.kr(0.1);
var out = \out.kr(0);
Out.ar(out, sig * amp);
});
);
var streamBuf = CtkBuffer.diskin(audioPath, startFrame: 5.8 * 60 * 48000).addTo(score);
stream.new(0.5, 15).buf_(streamBuf).out_(0).addTo(score);
/* would like to cue a different point in potentially a different soundfile
and then add another stream using the same buffer at say 16 seconds */
~score = score;
)
[0.0, ['/d_recv',
SynthDef(\stream, {
var buf = \buf.kr(0);
var sig = VDiskIn.ar(1, buf, 1);
var amp = \amp.kr(0.1);
var out = \out.kr(0);
Out.ar(out, sig * amp);
}).asBytes;
]]
(Of course I should have used an envelope instead of freeing the synth like this but the bits of the sound files are separated by silence and I was lazy…)
(edit: my purpose is, in this piece there will be thousands of buffer playback events, and I am trying to reduce this down to a manageable amount of VDiskIn buffers…)