I am trying to make a sample payback machine, like an MPC, that will be playable with Touch OSC. Im using the second page of the Simple MKII layout from Touch OSC (for now). I want the first push button to play the first 16th of a buffer, the second to play the second slice of audio, etc. I was told to use a gate or something? I could probably create 16 different synths and write the code that way but i want to use the array capabilities of SuperCollider.
[Is there an area or topic I would like specific feedback on?]
Buffer.freeAll;
/*(
~buffers = "C:/Users/ludov/OneDrive/Bureau/UNIVERSITY Projects/SuperCollider/Projet Final/PROJET FINAL/audio/AMEN_BREAK.wav".resolveRelative.pathMatch.collect({
arg path;
Buffer.read(s, path);
});
)
*/
~b0 = Buffer.read(s,"C:/Users/ludov/OneDrive/Bureau/UNIVERSITY Projects/SuperCollider/Projet Final/PROJET FINAL/audio/AMEN_BREAK.wav.wav");
~b0.play;
~b0.query;
(
SynthDef.new(\AmenBreak1, {
arg bufnum = 0, rate = 1.0, amp = 1.0, pos = 0.0, pan = 0.0, loop = 0.0, dur = 0.5;
var sig;
16.do{
sig = PlayBuf.ar(
numChannels: 2,
bufnum: bufnum,
rate: BufRateScale.kr(bufnum)*rate,
trigger:1,
startPos: 0,
loop:0,
doneAction:2,
);
Out.ar(0, sig);
}})
)
(
~notes = Array.fill(16, {
arg i ;
i = (1/16)*i
});
)
(
16.do({//de 0 à 15
arg num;
OSCdef(("push"++(num+1)), {
arg msg;
msg.postln;
}, "/2/push"++(num+1));
})
)
(
OSCdef(\play1, {
arg msg;
msg.postln;
(msg[1] ==1).if(
{~synths = ~notes.collect{
arg note;
Synth(\AmenBreak1,
\startPos, ~notes[num]) ,
}
}),
{~synths.do{
arg synth;
synth.free}
};
}, "/2/toggle1");
)