I was exploring Alberto de Campo’s examples of Wavesets operations (SC Book and Quarks), where I found the following problem. On his Wavesets Quark implementation, you basically analyse a soundfile, and annotate the zero-crossing points above a certain threshold to get the Wavesets (slices of waveform among three zero-crossing point). To play and manipulate the Wavesets, he basically creates a sampler SynthDef (based on BufRd) which runs through the soundfile – loaded into a buffer – via Patterns(a Pbindef defines how the buffer will be read). Here is a simple example from the book:
w = Wavesets.from(Platform.resourceDir +/+ "sounds/a11wlk01.wav");
(
b = w.buffer;
// Wavesets.prepareSynthDefs loads this synthdef:
SynthDef(\wvst0, { arg out = 0, buf = 0, start = 0, length = 441, playRate = 1, sustain = 1, amp=0.2, pan;
var phasor = Phasor.ar(0, BufRateScale.ir(buf) * playRate, 0, length) + start;
var env = EnvGen.ar(Env([amp, amp, 0], [sustain, 0]), doneAction: 2);
var snd = BufRd.ar(1, buf, phasor) * env;
OffsetOut.ar(out, Pan2.ar(snd, pan));
}, \ir.dup(8)).store;
)
(
Pbindef(\ws1).clear;
Pbindef(\ws1,
\instrument, \wvst0,
\startWs, Pn(Pseries(0, 1, 3435), 1),
\numWs, 1,
\playRate, 1,
\bufnum, b.bufnum,
\repeats, 1,
\amp, 0.4,
[\start, \length, \sustain], Pfunc({ |ev|
var start, length, wsDur;
#start, length, wsDur = w.frameFor(ev[\startWs], ev[\numWs]);
[start, length, wsDur * ev[\repeats] / ev[\playRate].abs]
}),
\dur, Pkey(\sustain)
).play;
)
The problem begins when you try some operations, like the following:
// waveset delete: time-contract the soundfile by deleting 'wavecycle', more simply just not reading some of them
Pbindef(\ws1, \playRate, 1.0, \startWs, Pn(Pseries(0, 4, 3435), 1)).play;
Which causes lots of late messages, showing that the patterns audio could not be handled by the server at the time they were expected to be.
Is it possible to manage this problem from the client side?
When I try to change latency, telling the server that the delivery could be done really late, like this:
Pbindef(\ws1, \playRate, 1.0, \startWs, Pn(Pseries(0, 4, 3435), 1), \latency, 1.0).play;
I do not receive late messages, but tons of FAILURE IN SERVER /s_new too many nodes
messages.
When I go futher and try really heavy stuff, I get audio glitches (big silence gaps in the audio stream):
(
~a = Pbind(
\instrument, \wvst0,
\startWs, Pn(Pseries(0, 1, 3435), 1),
\numWs, 1,
\playRate, 1,
\bufnum, b.bufnum,
\repeats, 1,
\amp, 0.4,
[\start, \length, \sustain], Pfunc({ |ev|
var start, length, wsDur;
#start, length, wsDur = w.frameFor(ev[\startWs], ev[\numWs]);
[start, length, wsDur * ev[\repeats] / ev[\playRate].abs]
}),
\dur, Pkey(\sustain)
);
)
(
Pdef(\ws1, ~a);
Pdef(\ws2, ~a);
Pdef(\ws3, ~a);
Pdef(\ws4, ~a);
Pdef(\ws5, ~a);
)
(
Pbindef(\ws1, \startWs, Pn(Pseries(0, 28, 3435), 1), \repeats, 28).play;
Pbindef(\ws2, \startWs, Pn(Pseries(0, 29, 3435), 1), \repeats, 29).play;
Pbindef(\ws3, \startWs, Pn(Pseries(0, 30, 3435), 1), \repeats, 30).play;
Pbindef(\ws4, \startWs, Pn(Pseries(0, 31, 3435), 1), \repeats, 31).play;
Pbindef(\ws5, \startWs, Pn(Pseries(0, 32, 3435), 1), \repeats, 32).play;
)
Is this a limitation of the implementation or can it be managed ?