本文整理汇总了C++中osc::ReceivedMessage::AddressPattern方法的典型用法代码示例。如果您正苦于以下问题:C++ ReceivedMessage::AddressPattern方法的具体用法?C++ ReceivedMessage::AddressPattern怎么用?C++ ReceivedMessage::AddressPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osc::ReceivedMessage
的用法示例。
在下文中一共展示了ReceivedMessage::AddressPattern方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMessage
// Process incoming OSC. Used for Kyma communication.
//
void SoundplaneModel::ProcessMessage(const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint)
{
osc::ReceivedMessageArgumentStream args = m.ArgumentStream();
osc::int32 a1;
try
{
if( std::strcmp( m.AddressPattern(), "/osc/response_from" ) == 0 )
{
args >> a1 >> osc::EndMessage;
// set Kyma mode
if (mOSCOutput.getKymaMode())
{
mKymaIsConnected = true;
}
}
else if (std::strcmp( m.AddressPattern(), "/osc/notify/midi/Soundplane" ) == 0 )
{
args >> a1 >> osc::EndMessage;
// set voice count to a1
int newTouches = clamp((int)a1, 0, kSoundplaneMaxTouches);
if(mKymaIsConnected)
{
// Kyma is sending 0 sometimes, which there is probably
// no reason to respond to
if(newTouches > 0)
{
setProperty("max_touches", newTouches);
}
}
}
示例2: ProcessMessage
//get OSC message
void OscInput::ProcessMessage( const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint )
{
try
{
if( strcmp( m.AddressPattern(), "/alpha" ) == 0 )
{
osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
int recievedPad = (arg++)->AsInt32();
int recievedValue = (arg++)->AsInt32();
if( arg != m.ArgumentsEnd() )
throw osc::ExcessArgumentException();
recievedPad = Layouts::padArrangementLayout[recievedPad];
//call callback function
oscCallBack(recievedPad, recievedValue);
}
}
catch( osc::Exception& e )
{
// any parsing errors such as unexpected argument types, or
// missing arguments get thrown as exceptions.
std::cout << "error while parsing message: "
<< m.AddressPattern() << ": " << e.what() << "\n";
}
}
示例3: ProcessMessage
void BitalinoPacketListener::ProcessMessage( const osc::ReceivedMessage& m ) {
try{
if( std::strcmp( m.AddressPattern(), "/wek/inputs" ) == 0 ){
osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
float emg = (arg++)->AsFloat();
float emgFilt = (arg++)->AsFloat();
float eda = (arg++)->AsFloat();
this->emgBuffer[this->curEmgBuffIdx++] = emgFilt;
if (this->curEmgBuffIdx >= BUFFER_SIZE) {
this->curEmgBuffIdx = 0;
}
this->emgStd = minMax(this->emgBuffer, BUFFER_SIZE);
float ecg = (arg++)->AsFloat();
this->accelMean =(arg++)->AsFloat();
this->lux = (arg++)->AsFloat();
//std::cout << "emg: " << emg << " emgfilt: " << emgFilt << " eda: " << eda << " ecg: " << ecg << " accel: " << accel << " lux: " << lux << '\n';
}
}catch( osc::Exception& e ){
// any parsing errors such as unexpected argument types, or
// missing arguments get thrown as exceptions.
std::cout << "error while parsing message: "
<< m.AddressPattern() << ": " << e.what() << "\n";
}
}
示例4: ProcessMessage
void ofxOscReceiver::ProcessMessage( const osc::ReceivedMessage &m, const osc::IpEndpointName& remoteEndpoint )
{
// convert the message to an ofxOscMessage
ofxOscMessage msg;
// set the address
msg.setAddress( m.AddressPattern() );
// set the sender ip/host
char endpoint_host[ osc::IpEndpointName::ADDRESS_STRING_LENGTH ];
remoteEndpoint.AddressAsString( endpoint_host );
msg.setRemoteEndpoint( endpoint_host, remoteEndpoint.port );
// transfer the arguments
for ( osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
arg != m.ArgumentsEnd();
++arg )
{
if ( arg->IsInt32() )
msg.addIntArg( arg->AsInt32Unchecked() );
else if ( arg->IsInt64() )
msg.addInt64Arg( arg->AsInt64Unchecked() );
else if ( arg->IsFloat() )
msg.addFloatArg( arg->AsFloatUnchecked() );
else if ( arg->IsDouble() )
msg.addDoubleArg( arg->AsDoubleUnchecked() );
else if ( arg->IsString() )
msg.addStringArg( arg->AsStringUnchecked() );
else if ( arg->IsSymbol() )
msg.addSymbolArg( arg->AsSymbolUnchecked() );
else if ( arg->IsChar() )
msg.addCharArg( arg->AsCharUnchecked() );
else if ( arg->IsMidiMessage() )
msg.addMidiMessageArg( arg->AsMidiMessageUnchecked() );
else if ( arg->IsBool())
msg.addBoolArg( arg->AsBoolUnchecked() );
else if ( arg->IsInfinitum() )
msg.addTriggerArg();
else if ( arg->IsTimeTag() )
msg.addTimetagArg( arg->AsTimeTagUnchecked() );
else if ( arg->IsRgbaColor() )
msg.addRgbaColorArg( arg->AsRgbaColorUnchecked() );
else if ( arg->IsBlob() ){
const char * dataPtr;
osc::osc_bundle_element_size_t len = 0;
arg->AsBlobUnchecked((const void*&)dataPtr, len);
ofBuffer buffer(dataPtr, len);
msg.addBlobArg( buffer );
}
else
{
ofLogError("ofxOscReceiver") << "ProcessMessage: argument in message " << m.AddressPattern() << " is not an int, float, or string";
}
}
// send msg to main thread
messagesChannel.send( std::move(msg) );
}
示例5: ProcessMessage
void MyPacketListener::ProcessMessage(const osc::ReceivedMessage &m, const IpEndpointName &remoteEndpoint)
{
(void) remoteEndpoint;
try {
auto args = m.ArgumentStream();
const char* msg;
args >> msg >> osc::EndMessage;
emit parent_->message(m.AddressPattern(), msg);
} catch (const osc::Exception& e) {
std::cerr << "[OSCReceiver] Error while parsing process message." << std::endl;
std::cerr << m.AddressPattern() << ": " << e.what() << std::endl;
}
}
示例6: currentString
void
ReceiveOSCThread::ProcessMessage(const osc::ReceivedMessage&m, const IpEndpointName& remoteEndPoint)
{
std::ostringstream oss;
if ((m.AddressPattern())[0] == '/') {
m_minuitMethods->receiveNetworkMessage(m.AddressPattern());
} else {
std::string currentString(m.AddressPattern());
if (currentString.find(":namespace") != currentString.npos) {
osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
if (arg->IsChar()) {
oss << arg->AsChar();
} else if (arg->IsInt32()) {
oss << arg->AsInt32();
} else if (arg->IsString()) {
oss << arg->AsString();
}
m_minuitMethods->minuitParseNamespaceRequest(oss.str(), m);
} else if (currentString.find(":get") != currentString.npos) {
osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
if (arg->IsChar()) {
oss << arg->AsChar();
} else if (arg->IsInt32()) {
oss << arg->AsInt32();
} else if (arg->IsString()) {
oss << arg->AsString();
}
m_minuitMethods->minuitParseGetRequest(oss.str(), m);
} else if (currentString.find("?namespace") != currentString.npos ||
currentString.find("?get") != currentString.npos) {
osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
if (arg->IsChar()) {
oss << arg->AsChar();
} else if (arg->IsInt32()) {
oss << arg->AsInt32();
} else if (arg->IsString()) {
oss << arg->AsString();
}
m_minuitMethods->receiveNetworkRequest(oss.str(), currentString);
}
}
};
示例7: ProcessMessage
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
{
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();
}
示例8: ProcessMessage
void Network::ProcessMessage(const osc::ReceivedMessage& m,
const IpEndpointName& remoteEndpoint)
{
try {
std::string address = m.AddressPattern();
if (address != "/mouse/position") // too noisy!
std::cerr << "Port " << m_port << " >>> Received '" << address << "' message with arguments: ";
(this->*(m_handlers[address]))(m, remoteEndpoint);
} catch(osc::Exception& e) {
std::cerr << "error while parsing message: "
<< m.AddressPattern() << ": " << e.what() << std::endl;
}
rescueOrphans();
}
示例9: ProcessMessage
void OscListener::ProcessMessage( const ::osc::ReceivedMessage &m, const IpEndpointName& remoteEndpoint ) {
Message* message = new Message();
message->setAddress(m.AddressPattern());
char endpoint_host[IpEndpointName::ADDRESS_STRING_LENGTH];
remoteEndpoint.AddressAsString(endpoint_host);
message->setRemoteEndpoint(endpoint_host, remoteEndpoint.port);
for (::osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin(); arg != m.ArgumentsEnd(); ++arg){
if (arg->IsInt32())
message->addIntArg( arg->AsInt32Unchecked());
else if (arg->IsFloat())
message->addFloatArg(arg->AsFloatUnchecked());
else if (arg->IsString())
message->addStringArg(arg->AsStringUnchecked());
else {
assert(false && "message argument type unknown");
}
}
lock_guard<mutex> lock(mMutex);
if( mMessageReceivedCbs.empty() ){
mMessages.push_back( message );
}else{
mMessageReceivedCbs.call( message );
delete message;
}
}
示例10: ProcessMessage
void oscReceiver::ProcessMessage(const osc::ReceivedMessage &_m, const IpEndpointName &remoteEndpoint)
{
boost::mutex::scoped_lock lock(listenerMutex);
if (retrievalMode == SIGNAL_PARSER_ONLY_AFTER_RELEASE)
{
if (currentMessage != 0) return;
}
osc::ReceivedMessage::const_iterator arg = _m.ArgumentsBegin();
currentMessage = new oscMessage(_m.AddressPattern(), oscMessage::NO_BUFFER);
// set source IP
char sourceString[ IpEndpointName::ADDRESS_STRING_LENGTH ];
remoteEndpoint.AddressAsString( sourceString );
currentMessage->sourceIP = sourceString;
while ( arg != _m.ArgumentsEnd() )
{
if ( arg->IsBool() ) { currentMessage->AppendBoolean (arg->AsBool());}
else if ( arg->IsInt32() ) { currentMessage->AppendInteger (arg->AsInt32());}
else if ( arg->IsFloat() ) { currentMessage->AppendFloat (arg->AsFloat());}
else if ( arg->IsString() ) { currentMessage->AppendString (arg->AsString());}
else { std::cout << "Unrecognized osc argument type\n"; }
arg++;
}
signalNewOscMessageReceived(currentMessage);
}
示例11: ProcessMessage
void OSCHandler::ProcessMessage(const osc::ReceivedMessage& m, const IpEndpointName& /*remoteEndpoint*/)
{
const String stripWildcard = OSCPrefix + "strip/*";
try
{
String msgPattern = m.AddressPattern();
if (msgPattern.equalsIgnoreCase(OSCPrefix + "press"))
{
// we need three arguments for button presses
const int numArgs = m.ArgumentCount();
if (numArgs != 3) throw osc::Exception();
osc::ReceivedMessageArgumentStream args = m.ArgumentStream();
// unpack the monome button, row and state (button up or down)
osc::int32 row, col, state;
args >> row >> col >> state >> osc::EndMessage;
buttonPressCallback(row, col, state == 1);
}
else if (msgPattern.matchesWildcard(stripWildcard, false))
{
// strip off the /mlrvst/strip/ part of the message
msgPattern = msgPattern.substring(stripWildcard.length() - 1);
// and extract the SampleStrip rowID from the message
const String rowIDStr = msgPattern.upToFirstOccurrenceOf("/", false, false);
const int stripID = rowIDStr.getIntValue();
handleStripMessage(stripID, m);
}
}
示例12: processOscMessage
void ScServer::processOscMessage( const osc::ReceivedMessage & message )
{
if (strcmp(message.AddressPattern(), "/status.reply") == 0)
{
processServerStatusMessage(message);
}
}
示例13: ProcessMessage
void Receiver::ProcessMessage( const osc::ReceivedMessage &m, const osc::IpEndpointName& remoteEndpoint ) {
// convert the m to a Message, return at the end to other main thread
Message message;
// set the address
message.setAddress( m.AddressPattern() );
// set the sender ip/host
char endpoint_host[ osc::IpEndpointName::ADDRESS_STRING_LENGTH ];
remoteEndpoint.AddressAsString( endpoint_host );
message.setRemoteEndpoint( endpoint_host, remoteEndpoint.port );
// transfer the arguments
for ( osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
arg != m.ArgumentsEnd();
++arg )
{
if ( arg->IsInt32() ) {
message.addIntArg( arg->AsInt32Unchecked() );
} else if ( arg->IsFloat() ) {
message.addFloatArg( arg->AsFloatUnchecked() );
} else if ( arg->IsString() ) {
message.addStringArg( arg->AsStringUnchecked() );
} else {
assert( false && "message argument is not int, float, or string" );
}
}
// at this point we are running inside the thread created by start()
// since we are returning a copy no shared memory management
for(unsigned int i=0; i<_oscHandlers.size(); ++i) {
_oscHandlers[i]->oscReceive( message );
}
}
示例14: ProcessMessage
//------------------------------------------------------------------------
void OSCListener::ProcessMessage( const osc::ReceivedMessage& m, const IpEndpointName& src )
{
string address(m.AddressPattern());
if (address == kGreensoundsAddr) {
ReceivedMessageArgumentIterator i = m.ArgumentsBegin();
while (i != m.ArgumentsEnd()) {
if (i->IsString()) {
string msg(i->AsStringUnchecked());
if (msg == "hello") {
char buff[120];
src.AddressAsString(buff);
fSensors->connect(buff);
}
else if (msg == "version") {
fSensors->send (kGreensoundsAddr, "version", kVersion);
}
}
else if (i->IsInt32()) {
}
else if (i->IsFloat()) {
}
i++;
}
}
}
示例15: ProcessMessage
void PortVideoSDL::ProcessMessage( const osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint )
{
//For now print the messages we recieve.
std::cout << "Recieved a message: '" << m.AddressPattern() << "'" << std::endl;
SDL_Event e={0};
e.type=SDL_USEREVENT;
std::string pattern(m.AddressPattern());
if(pattern == "camera_off"){
e.user.code=CAMERA_OFF;
}
if(pattern == "camera_on"){
e.user.code=CAMERA_ON;
}
//Push the camera event onto the queue
SDL_PushEvent(&e);
}