diff options
Diffstat (limited to 'ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.cpp')
| -rwxr-xr-x | ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.cpp b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.cpp new file mode 100755 index 0000000..2cf7a11 --- /dev/null +++ b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.cpp @@ -0,0 +1,39 @@ +/* + * ofxOscParameterSync.cpp + * + * Created on: 13/07/2012 + * Author: arturo + */ + +#include "ofxOscParameterSync.h" + +ofxOscParameterSync::ofxOscParameterSync() { + syncGroup = NULL; + updatingParameter = false; +} + +ofxOscParameterSync::~ofxOscParameterSync(){ + if(syncGroup) + ofRemoveListener(syncGroup->parameterChangedE,this,&ofxOscParameterSync::parameterChanged); +} + + +void ofxOscParameterSync::setup(ofParameterGroup & group, int localPort, string host, int remotePort){ + syncGroup = &group; + ofAddListener(group.parameterChangedE,this,&ofxOscParameterSync::parameterChanged); + sender.setup(host,remotePort); + receiver.setup(localPort); +} + +void ofxOscParameterSync::update(){ + if(receiver.hasWaitingMessages()){ + updatingParameter = true; + receiver.getParameter(*syncGroup); + updatingParameter = false; + } +} + +void ofxOscParameterSync::parameterChanged( ofAbstractParameter & parameter ){ + if(updatingParameter) return; + sender.sendParameter(parameter); +} |
