本文整理汇总了C++中OSCMessage::size方法的典型用法代码示例。如果您正苦于以下问题:C++ OSCMessage::size方法的具体用法?C++ OSCMessage::size怎么用?C++ OSCMessage::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSCMessage
的用法示例。
在下文中一共展示了OSCMessage::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: oscMessageReceived
// this is called if an OSC message is received
void Ambix_encoderAudioProcessor::oscMessageReceived (const OSCMessage& message)
{
// /ambi_enc_set <id> <distance> <azimuth> <elevation> <size>
// parse the message for int and float
float val[5];
for (int i=0; i < jmin(5,message.size()); i++) {
val[i] = 0.5f;
// get the value wheter it is a int or float value
if (message[i].getType() == OSCTypes::float32)
{
val[i] = (float)message[i].getFloat32();
}
else if (message[i].getType() == OSCTypes::int32)
{
val[i] = (float)message[i].getInt32();
}
}
setParameterNotifyingHost(Ambix_encoderAudioProcessor::AzimuthParam, jlimit(0.f, 1.f, (val[2]+180.f)/360.f) );
setParameterNotifyingHost(Ambix_encoderAudioProcessor::ElevationParam, jlimit(0.f, 1.f, (val[3]+180.f)/360.f) );
setParameterNotifyingHost(Ambix_encoderAudioProcessor::SizeParam, jlimit(0.f, 1.f, val[4]));
}
示例2: getValueFromMessage
bool OSCServer::getValueFromMessage(const OSCMessage& message,float & val){
// allow empty messages for boolean actions
if(message.size() == 0){
val = 1;
return true;
}
if(message[0].isInt32()){
val = message[0].getInt32();
return true;
}
else if(message[0].isFloat32()){
val = message[0].getFloat32();
return true;
}
else if(message[0].isBlob()){
//not supported
jassert(false);
}
return false;
}
示例3: oscMessageReceived
void TuioClient::oscMessageReceived (const OSCMessage& message) {
if( message.getAddressPattern() == "/tuio/2Dcur" ) {
String cmd;
cmd = message[0].getString();
if (cmd == "set") {
int32 s_id;
float xpos, ypos, xspeed, yspeed, maccel;
s_id=message[1].getInt32();
xpos=message[2].getFloat32();
ypos=message[3].getFloat32();
xspeed =message[4].getFloat32();
yspeed=message[5].getFloat32();
maccel=message[6].getFloat32();
std::list<TuioCursor*>::iterator tcur;
for (tcur=cursorList.begin(); tcur!= cursorList.end(); tcur++)
if((*tcur)->getSessionID()==(long)s_id) break;
if (tcur==cursorList.end()) {
TuioCursor *addCursor = new TuioCursor((long)s_id,-1,xpos,ypos);
frameCursors.push_back(addCursor);
} else if ( ((*tcur)->getX()!=xpos) || ((*tcur)->getY()!=ypos) || ((*tcur)->getXSpeed()!=xspeed) || ((*tcur)->getYSpeed()!=yspeed) || ((*tcur)->getMotionAccel()!=maccel) ) {
int id = (*tcur)->getCursorID();
TuioCursor *updateCursor = new TuioCursor((long)s_id,id,xpos,ypos);
updateCursor->update(xpos,ypos,xspeed,yspeed,maccel);
frameCursors.push_back(updateCursor);
}
} else if (cmd=="alive") {
aliveCursorList.clear();
for(int i = 1; i < message.size() ; i++) {
aliveCursorList.push_back(message[i].getInt32());
}
} else if( cmd== "fseq" ){
int32 fseq;
fseq = message[1].getInt32();
bool lateFrame = false;
if (fseq>0) {
if (fseq>currentFrame) currentTime = TuioTime::getSessionTime();
if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame = fseq;
else lateFrame = true;
} else if ((TuioTime::getSessionTime().getTotalMilliseconds()-currentTime.getTotalMilliseconds())>100) {
currentTime = TuioTime::getSessionTime();
}
if (!lateFrame) {
// lockCursorList();
// find the removed cursors first
for (std::list<TuioCursor*>::iterator tcur=cursorList.begin(); tcur != cursorList.end(); tcur++) {
std::list<long>::iterator iter = find(aliveCursorList.begin(), aliveCursorList.end(), (*tcur)->getSessionID());
if (iter == aliveCursorList.end()) {
(*tcur)->remove(currentTime);
frameCursors.push_back(*tcur);
}
}
// unlockCursorList();
for (std::list<TuioCursor*>::iterator iter=frameCursors.begin(); iter != frameCursors.end(); iter++) {
TuioCursor *tcur = (*iter);
int c_id = -1;
TuioCursor *frameCursor = NULL;
switch (tcur->getTuioState()) {
case TUIO_REMOVED:
frameCursor = tcur;
frameCursor->remove(currentTime);
for (std::list<TuioListener*>::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
(*listener)->removeTuioCursor(frameCursor);
// lockCursorList();
for (std::list<TuioCursor*>::iterator delcur=cursorList.begin(); delcur!=cursorList.end(); delcur++) {
if((*delcur)->getSessionID()==frameCursor->getSessionID()) {
cursorList.erase(delcur);
break;
}
}
//.........这里部分代码省略.........
示例4: runTest
void runTest()
{
beginTest ("Basic usage");
{
OSCMessage msg ("/test/param0");
expectEquals (msg.size(), 0);
expect (msg.getAddressPattern().toString() == "/test/param0");
const int numTestArgs = 4;
const int testInt = 42;
const float testFloat = 3.14159f;
const String testString = "Hello, World!";
const uint8 testBlobData[5] = { 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
const MemoryBlock testBlob (testBlobData, sizeof (testBlobData));
msg.addInt32 (testInt);
msg.addFloat32 (testFloat);
msg.addString (testString);
msg.addBlob (testBlob);
expectEquals (msg.size(), numTestArgs);
expectEquals (msg[0].getType(), OSCTypes::int32);
expectEquals (msg[1].getType(), OSCTypes::float32);
expectEquals (msg[2].getType(), OSCTypes::string);
expectEquals (msg[3].getType(), OSCTypes::blob);
expect (msg[0].isInt32());
expect (msg[1].isFloat32());
expect (msg[2].isString());
expect (msg[3].isBlob());
expectEquals (msg[0].getInt32(), testInt);
expectEquals (msg[1].getFloat32(), testFloat);
expectEquals (msg[2].getString(), testString);
expect (msg[3].getBlob() == testBlob);
expect (msg.begin() + numTestArgs == msg.end());
OSCArgument* arg = msg.begin();
expect (arg->isInt32());
expectEquals (arg->getInt32(), testInt);
++arg;
expect (arg->isFloat32());
expectEquals (arg->getFloat32(), testFloat);
++arg;
expect (arg->isString());
expectEquals (arg->getString(), testString);
++arg;
expect (arg->isBlob());
expect(arg->getBlob() == testBlob);
++arg;
expect (arg == msg.end());
}
beginTest ("Initialisation with argument list (C++11 only)");
{
int testInt = 42;
float testFloat = 5.5;
String testString = "Hello, World!";
{
OSCMessage msg ("/test", testInt);
expect (msg.getAddressPattern().toString() == String ("/test"));
expectEquals (msg.size(), 1);
expect (msg[0].isInt32());
expectEquals (msg[0].getInt32(), testInt);
}
{
OSCMessage msg ("/test", testFloat);
expect (msg.getAddressPattern().toString() == String ("/test"));
expectEquals (msg.size(), 1);
expect (msg[0].isFloat32());
expectEquals (msg[0].getFloat32(), testFloat);
}
{
OSCMessage msg ("/test", testString);
expect (msg.getAddressPattern().toString() == String ("/test"));
expectEquals (msg.size(), 1);
expect (msg[0].isString());
expectEquals (msg[0].getString(), testString);
}
{
OSCMessage msg ("/test", testInt, testFloat, testString, testFloat, testInt);
expect (msg.getAddressPattern().toString() == String ("/test"));
expectEquals (msg.size(), 5);
expect (msg[0].isInt32());
expect (msg[1].isFloat32());
expect (msg[2].isString());
expect (msg[3].isFloat32());
expect (msg[4].isInt32());
expectEquals (msg[0].getInt32(), testInt);
expectEquals (msg[1].getFloat32(), testFloat);
expectEquals (msg[2].getString(), testString);
expectEquals (msg[3].getFloat32(), testFloat);
expectEquals (msg[4].getInt32(), testInt);
//.........这里部分代码省略.........