418 lines
10 KiB
Plaintext
418 lines
10 KiB
Plaintext
/************************
|
|
* MIDI / OSC MAPIRANJE *
|
|
***********************/
|
|
|
|
NetAddr.langPort;
|
|
|
|
/***********************************
|
|
* OSC MAPPING: Povezava na simona *
|
|
**********************************/
|
|
(
|
|
|
|
//~simonIP = "10.42.1.2";
|
|
~simonIP = "192.168.0.171";
|
|
~oscS = NetAddr.new(~simonIP, 57120);
|
|
OSCFunc.trace(true); // debug osc
|
|
OSCFunc.trace(false); // debug osc
|
|
|
|
~senzorji.keys.do({ |id|
|
|
~senzorji[id].postln;
|
|
|
|
OSCdef.new((\accOSC ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accX", msg[1].linlin(-50, 50, 0, 1));
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accY", msg[2].linlin(-50, 50, 0, 1));
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accZ", msg[3].linlin(-50, 50, 0, 1));
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accSum", msg[4].linlin(-50, 50, 0, 1));
|
|
}, "/acc/" ++ id);
|
|
|
|
OSCdef.new((\eulerOSC ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
//[pitch, roll, yaw].postln;
|
|
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/pitch", pitch);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/roll", roll);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/yaw", yaw);
|
|
//["simon", pitch, roll, yaw].postln;
|
|
}, "/euler/" ++ id);
|
|
});
|
|
|
|
)
|
|
|
|
|
|
|
|
/************************************
|
|
* MIDI MAPPING: Povezava na boruta *
|
|
***********************************/
|
|
|
|
// Midi mapping funkcija
|
|
|
|
(
|
|
~midiVals = Dictionary.new;
|
|
~sendMidi = { | chan=0, cc=0, val=0 |
|
|
var key = chan.asString ++ "_" ++ cc, v = val;
|
|
v = val.floor.clip(0, 127);
|
|
if ((~midiVals[key] == nil) || (~midiVals[key] != val)) {
|
|
~midiVals[key] = val;
|
|
~midi.control(chan, cc, val);
|
|
["midi " ++ ~map, chan, cc, v].postln;
|
|
};
|
|
};
|
|
)
|
|
|
|
// MIDI MAP I
|
|
(
|
|
|
|
"MIDI MAP I !!!".postln;
|
|
~map = "I";
|
|
~senzorji.keys.do({ |id|
|
|
|
|
OSCdef.new((\eulerMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw, freq, gain;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
|
|
// quick 16 (1) = frekvenca, quick 17 (2) = gain
|
|
switch (id,
|
|
4, {
|
|
freq = roll;
|
|
// Quick slots 1-3
|
|
~sendMidi.value(0, 16, freq * 127);
|
|
},
|
|
1, {
|
|
gain = yaw;
|
|
if (gain <= 0.5, {
|
|
gain = 0.5 - gain;
|
|
}, {
|
|
gain = gain - 0.5;
|
|
});
|
|
~sendMidi.value(0, 17, 64 + (gain * 127));
|
|
}
|
|
);
|
|
}, "/euler/" ++ id);
|
|
|
|
OSCdef.new((\accMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
// Pospeski: gremo od 0 ali iz sredine?
|
|
var accX, accY, accZ, accSum;
|
|
accX = msg[1].linlin(-50, 50, 0, 1);
|
|
accY = msg[2].linlin(-50, 50, 0, 1);
|
|
accZ = msg[3].linlin(-50, 50, 0, 1);
|
|
accSum = msg[4].linlin(-50, 50, 0, 1);
|
|
|
|
/*
|
|
switch (id,
|
|
3, {
|
|
~sendMidi.value(0, 19, (accX * 127).floor);
|
|
~sendMidi.value(0, 20, (accY * 127).floor);
|
|
~sendMidi.value(0, 21, (accZ * 127).floor);
|
|
}
|
|
);
|
|
*/
|
|
|
|
}, "/acc/" ++ id);
|
|
});
|
|
)
|
|
|
|
// MIDI MAP II
|
|
(
|
|
|
|
~map = "II";
|
|
"MIDI MAP II !!!".postln;
|
|
~senzorji.keys.do({ |id|
|
|
|
|
OSCdef.new((\eulerMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
|
|
// MORPHING EFEKT
|
|
switch (id,
|
|
4, {
|
|
// Quick slots 1-3
|
|
~sendMidi.value(0, 16, (-20 + (yaw * 150)).floor);
|
|
},
|
|
3, {
|
|
~sendMidi.value(0, 17, (-20 + (roll * 150).floor));
|
|
}
|
|
);
|
|
}, "/euler/" ++ id);
|
|
|
|
OSCdef.new((\accMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
// Pospeski: gremo od 0 ali iz sredine?
|
|
var accX, accY, accZ, accSum;
|
|
accX = msg[1].linlin(-50, 50, 0, 1);
|
|
accY = msg[2].linlin(-50, 50, 0, 1);
|
|
accZ = msg[3].linlin(-50, 50, 0, 1);
|
|
accSum = msg[4].linlin(-50, 50, 0, 1);
|
|
|
|
/*
|
|
switch (id,
|
|
3, {
|
|
~sendMidi.value(0, 19, (accX * 127).floor);
|
|
~sendMidi.value(0, 20, (accY * 127).floor);
|
|
~sendMidi.value(0, 21, (accZ * 127).floor);
|
|
}
|
|
);
|
|
*/
|
|
|
|
}, "/acc/" ++ id);
|
|
});
|
|
)
|
|
|
|
// MIDI MAP III
|
|
(
|
|
|
|
"MIDI MAP III !!!".postln;
|
|
~map = "III";
|
|
~senzorji.keys.do({ |id|
|
|
|
|
OSCdef.new((\eulerMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
|
|
switch (id,
|
|
3, {
|
|
// Quick slots 1-3
|
|
~sendMidi.value(0, 16, (pitch * 127));
|
|
},
|
|
4, {
|
|
~sendMidi.value(0, 17, (pitch * 127));
|
|
}
|
|
);
|
|
}, "/euler/" ++ id);
|
|
|
|
OSCdef.new((\accMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
// Pospeski: gremo od 0 ali iz sredine?
|
|
var accX, accY, accZ, accSum;
|
|
accX = msg[1].linlin(-50, 50, 0, 1);
|
|
accY = msg[2].linlin(-50, 50, 0, 1);
|
|
accZ = msg[3].linlin(-50, 50, 0, 1);
|
|
accSum = msg[4].linlin(-50, 50, 0, 1);
|
|
|
|
accSum = accSum - 0.5;
|
|
switch (id,
|
|
4, {
|
|
//~sendMidi.value(0, 18, (accSum * 256).floor);
|
|
}
|
|
);
|
|
|
|
}, "/acc/" ++ id);
|
|
});
|
|
)
|
|
|
|
// MIDI MAP IV (II)
|
|
(
|
|
|
|
~map = "IV (2)";
|
|
"MIDI MAP IV (II) !!!".postln;
|
|
~senzorji.keys.do({ |id|
|
|
|
|
OSCdef.new((\eulerMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
|
|
// MORPHING EFEKT
|
|
switch (id,
|
|
4, {
|
|
// Quick slots 1-3
|
|
~sendMidi.value(0, 16, -10 + (yaw * 150));
|
|
},
|
|
3, {
|
|
~sendMidi.value(0, 17, (roll * 150));
|
|
}
|
|
);
|
|
}, "/euler/" ++ id);
|
|
|
|
OSCdef.new((\accMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
// Pospeski: gremo od 0 ali iz sredine?
|
|
var accX, accY, accZ, accSum;
|
|
accX = msg[1].linlin(-50, 50, 0, 1);
|
|
accY = msg[2].linlin(-50, 50, 0, 1);
|
|
accZ = msg[3].linlin(-50, 50, 0, 1);
|
|
accSum = msg[4].linlin(-50, 50, 0, 1);
|
|
|
|
/*
|
|
switch (id,
|
|
3, {
|
|
~sendMidi.value(0, 19, (accX * 127).floor);
|
|
}
|
|
);
|
|
*/
|
|
|
|
}, "/acc/" ++ id);
|
|
});
|
|
)
|
|
|
|
(
|
|
|
|
~map = "V (3)";
|
|
"MIDI MAP V (3)".postln;
|
|
~senzorji.keys.do({ |id|
|
|
|
|
OSCdef.new((\eulerMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
|
|
// MORPHING EFEKT
|
|
switch (id,
|
|
4, {
|
|
// Quick slots 1-3
|
|
~sendMidi.value(0, 16, (-15 + (yaw * 150)).floor);
|
|
},
|
|
3, {
|
|
~sendMidi.value(0, 17, (-15 + (roll * 150).floor));
|
|
}
|
|
);
|
|
}, "/euler/" ++ id);
|
|
|
|
OSCdef.new((\accMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
// Pospeski: gremo od 0 ali iz sredine?
|
|
var accX, accY, accZ, accSum;
|
|
accX = msg[1].linlin(-50, 50, 0, 1);
|
|
accY = msg[2].linlin(-50, 50, 0, 1);
|
|
accZ = msg[3].linlin(-50, 50, 0, 1);
|
|
accSum = msg[4].linlin(-50, 50, 0, 1);
|
|
|
|
/*
|
|
switch (id,
|
|
3, {
|
|
~sendMidi.value(0, 19, (accX * 127).floor);
|
|
~sendMidi.value(0, 20, (accY * 127).floor);
|
|
~sendMidi.value(0, 21, (accZ * 127).floor);
|
|
}
|
|
);
|
|
*/
|
|
|
|
}, "/acc/" ++ id);
|
|
});
|
|
)
|
|
|
|
|
|
(
|
|
|
|
~map = "VI (3)";
|
|
"MIDI MAP VI (3) !!!".postln;
|
|
~senzorji.keys.do({ |id|
|
|
|
|
OSCdef.new((\eulerMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
|
|
switch (id,
|
|
3, {
|
|
// Quick slots 1-3
|
|
~sendMidi.value(0, 16, (pitch * 127).floor);
|
|
~sendMidi.value(0, 17, (yaw * 127).floor);
|
|
}
|
|
);
|
|
}, "/euler/" ++ id);
|
|
|
|
OSCdef.new((\accMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
// Pospeski: gremo od 0 ali iz sredine?
|
|
var accX, accY, accZ, accSum;
|
|
accX = msg[1].linlin(-50, 50, 0, 1);
|
|
accY = msg[2].linlin(-50, 50, 0, 1);
|
|
accZ = msg[3].linlin(-50, 50, 0, 1);
|
|
accSum = msg[4].linlin(-50, 50, 0, 1);
|
|
|
|
accSum = accSum - 0.5;
|
|
switch (id,
|
|
4, {
|
|
//~sendMidi.value(0, 18, (accSum * 200).floor);
|
|
}
|
|
);
|
|
|
|
}, "/acc/" ++ id);
|
|
});
|
|
)
|
|
|
|
(
|
|
"MIDI MAP VII (2)".postln;
|
|
~senzorji.keys.do({ |id|
|
|
|
|
OSCdef.new((\eulerMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
var pitch, roll, yaw;
|
|
|
|
// vrtenje sinusoidiziramo, da ni preskokov
|
|
pitch = msg[1].sin.linlin(-pi, pi, 0, 1);
|
|
roll = msg[2].sin.linlin(-pi, pi, 0, 1);
|
|
yaw = msg[3].sin.linlin(-pi, pi, 0, 1);
|
|
|
|
// BITCRUSH EFEKT
|
|
switch (id,
|
|
4, {
|
|
// Quick slots 1-3
|
|
~sendMidi.value(0, 16, (-10 + (yaw * 150)).floor);
|
|
},
|
|
3, {
|
|
~sendMidi.value(0, 17, (-25 + (roll * 150).floor));
|
|
}
|
|
);
|
|
}, "/euler/" ++ id);
|
|
|
|
OSCdef.new((\accMIDI ++ id).asSymbol, { |msg, time, addr, recvPort|
|
|
// Pospeski: gremo od 0 ali iz sredine?
|
|
var accX, accY, accZ, accSum;
|
|
accX = msg[1].abs.linlin(-50, 50, 0, 1);
|
|
accY = msg[2].abs.linlin(0, 50, 0, 1);
|
|
accZ = msg[3].abs.linlin(0, 50, 0, 1);
|
|
accSum = msg[4].linlin(0, 50, 0, 1);
|
|
|
|
switch (id,
|
|
1, {
|
|
/*
|
|
~sendMidi.value(0, 16, 40 + (accY * 150));
|
|
~sendMidi.value(0, 17, 40 + (accZ * 150));
|
|
*/
|
|
}
|
|
);
|
|
}, "/acc/" ++ id);
|
|
});
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// VDMX mapping setup za simona - dedicated controls
|
|
|
|
(
|
|
|
|
~senzorji.keys.do({|id|
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/pitch", 0.5);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/roll", 0.5);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/yaw", 0.5);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accX", 0.5);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accY", 0.5);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accZ", 0.5);
|
|
~oscS.sendMsg("/senzor/" ++ id ++ "/accSum", 0.5);
|
|
});
|
|
|
|
) |