diff options
| author | mick grierson <mickgrierson@gmail.com> | 2015-06-29 16:01:29 +0100 |
|---|---|---|
| committer | mick grierson <mickgrierson@gmail.com> | 2015-06-29 16:01:29 +0100 |
| commit | bc8d2ebccb48531c7d32d63c608561e495cbd7a3 (patch) | |
| tree | 19c21a5cd23427126c7639697c705dada452a308 /ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src | |
| parent | b86dfa8f6f99713ee4605c30ebb1a58309aaeb8a (diff) | |
updating examples
Diffstat (limited to 'ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src')
12 files changed, 0 insertions, 1408 deletions
diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOsc.h b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOsc.h deleted file mode 100755 index 1e65237..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOsc.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include "ofxOscArg.h" -#include "ofxOscMessage.h" -#include "ofxOscSender.h" -#include "ofxOscReceiver.h" diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscArg.h b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscArg.h deleted file mode 100755 index 0e16fbe..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscArg.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include <string> -#include "ofMain.h" - -typedef enum _ofxOscArgType -{ - OFXOSC_TYPE_NONE, - OFXOSC_TYPE_INT32, - OFXOSC_TYPE_INT64, - OFXOSC_TYPE_FLOAT, - OFXOSC_TYPE_STRING, - OFXOSC_TYPE_BLOB, - OFXOSC_TYPE_BUNDLE, - OFXOSC_TYPE_INDEXOUTOFBOUNDS -} ofxOscArgType; - -/* - -ofxOscArg - -base class for arguments - -*/ - -class ofxOscArg -{ -public: - ofxOscArg() {}; - virtual ~ofxOscArg() {}; - - virtual ofxOscArgType getType() { return OFXOSC_TYPE_NONE; } - virtual string getTypeName() { return "none"; } - -private: -}; - - -/* - -subclasses for each possible argument type - -*/ - -class ofxOscArgInt32 : public ofxOscArg -{ -public: - ofxOscArgInt32( int32_t _value ) { value = _value; } - ~ofxOscArgInt32() {}; - - /// return the type of this argument - ofxOscArgType getType() { return OFXOSC_TYPE_INT32; } - string getTypeName() { return "int32"; } - - /// return value - int32_t get() const { return value; } - /// set value - void set( int32_t _value ) { value = _value; } - -private: - int32_t value; -}; - -class ofxOscArgInt64 : public ofxOscArg -{ -public: - ofxOscArgInt64( uint64_t _value ) { value = _value; } - ~ofxOscArgInt64() {}; - - /// return the type of this argument - ofxOscArgType getType() { return OFXOSC_TYPE_INT64; } - string getTypeName() { return "int64"; } - - /// return value - uint64_t get() const { return value; } - /// set value - void set( uint64_t _value ) { value = _value; } - -private: - uint64_t value; -}; - -class ofxOscArgFloat : public ofxOscArg -{ -public: - ofxOscArgFloat( float _value ) { value = _value; } - ~ofxOscArgFloat() {}; - - /// return the type of this argument - ofxOscArgType getType() { return OFXOSC_TYPE_FLOAT; } - string getTypeName() { return "float"; } - - /// return value - float get() const { return value; } - /// set value - void set( float _value ) { value = _value; } - -private: - float value; -}; - -class ofxOscArgString : public ofxOscArg -{ -public: - ofxOscArgString( string _value ) { value = _value; } - ~ofxOscArgString() {}; - - /// return the type of this argument - ofxOscArgType getType() { return OFXOSC_TYPE_STRING; } - string getTypeName() { return "string"; } - - /// return value - string get() const { return value; } - /// set value - void set( const char* _value ) { value = _value; } - -private: - std::string value; -}; - -class ofxOscArgBlob : public ofxOscArg -{ -public: - ofxOscArgBlob( ofBuffer _value ){ - value = _value; - } - ~ofxOscArgBlob(){}; - - /// return the type of this argument - ofxOscArgType getType() { return OFXOSC_TYPE_BLOB; } - string getTypeName() { return "blob"; } - - /// return value - ofBuffer get() const { return value; } - /// set value - void set( const char * _value, unsigned int length ) { value.set(_value, length); } - -private: - ofBuffer value; -}; diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscBundle.cpp b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscBundle.cpp deleted file mode 100755 index 3bb19c2..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscBundle.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ofxOscBundle.h" - - -ofxOscBundle::ofxOscBundle() -{ -} - -ofxOscBundle::~ofxOscBundle() -{ -} - -ofxOscBundle& ofxOscBundle::copy( const ofxOscBundle& other ) -{ - for ( int i=0; i<(int)other.bundles.size(); i++ ) - { - bundles.push_back( other.bundles[i] ); - } - for ( int i=0; i<(int)other.messages.size(); i++ ) - { - messages.push_back( other.messages[i] ); - } - return *this; -} - - - -void ofxOscBundle::addBundle( const ofxOscBundle& bundle ) -{ - bundles.push_back( bundle ); -} - -void ofxOscBundle::addMessage( const ofxOscMessage& message ) -{ - messages.push_back( message ); -} - diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscBundle.h b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscBundle.h deleted file mode 100755 index a7c9640..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscBundle.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include <vector> -#include "ofxOscMessage.h" - -class ofxOscBundle -{ -public: - ofxOscBundle(); - ~ofxOscBundle(); - ofxOscBundle( const ofxOscBundle& other ) { copy ( other ); } - ofxOscBundle& operator= ( const ofxOscBundle& other ) { return copy( other ); } - /// for operator= and copy constructor - ofxOscBundle& copy( const ofxOscBundle& other ); - - /// erase contents - void clear() { messages.clear(); bundles.clear(); } - - /// add bundle elements - void addBundle( const ofxOscBundle& element ); - void addMessage( const ofxOscMessage& message ); - - /// get bundle elements - int getBundleCount() const { return bundles.size(); } - int getMessageCount() const { return messages.size(); } - /// return the bundle or message at the given index - ofxOscBundle& getBundleAt( int i ) { return bundles[i]; } - ofxOscMessage& getMessageAt( int i ) { return messages[i]; } - -private: - - std::vector< ofxOscMessage > messages; - std::vector< ofxOscBundle > bundles; -}; diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscMessage.cpp b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscMessage.cpp deleted file mode 100755 index 46f8d99..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscMessage.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ofxOscMessage.h" -#include "ofLog.h" -#include <iostream> -#include <assert.h> - -ofxOscMessage::ofxOscMessage() - -{ -} - -ofxOscMessage::~ofxOscMessage() -{ - clear(); -} - -void ofxOscMessage::clear() -{ - for ( unsigned int i=0; i<args.size(); ++i ) - delete args[i]; - args.clear(); - address = ""; -} - -/* - -get methods - -*/ - -int ofxOscMessage::getNumArgs() const -{ - return (int)args.size(); -} - -ofxOscArgType ofxOscMessage::getArgType( int index ) const -{ - if ( index >= (int)args.size() ) - { - ofLogError("ofxOscMessage") << "getArgType(): index " << index << " out of bounds"; - return OFXOSC_TYPE_INDEXOUTOFBOUNDS; - } - else - return args[index]->getType(); -} - -string ofxOscMessage::getArgTypeName( int index ) const -{ - if ( index >= (int)args.size() ) - { - ofLogError("ofxOscMessage") << "getArgTypeName(): index " << index << " out of bounds"; - return "INDEX OUT OF BOUNDS"; - } - else - return args[index]->getTypeName(); -} - - -int32_t ofxOscMessage::getArgAsInt32( int index ) const -{ - if ( getArgType(index) != OFXOSC_TYPE_INT32 ) - { - if ( getArgType( index ) == OFXOSC_TYPE_FLOAT ) - { - ofLogWarning("ofxOscMessage") << "getArgAsInt32(): converting int32 to float for argument " << index; - return ((ofxOscArgFloat*)args[index])->get(); - } - else - { - ofLogError("ofxOscMessage") << "getArgAsInt32(): argument " << index << " is not a number"; - return 0; - } - } - else - return ((ofxOscArgInt32*)args[index])->get(); -} - -uint64_t ofxOscMessage::getArgAsInt64( int index ) const -{ - if ( getArgType(index) != OFXOSC_TYPE_INT64 ) - { - if ( getArgType( index ) == OFXOSC_TYPE_FLOAT ) - { - ofLogWarning("ofxOscMessage") << "getArgAsInt64(): converting int64 to float for argument " << index; - return ((ofxOscArgFloat*)args[index])->get(); - } - else - { - ofLogError("ofxOscMessage") << "getArgAsInt64(): argument " << index << " is not a number"; - return 0; - } - } - else - return ((ofxOscArgInt64*)args[index])->get(); -} - - -float ofxOscMessage::getArgAsFloat( int index ) const -{ - if ( getArgType(index) != OFXOSC_TYPE_FLOAT ) - { - if ( getArgType( index ) == OFXOSC_TYPE_INT32 ) - { - ofLogWarning("ofxOscMessage") << "getArgAsFloat(): converting float to int32 for argument " << index; - return ((ofxOscArgInt32*)args[index])->get(); - } - else - { - ofLogError("ofxOscMessage") << "getArgAsFloat(): argument " << index << " is not a number"; - return 0; - } - } - else - return ((ofxOscArgFloat*)args[index])->get(); -} - - -string ofxOscMessage::getArgAsString( int index ) const -{ - if ( getArgType(index) != OFXOSC_TYPE_STRING ) - { - if ( getArgType( index ) == OFXOSC_TYPE_FLOAT ) - { - char buf[1024]; - sprintf(buf,"%f",((ofxOscArgFloat*)args[index])->get() ); - ofLogWarning("ofxOscMessage") << "getArgAsString(): converting float to string for argument " << index; - return buf; - } - else if ( getArgType( index ) == OFXOSC_TYPE_INT32 ) - { - char buf[1024]; - sprintf(buf,"%i",((ofxOscArgInt32*)args[index])->get() ); - ofLogWarning("ofxOscMessage") << "getArgAsString(): converting int32 to string for argument " << index; - return buf; - } - else - { - ofLogError("ofxOscMessage") << "getArgAsString(): argument " << index << " is not a string"; - return ""; - } - } - else - return ((ofxOscArgString*)args[index])->get(); -} - -ofBuffer ofxOscMessage::getArgAsBlob( int index ) const -{ - if ( getArgType(index) != OFXOSC_TYPE_BLOB ) - { - ofLogError("ofxOscMessage") << "getArgAsBlob(): argument " << index << " is not a blob"; - return ofBuffer(); - } - else - return ((ofxOscArgBlob*)args[index])->get(); -} - - - -/* - -set methods - -*/ - - -void ofxOscMessage::addIntArg( int32_t argument ) -{ - - args.push_back( new ofxOscArgInt32( argument ) ); -} - -void ofxOscMessage::addInt64Arg( uint64_t argument ) -{ - - args.push_back( new ofxOscArgInt64( argument ) ); -} - - -void ofxOscMessage::addFloatArg( float argument ) -{ - args.push_back( new ofxOscArgFloat( argument ) ); -} - -void ofxOscMessage::addStringArg( string argument ) -{ - args.push_back( new ofxOscArgString( argument ) ); -} - -void ofxOscMessage::addBlobArg( ofBuffer argument ) -{ - args.push_back( new ofxOscArgBlob( argument ) ); -} - -/* - - housekeeping - - */ - -ofxOscMessage& ofxOscMessage::copy( const ofxOscMessage& other ) -{ - clear(); - // copy address - address = other.address; - - remote_host = other.remote_host; - remote_port = other.remote_port; - - // copy arguments - for ( int i=0; i<(int)other.args.size(); ++i ) - { - ofxOscArgType argType = other.getArgType( i ); - if ( argType == OFXOSC_TYPE_INT32 ) - args.push_back( new ofxOscArgInt32( other.getArgAsInt32( i ) ) ); - else if ( argType == OFXOSC_TYPE_INT64 ) - args.push_back( new ofxOscArgInt64( other.getArgAsInt64( i ) ) ); - else if ( argType == OFXOSC_TYPE_FLOAT ) - args.push_back( new ofxOscArgFloat( other.getArgAsFloat( i ) ) ); - else if ( argType == OFXOSC_TYPE_STRING ) - args.push_back( new ofxOscArgString( other.getArgAsString( i ) ) ); - else if ( argType == OFXOSC_TYPE_BLOB ) - args.push_back( new ofxOscArgBlob( other.getArgAsBlob( i ) ) ); - else - { - assert( false && "bad argument type" ); - } - } - - return *this; -} diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscMessage.h b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscMessage.h deleted file mode 100755 index ea45f24..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscMessage.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include "ofxOscArg.h" -#include <vector> -#include <string> - -using namespace std; - -class ofxOscMessage -{ -public: - ofxOscMessage(); - ~ofxOscMessage(); - ofxOscMessage( const ofxOscMessage& other ){ copy ( other ); } - ofxOscMessage& operator= ( const ofxOscMessage& other ) { return copy( other ); } - /// for operator= and copy constructor - ofxOscMessage& copy( const ofxOscMessage& other ); - - /// clear this message, erase all contents - void clear(); - - /// return the address - string getAddress() const { return address; } - - /// return the remote ip - string getRemoteIp() const { return remote_host; } - /// return the remote port - int getRemotePort() const { return remote_port; } - - /// return number of argumentsļ - int getNumArgs() const; - /// return argument type code for argument # index - ofxOscArgType getArgType( int index ) const; - /// return argument type name as string - /// - either "int", "float", or "string" - string getArgTypeName( int index ) const; - - /// get the argument with the given index as an int, float, or string - /// ensure that the type matches what you're requesting - /// (eg for an int argument, getArgType(index)==OF_TYPE_INT32 - /// or getArgTypeName(index)=="int32") - int32_t getArgAsInt32( int index ) const; - uint64_t getArgAsInt64( int index ) const; - float getArgAsFloat( int index ) const; - string getArgAsString( int index ) const; - ofBuffer getArgAsBlob( int index ) const; - - /// message construction - void setAddress( string _address ) { address = _address; }; - /// host and port of the remote endpoint - void setRemoteEndpoint( string host, int port ) { remote_host = host; remote_port = port; } - void addIntArg( int32_t argument ); - void addInt64Arg( uint64_t argument ); - void addFloatArg( float argument ); - void addStringArg( string argument ); - void addBlobArg( ofBuffer argument ); - -private: - - string address; - vector<ofxOscArg*> args; - - string remote_host; - int remote_port; - - -}; 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 deleted file mode 100755 index 2cf7a11..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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); -} diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.h b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.h deleted file mode 100755 index 3272257..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscParameterSync.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ofxOscParameterSync.h - * - * Created on: 13/07/2012 - * Author: arturo - */ - -#pragma once - -#include "ofxOscSender.h" -#include "ofxOscReceiver.h" -#include "ofParameter.h" -#include "ofParameterGroup.h" - -class ofxOscParameterSync { -public: - ofxOscParameterSync(); - ~ofxOscParameterSync(); - - /// the remote and local ports must be different to avoid collisions - void setup(ofParameterGroup & group, int localPort, string remoteHost, int remotePort); - void update(); - -private: - void parameterChanged( ofAbstractParameter & parameter ); - ofxOscSender sender; - ofxOscReceiver receiver; - ofParameterGroup * syncGroup; - bool updatingParameter; -}; diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscReceiver.cpp b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscReceiver.cpp deleted file mode 100755 index d7ffd4e..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscReceiver.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ofxOscReceiver.h" - -#ifndef TARGET_WIN32 - #include <pthread.h> -#endif -#include <iostream> -#include <assert.h> - -ofxOscReceiver::ofxOscReceiver() -{ - listen_socket = NULL; -} - -void ofxOscReceiver::setup( int listen_port ) -{ - // if we're already running, shutdown before running again - if ( listen_socket ) - shutdown(); - - // create the mutex - #ifdef TARGET_WIN32 - mutex = CreateMutexA( NULL, FALSE, NULL ); - #else - pthread_mutex_init( &mutex, NULL ); - #endif - - // create socket - socketHasShutdown = false; - listen_socket = new UdpListeningReceiveSocket( IpEndpointName( IpEndpointName::ANY_ADDRESS, listen_port ), this ); - - // start thread - #ifdef TARGET_WIN32 - thread = CreateThread( - NULL, // default security attributes - 0, // use default stack size - &ofxOscReceiver::startThread, // thread function - (void*)this, // argument to thread function - 0, // use default creation flags - NULL); // we don't the the thread id - - #else - pthread_create( &thread, NULL, &ofxOscReceiver::startThread, (void*)this ); - #endif -} - -void ofxOscReceiver::shutdown() -{ - if ( listen_socket ) - { - // tell the socket to shutdown - listen_socket->AsynchronousBreak(); - // wait for shutdown to complete - while (!socketHasShutdown) - { - #ifdef TARGET_WIN32 - Sleep(1); - #else - // sleep 0.1ms - usleep(100); - #endif - } - - // thread will clean up itself - - // clean up the mutex - #ifdef TARGET_WIN32 - ReleaseMutex( mutex ); - #else - pthread_mutex_destroy( &mutex ); - #endif - - // delete the socket - delete listen_socket; - listen_socket = NULL; - } -} - -ofxOscReceiver::~ofxOscReceiver() -{ - shutdown(); -} - -#ifdef TARGET_WIN32 -DWORD WINAPI -#else -void* -#endif - -ofxOscReceiver::startThread( void* receiverInstance ) -{ - // cast the instance - ofxOscReceiver* instance = (ofxOscReceiver*)receiverInstance; - // start the socket listener - instance->listen_socket->Run(); - // socket listener has finished - remember this fact - instance->socketHasShutdown = true; - // return - #ifdef TARGET_WIN32 - return 0; - #else - return NULL; - #endif -} - -void ofxOscReceiver::ProcessMessage( const osc::ReceivedMessage &m, const IpEndpointName& remoteEndpoint ) -{ - - // convert the message to an ofxOscMessage - ofxOscMessage* ofMessage = new ofxOscMessage(); - - // set the address - ofMessage->setAddress( m.AddressPattern() ); - - // set the sender ip/host - char endpoint_host[ IpEndpointName::ADDRESS_STRING_LENGTH ]; - remoteEndpoint.AddressAsString( endpoint_host ); - ofMessage->setRemoteEndpoint( endpoint_host, remoteEndpoint.port ); - - // transfer the arguments - for ( osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin(); - arg != m.ArgumentsEnd(); - ++arg ) - { - if ( arg->IsInt32() ) - ofMessage->addIntArg( arg->AsInt32Unchecked() ); - else if ( arg->IsInt64() ) - ofMessage->addInt64Arg( arg->AsInt64Unchecked() ); - else if ( arg->IsFloat() ) - ofMessage->addFloatArg( arg->AsFloatUnchecked() ); - else if ( arg->IsString() ) - ofMessage->addStringArg( arg->AsStringUnchecked() ); - else if ( arg->IsBlob() ){ - const char * dataPtr; - unsigned long len = 0; - arg->AsBlobUnchecked((const void*&)dataPtr, len); - ofBuffer buffer(dataPtr, len); - ofMessage->addBlobArg( buffer ); - }else - { - ofLogError("ofxOscReceiver") << "ProcessMessage: argument in message " << m.AddressPattern() << " is not an int, float, or string"; - } - } - - // now add to the queue - - // at this point we are running inside the thread created by startThread, - // so anyone who calls hasWaitingMessages() or getNextMessage() is coming - // from a different thread - - // so we have to practise shared memory management - - // grab a lock on the queue - grabMutex(); - - // add incoming message on to the queue - messages.push_back( ofMessage ); - - // release the lock - releaseMutex(); -} - -bool ofxOscReceiver::hasWaitingMessages() -{ - // grab a lock on the queue - grabMutex(); - - // check the length of the queue - int queue_length = (int)messages.size(); - - // release the lock - releaseMutex(); - - // return whether we have any messages - return queue_length > 0; -} - -bool ofxOscReceiver::getNextMessage( ofxOscMessage* message ) -{ - // grab a lock on the queue - grabMutex(); - - // check if there are any to be got - if ( messages.size() == 0 ) - { - // no: release the mutex - releaseMutex(); - return false; - } - - // copy the message from the queue to message - ofxOscMessage* src_message = messages.front(); - message->copy( *src_message ); - - // now delete the src message - delete src_message; - // and remove it from the queue - messages.pop_front(); - - // release the lock on the queue - releaseMutex(); - - // return success - return true; -} - - -bool ofxOscReceiver::getParameter(ofAbstractParameter & parameter){ - ofxOscMessage msg; - if ( messages.size() == 0 ) return false; - while(hasWaitingMessages()){ - ofAbstractParameter * p = ¶meter; - - getNextMessage(&msg); - vector<string> address = ofSplitString(msg.getAddress(),"/",true); - - for(int i=0;i<address.size();i++){ - - if(p) { - if(address[i]==p->getEscapedName()){ - if(p->type()==typeid(ofParameterGroup).name()){ - if(address.size()>=i+1){ - p = &static_cast<ofParameterGroup*>(p)->get(address[i+1]); - } - }else if(p->type()==typeid(ofParameter<int>).name() && msg.getArgType(0)==OFXOSC_TYPE_INT32){ - p->cast<int>() = msg.getArgAsInt32(0); - }else if(p->type()==typeid(ofParameter<float>).name() && msg.getArgType(0)==OFXOSC_TYPE_FLOAT){ - p->cast<float>() = msg.getArgAsFloat(0); - }else if(p->type()==typeid(ofParameter<bool>).name() && msg.getArgType(0)==OFXOSC_TYPE_INT32){ - p->cast<bool>() = msg.getArgAsInt32(0); - }else if(msg.getArgType(0)==OFXOSC_TYPE_STRING){ - p->fromString(msg.getArgAsString(0)); - } - } - } - } - } - return true; -} - -void ofxOscReceiver::grabMutex() -{ -#ifdef TARGET_WIN32 - WaitForSingleObject( mutex, INFINITE ); -#else - pthread_mutex_lock( &mutex ); -#endif -} - -void ofxOscReceiver::releaseMutex() -{ -#ifdef TARGET_WIN32 - ReleaseMutex( mutex ); -#else - pthread_mutex_unlock( &mutex ); -#endif -} diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscReceiver.h b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscReceiver.h deleted file mode 100755 index c844c33..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscReceiver.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include <deque> -#include "ofMain.h" - -#ifdef TARGET_WIN32 -// threads -#include <windows.h> -#else -// threads -#include <pthread.h> -#endif - -// osc -#include "OscTypes.h" -#include "OscPacketListener.h" -#include "UdpSocket.h" - -// ofxOsc -#include "ofxOscMessage.h" - -class ofxOscReceiver : public osc::OscPacketListener -{ -public: - ofxOscReceiver(); - ~ofxOscReceiver(); - - /// listen_port is the port to listen for messages on - void setup( int listen_port ); - - /// returns true if there are any messages waiting for collection - bool hasWaitingMessages(); - /// take the next message on the queue of received messages, copy its details into message, and - /// remove it from the queue. return false if there are no more messages to be got, otherwise - /// return true - bool getNextMessage( ofxOscMessage* ); - - bool getParameter(ofAbstractParameter & parameter); - -protected: - /// process an incoming osc message and add it to the queue - virtual void ProcessMessage( const osc::ReceivedMessage &m, const IpEndpointName& remoteEndpoint ); - -private: - // shutdown the listener - void shutdown(); - - // start the listening thread -#ifdef TARGET_WIN32 - static DWORD WINAPI startThread( void* ofxOscReceiverInstance ); -#else - static void* startThread( void* ofxOscReceiverInstance ); -#endif - // queue of osc messages - std::deque< ofxOscMessage* > messages; - - // socket to listen on - UdpListeningReceiveSocket* listen_socket; - - // mutex helpers - void grabMutex(); - void releaseMutex(); - -#ifdef TARGET_WIN32 - // thread to listen with - HANDLE thread; - // mutex for the thread queue - HANDLE mutex; -#else - // thread to listen with - pthread_t thread; - // mutex for the message queue - pthread_mutex_t mutex; -#endif - // ready to be deleted - bool socketHasShutdown; - -}; diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscSender.cpp b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscSender.cpp deleted file mode 100755 index e19e6a4..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscSender.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "ofxOscSender.h" -#include "ofUtils.h" -#include "ofParameterGroup.h" - - -#include "UdpSocket.h" - -#include <assert.h> - -ofxOscSender::ofxOscSender() -{ - socket = NULL; -} - -ofxOscSender::~ofxOscSender() -{ - if ( socket ) - shutdown(); -} - -void ofxOscSender::setup( std::string hostname, int port ) -{ - if ( socket ) - shutdown(); - - socket = new UdpTransmitSocket( IpEndpointName( hostname.c_str(), port ) ); -} - -void ofxOscSender::shutdown() -{ - if ( socket ) - delete socket; - socket = NULL; -} - -void ofxOscSender::sendBundle( ofxOscBundle& bundle ) -{ - //setting this much larger as it gets trimmed down to the size its using before being sent. - //TODO: much better if we could make this dynamic? Maybe have ofxOscBundle return its size? - static const int OUTPUT_BUFFER_SIZE = 327680; - char buffer[OUTPUT_BUFFER_SIZE]; - osc::OutboundPacketStream p(buffer, OUTPUT_BUFFER_SIZE ); - - // serialise the bundle - appendBundle( bundle, p ); - - socket->Send( p.Data(), p.Size() ); -} - -void ofxOscSender::sendMessage( ofxOscMessage& message ) -{ - //setting this much larger as it gets trimmed down to the size its using before being sent. - //TODO: much better if we could make this dynamic? Maybe have ofxOscMessage return its size? - static const int OUTPUT_BUFFER_SIZE = 327680; - char buffer[OUTPUT_BUFFER_SIZE]; - osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE ); - - // serialise the message - p << osc::BeginBundleImmediate; - appendMessage( message, p ); - p << osc::EndBundle; - - socket->Send( p.Data(), p.Size() ); -} - -void ofxOscSender::sendParameter( const ofAbstractParameter & parameter){ - if(!parameter.isSerializable()) return; - if(parameter.type()==typeid(ofParameterGroup).name()){ - string address = "/"; - const vector<string> hierarchy = parameter.getGroupHierarchyNames(); - for(int i=0;i<(int)hierarchy.size()-1;i++){ - address+=hierarchy[i] + "/"; - } - ofxOscBundle bundle; - appendParameter(bundle,parameter,address); - sendBundle(bundle); - }else{ - string address = ""; - const vector<string> hierarchy = parameter.getGroupHierarchyNames(); - for(int i=0;i<(int)hierarchy.size()-1;i++){ - address+= "/" + hierarchy[i]; - } - if(address.length()) address += "/"; - ofxOscMessage msg; - appendParameter(msg,parameter,address); - sendMessage(msg); - } -} - - -void ofxOscSender::appendParameter( ofxOscBundle & _bundle, const ofAbstractParameter & parameter, string address){ - if(parameter.type()==typeid(ofParameterGroup).name()){ - ofxOscBundle bundle; - const ofParameterGroup & group = static_cast<const ofParameterGroup &>(parameter); - for(int i=0;i<group.size();i++){ - const ofAbstractParameter & p = group[i]; - if(p.isSerializable()){ - appendParameter(bundle,p,address+group.getEscapedName()+"/"); - } - } - _bundle.addBundle(bundle); - }else{ - if(parameter.isSerializable()){ - ofxOscMessage msg; - appendParameter(msg,parameter,address); - _bundle.addMessage(msg); - } - } -} - -void ofxOscSender::appendParameter( ofxOscMessage & msg, const ofAbstractParameter & parameter, string address){ - msg.setAddress(address+parameter.getEscapedName()); - if(parameter.type()==typeid(ofParameter<int>).name()){ - msg.addIntArg(parameter.cast<int>()); - }else if(parameter.type()==typeid(ofParameter<float>).name()){ - msg.addFloatArg(parameter.cast<float>()); - }else if(parameter.type()==typeid(ofParameter<bool>).name()){ - msg.addIntArg(parameter.cast<bool>()); - }else{ - msg.addStringArg(parameter.toString()); - } -} - -void ofxOscSender::appendBundle( ofxOscBundle& bundle, osc::OutboundPacketStream& p ) -{ - // recursively serialise the bundle - p << osc::BeginBundleImmediate; - for ( int i=0; i<bundle.getBundleCount(); i++ ) - { - appendBundle( bundle.getBundleAt( i ), p ); - } - for ( int i=0; i<bundle.getMessageCount(); i++ ) - { - appendMessage( bundle.getMessageAt( i ), p ); - } - p << osc::EndBundle; -} - -void ofxOscSender::appendMessage( ofxOscMessage& message, osc::OutboundPacketStream& p ) -{ - p << osc::BeginMessage( message.getAddress().c_str() ); - for ( int i=0; i< message.getNumArgs(); ++i ) - { - if ( message.getArgType(i) == OFXOSC_TYPE_INT32 ) - p << message.getArgAsInt32( i ); - else if ( message.getArgType(i) == OFXOSC_TYPE_INT64 ) - p << (osc::int64)message.getArgAsInt64( i ); - else if ( message.getArgType( i ) == OFXOSC_TYPE_FLOAT ) - p << message.getArgAsFloat( i ); - else if ( message.getArgType( i ) == OFXOSC_TYPE_STRING ) - p << message.getArgAsString( i ).c_str(); - else if ( message.getArgType( i ) == OFXOSC_TYPE_BLOB ){ - ofBuffer buff = message.getArgAsBlob(i); - osc::Blob b(buff.getBinaryBuffer(), (unsigned long)buff.size()); - p << b; - }else - { - ofLogError("ofxOscSender") << "appendMessage(): bad argument type " << message.getArgType( i ); - assert( false ); - } - } - p << osc::EndMessage; -} diff --git a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscSender.h b/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscSender.h deleted file mode 100755 index 5b07e6e..0000000 --- a/ofxMaxim/ofxMaximExample_0.8.4_OSX_Granular/ofxOsc/src/ofxOscSender.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - - Copyright (c) 2007-2009, Damian Stewart - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the developer nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DAMIAN STEWART ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL DAMIAN STEWART BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -/** - -ofxOscSender - -an ofxOscSender sends messages to a single host/port - -*/ - -class UdpTransmitSocket; -#include <string> -#include "OscTypes.h" -#include "OscOutboundPacketStream.h" - -#include "ofxOscBundle.h" -#include "ofxOscMessage.h" -#include "ofParameter.h" -#include "ofParameterGroup.h" - - -class ofxOscSender -{ -public: - ofxOscSender(); - ~ofxOscSender(); - - /// send messages to hostname and port - void setup( std::string hostname, int port ); - - /// send the given message - void sendMessage( ofxOscMessage& message ); - /// send the given bundle - void sendBundle( ofxOscBundle& bundle ); - /// creates a message using an ofParameter - void sendParameter( const ofAbstractParameter & parameter); - - -private: - void shutdown(); - - // helper methods for constructing messages - void appendBundle( ofxOscBundle& bundle, osc::OutboundPacketStream& p ); - void appendMessage( ofxOscMessage& message, osc::OutboundPacketStream& p ); - void appendParameter( ofxOscBundle & bundle, const ofAbstractParameter & parameter, string address); - void appendParameter( ofxOscMessage & msg, const ofAbstractParameter & parameter, string address); - - UdpTransmitSocket* socket; -}; |
