musikinformatik / SuperDirt

Tidal Audio Engine
GNU General Public License v2.0
519 stars 75 forks source link

Receiving rms data in sclang #249

Closed yaxu closed 2 years ago

yaxu commented 2 years ago

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 2 years ago

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

yaxu commented 2 years ago

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);
);
telephon commented 2 years ago

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
);