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@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@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@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users