[chuck-users] Determining the address of an OSC message
Brian Robison
brobison at gmail.com
Sun Sep 6 19:32:36 EDT 2020
That worked great! I had seen the OscMsg.address member mentioned in the
VERSIONS file etc. but wasn't sure offhand how to hook it up. Thank you!
Brian
On Sun, Sep 6, 2020 at 3:36 PM Eric Heep <ericheep at gmail.com> wrote:
> I would try using OscIn instead of OscRecv, and then use the listenAll()
> function of OscIn -- something like this.
>
> OscIn osc;
> osc.port(12345);
> osc.listenAll();
>
> OscMsg msg;
>
> while (true) {
> osc => now;
> while (osc.recv(msg)) {
> if (msg.address == "/myAddress") {
> // do something
> }
> }
> }
>
> On Sun, Sep 6, 2020 at 4:12 PM Brian Robison <brobison at gmail.com> wrote:
>
>> Hello, ChucKers! I am looking for a way to receive an arbitrary OSC
>> message and determine its address. In my toy example, my receiver will
>> receive messages at /sndadj/lgain and /sndadj/rgain and adjust the gain of
>> the L or R channel accordingly.
>>
>> Here's a program that would probably work if there were an
>> OscEvent.address() function:
>>
>> SinOsc sl => dac.left;
>> SinOsc sr => dac.right;
>>
>> 0.5 => sl.gain;
>> 0.5 => sr.gain;
>>
>> 225 => float lfreq;
>> 150 => float rfreq;
>>
>> lfreq => sl.freq;
>> rfreq => sr.freq;
>>
>> OscRecv recv;
>> 6449 => recv.port;
>> recv.listen();
>>
>> OscEvent oe;
>> recv.event("/sndadj/lgain, f" ) @=> oe;
>> recv.event("/sndadj/rgain, f" ) @=> oe;
>>
>> while (true) {
>> oe => now;
>>
>> while (oe.nextMsg() != 0) {
>> // XXX - OscEvent.address() doesn't exist
>> if (oe.address() == "/sndadj/lgain") {
>> oe.getFloat() => sl.gain;
>> }
>> else {
>> oe.getFloat() => sr.gain;
>> }
>> }
>> }
>>
>> I do have a version working with a single /sndadj/gain address which
>> sends two floats, but it makes my sender uglier and I feel like address
>> discernment is something ChucK probably does anyway.
>>
>> Any ideas? Thanks!
>>
>> Brian
>>
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200906/7691563c/attachment-0001.html>
More information about the chuck-users
mailing list