本文整理汇总了C++中ofxOscMessage::getArgAsBlob方法的典型用法代码示例。如果您正苦于以下问题:C++ ofxOscMessage::getArgAsBlob方法的具体用法?C++ ofxOscMessage::getArgAsBlob怎么用?C++ ofxOscMessage::getArgAsBlob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofxOscMessage
的用法示例。
在下文中一共展示了ofxOscMessage::getArgAsBlob方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleControlMessage
//--------------------------------------------------------------
void DonutCop::handleControlMessage(const ofxOscMessage &m) {
ofBuffer data = m.getArgAsBlob(0);
_maxSprinkles = m.getArgAsInt32(1);
_minSprinkles = m.getArgAsInt32(2);
_maxNewSprinkles = m.getArgAsInt32(3);
_maxVelocity = m.getArgAsFloat(4);
_maxAcceleration = m.getArgAsFloat(5);
// Calculate left and right IDs
int val;
int maxId = 0;
leftId = 256;
rightId = -1;
for (int i = 0; i < data.size(); ++i) {
val = (int)(data.getData()[i]);
if (val > id && val < leftId) {
leftId = val;
}
if (val < id && val > rightId) {
rightId = val;
}
if (val > maxId) {
maxId = val;
}
}
if (leftId == 256) {
leftId = 0;
}
if (rightId == -1) {
rightId = maxId;
}
ofLogVerbose() << "My left ID is " << leftId << " and my right ID is " << rightId << ".";
}
示例2: 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);
}
}
}
}
}
示例3: 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;
}
}
}
示例4: appendMessage
void ofApp::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_DOUBLE )
p << message.getArgAsDouble( i );
else if ( message.getArgType( i ) == OFXOSC_TYPE_STRING || message.getArgType( i ) == OFXOSC_TYPE_SYMBOL)
p << message.getArgAsString( i ).c_str();
else if ( message.getArgType( i ) == OFXOSC_TYPE_CHAR )
p << message.getArgAsChar( i );
else if ( message.getArgType( i ) == OFXOSC_TYPE_MIDI_MESSAGE )
p << message.getArgAsMidiMessage( i );
else if ( message.getArgType( i ) == OFXOSC_TYPE_TRUE || message.getArgType( i ) == OFXOSC_TYPE_FALSE )
p << message.getArgAsBool( i );
else if ( message.getArgType( i ) == OFXOSC_TYPE_TRIGGER )
p << message.getArgAsTrigger( i );
else if ( message.getArgType( i ) == OFXOSC_TYPE_TIMETAG )
p << (osc::int64)message.getArgAsTimetag( i );
//else if ( message.getArgType( i ) == OFXOSC_TYPE_RGBA_COLOR )
// p << message.getArgAsRgbaColor( i );
else if ( message.getArgType( i ) == OFXOSC_TYPE_BLOB ){
ofBuffer buff = message.getArgAsBlob(i);
osc::Blob b(buff.getData(), (unsigned long)buff.size());
p << b;
}else
{
ofLogError("ofxOscSender") << "appendMessage(): bad argument type " << message.getArgType( i );
assert( false );
}
}
p << osc::EndMessage;
}