You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.1 KiB

4 => int device;
13 => int ctlNrFreq;
16 => int ctlNrVol;
9 => int ctlNrAux1;
10 => int ctlNrAux2;
64 => int voicesNr;
// Midi
MidiIn min;
MidiMsg msg;
if( !min.open( device ) ) {
me.exit();
}
<<< "MIDI device:", min.num(), " -> ", min.name() >>>;
//UGENs
SinOsc s[voicesNr];
for(0 => int i; i < voicesNr-2; i++) {
s[i] => s[i+1];
s[i].sync(2);
}
s[voicesNr-3] => dac;
//params
0. => float aux1;
0. => float aux2;
0. => float freq;
0.1 => float gain;
while( true )
{
min => now;
while( min.recv(msg) ) {
<<< msg.data1, msg.data2, msg.data3 >>>;
}
if(msg.data2 == ctlNrFreq) {
msg.data3 => freq;
}
if(msg.data2 == ctlNrVol) {
msg.data3/127. => gain;
}
if(msg.data2 == ctlNrAux1) {
msg.data3/127. => aux1;
}
if(msg.data2 == ctlNrAux2) {
msg.data3/127. => aux2;
}
for(0 => int i; i < voicesNr; i++) {
voice(i);
}
}
fun void voice(int i) {
1. / voicesNr => s[i].gain;
50 + i => s[i].freq;
freq * (i+aux1) => s[i].sfreq;
gain => s[i].gain;
}