Sending OSC messages from SC to Blender

Hi all

I am trying to send OSC messages from SuperCollider to Blender.
In Blender I am using the AddRoutes plugin (AddRoutes | JPfeP)
I could send OSC to Blender with open-stage-control.

Blender listens for OSC messages on: 0.0.0.0:9001.

That’s my code:

(
(
SynthDef(\modulator, {
	Out.kr(\out.kr(0), LFNoise2.kr(\freq.kr(1, 0.5)).range(-10, 10));
}).add;
);

~bus = Bus.control(s,1);
~modulatorSynth = Synth(\modulator, [out: ~bus]);



~proc = NetAddr("0.0.0.0", 9001);

(
OSCdef(\blender, {
	~proc.sendMsg("/mod", ~bus.getSynchronous.asFloat);
}, "/blender/01");
)
)

Thanks for your help!

I’m no expert but maybe this:

should be:
~proc = NetAddr("127.0.0.1", 9001);

127.0.0.1 is usually used to send to another app on the same device

Best,
Paul

Hello Paul

Actually by default in Blender the Address is: 0.0.0.0
But it’s no change with 127.0.0.1

OSCdef listens for OSC messages. You want to send the values from the server to the language, and then from the language to blender, e.g as follows:

(
s.waitForBoot {
	OSCdef.freeAll;

	b = NetAddr.new("127.0.0.1", 9001); // create the NetAddr to send to blender

	SynthDef(\modulator, {
		// generate a signal
		var sig = LFNoise2.kr(\freq.kr(1, 0.5)).range(-10, 10);
		// send signal from server to language 10 times per second
		SendReply.kr(Impulse.kr(10), '/modval', sig.poll(label:"server value"));
	}).add;

	s.sync;

	Synth(\modulator); // start the synth

	OSCdef(\receive_mod, {
		| msg, time, addr, recvPort |
		msg.debug("msg");
		b.sendMsg("/blender/01", msg[3]); // send value to blender
	}, '/modval');

};
)
1 Like

Great! Thanks a lot!

There’s software based on Blender & openframeworks which converts 3D shapes into oscilloscope (lissajous x/y) based audio/visual format.

It may be of interest,

image

1 Like

It’s nowhere near the same level of performance with Blender, but if anyone finds it’s interesting, there’s also free x/y patches for Max, Pd, & M4L