MUSE in Processing?


#1

Hey all!

I’m working in Processing 3 and I was able to get the introductory sketch up and running no problem:

I’m now wondering how to take the values from oscEvent and convert them into usable variables in draw?

Specifically, I’d like to have delta relative as a usable value as well as an “overall average” as a usable value…

Let me know what steps I should take next! Thank you!


#2

Hi there,

The simplest possible way to do it is to just use a global variable.

The following example simply draws a white circle whose radius is proportional to the delta_relative score in the left ear electrode (the setup code and lib imports have been left out for simplicity):


float[] delta_relative = new float[4];

void draw() {
  background(0);
  fill(255);
  ellipse(width/2, height/2, delta_relative*100, delta_relative*100);
}

void oscEvent(OscMessage msg) {
  if (msg.checkAddrPattern("/muse/elements/delta_relative")==true) {  
    for (int i = 0; i < 4; i++) {
      delta_relative[i] = msg.get(i).floatValue();
    }
  }
}