hello jamshark!
I am sorry again for the not formated code, but I put this answer directly via email.
here is my complete code:
it partially works, but the „play“ routine is not reset, and the .defer and timeout settings are ignored, when playing it with a sustain pedal.
I guess, the MIDIdef comes in in a wrong place?
(
~numSpeakers = 2; // sets the number of available speakers (currently 2, will finally be set to 4)
s.options.numOutputBusChannels = ~numSpeakers; // sets accordingly the number of output channels
s.options.memSize= 1000000000;
s.boot;
)
(
Buffer.freeAll;
~pS = PathName(thisProcess.nowExecutingPath).parentPath ++ “projectSamples”;
~samples = ();
s.waitForBoot(~samples = PathName(~pS).files.collect({|n| Buffer.readChannel(s, n.fullPath, 0, -1, [0])}), limit: 100);
)
~samples.at(0).play;
(
SynthDef(\player, {
var env, sig;
env = Env.asr(
0.01, 1.0, 0.01, -4
).ar(2, [gate.kr](http://gate.kr)(1));
sig = PlayBuf.ar(
1, [bufnum.kr](http://bufnum.kr)(0), [pbRate.kr](http://pbRate.kr)(1), loop: 0
);
sig = sig * env;
sig = sig * [amp.kr](http://amp.kr)(1.0);
OffsetOut.ar([out.kr](http://out.kr)(0), sig)
}).add;
)
~testPlayer = Synth(\player, [\amp, 1]);
~testPlayer.set(\gate, 0);
(
~t1 = TempoClock(60 / 60).permanent_(true);
~bufnum = Pseq([0, Pseq((1…8).scramble, 1), 9], 1).asStream;
~speakerSeq = Pxrand((0…(~numSpeakers - 1)), inf).asStream;
~previousPlayer = nil;
~sendSwitchTrigger = {
~previousPlayer !? {|p| p.set(\gate, 0) };
~previousPlayer = Synth(\player, [\bufnum, ~bufnum.next, \out, ~speakerSeq.next]);
};
)
(
MIDIIn.connectAll;
MIDIdef.freeAll;
MIDIdef.cc(\ped1, {
val, ccNum, chan, src| val.postln;
~sendSwitchTrigger.set(\trig, val)
},
[ccNum: 64, chan: 0, src: “DOREMiDi MPC-20-13C4”]
).permanent_(true);
)
)
(
~play = Routine{
~bufnum = Pseq([0, Pseq((1…8).scramble), 9], inf).asStream; // deffines the sequence of audio samples to be played
~speakerSeq = Pxrand((0…(~numSpeakers - 1)), inf).asStream; // defines the sequence of speakers
10.do{
~previousPlayer;
0.yield;
}.yieldAndReset(reset: true);
};
)
~perform = {~play.next}.defer(rrand(0.0, 2.0));
(
~go = {
~play.next;
if(~timeout.notNil) { ~timeout.stop };
~timeout = Routine {
10.wait;
~play.reset;
}.play;
};
)
great thanks for any advise!best
Rainer