本文整理汇总了C++中OSCMessage类的典型用法代码示例。如果您正苦于以下问题:C++ OSCMessage类的具体用法?C++ OSCMessage怎么用?C++ OSCMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSCMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: osc_message_handler
static int osc_message_handler(const char *path, const char *types, lo_arg **argv,
int argc, lo_message, void *user_data)
{
AudioPluginOSCGUIManager *manager = (AudioPluginOSCGUIManager *)user_data;
InstrumentId instrument;
int position;
QString method;
if (!manager->parseOSCPath(path, instrument, position, method)) {
return 1;
}
OSCMessage *message = new OSCMessage();
message->setTarget(instrument);
message->setTargetData(position);
message->setMethod(qstrtostr(method));
int arg = 0;
while (types && arg < argc && types[arg]) {
message->addArg(types[arg], argv[arg]);
++arg;
}
manager->postMessage(message);
return 0;
}
示例2: aviableCheck
int OSCServer::aviableCheck(void)
{
if( udpserver.available() == 0 )
{
return -1;
}
OSCMessage rcvMes;
//get max receive data
udpserver.read(_rcvData, kMaxRecieveData);
//get client ip
udpserver.getip(rcvMes._ip);
//get client port
rcvMes.setPortNumber(udpserver.getport());
//clear input buffer
udpserver.flush();
//decode message
if( _decoder.decode(&rcvMes, _rcvData) < 0 )
{
return -1;
}
_adrMatch.paternComp(&rcvMes);
return 1;
}
示例3: errorCue
void SmSnDevice::handleOSCBundleInternal(class OSCBundle &bundle) {
if (bundle.hasError()) {
errorCue();
playTone(400,100);
osc.sendOSCBundleError(bundle);
} else if (!(handleOSCBundle(bundle)
// TODO: copying addresses into buffers on the fly (via address()), one by one, is inefficient
|| bundle.dispatch(address(OSC_ERROR), handleErrorMessage)
|| bundle.dispatch(address(OSC_INFO), handleInfoMessage)
//|| bundle.dispatch(address(OSC_MORSE), handleMorseMessage)
|| bundle.dispatch(address(OSC_OK), handleOkMessage)
|| bundle.dispatch(address(OSC_PING), handlePingMessage)
|| bundle.dispatch(address(OSC_READY), handleReadyMessage)
#ifdef BOUNTIFUL_RAM
|| bundle.dispatch(address(OSC_CONTEXT_SET), handleContextSetMessage)
|| bundle.dispatch(address(OSC_PING_REPLY), handlePingReplyMessage)
|| bundle.dispatch(address(OSC_RGB_SET), handleRGBSetMessage)
|| bundle.dispatch(address(OSC_TONE), handleToneMessage)
|| bundle.dispatch(address(OSC_VIBRO), handleVibroMessage)
#endif // BOUNTIFUL_RAM
|| bundle.dispatch(address(OSC_WARNING), handleWarningMessage)
)) {
if (!bundle.size()) {
osc.sendError(ERR_EMPTY_OSC_BUNDLE);
} else {
for (int i = 0; i < bundle.size(); i++) {
OSCMessage *m = bundle.getOSCMessage(i);
char address[64];
m->getAddress(address);
osc.sendError(ERR_NO_HANDLER, address);
}
}
errorCue();
}
}
示例4: BigEndian
void OSCBundle::send(Print &p){
//don't send a bundle with errors
if (hasError()){
return;
}
//write the bundle header
static uint8_t header[] = {'#', 'b', 'u', 'n', 'd', 'l', 'e', 0};
p.write(header, 8);
//write the timetag
{
osctime_t time = timetag;
uint32_t d = BigEndian(time.seconds);
uint8_t * ptr = (uint8_t *) &d;
p.write(ptr, 4);
d = BigEndian(time.fractionofseconds);
ptr = (uint8_t *) &d;
p.write(ptr, 4);
}
//send the messages
for (int i = 0; i < numMessages; i++){
OSCMessage * msg = getOSCMessage(i);
int msgSize = msg->bytes();
//turn the message size into a pointer
uint32_t s32 = BigEndian((uint32_t) msgSize);
uint8_t * sptr = (uint8_t *) &s32;
//write the messsage size
p.write(sptr, 4);
msg->send(p);
}
}
示例5: getOSCMessage
//returns the first fullMatch.
OSCMessage * OSCBundle::getOSCMessage( char * addr){
for (int i = 0; i < numMessages; i++){
OSCMessage * msg = getOSCMessage(i);
if (msg->fullMatch(addr)){
return msg;
}
}
}
示例6: void
bool OSCBundle::route(const char * pattern, void (*callback)(OSCMessage&, int), int initial_offset){
bool called = false;
for (int i = 0; i < numMessages; i++){
OSCMessage msg = getOSCMessage(i);
called = msg.route(pattern, callback, initial_offset) || called;
}
return called;
}
示例7: encoderButton
void encoderButton(OSCMessage &msg){
if (msg.isInt(0)){
if (msg.getInt(0) == 1) {
ui.encoderPress();
}
if (msg.getInt(0) == 0) {
ui.encoderRelease();
}
}
}
示例8: setScreenLine
/* helpers */
void setScreenLine(OledScreen &screen, int lineNum, OSCMessage &msg){
char str[256];
char screenLine[256];
int i = 0;
screenLine[0] = 0;
// since there are no strings in pd, the line message will be made of different types
// cat the line together, then throw it up on the patch screen
while (msg.isString(i) || msg.isFloat(i) || msg.isInt(i)){
if (msg.isString(i)){
msg.getString(i, str, 256);
strcat(screenLine, str);
strcat(screenLine, " ");
}
if (msg.isFloat(i)){
sprintf(str, "%g ", msg.getFloat(i));
strcat(screenLine, str);
}
if (msg.isInt(i)){
sprintf(str, "%d ", msg.getInt(i));
strcat(screenLine, str);
}
i++;
}
screen.setLine(lineNum, screenLine);
// printf("%s\n", screenLine);
}
示例9: OSCMessage
void Ambix_encoderAudioProcessor::sendOSC() // send osc data
{
if (osc_out)
{
OSCMessage mymsg = OSCMessage("/ambi_enc");
mymsg.addInt32(m_id); // source id
mymsg.addString("test"); // name... currently unused
mymsg.addFloat32(2.0f); // distance... currently unused
mymsg.addFloat32(360.f*(azimuth_param-0.5f)); // azimuth -180....180°
mymsg.addFloat32(360.f*(elevation_param-0.5f)); // elevation -180....180°
mymsg.addFloat32(size_param); // size param 0.0 ... 1.0
mymsg.addFloat32(dpk); // digital peak value linear 0.0 ... 1.0 (=0dBFS)
mymsg.addFloat32(rms); // rms value linear 0.0 ... 1.0 (=0dBFS)
if(osc_in)
{
mymsg.addInt32(osc_in_port.getIntValue()); // osc receiver udp port
}
for (int i = 0; i < oscSenders.size(); i++) {
oscSenders.getUnchecked(i)->send(mymsg);
}
_azimuth_param = azimuth_param; // change buffers
_elevation_param = elevation_param;
_size_param = size_param;
_rms = rms;
_dpk = dpk;
}
}
示例10: oscMessageReceived
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()));
}
}
}
}
}
}
示例11: vuMeter
void vuMeter(OSCMessage &msg){
static int count;
char line[1024];
int len, i, outR, outL, inR, inL;
if (msg.isInt(0)) inR = msg.getInt(0);
if (msg.isInt(1)) inL = msg.getInt(1);
if (msg.isInt(2)) outR = msg.getInt(2);
if (msg.isInt(3)) outL = msg.getInt(3);
ui.patchScreen.drawInfoBar(inR, inL, outR, outL);
}
示例12: OSCMessage
OSCMessage & OSCBundle::add(OSCMessage & _msg){
OSCMessage * msg = new OSCMessage(_msg);
if (!msg->hasError()){
//realloc the array to fit the message
OSCMessage ** messageMem = (OSCMessage **) realloc(messages, sizeof(OSCMessage *) * (numMessages + 1));
if (messageMem != NULL){
messages = messageMem;
messages[numMessages] = msg;
numMessages++;
} else {
error = ALLOCFAILED;
}
}
return *msg;
}
示例13: decodeMessage
void OSCBundle::decodeMessage(uint8_t incomingByte){
//get the current message
if (numMessages > 0){
OSCMessage * lastMessage = messages[numMessages - 1];
//put the bytes in there
lastMessage->fill(incomingByte);
//if it's all done
if (incomingBufferSize == incomingMessageSize){
//move onto the next message
decodeState = MESSAGE_SIZE;
clearIncomingBuffer();
} else if (incomingBufferSize > incomingMessageSize){
error = INVALID_OSC;
}
}
}
示例14: 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]));
}
示例15: createClientIfNeeded
bool OSCServer::createClientIfNeeded(const OSCMessage &m){
// m.
// TODO what clever protocol should we implement
if(m.getAddressPattern().matches(OSCAddress("/Hi"))){
String host = m[0].getString();
if(host == "localhost"){
host = "127.0.0.1";
}
int port = m[1].getInt32();
for(auto & c:clients){
if(c->host==host && c->port == port)
return false;
}
OSCClient * cli = new OSCClient(host,port,true);
for(auto & t:owner->tracks){
for(auto & p :t.get()->getParameters()){
cli->bindParameter(t, p, "/Tracks/"+String(*t->groupID) + "/" +String(*t->trackNum) + "/" + p->getName(50) );
}
}
clients.add(cli);
return true;
}
else if(m.getAddressPattern().matches(OSCAddress("/Bye"))){
String host = m[0].getString();
if(host == "localhost"){
host = "127.0.0.1";
}
int port = m[1].getInt32();
for(auto & c:clients){
if(c->host==host && c->port == port){
clients.removeObject(c);
break;
}
}
}
return false;
}