musikinformatik/SuperDirt

Receiving rms data in sclang

yaxu opened this issue · 3 comments

yaxu commented

I'd like to send the rms data out over midi, and thought the easiest way would be to make an osc->midi bridge in sclang.

I thought that ~dirt.startSendRMS; would send the rms from scsynth to all of its clients, including sclang. However if I do OSCFunc.trace() I don't see it.

Am I thinking about this the wrong way?

yaxu commented

Stupidly, I wasn't playing any sounds, hence the lack of rms messages.. Sorry for the (non-)noise!

yaxu commented

For the curious, and my future self, this works:

(
f = { |msg, time, addr|
    if(msg[0] == '/rms') {
		var o = msg[2];
		var vol = (msg[4] + msg[6]);
		if (o < 8) {
			~midiOut.control(0,o+1,(vol*255).min(127));
		}
    }
};
thisProcess.addOSCRecvFunc(f);
);

This should also work:

(
OSCFunc({ |msg, time, addr|
		var o = msg[2];
		var vol = (msg[4] + msg[6]);
		if (o < 8) {
			~midiOut.control(0,o+1,(vol*255).min(127));
		}
}, '/rms').fix
);