Ejemplo n.º 1
0
void Client::send( const osc::Message &message )
{
	lo_message msg = lo_message_new();

	for ( size_t i = 0; i < message.getNumArgs(); i++ )
	{
		switch ( message.getArgType( i ) )
		{
			case 'i':
				lo_message_add_int32( msg, message.getArg< int32_t >( i ) );
				break;

			case 'f':
				lo_message_add_float( msg, message.getArg< float >( i ) );
				break;

			case 's':
				lo_message_add_string( msg, message.getArg< std::string >( i ).c_str() );
				break;

			default:
				break;
		}
	}

	lo_send_message( mAddress, message.getAddressPattern().c_str(), msg );
	lo_message_free( msg );
}
void ParameterServer::onMessage(osc::Message &m)
{
	std::string requestAddress = "/request";
	if(m.addressPattern() == requestAddress && m.typeTags() == "s") {
		std::string parameterAddress;
		m >> parameterAddress;
	}
Ejemplo n.º 3
0
string toString(osc::Message const& m)
{
	stringstream s;
	s << '[' << m.getAddress() << ' ';
	for (int i=0; i<m.getNumArgs(); ++i)
	{
		s << m.getArgAsString(i, true);
	}
	s << ']';
	return s.str();
}
void PluginOSCController::processMessage( const osc::Message& message ){
    string address = boost::to_upper_copy(message.getAddress());
    if( mPluginsOSCMapping.count(address) > 0 ){
        processPluginMessageDirect( message, mPluginsOSCMapping[address] );
        return;
    }
    
    return;

    // TODO fix the group function
    
    vector<string> tokens;
    boost::split(tokens,address,boost::is_any_of("/"));
    tokens.erase (tokens.begin(),tokens.begin()+1);

    bool isPluginMessage = false;
    string sig = boost::to_upper_copy(tokens[0]);
    map<string, vector<BasePlugin*> >::const_iterator itr;
    for(itr = mPluginsDirectory.begin(); itr != mPluginsDirectory.end(); ++itr){
//        console() << "Key: " << (*itr).first << " Value: " << (*itr).second.size();
        if(sig.compare( boost::to_upper_copy( (*itr).first )) == 0 ){
//            console() << " FOUND THE PLUGIN! " << std::endl;
            isPluginMessage = true;
            break;
        }
    }
    
    if(isPluginMessage){
        processPluginMessage( message, tokens );
    }else{
        processInteralMessage( message, tokens );
    }
    
}
Ejemplo n.º 5
0
inline void OmniApp::onMessage(osc::Message& m) {
	float x;
	if (m.addressPattern() == "/mx") {
		m >> x;
		nav().moveR(-x * mNavSpeed);

	} else if (m.addressPattern() == "/my") {
void GstVideoServer::sendToClients(const osc::Message &m)
{
	CI_LOG_I("Send to Clients " << m );
	for( auto& clientKey : mConnectedClients){
        auto& client = clientKey.second;
		CI_LOG_I( "Sending " << m.getAddress() << " to " << client.getRemoteEndpoint().address() << ":" << client.getRemoteEndpoint().port() );
        client.send(m);
    }
}
void GstVideoServer::sendToClient( const osc::Message &m, const std::string &address )
{
    const auto& clientKey = mConnectedAdressedClients.find(address);
    if(clientKey != mConnectedAdressedClients.end() ){
        auto& client = clientKey->second->second;
		CI_LOG_I("Sending " << m.getAddress() << " to " << client.getRemoteEndpoint().address() << ":" << client.getRemoteEndpoint().port() );
        client.send(m);
    } else{
		CI_LOG_I( "Couldn't find client with address: " << address );
    }
}
/**
 * Log incomming OSC msgs
 * Taken from OSCListener example provided with the Cinder OSC block
 */
void OSCController::__logMessage( osc::Message msg )
{
    if( displayMsgLog ){
        console() << "Incomming OSC msg: @ " << getId() << std::endl;
		console() << "Address: " << msg.getAddress() << std::endl;
		if( displayMsgExtended ){
			console() << "Num Arg: " << msg.getNumArgs() << std::endl;
			for (int i = 0; i < msg.getNumArgs(); i++) {
				console() << "-- Argument " << i << std::endl;
				console() << "---- type: " << msg.getArgTypeName(i) << std::endl;
				if (msg.getArgType(i) == osc::TYPE_INT32){
					try {
						console() << "------ value: "<< msg.getArgAsInt32(i) << std::endl;
					}
					catch (...) {
						console() << "Exception reading argument as int32" << std::endl;
					}
					
				}else if (msg.getArgType(i) == osc::TYPE_FLOAT){
					try {
						console() << "------ value: " << msg.getArgAsFloat(i) << std::endl;
					}
					catch (...) {
						console() << "Exception reading argument as float" << std::endl;
					}
					
				}else if (msg.getArgType(i) == osc::TYPE_STRING){
					try {
						console() << "------ value: " << msg.getArgAsString(i).c_str() << std::endl;
					}
					catch (...) {
						console() << "Exception reading argument as string" << std::endl;
					}
					
				}
			}
		}

        
    }
}
void PluginOSCController::processPluginMessageDirect( const osc::Message& message, OSCElement* oscElement ){

    cinder::osc::ArgType typeOsc = message.getArgType(0);
    OSCElement::OSCElementTypes typeVar = oscElement->type;
    
    if( typeOsc == osc::TYPE_INT32 && typeVar == OSCElement::OSCElementTypes::INTEGER ) {
        try {
//            int val = message.getArgAsInt32(0);
            float val = cinder::math<float>::clamp( message.getArgAsFloat(0), 0.0f, 1.0f );
            val = lerp( oscElement->minValue, oscElement->maxValue, val );
            *static_cast<int*>(oscElement->pointer) = val;
        }
        catch (...) {
            console() << "Exception reading argument as int32" << std::endl;
        }
    }
    else if( typeOsc == osc::TYPE_FLOAT && typeVar == OSCElement::OSCElementTypes::FLOAT  ) {
        try {
            float val = cinder::math<float>::clamp( message.getArgAsFloat(0), 0.0f, 1.0f );
            val = lerp( oscElement->minValue, oscElement->maxValue, val );
            *(static_cast<float*>(oscElement->pointer)) = val;
        }
        catch (...) {
            console() << "Exception reading argument as float" << std::endl;
        }
    }
//    else if( message.getArgType(i) == osc::TYPE_STRING) {
//        try {
//            message.getArgAsString(i);
//        }
//        catch (...) {
//            console() << "Exception reading argument as string" << std::endl;
//        }
//    }
    
}
Ejemplo n.º 10
0
void PluginOSCController::processInteralMessage( const osc::Message& message, vector<string> tokens ){
    
    return;
    
    console() << "========= INTERNAL MESSAGE ==========" << std::endl;
    console() << "Num Arg: " << message.getNumArgs() << std::endl;
    for (int i = 0; i < message.getNumArgs(); i++) {
        console() << "-- Argument " << i << std::endl;
        console() << "---- type: " << message.getArgTypeName(i) << std::endl;
        if( message.getArgType(i) == osc::TYPE_INT32 ) {
            try {
                console() << "------ value: "<< message.getArgAsInt32(i) << std::endl;
            }
            catch (...) {
                console() << "Exception reading argument as int32" << std::endl;
            }
        }
        else if( message.getArgType(i) == osc::TYPE_FLOAT ) {
            try {
                console() << "------ value: " << message.getArgAsFloat(i) << std::endl;
            }
            catch (...) {
                console() << "Exception reading argument as float" << std::endl;
            }
        }
        else if( message.getArgType(i) == osc::TYPE_STRING) {
            try {
                console() << "------ value: " << message.getArgAsString(i).c_str() << std::endl;
            }
            catch (...) {
                console() << "Exception reading argument as string" << std::endl;
            }
        }
    }
    
}
Ejemplo n.º 11
0
void OscController::sendMessage(const osc::Message message) {
	app::console() << "Sending Address" << message.getAddress() << std::endl;
	mSender.send(message);
}