Пример #1
0
bool CarlaBridgeUI::msgReceived(const char* const msg) noexcept
{
    carla_debug("CarlaBridgeUI::msgReceived(\"%s\")", msg);

    if (! fGotOptions) {
        CARLA_SAFE_ASSERT_RETURN(std::strcmp(msg, "urid") == 0 || std::strcmp(msg, "uiOptions") == 0, true);
    }

    if (fLastMsgTimer > 0)
        --fLastMsgTimer;

    if (std::strcmp(msg, "control") == 0)
    {
        uint32_t index;
        float value;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(index), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

        dspParameterChanged(index, value);
        return true;
    }

    if (std::strcmp(msg, "program") == 0)
    {
        uint32_t index;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(index), true);

        dspProgramChanged(index);
        return true;
    }

    if (std::strcmp(msg, "midiprogram") == 0)
    {
        uint32_t bank, program;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(bank), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(program), true);

        dspMidiProgramChanged(bank, program);
        return true;
    }

    if (std::strcmp(msg, "configure") == 0)
    {
        const char* key;
        const char* value;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(key), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(value), true);

        dspStateChanged(key, value);

        delete[] key;
        delete[] value;
        return true;
    }

    if (std::strcmp(msg, "note") == 0)
    {
        bool onOff;
        uint8_t channel, note, velocity;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(onOff), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsByte(channel), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsByte(note), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsByte(velocity), true);

        dspNoteReceived(onOff, channel, note, velocity);
    }

    if (std::strcmp(msg, "atom") == 0)
    {
        uint32_t index, atomTotalSize;
        const char* base64atom;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(index), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(atomTotalSize), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(base64atom), true);

        std::vector<uint8_t> chunk(carla_getChunkFromBase64String(base64atom));
        delete[] base64atom;
        CARLA_SAFE_ASSERT_RETURN(chunk.size() >= sizeof(LV2_Atom), true);

        const LV2_Atom* const atom((const LV2_Atom*)chunk.data());
        const uint32_t atomTotalSizeCheck(lv2_atom_total_size(atom));

        CARLA_SAFE_ASSERT_RETURN(atomTotalSizeCheck == atomTotalSize, true);
        CARLA_SAFE_ASSERT_RETURN(atomTotalSizeCheck == chunk.size(), true);

        dspAtomReceived(index, atom);
        return true;
    }

    if (std::strcmp(msg, "urid") == 0)
    {
        uint32_t urid;
        const char* uri;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(urid), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(uri), true);

        if (urid != 0)
            dspURIDReceived(urid, uri);

        delete[] uri;
        return true;
    }

    if (std::strcmp(msg, "uiOptions") == 0)
    {
        double sampleRate;
        bool useTheme, useThemeColors;
        const char* windowTitle;
        uint64_t transientWindowId;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsDouble(sampleRate), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(useTheme), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(useThemeColors), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(windowTitle), true);
        CARLA_SAFE_ASSERT_RETURN(readNextLineAsULong(transientWindowId), true);

        fGotOptions = true;
        uiOptionsChanged(sampleRate, useTheme, useThemeColors, windowTitle, static_cast<uintptr_t>(transientWindowId));

        delete[] windowTitle;
        return true;
    }

    CARLA_SAFE_ASSERT_RETURN(fToolkit != nullptr, true);

    if (std::strcmp(msg, "show") == 0)
    {
        fToolkit->show();
        return true;
    }

    if (std::strcmp(msg, "focus") == 0)
    {
        fToolkit->focus();
        return true;
    }

    if (std::strcmp(msg, "hide") == 0)
    {
        fToolkit->hide();
        return true;
    }

    if (std::strcmp(msg, "quit") == 0)
    {
        fQuitReceived = true;
        fToolkit->quit();
        delete fToolkit;
        fToolkit = nullptr;
        return true;
    }

    if (std::strcmp(msg, "uiTitle") == 0)
    {
        const char* title;

        CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(title), true);

        fToolkit->setTitle(title);

        delete[] title;
        return true;
    }

    carla_stderr("CarlaBridgeUI::msgReceived : %s", msg);
    return false;
}
Пример #2
0
static inline
const char* PluginBridgeNonRtClientOpcode2str(const PluginBridgeNonRtClientOpcode opcode) noexcept
{
    switch (opcode)
    {
    case kPluginBridgeNonRtClientNull:
        return "kPluginBridgeNonRtClientNull";
    case kPluginBridgeNonRtClientPing:
        return "kPluginBridgeNonRtClientPing";
    case kPluginBridgeNonRtClientPingOnOff:
        return "kPluginBridgeNonRtClientPingOnOff";
    case kPluginBridgeNonRtClientActivate:
        return "kPluginBridgeNonRtClientActivate";
    case kPluginBridgeNonRtClientDeactivate:
        return "kPluginBridgeNonRtClientDeactivate";
    case kPluginBridgeNonRtClientSetBufferSize:
        return "kPluginBridgeNonRtClientSetBufferSize";
    case kPluginBridgeNonRtClientSetSampleRate:
        return "kPluginBridgeNonRtClientSetSampleRate";
    case kPluginBridgeNonRtClientSetOffline:
        return "kPluginBridgeNonRtClientSetOffline";
    case kPluginBridgeNonRtClientSetOnline:
        return "kPluginBridgeNonRtClientSetOnline";
    case kPluginBridgeNonRtClientSetParameterValue:
        return "kPluginBridgeNonRtClientSetParameterValue";
    case kPluginBridgeNonRtClientSetParameterMidiChannel:
        return "kPluginBridgeNonRtClientSetParameterMidiChannel";
    case kPluginBridgeNonRtClientSetParameterMidiCC:
        return "kPluginBridgeNonRtClientSetParameterMidiCC";
    case kPluginBridgeNonRtClientSetProgram:
        return "kPluginBridgeNonRtClientSetProgram";
    case kPluginBridgeNonRtClientSetMidiProgram:
        return "kPluginBridgeNonRtClientSetMidiProgram";
    case kPluginBridgeNonRtClientSetCustomData:
        return "kPluginBridgeNonRtClientSetCustomData";
    case kPluginBridgeNonRtClientSetChunkDataFile:
        return "kPluginBridgeNonRtClientSetChunkDataFile";
    case kPluginBridgeNonRtClientSetCtrlChannel:
        return "kPluginBridgeNonRtClientSetCtrlChannel";
    case kPluginBridgeNonRtClientSetOption:
        return "kPluginBridgeNonRtClientSetOption";
    case kPluginBridgeNonRtClientPrepareForSave:
        return "kPluginBridgeNonRtClientPrepareForSave";
    case kPluginBridgeNonRtClientShowUI:
        return "kPluginBridgeNonRtClientShowUI";
    case kPluginBridgeNonRtClientHideUI:
        return "kPluginBridgeNonRtClientHideUI";
    case kPluginBridgeNonRtClientUiParameterChange:
        return "kPluginBridgeNonRtClientUiParameterChange";
    case kPluginBridgeNonRtClientUiProgramChange:
        return "kPluginBridgeNonRtClientUiProgramChange";
    case kPluginBridgeNonRtClientUiMidiProgramChange:
        return "kPluginBridgeNonRtClientUiMidiProgramChange";
    case kPluginBridgeNonRtClientUiNoteOn:
        return "kPluginBridgeNonRtClientUiNoteOn";
    case kPluginBridgeNonRtClientUiNoteOff:
        return "kPluginBridgeNonRtClientUiNoteOff";
    case kPluginBridgeNonRtClientQuit:
        return "kPluginBridgeNonRtClientQuit";
    }

    carla_stderr("CarlaBackend::PluginBridgeNonRtClientOpcode2str(%i) - invalid opcode", opcode);
    return nullptr;
}
Пример #3
0
static inline
const char* PluginBridgeNonRtServerOpcode2str(const PluginBridgeNonRtServerOpcode opcode) noexcept
{
    switch (opcode)
    {
    case kPluginBridgeNonRtServerNull:
        return "kPluginBridgeNonRtServerNull";
    case kPluginBridgeNonRtServerPong:
        return "kPluginBridgeNonRtServerPong";
    case kPluginBridgeNonRtServerPluginInfo1:
        return "kPluginBridgeNonRtServerPluginInfo1";
    case kPluginBridgeNonRtServerPluginInfo2:
        return "kPluginBridgeNonRtServerPluginInfo2";
    case kPluginBridgeNonRtServerAudioCount:
        return "kPluginBridgeNonRtServerAudioCount";
    case kPluginBridgeNonRtServerMidiCount:
        return "kPluginBridgeNonRtServerMidiCount";
    case kPluginBridgeNonRtServerCvCount:
        return "kPluginBridgeNonRtServerCvCount";
    case kPluginBridgeNonRtServerParameterCount:
        return "kPluginBridgeNonRtServerParameterCount";
    case kPluginBridgeNonRtServerProgramCount:
        return "kPluginBridgeNonRtServerProgramCount";
    case kPluginBridgeNonRtServerMidiProgramCount:
        return "kPluginBridgeNonRtServerMidiProgramCount";
    case kPluginBridgeNonRtServerPortName:
        return "kPluginBridgeNonRtServerPortName";
    case kPluginBridgeNonRtServerParameterData1:
        return "kPluginBridgeNonRtServerParameterData1";
    case kPluginBridgeNonRtServerParameterData2:
        return "kPluginBridgeNonRtServerParameterData2";
    case kPluginBridgeNonRtServerParameterRanges:
        return "kPluginBridgeNonRtServerParameterRanges";
    case kPluginBridgeNonRtServerParameterValue:
        return "kPluginBridgeNonRtServerParameterValue";
    case kPluginBridgeNonRtServerParameterValue2:
        return "kPluginBridgeNonRtServerParameterValue2";
    case kPluginBridgeNonRtServerDefaultValue:
        return "kPluginBridgeNonRtServerDefaultValue";
    case kPluginBridgeNonRtServerCurrentProgram:
        return "kPluginBridgeNonRtServerCurrentProgram";
    case kPluginBridgeNonRtServerCurrentMidiProgram:
        return "kPluginBridgeNonRtServerCurrentMidiProgram";
    case kPluginBridgeNonRtServerProgramName:
        return "kPluginBridgeNonRtServerProgramName";
    case kPluginBridgeNonRtServerMidiProgramData:
        return "kPluginBridgeNonRtServerMidiProgramData";
    case kPluginBridgeNonRtServerSetCustomData:
        return "kPluginBridgeNonRtServerSetCustomData";
    case kPluginBridgeNonRtServerSetChunkDataFile:
        return "kPluginBridgeNonRtServerSetChunkDataFile";
    case kPluginBridgeNonRtServerSetLatency:
        return "kPluginBridgeNonRtServerSetLatency";
    case kPluginBridgeNonRtServerReady:
        return "kPluginBridgeNonRtServerReady";
    case kPluginBridgeNonRtServerSaved:
        return "kPluginBridgeNonRtServerSaved";
    case kPluginBridgeNonRtServerUiClosed:
        return "kPluginBridgeNonRtServerUiClosed";
    case kPluginBridgeNonRtServerError:
        return "kPluginBridgeNonRtServerError";
    }

    carla_stderr("CarlaBackend::PluginBridgeNonRtServerOpcode2str%i) - invalid opcode", opcode);
    return nullptr;
}
Пример #4
0
static inline
const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
{
    switch (opcode)
    {
    case ENGINE_CALLBACK_DEBUG:
        return "ENGINE_CALLBACK_DEBUG";
    case ENGINE_CALLBACK_PLUGIN_ADDED:
        return "ENGINE_CALLBACK_PLUGIN_ADDED";
    case ENGINE_CALLBACK_PLUGIN_REMOVED:
        return "ENGINE_CALLBACK_PLUGIN_REMOVED";
    case ENGINE_CALLBACK_PLUGIN_RENAMED:
        return "ENGINE_CALLBACK_PLUGIN_RENAMED";
    case ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
        return "ENGINE_CALLBACK_PLUGIN_UNAVAILABLE";
    case ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
        return "ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED";
    case ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
        return "ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED";
    case ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
        return "ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED";
    case ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
        return "ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED";
    case ENGINE_CALLBACK_PROGRAM_CHANGED:
        return "ENGINE_CALLBACK_PROGRAM_CHANGED";
    case ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
        return "ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED";
    case ENGINE_CALLBACK_OPTION_CHANGED:
        return "ENGINE_CALLBACK_OPTION_CHANGED";
    case ENGINE_CALLBACK_UI_STATE_CHANGED:
        return "ENGINE_CALLBACK_UI_STATE_CHANGED";
    case ENGINE_CALLBACK_NOTE_ON:
        return "ENGINE_CALLBACK_NOTE_ON";
    case ENGINE_CALLBACK_NOTE_OFF:
        return "ENGINE_CALLBACK_NOTE_OFF";
    case ENGINE_CALLBACK_UPDATE:
        return "ENGINE_CALLBACK_UPDATE";
    case ENGINE_CALLBACK_RELOAD_INFO:
        return "ENGINE_CALLBACK_RELOAD_INFO";
    case ENGINE_CALLBACK_RELOAD_PARAMETERS:
        return "ENGINE_CALLBACK_RELOAD_PARAMETERS";
    case ENGINE_CALLBACK_RELOAD_PROGRAMS:
        return "ENGINE_CALLBACK_RELOAD_PROGRAMS";
    case ENGINE_CALLBACK_RELOAD_ALL:
        return "ENGINE_CALLBACK_RELOAD_ALL";
    case ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
        return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED";
    case ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
        return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED";
    case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
        return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED";
    case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED:
        return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED";
    case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
        return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED";
    case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
        return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED";
    case ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED:
        return "ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED";
    case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
        return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED";
    case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
        return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED";
    case ENGINE_CALLBACK_ENGINE_STARTED:
        return "ENGINE_CALLBACK_ENGINE_STARTED";
    case ENGINE_CALLBACK_ENGINE_STOPPED:
        return "ENGINE_CALLBACK_ENGINE_STOPPED";
    case ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
        return "ENGINE_CALLBACK_PROCESS_MODE_CHANGED";
    case ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
        return "ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED";
    case ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
        return "ENGINE_CALLBACK_BUFFER_SIZE_CHANGED";
    case ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
        return "ENGINE_CALLBACK_SAMPLE_RATE_CHANGED";
    case ENGINE_CALLBACK_IDLE:
        return "ENGINE_CALLBACK_IDLE";
    case ENGINE_CALLBACK_INFO:
        return "ENGINE_CALLBACK_INFO";
    case ENGINE_CALLBACK_ERROR:
        return "ENGINE_CALLBACK_ERROR";
    case ENGINE_CALLBACK_QUIT:
        return "ENGINE_CALLBACK_QUIT";
    }

    carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);
    return nullptr;
}