Send values (from Osc) to different classes


I’d like to send informations from a class (oscTest.h and .cpp) to another class (like makeItReacts.h and cpp) , but initializing and updating my oscTest in my ofApp.cpp.

For more details, you can read this :

oscTest.h class and oscTest.cpp contains basic operations and get some informations (myOscInformationFloat) based on the exemple

Then, I’ve got my ofApp.cpp which initialize my osc with :


I’m able to send informations from oscTest to my OfApp.cpp by creating in my ofApp.h file :
oscTest oscTest;

and then getting it by

But I’ve got another class, makeItReacts.h and makeItReacts.cpp and I want to receive myOscInformationFloat into it, but I can’t because oscTest.setup(); oscTest.draw(); and oscTest.update() are already used in my ofApp.h

So, to resume I’d like to send myOscInformationFloat from oscTest to makeItReacts.cpp, but initializing and updating oscTest in my ofApp.cpp

look under OF_ROOT/examples/addons/ {oscReceiveExample, oscSenderExample} for basic usage of OSC. You get the information by listenening on a network port, not by accessing the class member. So your MakeItsReacts class has to have an ofxOscReceiver.
Wait…you did mean OpenSoundControl (OSC), right?

Yes, I’m listening some informations by my network port, but then, I want to send some informations to a class and others informations to another class, like :

OscReceiver -> oscTest listening to everything -> Main App : Setup, update, draw

                                    ⎪   -> myClass : Information that I need

I don’t think MakeItReacts need to have a listener, because oscTest as already one ?

It’s like getting a value from a class, and then send it to another class in C++


use the extern keyword.


Thanks Vjacobs, it works ! :smiley: