Exemplo n.º 1
0
int
OSCQueue::oscMessageHandler(const char *path, const char *types, lo_arg **argv,
                            int argc, lo_message, void *user_data)
{
    OSCQueue *queue = static_cast<OSCQueue *>(user_data);

    int target;
    int targetData;
    QString method;

    if (!queue->parseOSCPath(path, target, targetData, method)) {
	return 1;
    }

    OSCMessage message;
    message.setTarget(target);
    message.setTargetData(targetData);
    message.setMethod(method);

    int i = 0;

    while (types && i < argc && types[i]) {

        char type = types[i];
        lo_arg *arg = argv[i];

        switch (type) {
        case 'i': message.addArg(arg->i); break;
            // This conversion fails to compile in 64-bit environments
            // at present, and we don't use the h type anyway so we
            // can safely omit it
//        case 'h': message.addArg(arg->h); break;
        case 'f': message.addArg(arg->f); break;
        case 'd': message.addArg(arg->d); break;
        case 'c': message.addArg(arg->c); break;
        case 't': message.addArg(arg->i); break;
        case 's': message.addArg(&arg->s); break;
        default:  std::cerr << "WARNING: OSCQueue::oscMessageHandler: "
                            << "Unsupported OSC type '" << type << "'" 
                            << std::endl;
            break;
        }

	++i;
    }

    queue->postMessage(message);
    return 0;
}
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;
}