Directing OSC signals to specific OSC addresses


#1

Dear forum,

I am trying to use the Muse 2016 OSC signals to control a program. The program is receiving the OSC signals from my Muse already, but I don’t know how I can address the specific OSC addresses in the program with it. Any ideas? The input adress in the program looks like this: /composition/layers/2/master

Thank you!

Best regards,

Vincent


#2

What platform are you developing for and in what language and IDE?

Did you use any of the reference examples from the developer page? http://developer.choosemuse.com/research-tools-example/grabbing-data-from-museio-a-few-simple-examples-of-muse-osc-servers

If not, could you share your code that receives/listens to the OSC port?


#3

Hi Joe,

many thanks for the response. I am not a developer, that’s the troublesome part. I am simply trying to find some kind of piece of code or existing software, where i can somehow translate the input OSC signals that the Muse 2016 sends into an OSC output signal with a certain address, that my programme Resolume can then recieve as OSC input on a spefici port: https://resolume.com/support/en/osc

I am a little familiar with processing, so it would be easiest to use this as a base:

import oscP5.*;

// OSC PARAMETERS & PORTS
int recvPort = 7000;
OscP5 oscP5;

// DISPLAY PARAMETERS
int WIDTH = 100;
int HEIGHT = 100;

void setup() {
size(1280,720);
frameRate(60);

/* start oscP5, listening for incoming messages at recvPort */
oscP5 = new OscP5(this, recvPort);
background(0);

}

void draw() {
background(0);
}

void oscEvent(OscMessage msg) {
System.out.println("### got a message " + msg);
if (msg.checkAddrPattern("/muse/eeg")==true) {
for(int i = 0; i < 4; i++) {
System.out.print("EEG on channel " + i + ": " + msg.get(i).floatValue() + “\n”);
}
}
}

Is there a simple way that you see, where you could add to that code, so that it outputs OSCs from Muse and I could link the different sensors to become signals between 0 and 1 on addresses like " /composition/layers/2/master" that i can then adjust?

That would be incredibly helpful :).

Many thanks in advance and best regards from Berlin,

Vincent


#4

In other words:

How can I translate the normal signals (best relative signal for) alpha beta gamma theta delta that is delivered on the address “muse/eeg/…” into one that being sent out as floating nr between 0 and 1 to the address “/composition/layers/2/master” (for example).

I am grateful for your help, thanks :slight_smile:


#5

Sounds like you’re trying to create a bridge or forwarding program to listen and translate Muse OSC messages on one port to send Resolume compatible messages to another.

I haven’t used the OscP5 library with processing, but fundamentally you could proceed with something like this:

At the end of setup() function, reference this OscP5 library example to create a myResolumeLocation that is the IP (assuming same local machine, 127.0.0.1, and Resolume listening UDP port).

   /* start oscP5, listening for incoming messages at recvPort */
   oscP5 = new OscP5(this, recvPort);
   background(0);

  /* myResolumeLocation is a NetAddress. a NetAddress takes 2 parameters,
   * an ip address and a port number. myResolumeLocation is used as parameter in
   * oscP5.send() when sending osc packets to another computer, device, 
   * application. usage see below. for testing purposes the listening port
   * and the port of the remote location address are the same, hence you will
   * send messages back to this sketch.
   */
   myResolumeLocation = new NetAddress("127.0.0.1",12000);

}

And then the oscEvent() function is parsing your Muse messages (reference here the available data and OSC paths). Find the signals you want like you are with checkAddrPattern, and then prepare a Resolume friendly message like the OscP5 library example similar to their mousePressed() function.

void oscEvent(OscMessage msg) {
   System.out.println("### got a message " + msg);

   /*  Example if you wanted the alpha relative values from Muse to send to Revolume 
    * 
    *  Relative Band Powers are in the range 0-1 according to the
    *  Muse 'available data' documentation
    */
   if (msg.checkAddrPattern("/muse/elements/alpha_relative")==true) {
       /* Send only Muse channel 0 / Tp0 Alpha Relative to Revolume address in your post */
       OscMessage myRevolumeMessage = new OscMessage("/composition/layers/2/master");
       System.out.print("Alpha Relative on channel 0: " + msg.get(i).floatValue() + “\n”);
       myRevolumeMessage .add(msg.get(i).floatValue());
       /* send the message to Revolume */
       oscP5.send(myRevolumeMessage , myResolumeLocation ); 
   }
}

Of course I only typed this out and haven’t even compiled it. But hopefully the links and example code could help you piece it together. If you’ve gone this far without being a programmer, you should be ok :wink:

If you want to monitor the forwarded OSC messages from your Processing program, you can verify them with this OSC Data Monitor. Try that if Revolume gives you any trouble.

Good luck,
Joe