Wicked - there is no documentation of AnalogIn or DigitalIn, so knowing what they can actually do with examples is really needed:
Code i'm trying:
// 1am anger.
SynthDef(\shh, {
arg out=~outBack, t_trig=0;
var sound, env;
sound = Mix(LFPulse.ar(110*[1,5/2],0.0,0.5,0.2));
env = EnvGen.ar(Env.perc(0.02,0.2), t_trig);
sound = Pan2.ar(sound * env,0.0);
Out.ar(out, sound);
}, [\tr]).add;
~buttonMonitor = {
var d0 = DigitalIn.kr(0); // Digital pin 0 - Button
var d1 = DigitalIn.kr(1); // Digital pin 1 - Button
var d2 = DigitalIn.kr(2); // Digital pin 2 - Button
var d3 = DigitalIn.kr(3); // Digital pin 3 - Button
SendReply.kr(Impulse.kr(10), '/buttonMonitor', [d0, d1, d2, d3]);
}.play;
~button1 = 0;
~button2 = 0;
~button3 = 0;
~button4 = 1;
// Listen to the buttons
OSCdef('listenToButtons', {
arg msg;
// Buttons
~button1 = msg[3].asInteger;
~button2 = msg[4].asInteger;
~button3 = msg[5].asInteger;
~button4 = msg[6].asInteger;
["Buttons: " ++ ~button1, ~button2, ~button3, ~button4 ].postln;
}, '/buttonMonitor');
{
q = Synth(\shh);
q.set(\t_trig, Pfunc({~button3}));
};
Trying to get any 'button' to actually trigger a sound, nothing seems to work and it's an endless hole of errors in the console.
Trying to also trigger one sound in a sequence of buffers, so each button is the next buffer number, which is as simple as saying, have a DigitalIn choose from an array of numbers.