(
-// TODO: for whatever reason when called from mac os,
-// every method here is executed 4 times
-
~samplerFactory = {
var maxDur = 10.0;
var sampler = Environment[
- \version -> "33.7.2.3",
+ \version -> "33.7.4.1",
\maxDur -> maxDur,
\synthName -> \samplerPlay,
\buf -> Buffer.alloc(s, s.sampleRate * maxDur, 1),
Out.ar(out, sig!2);
}).add,
\startRec -> { |zi, pleiPich=false|
- "startRec called".postln;
zi.startPos = 0.0;
zi.recSynth = Synth(\samplerRecord, [\input, s.inputBus, \buf, zi.buf], addAction: \addToTail);
zi.endPos = s.sampleRate * 10;
\startPos -> 0,
\duration -> 0,
\stopRec -> { |zi|
- "stopRec called".postln;
zi.duration = min(thisThread.seconds - zi.startTime, 10);
zi.recSynth.free;
if (zi.pleiPich, {
});
},
\playSample -> { |zi|
- "playSample called".postln;
zi.playSynth = Synth(\samplerPlay,
[\out, 0, \buf, zi.buf, \startPos, zi.startPos, \duration, zi.duration],
addAction: \addToHead);
zi.playSynth.set(\gate, 0);
},
\makeSynthBind -> { |zi|
- "makeSynthBind called".postln;
Pbind(
\instrument, \samplerPlay,
\buf, zi.buf,
);
},
\makeSynthArgs -> { |zi|
- "makeSynthArgs called".postln;
[
\buf, zi.buf,
\startPos, zi.startPos,
},
\shiftPos -> { |zi, delta|
var endPos = zi.startPos + zi.duration;
- ("shiftPos called"++[delta, endPos, zi.startPos, zi.duration]).postln;
zi.startPos = (zi.startPos + delta).clip(0, endPos);
zi.duration = endPos - zi.startPos;
zi.buf.loadToFloatArray(zi.startPos*zi.buf.sampleRate, zi.duration*zi.buf.sampleRate, action: { |array|