| @@ -741,15 +741,12 @@ public: | |||
| /*! | |||
| * Add new plugin. | |||
| */ | |||
| bool addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra = nullptr); | |||
| bool addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra); | |||
| /*! | |||
| * Add new plugin, using native binary type. | |||
| */ | |||
| bool addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra = nullptr) | |||
| { | |||
| return addPlugin(BINARY_NATIVE, ptype, filename, name, label, extra); | |||
| } | |||
| bool addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra); | |||
| /*! | |||
| * Remove plugin with id \a id. | |||
| @@ -1124,7 +1121,7 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| // Bridge/Controller OSC stuff | |||
| void oscSend_bridge_plugin_info1(const PluginCategory category, const uint hints, const long uniqueId) const noexcept; | |||
| void oscSend_bridge_plugin_info1(const PluginCategory category, const uint hints, const int64_t uniqueId) const noexcept; | |||
| void oscSend_bridge_plugin_info2(const char* const realName, const char* const label, const char* const maker, const char* const copyright) const noexcept; | |||
| void oscSend_bridge_audio_count(const uint32_t ins, const uint32_t outs) const noexcept; | |||
| void oscSend_bridge_midi_count(const uint32_t ins, const uint32_t outs) const noexcept; | |||
| @@ -1152,7 +1149,7 @@ public: | |||
| void oscSend_control_add_plugin_start(const uint pluginId, const char* const pluginName) const noexcept; | |||
| void oscSend_control_add_plugin_end(const uint pluginId) const noexcept; | |||
| void oscSend_control_remove_plugin(const uint pluginId) const noexcept; | |||
| void oscSend_control_set_plugin_info1(const uint pluginId, const PluginType type, const PluginCategory category, const uint hints, const long uniqueId) const noexcept; | |||
| void oscSend_control_set_plugin_info1(const uint pluginId, const PluginType type, const PluginCategory category, const uint hints, const int64_t uniqueId) const noexcept; | |||
| void oscSend_control_set_plugin_info2(const uint pluginId, const char* const realName, const char* const label, const char* const maker, const char* const copyright) const noexcept; | |||
| void oscSend_control_set_audio_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept; | |||
| void oscSend_control_set_midi_count(const uint pluginId, const uint32_t ins, const uint32_t outs) const noexcept; | |||
| @@ -128,7 +128,7 @@ typedef struct _CarlaPluginInfo { | |||
| * Plugin unique Id.\n | |||
| * This Id is dependant on the plugin type and may sometimes be 0. | |||
| */ | |||
| long uniqueId; | |||
| int64_t uniqueId; | |||
| #ifdef __cplusplus | |||
| /*! | |||
| @@ -628,9 +628,10 @@ CARLA_EXPORT const CarlaTransportInfo* carla_get_transport_info(); | |||
| * @param filename Filename, if applicable | |||
| * @param name Name of the plugin, can be NULL | |||
| * @param label Plugin label, if applicable | |||
| * @param uniqueId Plugin unique Id, if applicable | |||
| * @param extraPtr Extra pointer, defined per plugin type | |||
| */ | |||
| CARLA_EXPORT bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, const void* extraPtr); | |||
| CARLA_EXPORT bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, int64_t uniqueId, const void* extraPtr); | |||
| /*! | |||
| * Remove one plugin. | |||
| @@ -158,7 +158,7 @@ public: | |||
| * Get the plugin's native unique Id.\n | |||
| * May return 0 on plugin types that don't support Ids. | |||
| */ | |||
| virtual long getUniqueId() const noexcept; | |||
| virtual int64_t getUniqueId() const noexcept; | |||
| /*! | |||
| * Get the plugin's latency, in sample frames. | |||
| @@ -827,6 +827,7 @@ public: | |||
| const char* const filename; | |||
| const char* const name; | |||
| const char* const label; | |||
| const int64_t uniqueId; | |||
| }; | |||
| static size_t getNativePluginCount() noexcept; | |||
| @@ -704,7 +704,7 @@ CarlaEngineClient* CarlaEngine::addClient(CarlaPlugin* const) | |||
| // ----------------------------------------------------------------------- | |||
| // Plugin management | |||
| bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra) | |||
| bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #10)"); | |||
| CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextPluginId <= pData->maxPluginNumber, "Invalid engine internal data (err #11)"); | |||
| @@ -712,7 +712,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
| CARLA_SAFE_ASSERT_RETURN_ERR(btype != BINARY_NONE, "Invalid plugin params (err #1)"); | |||
| CARLA_SAFE_ASSERT_RETURN_ERR(ptype != PLUGIN_NONE, "Invalid plugin params (err #2)"); | |||
| CARLA_SAFE_ASSERT_RETURN_ERR((filename != nullptr && filename[0] != '\0') || (label != nullptr && label[0] != '\0'), "Invalid plugin params (err #3)"); | |||
| carla_debug("CarlaEngine::addPlugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", %p)", btype, BinaryType2Str(btype), ptype, PluginType2Str(ptype), filename, name, label, extra); | |||
| carla_debug("CarlaEngine::addPlugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p)", btype, BinaryType2Str(btype), ptype, PluginType2Str(ptype), filename, name, label, uniqueId, extra); | |||
| CARLA_ENGINE_THREAD_SAFE_SECTION | |||
| unsigned int id; | |||
| @@ -745,7 +745,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
| id, | |||
| filename, | |||
| name, | |||
| label | |||
| label, | |||
| uniqueId | |||
| }; | |||
| CarlaPlugin* plugin = nullptr; | |||
| @@ -815,7 +816,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
| id, | |||
| "/usr/lib/dssi/dssi-vst.so", | |||
| name, | |||
| (const char*)label2 | |||
| (const char*)label2, | |||
| uniqueId | |||
| }; | |||
| char* const oldVstPath(getenv("VST_PATH")); | |||
| @@ -956,6 +958,11 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
| return true; | |||
| } | |||
| bool CarlaEngine::addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra) | |||
| { | |||
| return addPlugin(BINARY_NATIVE, ptype, filename, name, label, uniqueId, extra); | |||
| } | |||
| bool CarlaEngine::removePlugin(const unsigned int id) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #14)"); | |||
| @@ -1072,7 +1079,7 @@ bool CarlaEngine::clonePlugin(const unsigned int id) | |||
| const unsigned int pluginCountBefore(pData->curPluginCount); | |||
| if (! addPlugin(plugin->getBinaryType(), plugin->getType(), plugin->getFilename(), plugin->getName(), label, plugin->getExtraStuff())) | |||
| if (! addPlugin(plugin->getBinaryType(), plugin->getType(), plugin->getFilename(), plugin->getName(), label, plugin->getUniqueId(), plugin->getExtraStuff())) | |||
| return false; | |||
| CARLA_ASSERT(pluginCountBefore+1 == pData->curPluginCount); | |||
| @@ -1278,23 +1285,23 @@ bool CarlaEngine::loadFile(const char* const filename) | |||
| // ------------------------------------------------------------------- | |||
| if (extension == "csd") | |||
| return addPlugin(PLUGIN_FILE_CSD, filename, baseName, baseName); | |||
| return addPlugin(PLUGIN_FILE_CSD, filename, baseName, baseName, 0, nullptr); | |||
| if (extension == "gig") | |||
| return addPlugin(PLUGIN_FILE_GIG, filename, baseName, baseName); | |||
| return addPlugin(PLUGIN_FILE_GIG, filename, baseName, baseName, 0, nullptr); | |||
| if (extension == "sf2") | |||
| return addPlugin(PLUGIN_FILE_SF2, filename, baseName, baseName); | |||
| return addPlugin(PLUGIN_FILE_SF2, filename, baseName, baseName, 0, nullptr); | |||
| if (extension == "sfz") | |||
| return addPlugin(PLUGIN_FILE_SFZ, filename, baseName, baseName); | |||
| return addPlugin(PLUGIN_FILE_SFZ, filename, baseName, baseName, 0, nullptr); | |||
| // ------------------------------------------------------------------- | |||
| if (extension == "aiff" || extension == "flac" || extension == "oga" || extension == "ogg" || extension == "w64" || extension == "wav") | |||
| { | |||
| #ifdef WANT_AUDIOFILE | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile")) | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile", 0, nullptr)) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true); | |||
| @@ -1312,7 +1319,7 @@ bool CarlaEngine::loadFile(const char* const filename) | |||
| { | |||
| #ifdef WANT_AUDIOFILE | |||
| # ifdef HAVE_FFMPEG | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile")) | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile", 0, nullptr)) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true); | |||
| @@ -1334,7 +1341,7 @@ bool CarlaEngine::loadFile(const char* const filename) | |||
| if (extension == "mid" || extension == "midi") | |||
| { | |||
| #ifdef WANT_MIDIFILE | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "midifile")) | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "midifile", 0, nullptr)) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true); | |||
| @@ -1353,7 +1360,7 @@ bool CarlaEngine::loadFile(const char* const filename) | |||
| if (extension == "xmz" || extension == "xiz") | |||
| { | |||
| #ifdef WANT_ZYNADDSUBFX | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "zynaddsubfx")) | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "zynaddsubfx", 0, nullptr)) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, (extension == "xmz") ? "CarlaAlternateFile1" : "CarlaAlternateFile2", filename, true); | |||
| @@ -1412,15 +1419,17 @@ bool CarlaEngine::loadProject(const char* const filename) | |||
| // check if using GIG, SF2 or SFZ 16outs | |||
| static const char kUse16OutsSuffix[] = " (16 outs)"; | |||
| const PluginType ptype(getPluginTypeFromString(saveState.type)); | |||
| if (CarlaString(saveState.label).endsWith(kUse16OutsSuffix)) | |||
| { | |||
| if (std::strcmp(saveState.type, "GIG") == 0 || std::strcmp(saveState.type, "SF2") == 0) | |||
| if (ptype == PLUGIN_FILE_GIG || ptype == PLUGIN_FILE_SF2) | |||
| extraStuff = "true"; | |||
| } | |||
| // TODO - proper find&load plugins | |||
| if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, extraStuff)) | |||
| if (addPlugin(ptype, saveState.binary, saveState.name, saveState.label, saveState.uniqueId, extraStuff)) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) | |||
| plugin->loadSaveState(saveState); | |||
| @@ -2214,17 +2223,17 @@ void CarlaEngine::restorePatchbayConnection(const char* const connSource, const | |||
| // Bridge/Controller OSC stuff | |||
| #ifdef BUILD_BRIDGE | |||
| void CarlaEngine::oscSend_bridge_plugin_info1(const PluginCategory category, const uint hints, const long uniqueId) const noexcept | |||
| void CarlaEngine::oscSend_bridge_plugin_info1(const PluginCategory category, const uint hints, const int64_t uniqueId) const noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,); | |||
| CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',); | |||
| CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,); | |||
| carla_debug("CarlaEngine::oscSend_bridge_plugin_info1(%i:%s, %X, %l)", category, PluginCategory2Str(category), hints, uniqueId); | |||
| carla_debug("CarlaEngine::oscSend_bridge_plugin_info1(%i:%s, %X, " P_INT64 ")", category, PluginCategory2Str(category), hints, uniqueId); | |||
| char targetPath[std::strlen(pData->oscData->path)+21]; | |||
| std::strcpy(targetPath, pData->oscData->path); | |||
| std::strcat(targetPath, "/bridge_plugin_info1"); | |||
| try_lo_send(pData->oscData->target, targetPath, "iih", static_cast<int32_t>(category), static_cast<int32_t>(hints), static_cast<int64_t>(uniqueId)); | |||
| try_lo_send(pData->oscData->target, targetPath, "iih", static_cast<int32_t>(category), static_cast<int32_t>(hints), uniqueId); | |||
| } | |||
| void CarlaEngine::oscSend_bridge_plugin_info2(const char* const realName, const char* const label, const char* const maker, const char* const copyright) const noexcept | |||
| @@ -2557,14 +2566,14 @@ void CarlaEngine::oscSend_control_remove_plugin(const uint pluginId) const noexc | |||
| try_lo_send(pData->oscData->target, targetPath, "i", static_cast<int32_t>(pluginId)); | |||
| } | |||
| void CarlaEngine::oscSend_control_set_plugin_info1(const uint pluginId, const PluginType type, const PluginCategory category, const uint hints, const long uniqueId) const noexcept | |||
| void CarlaEngine::oscSend_control_set_plugin_info1(const uint pluginId, const PluginType type, const PluginCategory category, const uint hints, const int64_t uniqueId) const noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pData->oscData != nullptr,); | |||
| CARLA_SAFE_ASSERT_RETURN(pData->oscData->path != nullptr && pData->oscData->path[0] != '\0',); | |||
| CARLA_SAFE_ASSERT_RETURN(pData->oscData->target != nullptr,); | |||
| CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount,); | |||
| CARLA_SAFE_ASSERT_RETURN(type != PLUGIN_NONE,); | |||
| carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, %i:%s, %i:%s, %X, %l)", pluginId, type, PluginType2Str(type), category, PluginCategory2Str(category), hints, uniqueId); | |||
| carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, %i:%s, %i:%s, %X, " P_INT64 ")", pluginId, type, PluginType2Str(type), category, PluginCategory2Str(category), hints, uniqueId); | |||
| char targetPath[std::strlen(pData->oscData->path)+18]; | |||
| std::strcpy(targetPath, pData->oscData->path); | |||
| @@ -87,6 +87,8 @@ public: | |||
| protected: | |||
| void msgReceived(const char* const msg) override | |||
| { | |||
| bool ok = true; | |||
| if (std::strcmp(msg, "exiting") == 0) | |||
| { | |||
| waitChildClose(); | |||
| @@ -94,14 +96,15 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_engine_option") == 0) | |||
| { | |||
| int option, value; | |||
| uint32_t option; | |||
| int32_t value; | |||
| const char* valueStr; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(option),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(option),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(value),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(valueStr),); | |||
| fEngine->setOption((EngineOption)option, value, valueStr); | |||
| fEngine->setOption(static_cast<EngineOption>(option), value, valueStr); | |||
| delete[] valueStr; | |||
| } | |||
| @@ -111,7 +114,7 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename),); | |||
| fEngine->loadFile(filename); | |||
| ok = fEngine->loadFile(filename); | |||
| delete[] filename; | |||
| } | |||
| @@ -121,7 +124,7 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename),); | |||
| fEngine->loadProject(filename); | |||
| ok = fEngine->loadProject(filename); | |||
| delete[] filename; | |||
| } | |||
| @@ -131,30 +134,30 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename),); | |||
| fEngine->saveProject(filename); | |||
| ok = fEngine->saveProject(filename); | |||
| delete[] filename; | |||
| } | |||
| else if (std::strcmp(msg, "patchbay_connect") == 0) | |||
| { | |||
| int portA, portB; | |||
| int32_t portA, portB; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(portA),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(portB),); | |||
| fEngine->patchbayConnect(portA, portB); | |||
| ok = fEngine->patchbayConnect(portA, portB); | |||
| } | |||
| else if (std::strcmp(msg, "patchbay_disconnect") == 0) | |||
| { | |||
| uint connectionId; | |||
| uint32_t connectionId; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(connectionId),); | |||
| fEngine->patchbayDisconnect(connectionId); | |||
| ok = fEngine->patchbayDisconnect(connectionId); | |||
| } | |||
| else if (std::strcmp(msg, "patchbay_refresh") == 0) | |||
| { | |||
| fEngine->patchbayRefresh(); | |||
| ok = fEngine->patchbayRefresh(); | |||
| } | |||
| else if (std::strcmp(msg, "transport_play") == 0) | |||
| { | |||
| @@ -166,24 +169,26 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "transport_relocate") == 0) | |||
| { | |||
| long frame; | |||
| uint64_t frame; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsLong(frame),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsULong(frame),); | |||
| fEngine->transportRelocate((uint64_t)frame); | |||
| fEngine->transportRelocate(frame); | |||
| } | |||
| else if (std::strcmp(msg, "add_plugin") == 0) | |||
| { | |||
| int btype, ptype; | |||
| uint32_t btype, ptype; | |||
| const char* filename = nullptr; | |||
| const char* name; | |||
| const char* label; | |||
| int64_t uniqueId; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(btype),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(ptype),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(btype),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(ptype),); | |||
| readNextLineAsString(filename); // can be null | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(name),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(label),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsLong(uniqueId),); | |||
| if (filename != nullptr && std::strcmp(filename, "(null)") == 0) | |||
| { | |||
| @@ -197,72 +202,67 @@ protected: | |||
| name = nullptr; | |||
| } | |||
| const bool ok = fEngine->addPlugin((BinaryType)btype, (PluginType)ptype, filename, name, label); | |||
| ok = fEngine->addPlugin(static_cast<BinaryType>(btype), static_cast<PluginType>(ptype), filename, name, label, uniqueId, nullptr); | |||
| if (filename != nullptr) | |||
| delete[] filename; | |||
| if (name != nullptr) | |||
| delete[] name; | |||
| delete[] label; | |||
| if (! ok) | |||
| { | |||
| writeMsg("error\n", 6); | |||
| writeAndFixMsg(fEngine->getLastError()); | |||
| } | |||
| } | |||
| else if (std::strcmp(msg, "remove_plugin") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| fEngine->removePlugin(pluginId); | |||
| ok = fEngine->removePlugin(pluginId); | |||
| } | |||
| else if (std::strcmp(msg, "remove_all_plugins") == 0) | |||
| { | |||
| fEngine->removeAllPlugins(); | |||
| ok = fEngine->removeAllPlugins(); | |||
| } | |||
| else if (std::strcmp(msg, "rename_plugin") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| const char* newName; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(newName),); | |||
| // TODO | |||
| /*const char* name =*/ fEngine->renamePlugin(pluginId, newName); | |||
| delete[] newName; | |||
| } | |||
| else if (std::strcmp(msg, "clone_plugin") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| fEngine->clonePlugin(pluginId); | |||
| ok = fEngine->clonePlugin(pluginId); | |||
| } | |||
| else if (std::strcmp(msg, "replace_plugin") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| fEngine->replacePlugin(pluginId); | |||
| ok = fEngine->replacePlugin(pluginId); | |||
| } | |||
| else if (std::strcmp(msg, "switch_plugins") == 0) | |||
| { | |||
| uint pluginIdA, pluginIdB; | |||
| uint32_t pluginIdA, pluginIdB; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginIdA),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginIdB),); | |||
| fEngine->switchPlugins(pluginIdA, pluginIdB); | |||
| ok = fEngine->switchPlugins(pluginIdA, pluginIdB); | |||
| } | |||
| else if (std::strcmp(msg, "load_plugin_state") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| const char* filename; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -275,7 +275,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "save_plugin_state") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| const char* filename; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -288,8 +288,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_option") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint option; | |||
| uint32_t pluginId, option; | |||
| bool yesNo; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -301,7 +300,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_active") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| bool onOff; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -312,7 +311,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_drywet") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| float value; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -323,7 +322,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_volume") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| float value; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -334,7 +333,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_balance_left") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| float value; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -345,7 +344,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_balance_right") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| float value; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -356,7 +355,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_panning") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| float value; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -367,8 +366,8 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_ctrl_channel") == 0) | |||
| { | |||
| uint pluginId; | |||
| int channel; | |||
| uint32_t pluginId; | |||
| int32_t channel; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(channel),); | |||
| @@ -379,8 +378,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_parameter_value") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint parameterId; | |||
| uint32_t pluginId, parameterId; | |||
| float value; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -392,23 +390,20 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_parameter_midi_channel") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint parameterId; | |||
| int channel; | |||
| uint32_t pluginId, parameterId, channel; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(channel),); | |||
| CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < MAX_MIDI_CHANNELS,); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel),); | |||
| CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,); | |||
| if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId)) | |||
| plugin->setParameterMidiChannel(parameterId, uint8_t(channel), true, false); | |||
| plugin->setParameterMidiChannel(parameterId, static_cast<uint8_t>(channel), true, false); | |||
| } | |||
| else if (std::strcmp(msg, "set_parameter_midi_cc") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint parameterId; | |||
| int cc; | |||
| uint32_t pluginId, parameterId; | |||
| int32_t cc; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId),); | |||
| @@ -416,12 +411,12 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < 0x5F,); | |||
| if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId)) | |||
| plugin->setParameterMidiCC(parameterId, int16_t(cc), true, false); | |||
| plugin->setParameterMidiCC(parameterId, static_cast<int16_t>(cc), true, false); | |||
| } | |||
| else if (std::strcmp(msg, "set_program") == 0) | |||
| { | |||
| uint pluginId; | |||
| int index; | |||
| uint32_t pluginId; | |||
| int32_t index; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index),); | |||
| @@ -431,8 +426,8 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_midi_program") == 0) | |||
| { | |||
| uint pluginId; | |||
| int index; | |||
| uint32_t pluginId; | |||
| int32_t index; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index),); | |||
| @@ -442,7 +437,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_custom_data") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| const char* type; | |||
| const char* key; | |||
| const char* value; | |||
| @@ -457,7 +452,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "set_chunk_data") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| const char* cdata; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -468,7 +463,7 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "prepare_for_save") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -477,23 +472,22 @@ protected: | |||
| } | |||
| else if (std::strcmp(msg, "send_midi_note") == 0) | |||
| { | |||
| uint pluginId; | |||
| int channel, note, velocity; | |||
| uint32_t pluginId, channel, note, velocity; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(channel),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(note),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(velocity),); | |||
| CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < MAX_MIDI_CHANNELS,); | |||
| CARLA_SAFE_ASSERT_RETURN(note >= 0 && channel < MAX_MIDI_VALUE,); | |||
| CARLA_SAFE_ASSERT_RETURN(velocity >= 0 && channel < MAX_MIDI_VALUE,); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(note),); | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(velocity),); | |||
| CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,); | |||
| CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_VALUE,); | |||
| CARLA_SAFE_ASSERT_RETURN(velocity < MAX_MIDI_VALUE,); | |||
| if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId)) | |||
| plugin->sendMidiSingleNote(uint8_t(channel), uint8_t(note), uint8_t(velocity), true, true, false); | |||
| plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), static_cast<uint8_t>(velocity), true, true, false); | |||
| } | |||
| else if (std::strcmp(msg, "show_custom_ui") == 0) | |||
| { | |||
| uint pluginId; | |||
| uint32_t pluginId; | |||
| bool yesNo; | |||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId),); | |||
| @@ -506,6 +500,12 @@ protected: | |||
| { | |||
| carla_stderr("msgReceived : %s", msg); | |||
| } | |||
| if (! ok) | |||
| { | |||
| writeMsg("error\n", 6); | |||
| writeAndFixMsg(fEngine->getLastError()); | |||
| } | |||
| } | |||
| private: | |||
| @@ -1325,15 +1325,17 @@ protected: | |||
| // check if using GIG, SF2 or SFZ 16outs | |||
| static const char kUse16OutsSuffix[] = " (16 outs)"; | |||
| const PluginType ptype(getPluginTypeFromString(saveState.type)); | |||
| if (CarlaString(saveState.label).endsWith(kUse16OutsSuffix)) | |||
| { | |||
| if (std::strcmp(saveState.type, "GIG") == 0 || std::strcmp(saveState.type, "SF2") == 0) | |||
| if (ptype == PLUGIN_FILE_GIG || ptype == PLUGIN_FILE_SF2) | |||
| extraStuff = "true"; | |||
| } | |||
| // TODO - proper find&load plugins | |||
| if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, extraStuff)) | |||
| if (addPlugin(ptype, saveState.binary, saveState.name, saveState.label, saveState.uniqueId, extraStuff)) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) | |||
| plugin->loadSaveState(saveState); | |||
| @@ -23,7 +23,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newAU(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newAU({%p, \"%s\", \"%s\"})", init.engine, init.filename, init.name); | |||
| carla_debug("CarlaPlugin::newAU({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId); | |||
| #if defined(WANT_AU) && defined(HAVE_JUCE) | |||
| return newJuce(init, "AU"); | |||
| @@ -1950,7 +1950,7 @@ CarlaPlugin* CarlaPlugin::newBridge(const Initializer& init, BinaryType btype, P | |||
| CarlaPlugin* CarlaPlugin::newJACK(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newJACK({%p, \"%s\", \"%s\", \"%s\"})", init.engine, init.filename, init.name, init.label); | |||
| carla_debug("CarlaPlugin::newJACK({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.label, init.uniqueId); | |||
| #ifndef BUILD_BRIDGE | |||
| BridgePlugin* const plugin(new BridgePlugin(init.engine, init.id, BINARY_NATIVE, PLUGIN_JACK)); | |||
| @@ -202,7 +202,7 @@ PluginCategory CarlaPlugin::getCategory() const noexcept | |||
| return category; | |||
| } | |||
| long CarlaPlugin::getUniqueId() const noexcept | |||
| int64_t CarlaPlugin::getUniqueId() const noexcept | |||
| { | |||
| return 0; | |||
| } | |||
| @@ -440,7 +440,7 @@ const SaveState& CarlaPlugin::getSaveState() | |||
| pData->saveState.name = carla_strdup(pData->name); | |||
| pData->saveState.label = carla_strdup(strBuf); | |||
| pData->saveState.binary = carla_strdup(pData->filename); | |||
| pData->saveState.uniqueID = getUniqueId(); | |||
| pData->saveState.uniqueId = getUniqueId(); | |||
| // --------------------------------------------------------------- | |||
| // Internals | |||
| @@ -166,14 +166,14 @@ void CarlaPluginThread::run() | |||
| case PLUGIN_THREAD_DSSI_GUI: | |||
| /* osc-url */ arguments << QString("%1/%2").arg(fEngine->getOscServerPathUDP()).arg(fPlugin->getId()); | |||
| /* filename */ arguments << fPlugin->getFilename(); | |||
| /* label */ arguments << (const char*)fLabel; | |||
| /* label */ arguments << fLabel.getBuffer(); | |||
| /* ui-title */ arguments << QString("%1 (GUI)").arg(fPlugin->getName()); | |||
| break; | |||
| case PLUGIN_THREAD_LV2_GUI: | |||
| /* osc-url */ arguments << QString("%1/%2").arg(fEngine->getOscServerPathUDP()).arg(fPlugin->getId()); | |||
| /* URI */ arguments << (const char*)fLabel; | |||
| /* ui-URI */ arguments << (const char*)fExtra1; | |||
| /* URI */ arguments << fLabel.getBuffer(); | |||
| /* ui-URI */ arguments << fExtra1.getBuffer(); | |||
| /* ui-title */ arguments << QString("%1 (GUI)").arg(fPlugin->getName()); | |||
| break; | |||
| @@ -191,10 +191,11 @@ void CarlaPluginThread::run() | |||
| if (fPlugin->getType() != PLUGIN_JACK) | |||
| { | |||
| /* osc-url */ arguments << QString("%1/%2").arg(fEngine->getOscServerPathUDP()).arg(fPlugin->getId()); | |||
| /* stype */ arguments << (const char*)fExtra1; | |||
| /* stype */ arguments << fExtra1.getBuffer(); | |||
| /* filename */ arguments << fPlugin->getFilename(); | |||
| /* name */ arguments << name; | |||
| /* label */ arguments << (const char*)fLabel; | |||
| /* label */ arguments << fLabel.getBuffer(); | |||
| /* uniqueId */ arguments << QString("%1").arg(fPlugin->getUniqueId()); | |||
| } | |||
| else | |||
| { | |||
| @@ -86,7 +86,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newCsound(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newCsound(%p, \"%s\", \"%s\", \"%s\")", init.engine, init.filename, init.name, init.label); | |||
| carla_debug("CarlaPlugin::newCsound({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.label, init.uniqueId); | |||
| #ifdef WANT_CSOUND | |||
| CsoundPlugin* const plugin(new CsoundPlugin(init.engine, init.id)); | |||
| @@ -125,11 +125,11 @@ public: | |||
| return CarlaPlugin::getCategory(); | |||
| } | |||
| long getUniqueId() const noexcept override | |||
| int64_t getUniqueId() const noexcept override | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr, 0); | |||
| return static_cast<long>(fDescriptor->UniqueID); | |||
| return static_cast<int64_t>(fDescriptor->UniqueID); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| @@ -1220,7 +1220,6 @@ public: | |||
| midiEvent.data.control.param = ctrlEvent.param; | |||
| midiEvent.data.control.value = int8_t(ctrlEvent.value*127.0f); | |||
| } | |||
| break; | |||
| } // case kEngineControlEventTypeParameter | |||
| @@ -2046,7 +2045,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newDSSI(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newDSSI({%p, \"%s\", \"%s\", \"%s\"})", init.engine, init.filename, init.name, init.label); | |||
| carla_debug("CarlaPlugin::newDSSI({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.label, init.uniqueId); | |||
| #ifdef WANT_DSSI | |||
| DssiPlugin* const plugin(new DssiPlugin(init.engine, init.id)); | |||
| @@ -1718,7 +1718,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newFluidSynth(const Initializer& init, const bool use16Outs) | |||
| { | |||
| carla_debug("CarlaPlugin::newFluidSynth({%p, \"%s\", \"%s\", \"%s\"}, %s)", init.engine, init.filename, init.name, init.label, bool2str(use16Outs)); | |||
| carla_debug("CarlaPlugin::newFluidSynth({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s)", init.engine, init.filename, init.name, init.label, init.uniqueId, bool2str(use16Outs)); | |||
| #ifdef WANT_FLUIDSYNTH | |||
| if (init.engine->getProccessMode() == ENGINE_PROCESS_MODE_CONTINUOUS_RACK && use16Outs) | |||
| @@ -97,7 +97,7 @@ public: | |||
| return category; | |||
| } | |||
| long getUniqueId() const noexcept override | |||
| int64_t getUniqueId() const noexcept override | |||
| { | |||
| return fDesc.uid; | |||
| } | |||
| @@ -121,7 +121,6 @@ public: | |||
| unsigned int options = 0x0; | |||
| //options |= PLUGIN_OPTION_FIXED_BUFFERS; | |||
| options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; | |||
| //options |= PLUGIN_OPTION_USE_CHUNKS; | |||
| @@ -545,13 +544,279 @@ public: | |||
| pData->needsReset = false; | |||
| } | |||
| uint32_t l=0; | |||
| for (; l < pData->audioIn.count; ++l) | |||
| fAudioBuffer.clear(static_cast<int>(l), 0, static_cast<int>(frames)); | |||
| for (; l < pData->audioOut.count; ++l) | |||
| fAudioBuffer.clear(static_cast<int>(l), 0, static_cast<int>(frames)); | |||
| // -------------------------------------------------------------------------------------------------------- | |||
| // TimeInfo | |||
| // TODO | |||
| // -------------------------------------------------------------------------------------------------------- | |||
| // Event Input | |||
| fMidiBuffer.clear(); | |||
| if (pData->event.portIn != nullptr) | |||
| { | |||
| // ---------------------------------------------------------------------------------------------------- | |||
| // MIDI Input (External) | |||
| if (pData->extNotes.mutex.tryLock()) | |||
| { | |||
| for (; ! pData->extNotes.data.isEmpty();) | |||
| { | |||
| const ExternalMidiNote& note(pData->extNotes.data.getFirst(true)); | |||
| CARLA_SAFE_ASSERT_CONTINUE(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS); | |||
| uint8_t midiEvent[3]; | |||
| midiEvent[0] = static_cast<uint8_t>(note.channel + (note.velo > 0) ? MIDI_STATUS_NOTE_ON : MIDI_STATUS_NOTE_OFF); | |||
| midiEvent[1] = note.note; | |||
| midiEvent[2] = note.velo; | |||
| fMidiBuffer.addEvent(midiEvent, 3, 0); | |||
| } | |||
| pData->extNotes.mutex.unlock(); | |||
| } // End of MIDI Input (External) | |||
| // ---------------------------------------------------------------------------------------------------- | |||
| // Event Input (System) | |||
| bool allNotesOffSent = false; | |||
| uint32_t numEvents = pData->event.portIn->getEventCount(); | |||
| uint32_t nextBankId; | |||
| if (pData->midiprog.current >= 0 && pData->midiprog.count > 0) | |||
| nextBankId = pData->midiprog.data[pData->midiprog.current].bank; | |||
| else | |||
| nextBankId = 0; | |||
| for (uint32_t i=0; i < numEvents; ++i) | |||
| { | |||
| const EngineEvent& event(pData->event.portIn->getEvent(i)); | |||
| if (event.time >= frames) | |||
| continue; | |||
| switch (event.type) | |||
| { | |||
| case kEngineEventTypeNull: | |||
| break; | |||
| case kEngineEventTypeControl: { | |||
| const EngineControlEvent& ctrlEvent(event.ctrl); | |||
| switch (ctrlEvent.type) | |||
| { | |||
| case kEngineControlEventTypeNull: | |||
| break; | |||
| case kEngineControlEventTypeParameter: { | |||
| #ifndef BUILD_BRIDGE | |||
| // Control backend stuff | |||
| if (event.channel == pData->ctrlChannel) | |||
| { | |||
| float value; | |||
| if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) != 0) | |||
| { | |||
| value = ctrlEvent.value; | |||
| setDryWet(value, false, false); | |||
| pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); | |||
| break; | |||
| } | |||
| if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) != 0) | |||
| { | |||
| value = ctrlEvent.value*127.0f/100.0f; | |||
| setVolume(value, false, false); | |||
| pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); | |||
| break; | |||
| } | |||
| if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) != 0) | |||
| { | |||
| float left, right; | |||
| value = ctrlEvent.value/0.5f - 1.0f; | |||
| if (value < 0.0f) | |||
| { | |||
| left = -1.0f; | |||
| right = (value*2.0f)+1.0f; | |||
| } | |||
| else if (value > 0.0f) | |||
| { | |||
| left = (value*2.0f)-1.0f; | |||
| right = 1.0f; | |||
| } | |||
| else | |||
| { | |||
| left = -1.0f; | |||
| right = 1.0f; | |||
| } | |||
| setBalanceLeft(left, false, false); | |||
| setBalanceRight(right, false, false); | |||
| pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_BALANCE_LEFT, 0, left); | |||
| pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_BALANCE_RIGHT, 0, right); | |||
| break; | |||
| } | |||
| } | |||
| #endif | |||
| // Control plugin parameters | |||
| uint32_t k; | |||
| for (k=0; k < pData->param.count; ++k) | |||
| { | |||
| if (pData->param.data[k].midiChannel != event.channel) | |||
| continue; | |||
| if (pData->param.data[k].midiCC != ctrlEvent.param) | |||
| continue; | |||
| if (pData->param.data[k].type != PARAMETER_INPUT) | |||
| continue; | |||
| if ((pData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) | |||
| continue; | |||
| float value; | |||
| if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN) | |||
| { | |||
| value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max; | |||
| } | |||
| else | |||
| { | |||
| value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); | |||
| if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) | |||
| value = std::rint(value); | |||
| } | |||
| setParameterValue(k, value, false, false, false); | |||
| pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); | |||
| break; | |||
| } | |||
| // check if event is already handled | |||
| if (k != pData->param.count) | |||
| break; | |||
| if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F) | |||
| { | |||
| uint8_t midiData[3]; | |||
| midiData[0] = static_cast<uint8_t>(MIDI_STATUS_CONTROL_CHANGE + i); | |||
| midiData[1] = static_cast<uint8_t>(ctrlEvent.param); | |||
| midiData[2] = uint8_t(ctrlEvent.value*127.0f); | |||
| fMidiBuffer.addEvent(midiData, 3, static_cast<int>(event.time)); | |||
| } | |||
| break; | |||
| } // case kEngineControlEventTypeParameter | |||
| case kEngineControlEventTypeMidiBank: | |||
| if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
| nextBankId = ctrlEvent.param; | |||
| break; | |||
| case kEngineControlEventTypeMidiProgram: | |||
| if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
| { | |||
| const uint32_t nextProgramId = ctrlEvent.param; | |||
| for (uint32_t k=0; k < pData->midiprog.count; ++k) | |||
| { | |||
| if (pData->midiprog.data[k].bank == nextBankId && pData->midiprog.data[k].program == nextProgramId) | |||
| { | |||
| const int32_t index(static_cast<int32_t>(k)); | |||
| setMidiProgram(index, false, false, false); | |||
| pData->postponeRtEvent(kPluginPostRtEventMidiProgramChange, index, 0, 0.0f); | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| break; | |||
| case kEngineControlEventTypeAllSoundOff: | |||
| if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) | |||
| { | |||
| uint8_t midiData[3]; | |||
| midiData[0] = static_cast<uint8_t>(MIDI_STATUS_CONTROL_CHANGE + i); | |||
| midiData[1] = MIDI_CONTROL_ALL_SOUND_OFF; | |||
| midiData[2] = 0; | |||
| fMidiBuffer.addEvent(midiData, 3, static_cast<int>(event.time)); | |||
| } | |||
| break; | |||
| case kEngineControlEventTypeAllNotesOff: | |||
| if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) | |||
| { | |||
| if (event.channel == pData->ctrlChannel && ! allNotesOffSent) | |||
| { | |||
| allNotesOffSent = true; | |||
| sendMidiAllNotesOffToCallback(); | |||
| } | |||
| uint8_t midiData[3]; | |||
| midiData[0] = static_cast<uint8_t>(MIDI_STATUS_CONTROL_CHANGE + i); | |||
| midiData[1] = MIDI_CONTROL_ALL_NOTES_OFF; | |||
| midiData[2] = 0; | |||
| fMidiBuffer.addEvent(midiData, 3, static_cast<int>(event.time)); | |||
| } | |||
| break; | |||
| } // switch (ctrlEvent.type) | |||
| break; | |||
| } // case kEngineEventTypeControl | |||
| case kEngineEventTypeMidi: | |||
| { | |||
| const EngineMidiEvent& midiEvent(event.midi); | |||
| uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiEvent.data)); | |||
| uint8_t channel = event.channel; | |||
| // Fix bad note-off | |||
| if (MIDI_IS_STATUS_NOTE_ON(status) && midiEvent.data[2] == 0) | |||
| status = MIDI_STATUS_NOTE_OFF; | |||
| if (status == MIDI_STATUS_CHANNEL_PRESSURE && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0) | |||
| continue; | |||
| if (status == MIDI_STATUS_CONTROL_CHANGE && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0) | |||
| continue; | |||
| if (status == MIDI_STATUS_POLYPHONIC_AFTERTOUCH && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0) | |||
| continue; | |||
| if (status == MIDI_STATUS_PITCH_WHEEL_CONTROL && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) == 0) | |||
| continue; | |||
| fMidiBuffer.addEvent(midiEvent.data, midiEvent.size, static_cast<int>(event.time)); | |||
| if (status == MIDI_STATUS_NOTE_ON) | |||
| pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, midiEvent.data[1], midiEvent.data[2]); | |||
| else if (status == MIDI_STATUS_NOTE_OFF) | |||
| pData->postponeRtEvent(kPluginPostRtEventNoteOff, channel, midiEvent.data[1], 0.0f); | |||
| break; | |||
| } // case kEngineEventTypeMidi | |||
| } // switch (event.type) | |||
| } | |||
| pData->postRtEvents.trySplice(); | |||
| } // End of Event Input | |||
| // -------------------------------------------------------------------------------------------------------- | |||
| // Process | |||
| processSingle(inBuffer, outBuffer, frames); | |||
| // -------------------------------------------------------------------------------------------------------- | |||
| // MIDI Output | |||
| if (pData->event.portOut != nullptr) | |||
| { | |||
| // TODO | |||
| } | |||
| } | |||
| bool processSingle(float** const inBuffer, float** const outBuffer, const uint32_t frames) | |||
| @@ -577,22 +842,15 @@ public: | |||
| else if (! pData->singleMutex.tryLock()) | |||
| { | |||
| for (uint32_t i=0; i < pData->audioOut.count; ++i) | |||
| { | |||
| for (uint32_t k=0; k < frames; ++k) | |||
| outBuffer[i][k/*+timeOffset*/] = 0.0f; | |||
| } | |||
| FloatVectorOperations::clear(outBuffer[i], static_cast<int>(frames)); | |||
| return false; | |||
| } | |||
| // -------------------------------------------------------------------------------------------------------- | |||
| // Set audio in buffers | |||
| uint32_t l; | |||
| for (l=0; l < pData->audioIn.count; ++l) | |||
| fAudioBuffer.copyFrom(static_cast<int>(l), 0, inBuffer[l], static_cast<int>(frames)); | |||
| //for (l=0; l < pData->audioOut.count; ++l) | |||
| // fAudioBuffer.clear(static_cast<int>(l), 0, static_cast<int>(frames)); | |||
| for (uint32_t i=0; i < pData->audioIn.count; ++i) | |||
| fAudioBuffer.copyFrom(static_cast<int>(i), 0, inBuffer[i], static_cast<int>(frames)); | |||
| // -------------------------------------------------------------------------------------------------------- | |||
| // Run plugin | |||
| @@ -655,7 +913,7 @@ protected: | |||
| // ------------------------------------------------------------------- | |||
| public: | |||
| bool init(const char* const filename, const char* const name, const char* const label, const char* const format) | |||
| bool init(const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const char* const format) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false); | |||
| @@ -680,6 +938,12 @@ public: | |||
| return false; | |||
| } | |||
| if (format == nullptr || format[0] == '\0') | |||
| { | |||
| pData->engine->setLastError("null format"); | |||
| return false; | |||
| } | |||
| #ifdef CARLA_OS_LINUX | |||
| const MessageManagerLock mmLock; | |||
| #endif | |||
| @@ -698,7 +962,7 @@ public: | |||
| #endif | |||
| //fDesc.name = fDesc.descriptiveName = label; | |||
| fDesc.uid = 0; // TODO - set uid for shell plugins | |||
| fDesc.uid = static_cast<int>(uniqueId); | |||
| fDesc.fileOrIdentifier = jfilename; | |||
| fDesc.pluginFormatName = format; | |||
| @@ -743,7 +1007,7 @@ public: | |||
| // set default options | |||
| pData->options = 0x0; | |||
| //pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; | |||
| pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; | |||
| pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; | |||
| //pData->options |= PLUGIN_OPTION_USE_CHUNKS; | |||
| @@ -764,6 +1028,9 @@ public: | |||
| // load settings | |||
| pData->options = pData->loadSettings(pData->options, getOptionsAvailable()); | |||
| // ignore settings, we need this anyway | |||
| pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; | |||
| } | |||
| return true; | |||
| @@ -777,6 +1044,8 @@ private: | |||
| AudioSampleBuffer fAudioBuffer; | |||
| MidiBuffer fMidiBuffer; | |||
| const char* fUniqueId; | |||
| ScopedPointer<JucePluginWindow> fWindow; | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(JucePlugin) | |||
| @@ -792,12 +1061,12 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newJuce(const Initializer& init, const char* const format) | |||
| { | |||
| carla_debug("CarlaPlugin::newJuce({%p, \"%s\", \"%s\", \"%s\"}, %s)", init.engine, init.filename, init.name, init.label, format); | |||
| carla_debug("CarlaPlugin::newJuce({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s)", init.engine, init.filename, init.name, init.label, init.uniqueId, format); | |||
| #ifdef HAVE_JUCE | |||
| JucePlugin* const plugin(new JucePlugin(init.engine, init.id)); | |||
| if (! plugin->init(init.filename, init.name, init.label, format)) | |||
| if (! plugin->init(init.filename, init.name, init.label, init.uniqueId, format)) | |||
| { | |||
| delete plugin; | |||
| return nullptr; | |||
| @@ -135,11 +135,11 @@ public: | |||
| return CarlaPlugin::getCategory(); | |||
| } | |||
| long getUniqueId() const noexcept override | |||
| int64_t getUniqueId() const noexcept override | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr, 0); | |||
| return static_cast<long>(fDescriptor->UniqueID); | |||
| return static_cast<int64_t>(fDescriptor->UniqueID); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| @@ -1499,7 +1499,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* const rdfDescriptor) | |||
| { | |||
| carla_debug("CarlaPlugin::newLADSPA({%p, \"%s\", \"%s\", \"%s\"}, %p)", init.engine, init.filename, init.name, init.label, rdfDescriptor); | |||
| carla_debug("CarlaPlugin::newLADSPA({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %p)", init.engine, init.filename, init.name, init.label, init.uniqueId, rdfDescriptor); | |||
| #ifdef WANT_LADSPA | |||
| LadspaPlugin* const plugin(new LadspaPlugin(init.engine, init.id)); | |||
| @@ -1356,7 +1356,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newLinuxSampler(const Initializer& init, const char* const format, const bool use16Outs) | |||
| { | |||
| carla_debug("LinuxSamplerPlugin::newLinuxSampler({%p, \"%s\", \"%s\", \"%s\"}, %s, %s)", init.engine, init.filename, init.name, init.label, format, bool2str(use16Outs)); | |||
| carla_debug("LinuxSamplerPlugin::newLinuxSampler({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s, %s)", init.engine, init.filename, init.name, init.label, init.uniqueId, format, bool2str(use16Outs)); | |||
| #ifdef WANT_LINUXSAMPLER | |||
| if (init.engine->getProccessMode() == ENGINE_PROCESS_MODE_CONTINUOUS_RACK && use16Outs) | |||
| @@ -577,11 +577,11 @@ public: | |||
| return CarlaPlugin::getCategory(); | |||
| } | |||
| long getUniqueId() const noexcept override | |||
| int64_t getUniqueId() const noexcept override | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fRdfDescriptor != nullptr, 0); | |||
| return static_cast<long>(fRdfDescriptor->UniqueID); | |||
| return static_cast<int64_t>(fRdfDescriptor->UniqueID); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| @@ -2820,16 +2820,17 @@ public: | |||
| midiData[1] = static_cast<uint8_t>(ctrlEvent.param); | |||
| midiData[2] = uint8_t(ctrlEvent.value*127.0f); | |||
| const uint32_t mtime(isSampleAccurate ? startTime : event.time); | |||
| if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) | |||
| lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); | |||
| lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); | |||
| else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT) | |||
| lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], 0, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); | |||
| lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, CARLA_URI_MAP_ID_MIDI_EVENT, 3, midiData); | |||
| else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL) | |||
| lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], 0.0, 3, midiData); | |||
| lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData); | |||
| } | |||
| break; | |||
| } // case kEngineControlEventTypeParameter | |||
| @@ -5517,7 +5518,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newLV2(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newLV2({%p, \"%s\", \"%s\"})", init.engine, init.name, init.label); | |||
| carla_debug("CarlaPlugin::newLV2({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.name, init.label, init.uniqueId); | |||
| #ifdef WANT_LV2 | |||
| Lv2Plugin* const plugin(new Lv2Plugin(init.engine, init.id)); | |||
| @@ -2470,7 +2470,7 @@ const NativePluginDescriptor* CarlaPlugin::getNativePluginDescriptor(const size_ | |||
| CarlaPlugin* CarlaPlugin::newNative(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newNative({%p, \"%s\", \"%s\", \"%s\"})", init.engine, init.filename, init.name, init.label); | |||
| carla_debug("CarlaPlugin::newNative({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.label, init.uniqueId); | |||
| #ifdef WANT_NATIVE | |||
| NativePlugin* const plugin(new NativePlugin(init.engine, init.id)); | |||
| @@ -1067,7 +1067,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newReWire(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newReWire({%p, \"%s\", \"%s\"})", init.engine, init.filename, init.name); | |||
| carla_debug("CarlaPlugin::newReWire({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId); | |||
| #ifdef WANT_REWIRE | |||
| ReWirePlugin* const plugin(new ReWirePlugin(init.engine, init.id)); | |||
| @@ -23,7 +23,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newVST3(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newVST3({%p, \"%s\", \"%s\"})", init.engine, init.filename, init.name); | |||
| carla_debug("CarlaPlugin::newVST3({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId); | |||
| #if defined(WANT_VST) && defined(HAVE_JUCE) | |||
| return newJuce(init, "VST3"); | |||
| @@ -162,11 +162,11 @@ public: | |||
| return CarlaPlugin::getCategory(); | |||
| } | |||
| long getUniqueId() const noexcept override | |||
| int64_t getUniqueId() const noexcept override | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fEffect != nullptr, 0); | |||
| return static_cast<long>(fEffect->uniqueID); | |||
| return static_cast<int64_t>(fEffect->uniqueID); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| @@ -2081,7 +2081,7 @@ protected: | |||
| // ------------------------------------------------------------------- | |||
| public: | |||
| bool init(const char* const filename, const char* const name) | |||
| bool init(const char* const filename, const char* const name, const int64_t uniqueId) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false); | |||
| @@ -2270,6 +2270,9 @@ public: | |||
| } | |||
| return true; | |||
| // unused | |||
| (void)uniqueId; | |||
| } | |||
| private: | |||
| @@ -2463,7 +2466,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| CarlaPlugin* CarlaPlugin::newVST(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newVST({%p, \"%s\", \"%s\"})", init.engine, init.filename, init.name); | |||
| carla_debug("CarlaPlugin::newVST({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId); | |||
| #ifdef WANT_VST | |||
| # if defined(HAVE_JUCE) && USE_JUCE_FOR_VST | |||
| @@ -2471,7 +2474,7 @@ CarlaPlugin* CarlaPlugin::newVST(const Initializer& init) | |||
| # else | |||
| VstPlugin* const plugin(new VstPlugin(init.engine, init.id)); | |||
| if (! plugin->init(init.filename, init.name)) | |||
| if (! plugin->init(init.filename, init.name, init.uniqueId)) | |||
| { | |||
| delete plugin; | |||
| return nullptr; | |||
| @@ -927,13 +927,13 @@ const CarlaTransportInfo* carla_get_transport_info() | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, const void* extraPtr) | |||
| bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, int64_t uniqueId, const void* extraPtr) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0', false); | |||
| carla_debug("carla_add_plugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", %p)", btype, CB::BinaryType2Str(btype), ptype, CB::PluginType2Str(ptype), filename, name, label, extraPtr); | |||
| carla_debug("carla_add_plugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p)", btype, CB::BinaryType2Str(btype), ptype, CB::PluginType2Str(ptype), filename, name, label, uniqueId, extraPtr); | |||
| if (gStandalone.engine != nullptr) | |||
| return gStandalone.engine->addPlugin(btype, ptype, filename, name, label, extraPtr); | |||
| return gStandalone.engine->addPlugin(btype, ptype, filename, name, label, uniqueId, extraPtr); | |||
| carla_stderr2("Engine is not running"); | |||
| gStandalone.lastError = "Engine is not running"; | |||
| @@ -553,9 +553,9 @@ int main(int argc, char* argv[]) | |||
| // --------------------------------------------------------------------- | |||
| // Check argument count | |||
| if (argc != 6 && argc != 7) | |||
| if (argc != 7) | |||
| { | |||
| carla_stdout("usage: %s <osc-url|\"null\"> <type> <filename> <name|\"(none)\"> <label>", argv[0]); | |||
| carla_stdout("usage: %s <osc-url|\"null\"> <type> <filename> <name|\"(none)\"> <label> <uniqueId>", argv[0]); | |||
| return 1; | |||
| } | |||
| @@ -567,6 +567,7 @@ int main(int argc, char* argv[]) | |||
| const char* const filename = argv[3]; | |||
| const char* name = argv[4]; | |||
| const char* label = argv[5]; | |||
| const int64_t uniqueId = static_cast<int64_t>(std::atol(argv[6])); | |||
| // --------------------------------------------------------------------- | |||
| // Setup args | |||
| @@ -659,7 +660,7 @@ int main(int argc, char* argv[]) | |||
| int ret; | |||
| if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, extraStuff)) | |||
| if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, uniqueId, extraStuff)) | |||
| { | |||
| if (useOsc) | |||
| { | |||
| @@ -1019,7 +1019,7 @@ class CarlaPluginInfo(Structure): | |||
| # Plugin unique Id. | |||
| # This Id is dependant on the plugin type and may sometimes be 0. | |||
| ("uniqueId", c_long) | |||
| ("uniqueId", c_int64) | |||
| ] | |||
| # Information about an internal Carla plugin. | |||
| @@ -1349,12 +1349,13 @@ class Host(object): | |||
| # @param filename Filename, if applicable | |||
| # @param name Name of the plugin, can be NULL | |||
| # @param label Plugin label, if applicable | |||
| # @param uniqueId Plugin unique Id, if applicable | |||
| # @param extraPtr Extra pointer, defined per plugin type | |||
| def add_plugin(self, btype, ptype, filename, name, label, extraPtr): | |||
| def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr): | |||
| cfilename = filename.encode("utf-8") if filename else None | |||
| cname = name.encode("utf-8") if name else None | |||
| clabel = label.encode("utf-8") if label else None | |||
| return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, cast(extraPtr, c_void_p))) | |||
| return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, uniqueId, cast(extraPtr, c_void_p))) | |||
| # Remove a plugin. | |||
| # @param pluginId Plugin to remove. | |||
| @@ -1782,7 +1783,7 @@ class Host(object): | |||
| self.lib.carla_get_transport_info.argtypes = None | |||
| self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo) | |||
| self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_void_p] | |||
| self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_int64, c_void_p] | |||
| self.lib.carla_add_plugin.restype = c_bool | |||
| self.lib.carla_remove_plugin.argtypes = [c_uint] | |||
| @@ -860,9 +860,10 @@ class HostWindow(QMainWindow): | |||
| ptype = dialog.fRetPlugin['type'] | |||
| filename = dialog.fRetPlugin['filename'] | |||
| label = dialog.fRetPlugin['label'] | |||
| uniqueId = dialog.fRetPlugin['uniqueId'] | |||
| extraPtr = self.getExtraPtr(dialog.fRetPlugin) | |||
| if not Carla.host.add_plugin(btype, ptype, filename, None, label, extraPtr): | |||
| if not Carla.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr): | |||
| CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), charPtrToString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok) | |||
| return | |||
| @@ -301,7 +301,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsInt(int& value) | |||
| bool readNextLineAsInt(int32_t& value) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -315,18 +315,18 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsUInt(uint& value) | |||
| bool readNextLineAsUInt(uint32_t& value) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| if (const char* const msg = readline()) | |||
| { | |||
| int tmp = std::atoi(msg); | |||
| int32_t tmp = std::atoi(msg); | |||
| delete[] msg; | |||
| if (tmp >= 0) | |||
| { | |||
| value = static_cast<uint>(tmp); | |||
| value = static_cast<uint32_t>(tmp); | |||
| return true; | |||
| } | |||
| } | |||
| @@ -334,7 +334,7 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsLong(long& value) | |||
| bool readNextLineAsLong(int64_t& value) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -348,6 +348,25 @@ public: | |||
| return false; | |||
| } | |||
| bool readNextLineAsULong(uint64_t& value) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| if (const char* const msg = readline()) | |||
| { | |||
| int64_t tmp = std::atol(msg); | |||
| delete[] msg; | |||
| if (tmp >= 0) | |||
| { | |||
| value = static_cast<uint64_t>(tmp); | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| bool readNextLineAsFloat(float& value) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsReading, false); | |||
| @@ -86,7 +86,7 @@ SaveState::SaveState() noexcept | |||
| name(nullptr), | |||
| label(nullptr), | |||
| binary(nullptr), | |||
| uniqueID(0), | |||
| uniqueId(0), | |||
| active(false), | |||
| dryWet(1.0f), | |||
| volume(1.0f), | |||
| @@ -138,7 +138,7 @@ void SaveState::reset() | |||
| chunk = nullptr; | |||
| } | |||
| uniqueID = 0; | |||
| uniqueId = 0; | |||
| active = false; | |||
| dryWet = 1.0f; | |||
| volume = 1.0f; | |||
| @@ -225,8 +225,8 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
| else if (tag.compare("uniqueid", Qt::CaseInsensitive) == 0) | |||
| { | |||
| bool ok; | |||
| const long uniqueID(text.toLong(&ok)); | |||
| if (ok) saveState.uniqueID = uniqueID; | |||
| const qlonglong uniqueId(text.toLongLong(&ok)); | |||
| if (ok) saveState.uniqueId = static_cast<int64_t>(uniqueId); | |||
| } | |||
| } | |||
| } | |||
| @@ -426,7 +426,7 @@ void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) | |||
| case PLUGIN_LADSPA: | |||
| info += QString(" <Binary>%1</Binary>\n").arg(xmlSafeString(saveState.binary, true)); | |||
| info += QString(" <Label>%1</Label>\n").arg(xmlSafeString(saveState.label, true)); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueID); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueId); | |||
| break; | |||
| case PLUGIN_DSSI: | |||
| info += QString(" <Binary>%1</Binary>\n").arg(xmlSafeString(saveState.binary, true)); | |||
| @@ -438,17 +438,17 @@ void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) | |||
| break; | |||
| case PLUGIN_VST: | |||
| info += QString(" <Binary>%1</Binary>\n").arg(xmlSafeString(saveState.binary, true)); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueID); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueId); | |||
| break; | |||
| case PLUGIN_VST3: | |||
| // TODO? | |||
| info += QString(" <Binary>%1</Binary>\n").arg(xmlSafeString(saveState.binary, true)); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueID); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueId); | |||
| break; | |||
| case PLUGIN_AU: | |||
| // TODO? | |||
| info += QString(" <Binary>%1</Binary>\n").arg(xmlSafeString(saveState.binary, true)); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueID); | |||
| info += QString(" <UniqueID>%1</UniqueID>\n").arg(saveState.uniqueId); | |||
| break; | |||
| case PLUGIN_JACK: | |||
| info += QString(" <Binary>%1</Binary>\n").arg(xmlSafeString(saveState.binary, true)); | |||
| @@ -69,7 +69,7 @@ struct SaveState { | |||
| const char* name; | |||
| const char* label; | |||
| const char* binary; | |||
| long uniqueID; | |||
| int64_t uniqueId; | |||
| bool active; | |||
| float dryWet; | |||
| @@ -127,6 +127,32 @@ public: | |||
| _dup(strBuf); | |||
| } | |||
| /* | |||
| * Long long integer. | |||
| */ | |||
| explicit CarlaString(const long long int value) | |||
| { | |||
| char strBuf[0xff+1]; | |||
| carla_zeroChar(strBuf, 0xff+1); | |||
| std::snprintf(strBuf, 0xff, "%lld", value); | |||
| _init(); | |||
| _dup(strBuf); | |||
| } | |||
| /* | |||
| * Long long unsigned integer, possibly hexadecimal. | |||
| */ | |||
| explicit CarlaString(const unsigned long long int value, const bool hexadecimal = false) | |||
| { | |||
| char strBuf[0xff+1]; | |||
| carla_zeroChar(strBuf, 0xff+1); | |||
| std::snprintf(strBuf, 0xff, hexadecimal ? "0x%llx" : "%llu", value); | |||
| _init(); | |||
| _dup(strBuf); | |||
| } | |||
| /* | |||
| * Single-precision floating point number. | |||
| */ | |||