Go Down

Topic: TouchOSC: Passing OSC Control Name with server.addCallback() (Read 568 times) previous topic - next topic

carlmal

Hi there!

I know you have to have a server.addCallback() for every control in OSC, but I don't want to have it call a different function for every control.

Any idea if I can pass the OSC control name as an argument to the function being called?  My attempts have failed.

Code: [Select]
//here is the addCallback

server.addCallback("/1/fdr_GRN_01", &funcGRN_01);

//it calls this function
void funcGRN_01(OSCMessage *_mes){
  float value = _mes->getArgFloat(0); //TouchOSC expects float values
  dmx_master.setChannelValue ( 2, value);
 
  OSCMessage newMes;
  newMes.setAddress(_mes->getIpAddress(),destPort);
  newMes.beginMessage("/1/fdr_GRN_01");
  newMes.addArgFloat(value);
 
  //send osc message
  client.send(&newMes);
}

//Instead, I want it to call a function that takes the OSC Control Name as an argument
//void funcAnyColor(OSCMessage *_mes, char oscControlName)  if you see what I mean.


Instead, I want it to call a function that takes the OSC Control Name as an argument
void funcAnyColor(OSCMessage *_mes, char oscControlName)  if you see what I mean.

Headroom, I hope you see this.

PaulS

Without revising the library, the answer is no. If you revise the library, you can do what you want.

Go Up