void OSCServer::oscMessageReceived (const OSCMessage& message){ // we're realtime here, defer if needed if(createClientIfNeeded(message)) return; if(OSCAddressPattern("/All/*").matches(message.getAddressPattern().toString())){ StringArray res; res.addTokens(message.getAddressPattern().toString(),"/",""); res.removeRange(1, 1); String current = res.joinIntoString("/"); for(auto &c:clients){ for(auto & b:c->boundedParams){ StringArray res2; res2.addTokens(b->address.toString(),"/",""); // currently /Tracks/i/i/... res2.removeRange(1, 3); String curS = res2.joinIntoString("/"); if(curS == current){ float val; if(getValueFromMessage(message, val)){ b->setValue(val); } } } } } else{ for(auto &c:clients){ for(auto & b:c->boundedParams){ if(message.getAddressPattern() == b->address){ float val; if(getValueFromMessage(message, val)){ b->setValue(val); } else{ DBG("message format not supported : "+String( message[0].getType())); } } } } } }
nImO::SpValue nImO::Array::extractValue (const nImO::Message & theMessage, const int leadByte, size_t & position, nImO::SpArray parentValue) { ODL_ENTER(); //#### ODL_P3("theMessage = ", &theMessage, "position = ", &position, "parentValue = ", //#### parentValue.get()); //#### ODL_X1("leadByte = ", leadByte); //#### SpValue result; bool atEnd; bool isEmpty = (DataKind::OtherContainerEmptyValue == (DataKind::OtherContainerEmptyMask & leadByte)); int aByte; ++position; // We will always accept the lead byte ODL_I1("position <- ", position); //#### if (isEmpty) { ODL_LOG("(isEmpty)"); //#### aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (! atEnd) { ODL_LOG("(! atEnd)"); //#### static const DataKind endMarker = (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerEmptyValue); if (toUType(endMarker) == aByte) { ODL_LOG("(endMarker == aByte)"); //#### result.reset(new Array); ++position; ODL_I1("position <- ", position); //#### } else { ODL_LOG("! (endMarker == aByte)"); //#### result.reset(new Invalid("Empty Array with incorrect end tag @", position)); } } } else { ODL_LOG("! (isEmpty)"); //#### aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (! atEnd) { ODL_LOG("(! atEnd)"); //#### IntStatus numStatus; int64_t elementCount = extractInt64FromMessage(theMessage, aByte, position, numStatus); if (IntStatus::Successful == numStatus) { ODL_LOG("(IntStatus::Successful == status)"); //#### elementCount -= DataKindIntegerShortValueMinValue - 1; ODL_I1("elementCount <- ", elementCount); //#### if (0 >= elementCount) { ODL_LOG("(0 >= elementCount)"); //#### result.reset(new Invalid("Array with zero or negative count @", position)); } else { auto anArray = std::make_shared<Array>(); result = anArray; if (nullptr == result) { ODL_LOG("(nullptr == result)"); //#### result.reset(new Invalid("Could not allocate an Array")); } else { bool okSoFar = true; for ( ; okSoFar && (elementCount > static_cast<int64_t>(anArray->size())); ) { aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (atEnd) { ODL_LOG("(atEnd)"); //#### result.reset(); okSoFar = false; } else { SpValue aValue(getValueFromMessage(theMessage, position, aByte, anArray)); // Note that it is the responsibility of the extractor to add to // this Array, so it's not correct for this loop to perform an // append operation. if (nullptr == aValue) { ODL_LOG("(nullptr == aValue)"); //#### result.reset(new Invalid("Null Value read @", position)); okSoFar = false; } else if (aValue->asFlaw()) { ODL_LOG("(aValue->asFlaw())"); //#### result = aValue; okSoFar = false; } } } if (okSoFar) { aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (atEnd) { ODL_LOG("(atEnd)"); //#### result.reset(); okSoFar = false; } else { ODL_LOG("! (atEnd)"); //#### static const DataKind endMarker = (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerNonEmptyValue); if (toUType(endMarker) == aByte) { ODL_LOG("(toUType(endMarker) == aByte)"); //#### ++position; ODL_I1("position <- ", position); //#### } else { ODL_LOG("! (toUType(endMarker) == aByte)"); //#### result.reset(new Invalid("Non-empty Array with incorrect end " "tag @", position)); } } } } } } else { ODL_LOG("! (IntStatus::Successful == numStatus)"); //#### } } } if ((nullptr != parentValue) && (nullptr != result) && (! result->asFlaw())) { ODL_LOG("((nullptr != parentValue) && (nullptr != result) && (! result->asFlaw()))"); //#### parentValue->addValue(result); } ODL_EXIT_P(result.get()); //#### return result; } // nImO::Array::extractValue