本文整理汇总了C++中ofxOscMessage::getArgType方法的典型用法代码示例。如果您正苦于以下问题:C++ ofxOscMessage::getArgType方法的具体用法?C++ ofxOscMessage::getArgType怎么用?C++ ofxOscMessage::getArgType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofxOscMessage
的用法示例。
在下文中一共展示了ofxOscMessage::getArgType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleMessage
bool tuioVisBase::handleMessage(ofxOscMessage m) {
string address = m.getAddress();
// special cases first:
if (address=="/tuio/2dcur" && m.getNumArgs()==7 && m.getArgType(0)==OFXOSC_TYPE_STRING && m.getArgAsString(0)=="set") {
tuioCursor tc;
tc.s = m.getArgAsInt32(1);
tc.x = m.getArgAsFloat(2);
tc.y = m.getArgAsFloat(3);
tc.dx = m.getArgAsFloat(4);
tc.dy = m.getArgAsFloat(5);
tc.m = m.getArgAsFloat(6);
tc.age = 0;
return cursorCallback(tc);
}
else if (address=="/tuio/2Dcur" && m.getNumArgs()==2 && m.getArgType(0)==OFXOSC_TYPE_STRING && m.getArgAsString(0)=="fseq") {
return frameCallback(m.getArgAsInt32(1));
}
else if (linearCallbacks.find(address) != linearCallbacks.end() && m.getNumArgs()==1) {
return linearCallback(address, m.getArgAsFloat(0));
}
else if (colorCallbacks.find(address) != colorCallbacks.end() && m.getNumArgs()==3) {
return colorCallback(address, m.getArgAsFloat(0), m.getArgAsFloat(1), m.getArgAsFloat(2));
}
// message not handled:
else return false;
}
示例2: setOscDebugMessage
void testApp::setOscDebugMessage(ofxOscMessage message)
{
std::stringstream stream;
stream << "OSC messages";
if (!showOscDebugPosition)
{
stream << " (Not showing position messages)";
}
stream << " :\n";
stream << "[address]: " << message.getAddress() << ", ";
for (int i = 0; i < message.getNumArgs(); ++i) {
stream << "[" << (i+1) << "]: ";
if (message.getArgType(i) == OFXOSC_TYPE_INT32) {
stream << message.getArgAsInt32(i);
}
else if (message.getArgType(i) == OFXOSC_TYPE_STRING) {
stream << message.getArgAsString(i);
}
else if (message.getArgType(i) == OFXOSC_TYPE_FLOAT) {
stream << message.getArgAsFloat(i);
}
if (i != message.getNumArgs()-1) {stream << ", ";};
}
stream << ", time: ";
stream << ofGetElapsedTimef();
m_debugMessage = stream.str();
}
示例3: dumpOSC
void ofApp::dumpOSC(ofxOscMessage m) {
string msgString;
msgString = m.getAddress();
for (int i=0; i<m.getNumArgs(); i++){
msgString += " ";
if(m.getArgType(i) == OFXOSC_TYPE_INT32)
msgString += ofToString(m.getArgAsInt32(i));
else if(m.getArgType(i) == OFXOSC_TYPE_FLOAT)
msgString += ofToString(m.getArgAsFloat(i));
else if(m.getArgType(i) == OFXOSC_TYPE_STRING)
msgString += m.getArgAsString(i);
}
cout << msgString << endl;
}
示例4: dumpOSC
string messenger::dumpOSC(ofxOscMessage m) {
string msg_string;
msg_string = m.getAddress();
for (int i=0; i<m.getNumArgs(); i++ ) {
msg_string += " ";
if(m.getArgType(i) == OFXOSC_TYPE_INT32)
msg_string += ofToString( m.getArgAsInt32(i));
else if(m.getArgType(i) == OFXOSC_TYPE_FLOAT)
msg_string += ofToString( m.getArgAsFloat(i));
else if(m.getArgType(i) == OFXOSC_TYPE_STRING)
msg_string += m.getArgAsString(i);
}
return msg_string;
}
示例5: oscMsgToString
string ofApp::oscMsgToString(int num, string adr, ofxOscMessage msg) {
string res= adr;
for(int i= 0; i<num; i++) {
res= res+" ";
if(msg.getArgType(i)==OFXOSC_TYPE_INT32) {
res= res+ofToString(msg.getArgAsInt32(i));
} else if(msg.getArgType(i)==OFXOSC_TYPE_FLOAT) {
res= res+ofToString(msg.getArgAsFloat(i));
} else if(msg.getArgType(i)==OFXOSC_TYPE_STRING) {
res= res+msg.getArgAsString(i);
}
}
return res;
}
示例6: appendMessage
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_FLOAT )
p << message.getArgAsFloat( i );
else if ( message.getArgType( i ) == OFXOSC_TYPE_STRING )
p << message.getArgAsString( i ).c_str();
else
{
assert( false && "bad argument type" );
}
}
p << osc::EndMessage;
}
示例7: getOscMsgAsString
string ofApp::getOscMsgAsString(ofxOscMessage m){
// method from the client server ofxOsc example !
string msg_string;
msg_string ="";
for(int i = 0; i < m.getNumArgs(); i++){
// get the argument type
if(m.getArgType(i) == OFXOSC_TYPE_INT32){
msg_string += ofToString(m.getArgAsInt32(i));
}
else if(m.getArgType(i) == OFXOSC_TYPE_FLOAT){
msg_string += ofToString(m.getArgAsFloat(i));
}
else if(m.getArgType(i) == OFXOSC_TYPE_STRING){
msg_string += m.getArgAsString(i);
}
}
return msg_string;
}
示例8: parseInfoMessage
void ofxDuration::parseInfoMessage(const ofxOscMessage& m){
ofLogVerbose("ofxDuration::parseInfoMessage") << "Received track information from Duration, #args " << m.getNumArgs();
tracks.clear();
trackNames.clear();
//pairs of two strings per track, name and type
for(int i = 0; i < m.getNumArgs()-1; i+=2){
if(m.getArgType(i ) == OFXOSC_TYPE_STRING &&
m.getArgType(i+1) == OFXOSC_TYPE_STRING)
{
string trackType = m.getArgAsString(i );
string trackName = m.getArgAsString(i+1);
ofxDurationTrack t;
t.type = trackType;
t.name = trackName;
t.lastUpdatedTime = ofGetElapsedTimef();
ofLogVerbose("ofxDuration::parseInfoMessage") << "Adding track " << t.type << " : " << t.name;
if(trackType == "Curves" || trackType == "LFO"){
//consume two more args for min and max
if(i+3 < m.getNumArgs() &&
m.getArgType(i+2) == OFXOSC_TYPE_FLOAT &&
m.getArgType(i+3) == OFXOSC_TYPE_FLOAT)
{
t.range = ofRange(m.getArgAsFloat(i+2), m.getArgAsFloat(i+3));
ofLogVerbose("ofxDuration::parseInfoMessage") << " track range is " << t.range;
i+=2;
}
}
//only add unique names
if(tracks.find(t.name) == tracks.end()){
trackNames.push_back(t.name);
tracks[t.name] = t;
}
else{
ofLogNotice("ofxDuration::parseInfoMessage") << "Duplicate track name received: " << t.name;
}
}
}
ofLogVerbose("ofxDuration::parseInfoMessage") << "Created " << tracks.size() << " tracks";
}
示例9: setParameterValue
//--------------------------------------------------------------
void oscReceiver::setParameterValue(ofAbstractParameter& param, ofxOscMessage& msg, int oscArgIndex)
{
ofAbstractParameter* p = ¶m;
if(p->type()==typeid(ofParameter<int>).name() && msg.getArgType(oscArgIndex)==OFXOSC_TYPE_INT32)
{
p->cast<int>() = msg.getArgAsInt32(oscArgIndex);
}
else if(p->type()==typeid(ofParameter<float>).name() && msg.getArgType(oscArgIndex)==OFXOSC_TYPE_FLOAT)
{
p->cast<float>() = msg.getArgAsFloat(oscArgIndex);
}else if(p->type()==typeid(ofParameter<bool>).name() && msg.getArgType(oscArgIndex)==OFXOSC_TYPE_INT32)
{
p->cast<bool>() = msg.getArgAsInt32(oscArgIndex);
}else if(msg.getArgType(oscArgIndex)==OFXOSC_TYPE_STRING)
{
p->fromString(msg.getArgAsString(oscArgIndex));
}
}
示例10: appendMessage
void ofxGstRTPServer::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
{
ofLogError("ofxOscSender") << "appendMessage(): bad argument type " << message.getArgType( i );
}
//cout << i << ": " << p.Size() << endl;
}
p << osc::EndMessage;
}
示例11: handleMessage
//-------------------------------------------------------------
void ofApp::handleMessage(ofxOscMessage m) {
string send_string;
string address_string;
string ip_string;
ip_string = "/" + ofSplitString( ofToString(m.getRemoteIp()), ".")[3];
// check for battery message
if(m.getAddress() == "/battery"){
if(m.getArgType(0) == OFXOSC_TYPE_FLOAT){
// construct OSC message to send
sendBattery( ip_string, m.getArgAsFloat(0));
}
}
// check for blob message
else if(m.getAddress() == "/inputs/serial/1") {
for(int i = 0; i < m.getNumArgs(); i++){
// get the argument type
if(m.getArgType(i) == OFXOSC_TYPE_BLOB){
string blob = m.getArgAsBlob(0);
vector<string> parameters = ofSplitString(blob, ",");
if( parameters.size() >= 5 ) {
int distance = ofToInt(parameters[0]);
int velocity = ofToInt(parameters[1]);
int azimuth = ofToInt(parameters[2]);
int elevation = ofToInt(parameters[3]);
float angularRate = ofToFloat(parameters[4]);
// send osc messages
sendDistance(ip_string, distance);
sendVelocity(ip_string, velocity);
sendAzimuth(ip_string, azimuth);
sendElevation(ip_string, elevation);
sendAngularRate(ip_string, angularRate);
}
}
}
}
}
示例12: displayOscMessage
void Ableton::displayOscMessage(ofxOscMessage &m)
{
cout << "address : "<< m.getAddress() << endl;
for (int i = 0; i < m.getNumArgs(); i++)
{
if (m.getArgType(i) == OFXOSC_TYPE_INT32) {
cout << " i--> "<<m.getArgAsInt32(i)<<endl;
}
else if (m.getArgType(i) == OFXOSC_TYPE_INT64) {
cout << " j--> "<<m.getArgAsInt64(i)<<endl;
}
else if (m.getArgType(i) == OFXOSC_TYPE_FLOAT) {
cout << " f--> "<<m.getArgAsFloat(i)<<endl;
}
else if (m.getArgType(i) == OFXOSC_TYPE_STRING) {
cout << " s--> "<<m.getArgAsString(i)<<endl;
}
else if (m.getArgType(i) == OFXOSC_TYPE_BLOB) {
cout << " b--> "<<m.getArgAsBlob(i)<<endl;
}
}
}
示例13: getOscMsgAsString
//--------------------------------------------------------------
string ofApp::getOscMsgAsString(ofxOscMessage m){
string msg_string;
msg_string = m.getAddress();
msg_string += ":";
for(int i = 0; i < m.getNumArgs(); i++){
// get the argument type
msg_string += " " + m.getArgTypeName(i);
msg_string += ":";
// display the argument - make sure we get the right type
if(m.getArgType(i) == OFXOSC_TYPE_INT32){
msg_string += ofToString(m.getArgAsInt32(i));
}
else if(m.getArgType(i) == OFXOSC_TYPE_FLOAT){
msg_string += ofToString(m.getArgAsFloat(i));
}
else if(m.getArgType(i) == OFXOSC_TYPE_STRING){
msg_string += m.getArgAsString(i);
}
else{
msg_string += "unknown";
}
}
return msg_string;
}
示例14: getMessageAsString
string OscManager::getMessageAsString(const ofxOscMessage& m) const
{
string msg_string;
msg_string = m.getAddress();
for(int i = 0; i < m.getNumArgs(); i++){
// get the argument type
msg_string += " ";
// display the argument - make sure we get the right type
if(m.getArgType(i) == OFXOSC_TYPE_INT32){
msg_string += ofToString(m.getArgAsInt32(i));
}
else if(m.getArgType(i) == OFXOSC_TYPE_FLOAT){
msg_string += ofToString(m.getArgAsFloat(i));
}
else if(m.getArgType(i) == OFXOSC_TYPE_STRING){
msg_string += m.getArgAsString(i);
}
else{
msg_string += "unknown";
}
}
return msg_string;
}
示例15: matchTypes
// are this two objects compatible?
bool OscController::matchTypes(string controlName, ofxOscMessage message) {
ofAbstractParameter& p = controls[controlName]->getParameter();
// vezer can send these types of messages:
// float, int, bool, color and... string?
if(message.getNumArgs() == 3){
if(p.type() == typeid(ofParameter<ofColor>).name()
&& message.getArgType(0) == OFXOSC_TYPE_INT32){
return true;
}
else if(p.type() == typeid(ofParameter<ofFloatColor>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
}
else if(message.getNumArgs() == 1){
if(p.type() == typeid(ofParameter<int>).name()
&& message.getArgType(0) == OFXOSC_TYPE_INT32){
return true;
}
else if(p.type() == typeid(ofParameter<float>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
else if(p.type() == typeid(ofParameter<bool>).name()
&& message.getArgType(0) == OFXOSC_TYPE_INT32){
return true;
}
////////////////////////////////////////////////////////////////
// testing:
// floats will be converted to bool if parameter type is bool
else if(p.type() == typeid(ofParameter<bool>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
// floats will be converted to ints if parameter type is int
else if(p.type() == typeid(ofParameter<int>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
////////////////////////////////////////////////////////////////
}
return false;
}