OSC to Pitch control

Dear SC Community,

i want to translate OSC Data from Processing into pitch control of an oscillator in SC. But the only way I achieve it, is that for every OSC Data received, a new Synth is triggered.

I tried it like that:

(
OSCdef.new(‘OSClistenerNEW’, {
arg msg;
var x;
msg[1].postln;
x = msg[1];
g = {SinOsc.ar(msg[1],0,0.1)};
}, “/OSC”);
x.postln;
g.play;
)

I get the OSC Data via x.postln out but the pitch of the SinOsc will stay static. If i use a SynthDef it will be triggered for each value in a new instance, which i dont want.
Do you have any idea how to make this happen?

I hope you could understand my problem.

Kind regards,
Ronald

See the set method of Node.

hjh

1 Like

Just to clarify this solution, an extremely generalized solution would look something like this:

//some sound already playing, with a controllable frequency
~synth = {arg freq=250; SinOsc.ar(freq, mul:0.2!2)}.play;

(
//an OSC listener that sends set messages
OSCdef.new('OSClistenerNEW', {
	arg msg;
	~synth.set(\freq, msg[1]);
}, '/OSC');
)

Eli

1 Like

Thank you both so much!
Now it works like i intended to.
I will definitely dig deeper into these methods.

Kind Regards,
Ronald