I want to calculate the derivation of incoming OSC Data to use them as a modulator for my synth. I tried to afford that using an array. Unfortunately, the code is not repeated, as I intented to and I dont know how to implement it correctly. Does anyone have a quick solution or a hint for me?
OSCdef.new(‘OSClistenerNEW’, {
arg msg;
var z, d;
z = Array.with(0,0); //Derivation of OSC_data
z.put(0, msg[1]);
z.put(1, z[0]);
d = z[1] - z[0];
msg[1].postln;
d.postln;
I think the problem is that you reallocate a new array z every time you receive the OSC_data msg.
You should probably move the z = Array.with line outside the OSCdef.
This makes sense because your code is setting z[0] = msg, and z[1] = z[0]. So both entries in the array are identical. And later when you subtract one from the other you end up with d == 0.
It would be helpful to know what the OSC data stream looks to help find a way to proceed.