From b20ff6dae0fee9a25aa5f638e713d9505fcc7618 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 30 Jul 2013 18:40:53 +0100 Subject: [PATCH] Continue cleanup --- source/backend/CarlaPlugin.hpp | 4 +- source/backend/CarlaStandalone.hpp | 4 +- source/backend/standalone/CarlaStandalone.cpp | 899 +++++++++--------- source/carla.py | 9 +- source/carla_backend.py | 4 +- source/modules/utils/CarlaLogThread.hpp | 57 +- source/tests/ANSI.cpp | 17 +- 7 files changed, 519 insertions(+), 475 deletions(-) diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index 96a86a205..234cfe406 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -20,15 +20,13 @@ #include "CarlaBackend.hpp" #include "CarlaString.hpp" +#include "CarlaNative.h" // Avoid including extra libs here typedef void* lo_address; #ifndef LADSPA_RDF_HPP_INCLUDED struct LADSPA_RDF_Descriptor; #endif -#ifndef CARLA_NATIVE_H_INCLUDED -struct PluginDescriptor; -#endif CARLA_BACKEND_START_NAMESPACE diff --git a/source/backend/CarlaStandalone.hpp b/source/backend/CarlaStandalone.hpp index 9e3089bfb..eb81e0423 100644 --- a/source/backend/CarlaStandalone.hpp +++ b/source/backend/CarlaStandalone.hpp @@ -230,7 +230,7 @@ struct CarlaScalePointInfo { */ struct CarlaTransportInfo { bool playing; - uint32_t frame; + uint64_t frame; int32_t bar; int32_t beat; int32_t tick; @@ -384,7 +384,7 @@ CARLA_EXPORT void carla_transport_relocate(uint32_t frames); /*! * Get the current transport frame. */ -CARLA_EXPORT uint32_t carla_get_current_transport_frame(); +CARLA_EXPORT uint64_t carla_get_current_transport_frame(); /*! * Get the engine transport information. diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 2ba682c75..45ee3d362 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -22,10 +22,10 @@ #include "CarlaEngine.hpp" #include "CarlaPlugin.hpp" #include "CarlaMIDI.h" -#include "CarlaNative.h" #include "CarlaLogThread.hpp" #include "CarlaStyle.hpp" + #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) @@ -38,10 +38,8 @@ namespace CB = CarlaBackend; using CB::CarlaEngine; using CB::CarlaPlugin; -using CB::CallbackFunc; using CB::EngineOptions; using CB::EngineTimeInfo; -using CB::LogThread; // ------------------------------------------------------------------------------------------------------------------- // Single, standalone engine @@ -51,15 +49,12 @@ struct CarlaBackendStandalone { void* callbackPtr; CarlaEngine* engine; CarlaString lastError; - CarlaString procName; EngineOptions options; QApplication* app; CarlaStyle* style; bool needsInit; - LogThread logThread; - CarlaBackendStandalone() : callback(nullptr), callbackPtr(nullptr), @@ -73,8 +68,6 @@ struct CarlaBackendStandalone { ~CarlaBackendStandalone() { CARLA_ASSERT(engine == nullptr); - - logThread.stop(); } void init() @@ -121,7 +114,9 @@ struct CarlaBackendStandalone { if (app == nullptr || style != nullptr) return; - if (QSettings().value("Main/UseProTheme", true).toBool()) + QSettings settings("falkTX", "Carla"); + + if (settings.value("Main/UseProTheme", true).toBool()) { style = new CarlaStyle(); app->setStyle(style); @@ -129,8 +124,12 @@ struct CarlaBackendStandalone { } CARLA_DECLARE_NON_COPY_STRUCT(CarlaBackendStandalone) +}; -} standalone; +#ifndef DEBUG +static CarlaLogThread gLogThread; +#endif +static CarlaBackendStandalone gStandalone; // ------------------------------------------------------------------------------------------------------------------- // API @@ -143,82 +142,81 @@ const char* carla_get_extended_license_text() if (retText.isEmpty()) { - CarlaString text1, text2; + CarlaString text1, text2, text3, text4, text5; text1 += "

This current Carla build is using the following features and 3rd-party code:

"; text1 += ""; + text4 += ""; // code snippets - text2 += "

Additionally, Carla uses code snippets from the following projects:

"; - text2 += ""; + text5 += "

Additionally, Carla uses code snippets from the following projects:

"; + text5 += ""; // LinuxSampler GPL exception #ifdef WANT_LINUXSAMPLER - text2 += "

(*) Using LinuxSampler code in commercial hardware or software products is not allowed without prior written authorization by the authors.

"; + text5 += "

(*) Using LinuxSampler code in commercial hardware or software products is not allowed without prior written authorization by the authors.

"; #endif - retText += text1; - retText += text2; + retText = text1 + text2 + text3 + text4 + text5; } return retText; @@ -351,18 +349,21 @@ const CarlaNativePluginInfo* carla_get_internal_plugin_info(unsigned int interna bool carla_engine_init(const char* driverName, const char* clientName) { - CARLA_ASSERT(standalone.engine == nullptr); + CARLA_ASSERT(gStandalone.engine == nullptr); CARLA_ASSERT(driverName != nullptr); CARLA_ASSERT(clientName != nullptr); carla_debug("carla_engine_init(\"%s\", \"%s\")", driverName, clientName); -#ifndef NDEBUG - static bool showWarning = true; +#ifdef DEBUG + static bool firstInit = true; - if (showWarning && standalone.callback != nullptr) + if (firstInit) { - standalone.callback(standalone.callbackPtr, CB::CALLBACK_DEBUG, 0, 0, 0, 0.0f, "Debug builds don't use this, check the console instead"); - showWarning = false; + firstInit = false; + + if (gStandalone.callback != nullptr) + gStandalone.callback(gStandalone.callbackPtr, CB::CALLBACK_DEBUG, 0, 0, 0, 0.0f, + "Debug builds don't use this, please check the console instead."); } #endif @@ -377,145 +378,144 @@ bool carla_engine_init(const char* driverName, const char* clientName) carla_setenv("WINE_SVR_RT", "10"); } - if (standalone.engine != nullptr) + if (gStandalone.engine != nullptr) { - standalone.lastError = "Engine is already running"; + gStandalone.lastError = "Engine is already running"; return false; } - standalone.engine = CarlaEngine::newDriverByName(driverName); + gStandalone.engine = CarlaEngine::newDriverByName(driverName); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) { - standalone.lastError = "The seleted audio driver is not available!"; + gStandalone.lastError = "The seleted audio driver is not available!"; return false; } - if (standalone.callback != nullptr) - standalone.engine->setCallback(standalone.callback, nullptr); + if (gStandalone.callback != nullptr) + gStandalone.engine->setCallback(gStandalone.callback, nullptr); #ifndef BUILD_BRIDGE - standalone.engine->setOption(CB::OPTION_PROCESS_MODE, static_cast(standalone.options.processMode), nullptr); - standalone.engine->setOption(CB::OPTION_TRANSPORT_MODE, static_cast(standalone.options.transportMode), nullptr); + gStandalone.engine->setOption(CB::OPTION_PROCESS_MODE, static_cast(gStandalone.options.processMode), nullptr); + gStandalone.engine->setOption(CB::OPTION_TRANSPORT_MODE, static_cast(gStandalone.options.transportMode), nullptr); #endif - standalone.engine->setOption(CB::OPTION_FORCE_STEREO, standalone.options.forceStereo ? 1 : 0, nullptr); - standalone.engine->setOption(CB::OPTION_PREFER_PLUGIN_BRIDGES, standalone.options.preferPluginBridges ? 1 : 0, nullptr); - standalone.engine->setOption(CB::OPTION_PREFER_UI_BRIDGES, standalone.options.preferUiBridges ? 1 : 0, nullptr); - standalone.engine->setOption(CB::OPTION_UIS_ALWAYS_ON_TOP, standalone.options.uisAlwaysOnTop ? 1 : 0, nullptr); + gStandalone.engine->setOption(CB::OPTION_FORCE_STEREO, gStandalone.options.forceStereo ? 1 : 0, nullptr); + gStandalone.engine->setOption(CB::OPTION_PREFER_PLUGIN_BRIDGES, gStandalone.options.preferPluginBridges ? 1 : 0, nullptr); + gStandalone.engine->setOption(CB::OPTION_PREFER_UI_BRIDGES, gStandalone.options.preferUiBridges ? 1 : 0, nullptr); + gStandalone.engine->setOption(CB::OPTION_UIS_ALWAYS_ON_TOP, gStandalone.options.uisAlwaysOnTop ? 1 : 0, nullptr); #ifdef WANT_DSSI - standalone.engine->setOption(CB::OPTION_USE_DSSI_VST_CHUNKS, standalone.options.useDssiVstChunks ? 1 : 0, nullptr); + gStandalone.engine->setOption(CB::OPTION_USE_DSSI_VST_CHUNKS, gStandalone.options.useDssiVstChunks ? 1 : 0, nullptr); #endif - standalone.engine->setOption(CB::OPTION_MAX_PARAMETERS, static_cast(standalone.options.maxParameters), nullptr); - standalone.engine->setOption(CB::OPTION_UI_BRIDGES_TIMEOUT, static_cast(standalone.options.uiBridgesTimeout), nullptr); + gStandalone.engine->setOption(CB::OPTION_MAX_PARAMETERS, static_cast(gStandalone.options.maxParameters), nullptr); + gStandalone.engine->setOption(CB::OPTION_UI_BRIDGES_TIMEOUT, static_cast(gStandalone.options.uiBridgesTimeout), nullptr); #ifdef WANT_RTAUDIO - standalone.engine->setOption(CB::OPTION_RTAUDIO_NUMBER_PERIODS, static_cast(standalone.options.rtaudioNumPeriods), nullptr); - standalone.engine->setOption(CB::OPTION_RTAUDIO_BUFFER_SIZE, static_cast(standalone.options.rtaudioBufferSize), nullptr); - standalone.engine->setOption(CB::OPTION_RTAUDIO_SAMPLE_RATE, static_cast(standalone.options.rtaudioSampleRate), nullptr); - standalone.engine->setOption(CB::OPTION_RTAUDIO_DEVICE, 0, (const char*)standalone.options.rtaudioDevice); + gStandalone.engine->setOption(CB::OPTION_RTAUDIO_NUMBER_PERIODS, static_cast(gStandalone.options.rtaudioNumPeriods), nullptr); + gStandalone.engine->setOption(CB::OPTION_RTAUDIO_BUFFER_SIZE, static_cast(gStandalone.options.rtaudioBufferSize), nullptr); + gStandalone.engine->setOption(CB::OPTION_RTAUDIO_SAMPLE_RATE, static_cast(gStandalone.options.rtaudioSampleRate), nullptr); + gStandalone.engine->setOption(CB::OPTION_RTAUDIO_DEVICE, 0, (const char*)gStandalone.options.rtaudioDevice); #endif - standalone.engine->setOption(CB::OPTION_PATH_RESOURCES, 0, (const char*)standalone.options.resourceDir); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_NATIVE, 0, (const char*)standalone.options.bridge_native); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_POSIX32, 0, (const char*)standalone.options.bridge_posix32); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_POSIX64, 0, (const char*)standalone.options.bridge_posix64); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_WIN32, 0, (const char*)standalone.options.bridge_win32); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_WIN64, 0, (const char*)standalone.options.bridge_win64); + gStandalone.engine->setOption(CB::OPTION_PATH_RESOURCES, 0, (const char*)gStandalone.options.resourceDir); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_NATIVE, 0, (const char*)gStandalone.options.bridge_native); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_POSIX32, 0, (const char*)gStandalone.options.bridge_posix32); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_POSIX64, 0, (const char*)gStandalone.options.bridge_posix64); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_WIN32, 0, (const char*)gStandalone.options.bridge_win32); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_WIN64, 0, (const char*)gStandalone.options.bridge_win64); #ifdef WANT_LV2 - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_GTK2, 0, (const char*)standalone.options.bridge_lv2Gtk2); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_GTK3, 0, (const char*)standalone.options.bridge_lv2Gtk3); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_QT4, 0, (const char*)standalone.options.bridge_lv2Qt4); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_QT5, 0, (const char*)standalone.options.bridge_lv2Qt5); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_COCOA, 0, (const char*)standalone.options.bridge_lv2Cocoa); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_WINDOWS, 0, (const char*)standalone.options.bridge_lv2Win); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_X11, 0, (const char*)standalone.options.bridge_lv2X11); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_GTK2, 0, (const char*)gStandalone.options.bridge_lv2Gtk2); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_GTK3, 0, (const char*)gStandalone.options.bridge_lv2Gtk3); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_QT4, 0, (const char*)gStandalone.options.bridge_lv2Qt4); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_QT5, 0, (const char*)gStandalone.options.bridge_lv2Qt5); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_COCOA, 0, (const char*)gStandalone.options.bridge_lv2Cocoa); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_WINDOWS, 0, (const char*)gStandalone.options.bridge_lv2Win); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_LV2_X11, 0, (const char*)gStandalone.options.bridge_lv2X11); #endif #ifdef WANT_VST - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_VST_COCOA, 0, (const char*)standalone.options.bridge_vstCocoa); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_VST_HWND, 0, (const char*)standalone.options.bridge_vstHWND); - standalone.engine->setOption(CB::OPTION_PATH_BRIDGE_VST_X11, 0, (const char*)standalone.options.bridge_vstX11); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_VST_COCOA, 0, (const char*)gStandalone.options.bridge_vstCocoa); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_VST_HWND, 0, (const char*)gStandalone.options.bridge_vstHWND); + gStandalone.engine->setOption(CB::OPTION_PATH_BRIDGE_VST_X11, 0, (const char*)gStandalone.options.bridge_vstX11); #endif - if (standalone.procName.isNotEmpty()) - standalone.engine->setOption(CB::OPTION_PROCESS_NAME, 0, (const char*)standalone.procName); - - if (standalone.engine->init(clientName)) + if (gStandalone.engine->init(clientName)) { - standalone.lastError = "no error"; - standalone.init(); + gStandalone.lastError = "no error"; + gStandalone.init(); return true; } else { - standalone.lastError = standalone.engine->getLastError(); - delete standalone.engine; - standalone.engine = nullptr; + gStandalone.lastError = gStandalone.engine->getLastError(); + delete gStandalone.engine; + gStandalone.engine = nullptr; return false; } } bool carla_engine_close() { - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); carla_debug("carla_engine_close()"); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) { - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } - standalone.engine->setAboutToClose(); - standalone.engine->removeAllPlugins(); + gStandalone.engine->setAboutToClose(); + gStandalone.engine->removeAllPlugins(); - const bool closed(standalone.engine->close()); + const bool closed(gStandalone.engine->close()); if (! closed) - standalone.lastError = standalone.engine->getLastError(); + gStandalone.lastError = gStandalone.engine->getLastError(); - delete standalone.engine; - standalone.engine = nullptr; - standalone.close(); + delete gStandalone.engine; + gStandalone.engine = nullptr; + gStandalone.close(); return closed; } void carla_engine_idle() { - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.needsInit && standalone.app != nullptr) - standalone.app->processEvents(); + if (gStandalone.needsInit && gStandalone.app != nullptr) + gStandalone.app->processEvents(); - if (standalone.engine != nullptr) - standalone.engine->idle(); + if (gStandalone.engine != nullptr) + gStandalone.engine->idle(); } bool carla_is_engine_running() { carla_debug("carla_is_engine_running()"); - return (standalone.engine != nullptr && standalone.engine->isRunning()); + return (gStandalone.engine != nullptr && gStandalone.engine->isRunning()); } void carla_set_engine_about_to_close() { - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); carla_debug("carla_set_engine_about_to_close()"); - if (standalone.engine != nullptr) - standalone.engine->setAboutToClose(); + if (gStandalone.engine != nullptr) + gStandalone.engine->setAboutToClose(); } void carla_set_engine_callback(CarlaCallbackFunc func, void* ptr) { carla_debug("carla_set_engine_callback(%p)", func); - standalone.callback = func; - standalone.callbackPtr = ptr; + gStandalone.callback = func; + gStandalone.callbackPtr = ptr; - standalone.logThread.ready(func, ptr); + if (gStandalone.engine != nullptr) + gStandalone.engine->setCallback(func, ptr); - if (standalone.engine != nullptr) - standalone.engine->setCallback(func, ptr); +#ifndef DEBUG + gLogThread.setCallback(func, ptr); +#endif } void carla_set_engine_option(CarlaOptionsType option, int value, const char* valueStr) @@ -525,38 +525,42 @@ void carla_set_engine_option(CarlaOptionsType option, int value, const char* val switch (option) { case CB::OPTION_PROCESS_NAME: - standalone.procName = valueStr; + carla_setprocname(valueStr); break; case CB::OPTION_PROCESS_MODE: if (value < CB::PROCESS_MODE_SINGLE_CLIENT || value > CB::PROCESS_MODE_PATCHBAY) return carla_stderr2("carla_set_engine_option(OPTION_PROCESS_MODE, %i, \"%s\") - invalid value", value, valueStr); - standalone.options.processMode = static_cast(value); + gStandalone.options.processMode = static_cast(value); break; case CB::OPTION_TRANSPORT_MODE: if (value < CB::TRANSPORT_MODE_INTERNAL || value > CB::TRANSPORT_MODE_JACK) return carla_stderr2("carla_set_engine_option(OPTION_TRANSPORT_MODE, %i, \"%s\") - invalid value", value, valueStr); - standalone.options.transportMode = static_cast(value); + gStandalone.options.transportMode = static_cast(value); break; case CB::OPTION_FORCE_STEREO: - standalone.options.forceStereo = (value != 0); + gStandalone.options.forceStereo = (value != 0); break; case CB::OPTION_PREFER_PLUGIN_BRIDGES: - standalone.options.preferPluginBridges = (value != 0); + gStandalone.options.preferPluginBridges = (value != 0); break; case CB::OPTION_PREFER_UI_BRIDGES: - standalone.options.preferUiBridges = (value != 0); + gStandalone.options.preferUiBridges = (value != 0); + break; + + case CB::OPTION_UIS_ALWAYS_ON_TOP: + gStandalone.options.uisAlwaysOnTop = (value != 0); break; #ifdef WANT_DSSI case CB::OPTION_USE_DSSI_VST_CHUNKS: - standalone.options.useDssiVstChunks = (value != 0); + gStandalone.options.useDssiVstChunks = (value != 0); break; #endif @@ -564,103 +568,104 @@ void carla_set_engine_option(CarlaOptionsType option, int value, const char* val if (value <= 0) return carla_stderr2("carla_set_engine_option(OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr); - standalone.options.maxParameters = static_cast(value); + gStandalone.options.maxParameters = static_cast(value); break; - case CB::OPTION_OSC_UI_TIMEOUT: + case CB::OPTION_UI_BRIDGES_TIMEOUT: if (value <= 0) - return carla_stderr2("carla_set_engine_option(OPTION_OSC_UI_TIMEOUT, %i, \"%s\") - invalid value", value, valueStr); + return carla_stderr2("carla_set_engine_option(OPTION_UI_BRIDGES_TIMEOUT, %i, \"%s\") - invalid value", value, valueStr); - standalone.options.oscUiTimeout = static_cast(value); + gStandalone.options.uiBridgesTimeout = static_cast(value); break; - case CB::OPTION_JACK_AUTOCONNECT: - standalone.options.jackAutoConnect = (value != 0); - break; +#ifdef WANT_RTAUDIO + case CB::OPTION_RTAUDIO_NUMBER_PERIODS: + if (value <= 0 || value > 3) + return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_NUMBER_PERIODS, %i, \"%s\") - invalid value", value, valueStr); - case CB::OPTION_JACK_TIMEMASTER: - standalone.options.jackTimeMaster = (value != 0); + gStandalone.options.rtaudioNumPeriods = static_cast(value); break; -#ifdef WANT_RTAUDIO case CB::OPTION_RTAUDIO_BUFFER_SIZE: if (value <= 0) return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_BUFFER_SIZE, %i, \"%s\") - invalid value", value, valueStr); - standalone.options.rtaudioBufferSize = static_cast(value); + gStandalone.options.rtaudioBufferSize = static_cast(value); break; case CB::OPTION_RTAUDIO_SAMPLE_RATE: if (value <= 0) return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_SAMPLE_RATE, %i, \"%s\") - invalid value", value, valueStr); - standalone.options.rtaudioSampleRate = static_cast(value); + gStandalone.options.rtaudioSampleRate = static_cast(value); break; case CB::OPTION_RTAUDIO_DEVICE: - standalone.options.rtaudioDevice = valueStr; + gStandalone.options.rtaudioDevice = valueStr; break; #endif case CB::OPTION_PATH_RESOURCES: - standalone.options.resourceDir = valueStr; + gStandalone.options.resourceDir = valueStr; break; #ifndef BUILD_BRIDGE case CB::OPTION_PATH_BRIDGE_NATIVE: - standalone.options.bridge_native = valueStr; + gStandalone.options.bridge_native = valueStr; break; case CB::OPTION_PATH_BRIDGE_POSIX32: - standalone.options.bridge_posix32 = valueStr; + gStandalone.options.bridge_posix32 = valueStr; break; case CB::OPTION_PATH_BRIDGE_POSIX64: - standalone.options.bridge_posix64 = valueStr; + gStandalone.options.bridge_posix64 = valueStr; break; case CB::OPTION_PATH_BRIDGE_WIN32: - standalone.options.bridge_win32 = valueStr; + gStandalone.options.bridge_win32 = valueStr; break; case CB::OPTION_PATH_BRIDGE_WIN64: - standalone.options.bridge_win64 = valueStr; + gStandalone.options.bridge_win64 = valueStr; break; #endif + #ifdef WANT_LV2 case CB::OPTION_PATH_BRIDGE_LV2_GTK2: - standalone.options.bridge_lv2Gtk2 = valueStr; + gStandalone.options.bridge_lv2Gtk2 = valueStr; break; case CB::OPTION_PATH_BRIDGE_LV2_GTK3: - standalone.options.bridge_lv2Gtk3 = valueStr; + gStandalone.options.bridge_lv2Gtk3 = valueStr; break; case CB::OPTION_PATH_BRIDGE_LV2_QT4: - standalone.options.bridge_lv2Qt4 = valueStr; + gStandalone.options.bridge_lv2Qt4 = valueStr; break; case CB::OPTION_PATH_BRIDGE_LV2_QT5: - standalone.options.bridge_lv2Qt5 = valueStr; + gStandalone.options.bridge_lv2Qt5 = valueStr; break; case CB::OPTION_PATH_BRIDGE_LV2_COCOA: - standalone.options.bridge_lv2Cocoa = valueStr; + gStandalone.options.bridge_lv2Cocoa = valueStr; break; case CB::OPTION_PATH_BRIDGE_LV2_WINDOWS: - standalone.options.bridge_lv2Win = valueStr; + gStandalone.options.bridge_lv2Win = valueStr; break; case CB::OPTION_PATH_BRIDGE_LV2_X11: - standalone.options.bridge_lv2X11 = valueStr; + gStandalone.options.bridge_lv2X11 = valueStr; break; #endif + #ifdef WANT_VST case CB::OPTION_PATH_BRIDGE_VST_COCOA: - standalone.options.bridge_vstCocoa = valueStr; + gStandalone.options.bridge_vstCocoa = valueStr; break; case CB::OPTION_PATH_BRIDGE_VST_HWND: - standalone.options.bridge_vstHWND = valueStr; + gStandalone.options.bridge_vstHWND = valueStr; break; case CB::OPTION_PATH_BRIDGE_VST_X11: - standalone.options.bridge_vstX11 = valueStr; + gStandalone.options.bridge_vstX11 = valueStr; break; #endif } - if (standalone.engine != nullptr) - standalone.engine->setOption(option, value, valueStr); + if (gStandalone.engine != nullptr) + gStandalone.engine->setOption(option, value, valueStr); } // ------------------------------------------------------------------------------------------------------------------- @@ -668,39 +673,39 @@ void carla_set_engine_option(CarlaOptionsType option, int value, const char* val bool carla_load_filename(const char* filename) { carla_debug("carla_load_filename(\"%s\")", filename); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); CARLA_ASSERT(filename != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->loadFilename(filename); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->loadFilename(filename); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } bool carla_load_project(const char* filename) { carla_debug("carla_load_project(\"%s\")", filename); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); CARLA_ASSERT(filename != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->loadProject(filename); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->loadProject(filename); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } bool carla_save_project(const char* filename) { carla_debug("carla_save_project(\"%s\")", filename); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); CARLA_ASSERT(filename != nullptr); - if (standalone.engine != nullptr) // allow to save even if engine stopped - return standalone.engine->saveProject(filename); + if (gStandalone.engine != nullptr) // allow to save even if engine stopped + return gStandalone.engine->saveProject(filename); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } @@ -709,34 +714,34 @@ bool carla_save_project(const char* filename) bool carla_patchbay_connect(int portA, int portB) { carla_debug("carla_patchbay_connect(%i, %i)", portA, portB); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->patchbayConnect(portA, portB); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->patchbayConnect(portA, portB); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } bool carla_patchbay_disconnect(int connectionId) { carla_debug("carla_patchbay_disconnect(%i)", connectionId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->patchbayDisconnect(connectionId); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->patchbayDisconnect(connectionId); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } void carla_patchbay_refresh() { carla_debug("carla_patchbay_refresh()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - standalone.engine->patchbayRefresh(); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + gStandalone.engine->patchbayRefresh(); } // ------------------------------------------------------------------------------------------------------------------- @@ -744,37 +749,37 @@ void carla_patchbay_refresh() void carla_transport_play() { carla_debug("carla_transport_play()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - standalone.engine->transportPlay(); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + gStandalone.engine->transportPlay(); } void carla_transport_pause() { carla_debug("carla_transport_pause()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - standalone.engine->transportPause(); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + gStandalone.engine->transportPause(); } void carla_transport_relocate(uint32_t frames) { carla_debug("carla_transport_relocate(%i)", frames); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - standalone.engine->transportRelocate(frames); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + gStandalone.engine->transportRelocate(frames); } -uint32_t carla_get_current_transport_frame() +uint64_t carla_get_current_transport_frame() { - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr) + if (gStandalone.engine != nullptr) { - const EngineTimeInfo& timeInfo(standalone.engine->getTimeInfo()); + const EngineTimeInfo& timeInfo(gStandalone.engine->getTimeInfo()); return timeInfo.frame; } @@ -783,13 +788,13 @@ uint32_t carla_get_current_transport_frame() const CarlaTransportInfo* carla_get_transport_info() { - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaTransportInfo info; - if (standalone.engine != nullptr) + if (gStandalone.engine != nullptr) { - const EngineTimeInfo& timeInfo(standalone.engine->getTimeInfo()); + const EngineTimeInfo& timeInfo(gStandalone.engine->getTimeInfo()); info.playing = timeInfo.playing; info.frame = timeInfo.frame; @@ -827,81 +832,81 @@ const CarlaTransportInfo* carla_get_transport_info() bool carla_add_plugin(CarlaBinaryType btype, CarlaPluginType ptype, const char* filename, const char* const name, const char* label, const void* extraStuff) { carla_debug("carla_add_plugin(%s, %s, \"%s\", \"%s\", \"%s\", %p)", CB::BinaryType2Str(btype), CB::PluginType2Str(ptype), filename, name, label, extraStuff); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->addPlugin(btype, ptype, filename, name, label, extraStuff); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->addPlugin(btype, ptype, filename, name, label, extraStuff); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } bool carla_remove_plugin(unsigned int pluginId) { carla_debug("carla_remove_plugin(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->removePlugin(pluginId); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->removePlugin(pluginId); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } void carla_remove_all_plugins() { carla_debug("carla_remove_all_plugins()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - standalone.engine->removeAllPlugins(); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + gStandalone.engine->removeAllPlugins(); } const char* carla_rename_plugin(unsigned int pluginId, const char* newName) { carla_debug("carla_rename_plugin(%i, \"%s\")", pluginId, newName); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->renamePlugin(pluginId, newName); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->renamePlugin(pluginId, newName); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return nullptr; } bool carla_clone_plugin(unsigned int pluginId) { carla_debug("carla_clone_plugin(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->clonePlugin(pluginId); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->clonePlugin(pluginId); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } bool carla_replace_plugin(unsigned int pluginId) { carla_debug("carla_replace_plugin(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->replacePlugin(pluginId); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->replacePlugin(pluginId); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } bool carla_switch_plugins(unsigned int pluginIdA, unsigned int pluginIdB) { carla_debug("carla_switch_plugins(%i, %i)", pluginIdA, pluginIdB); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine != nullptr && standalone.engine->isRunning()) - return standalone.engine->switchPlugins(pluginIdA, pluginIdB); + if (gStandalone.engine != nullptr && gStandalone.engine->isRunning()) + return gStandalone.engine->switchPlugins(pluginIdA, pluginIdB); - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } @@ -910,15 +915,15 @@ bool carla_switch_plugins(unsigned int pluginIdA, unsigned int pluginIdB) bool carla_load_plugin_state(unsigned int pluginId, const char* filename) { carla_debug("carla_load_plugin_state(%i, \"%s\")", pluginId, filename); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr || ! standalone.engine->isRunning()) + if (gStandalone.engine == nullptr || ! gStandalone.engine->isRunning()) { - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->loadStateFromFile(filename); carla_stderr2("carla_load_plugin_state(%i, \"%s\") - could not find plugin", pluginId, filename); @@ -928,15 +933,15 @@ bool carla_load_plugin_state(unsigned int pluginId, const char* filename) bool carla_save_plugin_state(unsigned int pluginId, const char* filename) { carla_debug("carla_save_plugin_state(%i, \"%s\")", pluginId, filename); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) { - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return false; } - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->saveStateToFile(filename); carla_stderr2("carla_save_plugin_state(%i, \"%s\") - could not find plugin", pluginId, filename); @@ -948,7 +953,7 @@ bool carla_save_plugin_state(unsigned int pluginId, const char* filename) const CarlaPluginInfo* carla_get_plugin_info(unsigned int pluginId) { carla_debug("carla_get_plugin_info(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaPluginInfo info; @@ -984,26 +989,30 @@ const CarlaPluginInfo* carla_get_plugin_info(unsigned int pluginId) info.copyright = nullptr; } - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &info; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - char strBufLabel[STR_MAX+1] = { '\0' }; - char strBufMaker[STR_MAX+1] = { '\0' }; - char strBufCopyright[STR_MAX+1] = { '\0' }; + char strBufLabel[STR_MAX+1]; + char strBufMaker[STR_MAX+1]; + char strBufCopyright[STR_MAX+1]; + + carla_zeroChar(strBufLabel, STR_MAX+1); + carla_zeroChar(strBufMaker, STR_MAX+1); + carla_zeroChar(strBufCopyright, STR_MAX+1); - info.type = plugin->type(); - info.category = plugin->category(); - info.hints = plugin->hints(); - info.binary = plugin->filename(); - info.name = plugin->name(); - info.iconName = plugin->iconName(); - info.uniqueId = plugin->uniqueId(); - info.latency = plugin->latency(); + info.type = plugin->getType(); + info.category = plugin->getCategory(); + info.hints = plugin->getHints(); + info.binary = plugin->getFilename(); + info.name = plugin->getName(); + info.iconName = plugin->getIconName(); + info.uniqueId = plugin->getUniqueId(); + info.latency = plugin->getLatencyInFrames(); - info.optionsAvailable = plugin->availableOptions(); - info.optionsEnabled = plugin->options(); + info.optionsAvailable = plugin->getAvailableOptions(); + info.optionsEnabled = plugin->getOptions(); plugin->getLabel(strBufLabel); info.label = carla_strdup(strBufLabel); @@ -1024,7 +1033,7 @@ const CarlaPluginInfo* carla_get_plugin_info(unsigned int pluginId) const CarlaPortCountInfo* carla_get_audio_port_count_info(unsigned int pluginId) { carla_debug("carla_get_audio_port_count_info(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaPortCountInfo info; @@ -1033,13 +1042,13 @@ const CarlaPortCountInfo* carla_get_audio_port_count_info(unsigned int pluginId) info.outs = 0; info.total = 0; - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &info; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - info.ins = plugin->audioInCount(); - info.outs = plugin->audioOutCount(); + info.ins = plugin->getAudioInCount(); + info.outs = plugin->getAudioOutCount(); info.total = info.ins + info.outs; return &info; } @@ -1051,7 +1060,7 @@ const CarlaPortCountInfo* carla_get_audio_port_count_info(unsigned int pluginId) const CarlaPortCountInfo* carla_get_midi_port_count_info(unsigned int pluginId) { carla_debug("carla_get_midi_port_count_info(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaPortCountInfo info; @@ -1060,13 +1069,13 @@ const CarlaPortCountInfo* carla_get_midi_port_count_info(unsigned int pluginId) info.outs = 0; info.total = 0; - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &info; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - info.ins = plugin->midiInCount(); - info.outs = plugin->midiOutCount(); + info.ins = plugin->getMidiInCount(); + info.outs = plugin->getMidiOutCount(); info.total = info.ins + info.outs; return &info; } @@ -1078,7 +1087,7 @@ const CarlaPortCountInfo* carla_get_midi_port_count_info(unsigned int pluginId) const CarlaPortCountInfo* carla_get_parameter_count_info(unsigned int pluginId) { carla_debug("carla_get_parameter_count_info(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaPortCountInfo info; @@ -1087,10 +1096,10 @@ const CarlaPortCountInfo* carla_get_parameter_count_info(unsigned int pluginId) info.outs = 0; info.total = 0; - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &info; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { plugin->getParameterCountInfo(&info.ins, &info.outs, &info.total); return &info; @@ -1103,7 +1112,7 @@ const CarlaPortCountInfo* carla_get_parameter_count_info(unsigned int pluginId) const CarlaParameterInfo* carla_get_parameter_info(unsigned int pluginId, uint32_t parameterId) { carla_debug("carla_get_parameter_info(%i, %i)", pluginId, parameterId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaParameterInfo info; @@ -1129,18 +1138,18 @@ const CarlaParameterInfo* carla_get_parameter_info(unsigned int pluginId, uint32 info.unit = nullptr; } - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &info; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) + if (parameterId < plugin->getParameterCount()) { char strBufName[STR_MAX+1] = { '\0' }; char strBufSymbol[STR_MAX+1] = { '\0' }; char strBufUnit[STR_MAX+1] = { '\0' }; - info.scalePointCount = plugin->parameterScalePointCount(parameterId); + info.scalePointCount = plugin->getParameterScalePointCount(parameterId); plugin->getParameterName(parameterId, strBufName); info.name = carla_strdup(strBufName); @@ -1164,7 +1173,7 @@ const CarlaParameterInfo* carla_get_parameter_info(unsigned int pluginId, uint32 const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(unsigned int pluginId, uint32_t parameterId, uint32_t scalePointId) { carla_debug("carla_get_parameter_scalepoint_info(%i, %i, %i)", pluginId, parameterId, scalePointId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaScalePointInfo info; @@ -1178,14 +1187,14 @@ const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(unsigned int plug info.label = nullptr; } - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &info; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) + if (parameterId < plugin->getParameterCount()) { - if (scalePointId < plugin->parameterScalePointCount(parameterId)) + if (scalePointId < plugin->getParameterScalePointCount(parameterId)) { char strBufLabel[STR_MAX+1] = { '\0' }; @@ -1212,17 +1221,17 @@ const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(unsigned int plug const CarlaParameterData* carla_get_parameter_data(unsigned int pluginId, uint32_t parameterId) { carla_debug("carla_get_parameter_data(%i, %i)", pluginId, parameterId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaParameterData data; - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &data; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) - return &plugin->parameterData(parameterId); + if (parameterId < plugin->getParameterCount()) + return &plugin->getParameterData(parameterId); carla_stderr2("carla_get_parameter_data(%i, %i) - parameterId out of bounds", pluginId, parameterId); return &data; @@ -1235,17 +1244,17 @@ const CarlaParameterData* carla_get_parameter_data(unsigned int pluginId, uint32 const CarlaParameterRanges* carla_get_parameter_ranges(unsigned int pluginId, uint32_t parameterId) { carla_debug("carla_get_parameter_ranges(%i, %i)", pluginId, parameterId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaParameterRanges ranges; - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &ranges; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) - return &plugin->parameterRanges(parameterId); + if (parameterId < plugin->getParameterCount()) + return &plugin->getParameterRanges(parameterId); carla_stderr2("carla_get_parameter_ranges(%i, %i) - parameterId out of bounds", pluginId, parameterId); return &ranges; @@ -1258,17 +1267,17 @@ const CarlaParameterRanges* carla_get_parameter_ranges(unsigned int pluginId, ui const CarlaMidiProgramData* carla_get_midi_program_data(unsigned int pluginId, uint32_t midiProgramId) { carla_debug("carla_get_midi_program_data(%i, %i)", pluginId, midiProgramId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaMidiProgramData data; - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &data; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (midiProgramId < plugin->midiProgramCount()) - return &plugin->midiProgramData(midiProgramId); + if (midiProgramId < plugin->getMidiProgramCount()) + return &plugin->getMidiProgramData(midiProgramId); carla_stderr2("carla_get_midi_program_data(%i, %i) - midiProgramId out of bounds", pluginId, midiProgramId); return &data; @@ -1281,17 +1290,17 @@ const CarlaMidiProgramData* carla_get_midi_program_data(unsigned int pluginId, u const CarlaCustomData* carla_get_custom_data(unsigned int pluginId, uint32_t customDataId) { carla_debug("carla_get_custom_data(%i, %i)", pluginId, customDataId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); static CarlaCustomData data; - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return &data; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (customDataId < plugin->customDataCount()) - return &plugin->customData(customDataId); + if (customDataId < plugin->getCustomDataCount()) + return &plugin->getCustomData(customDataId); carla_stderr2("carla_get_custom_data(%i, %i) - customDataId out of bounds", pluginId, customDataId); return &data; @@ -1304,9 +1313,9 @@ const CarlaCustomData* carla_get_custom_data(unsigned int pluginId, uint32_t cus const char* carla_get_chunk_data(unsigned int pluginId) { carla_debug("carla_get_chunk_data(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return nullptr; static CarlaString chunkData; @@ -1314,12 +1323,12 @@ const char* carla_get_chunk_data(unsigned int pluginId) // cleanup chunkData.clear(); - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (plugin->options() & CB::PLUGIN_OPTION_USE_CHUNKS) + if (plugin->getOptions() & CB::PLUGIN_OPTION_USE_CHUNKS) { void* data = nullptr; - const int32_t dataSize = plugin->chunkData(&data); + const int32_t dataSize = plugin->getChunkData(&data); if (data != nullptr && dataSize > 0) { @@ -1345,13 +1354,13 @@ const char* carla_get_chunk_data(unsigned int pluginId) uint32_t carla_get_parameter_count(unsigned int pluginId) { carla_debug("carla_get_parameter_count(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->parameterCount(); + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) + return plugin->getParameterCount(); carla_stderr2("carla_get_parameter_count(%i) - could not find plugin", pluginId); return 0; @@ -1360,13 +1369,13 @@ uint32_t carla_get_parameter_count(unsigned int pluginId) uint32_t carla_get_program_count(unsigned int pluginId) { carla_debug("carla_get_program_count(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->programCount(); + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) + return plugin->getProgramCount(); carla_stderr2("carla_get_program_count(%i) - could not find plugin", pluginId); return 0; @@ -1375,13 +1384,13 @@ uint32_t carla_get_program_count(unsigned int pluginId) uint32_t carla_get_midi_program_count(unsigned int pluginId) { carla_debug("carla_get_midi_program_count(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->midiProgramCount(); + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) + return plugin->getMidiProgramCount(); carla_stderr2("carla_get_midi_program_count(%i) - could not find plugin", pluginId); return 0; @@ -1390,13 +1399,13 @@ uint32_t carla_get_midi_program_count(unsigned int pluginId) uint32_t carla_get_custom_data_count(unsigned int pluginId) { carla_debug("carla_get_custom_data_count(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->customDataCount(); + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) + return plugin->getCustomDataCount(); carla_stderr2("carla_get_custom_data_count(%i) - could not find plugin", pluginId); return 0; @@ -1407,17 +1416,17 @@ uint32_t carla_get_custom_data_count(unsigned int pluginId) const char* carla_get_parameter_text(unsigned int pluginId, uint32_t parameterId) { carla_debug("carla_get_parameter_text(%i, %i)", pluginId, parameterId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return nullptr; static char textBuf[STR_MAX+1]; carla_fill(textBuf, STR_MAX+1, '\0'); - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) + if (parameterId < plugin->getParameterCount()) { plugin->getParameterText(parameterId, textBuf); return textBuf; @@ -1434,17 +1443,17 @@ const char* carla_get_parameter_text(unsigned int pluginId, uint32_t parameterId const char* carla_get_program_name(unsigned int pluginId, uint32_t programId) { carla_debug("carla_get_program_name(%i, %i)", pluginId, programId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return nullptr; static char programName[STR_MAX+1]; carla_fill(programName, STR_MAX+1, '\0'); - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (programId < plugin->programCount()) + if (programId < plugin->getProgramCount()) { plugin->getProgramName(programId, programName); return programName; @@ -1461,17 +1470,17 @@ const char* carla_get_program_name(unsigned int pluginId, uint32_t programId) const char* carla_get_midi_program_name(unsigned int pluginId, uint32_t midiProgramId) { carla_debug("carla_get_midi_program_name(%i, %i)", pluginId, midiProgramId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return nullptr; static char midiProgramName[STR_MAX+1]; carla_fill(midiProgramName, STR_MAX+1, '\0'); - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (midiProgramId < plugin->midiProgramCount()) + if (midiProgramId < plugin->getMidiProgramCount()) { plugin->getMidiProgramName(midiProgramId, midiProgramName); return midiProgramName; @@ -1488,15 +1497,15 @@ const char* carla_get_midi_program_name(unsigned int pluginId, uint32_t midiProg const char* carla_get_real_plugin_name(unsigned int pluginId) { carla_debug("carla_get_real_plugin_name(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return nullptr; static char realPluginName[STR_MAX+1]; carla_fill(realPluginName, STR_MAX+1, '\0'); - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { plugin->getRealName(realPluginName); return realPluginName; @@ -1511,13 +1520,13 @@ const char* carla_get_real_plugin_name(unsigned int pluginId) int32_t carla_get_current_program_index(unsigned int pluginId) { carla_debug("carla_get_current_program_index(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return -1; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->currentProgram(); + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) + return plugin->getCurrentProgram(); carla_stderr2("carla_get_current_program_index(%i) - could not find plugin", pluginId); return -1; @@ -1526,13 +1535,13 @@ int32_t carla_get_current_program_index(unsigned int pluginId) int32_t carla_get_current_midi_program_index(unsigned int pluginId) { carla_debug("carla_get_current_midi_program_index(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return -1; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->currentMidiProgram(); + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) + return plugin->getCurrentMidiProgram(); carla_stderr2("carla_get_current_midi_program_index(%i) - could not find plugin", pluginId); return -1; @@ -1543,15 +1552,15 @@ int32_t carla_get_current_midi_program_index(unsigned int pluginId) float carla_get_default_parameter_value(unsigned int pluginId, uint32_t parameterId) { carla_debug("carla_get_default_parameter_value(%i, %i)", pluginId, parameterId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0.0f; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) - return plugin->parameterRanges(parameterId).def; + if (parameterId < plugin->getParameterCount()) + return plugin->getParameterRanges(parameterId).def; carla_stderr2("carla_get_default_parameter_value(%i, %i) - parameterId out of bounds", pluginId, parameterId); return 0.0f; @@ -1564,14 +1573,14 @@ float carla_get_default_parameter_value(unsigned int pluginId, uint32_t paramete float carla_get_current_parameter_value(unsigned int pluginId, uint32_t parameterId) { carla_debug("carla_get_current_parameter_value(%i, %i)", pluginId, parameterId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0.0f; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) + if (parameterId < plugin->getParameterCount()) return plugin->getParameterValue(parameterId); carla_stderr2("carla_get_current_parameter_value(%i, %i) - parameterId out of bounds", pluginId, parameterId); @@ -1586,24 +1595,24 @@ float carla_get_current_parameter_value(unsigned int pluginId, uint32_t paramete float carla_get_input_peak_value(unsigned int pluginId, unsigned short portId) { - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); CARLA_ASSERT(portId == 1 || portId == 2); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0.0f; - return standalone.engine->getInputPeak(pluginId, portId); + return gStandalone.engine->getInputPeak(pluginId, portId); } float carla_get_output_peak_value(unsigned int pluginId, unsigned short portId) { - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); CARLA_ASSERT(portId == 1 || portId == 2); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0.0f; - return standalone.engine->getOutputPeak(pluginId, portId); + return gStandalone.engine->getOutputPeak(pluginId, portId); } // ------------------------------------------------------------------------------------------------------------------- @@ -1611,12 +1620,12 @@ float carla_get_output_peak_value(unsigned int pluginId, unsigned short portId) void carla_set_option(unsigned int pluginId, unsigned int option, bool yesNo) { carla_debug("carla_set_option(%i, %i, %s)", pluginId, option, bool2str(yesNo)); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setOption(option, yesNo); carla_stderr2("carla_set_option(%i, %i, %s) - could not find plugin", pluginId, option, bool2str(yesNo)); @@ -1625,12 +1634,12 @@ void carla_set_option(unsigned int pluginId, unsigned int option, bool yesNo) void carla_set_active(unsigned int pluginId, bool onOff) { carla_debug("carla_set_active(%i, %s)", pluginId, bool2str(onOff)); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setActive(onOff, true, false); carla_stderr2("carla_set_active(%i, %s) - could not find plugin", pluginId, bool2str(onOff)); @@ -1640,12 +1649,12 @@ void carla_set_active(unsigned int pluginId, bool onOff) void carla_set_drywet(unsigned int pluginId, float value) { carla_debug("carla_set_drywet(%i, %f)", pluginId, value); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setDryWet(value, true, false); carla_stderr2("carla_set_drywet(%i, %f) - could not find plugin", pluginId, value); @@ -1654,12 +1663,12 @@ void carla_set_drywet(unsigned int pluginId, float value) void carla_set_volume(unsigned int pluginId, float value) { carla_debug("carla_set_volume(%i, %f)", pluginId, value); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setVolume(value, true, false); carla_stderr2("carla_set_volume(%i, %f) - could not find plugin", pluginId, value); @@ -1668,12 +1677,12 @@ void carla_set_volume(unsigned int pluginId, float value) void carla_set_balance_left(unsigned int pluginId, float value) { carla_debug("carla_set_balance_left(%i, %f)", pluginId, value); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setBalanceLeft(value, true, false); carla_stderr2("carla_set_balance_left(%i, %f) - could not find plugin", pluginId, value); @@ -1682,12 +1691,12 @@ void carla_set_balance_left(unsigned int pluginId, float value) void carla_set_balance_right(unsigned int pluginId, float value) { carla_debug("carla_set_balance_right(%i, %f)", pluginId, value); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setBalanceRight(value, true, false); carla_stderr2("carla_set_balance_right(%i, %f) - could not find plugin", pluginId, value); @@ -1696,12 +1705,12 @@ void carla_set_balance_right(unsigned int pluginId, float value) void carla_set_panning(unsigned int pluginId, float value) { carla_debug("carla_set_panning(%i, %f)", pluginId, value); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setPanning(value, true, false); carla_stderr2("carla_set_panning(%i, %f) - could not find plugin", pluginId, value); @@ -1711,12 +1720,12 @@ void carla_set_panning(unsigned int pluginId, float value) void carla_set_ctrl_channel(unsigned int pluginId, int8_t channel) { carla_debug("carla_set_ctrl_channel(%i, %i)", pluginId, channel); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setCtrlChannel(channel, true, false); carla_stderr2("carla_set_ctrl_channel(%i, %i) - could not find plugin", pluginId, channel); @@ -1727,14 +1736,14 @@ void carla_set_ctrl_channel(unsigned int pluginId, int8_t channel) void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, float value) { carla_debug("carla_set_parameter_value(%i, %i, %f)", pluginId, parameterId, value); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) + if (parameterId < plugin->getParameterCount()) return plugin->setParameterValue(parameterId, value, true, true, false); carla_stderr2("carla_set_parameter_value(%i, %i, %f) - parameterId out of bounds", pluginId, parameterId, value); @@ -1748,7 +1757,7 @@ void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, floa void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterId, uint8_t channel) { carla_debug("carla_set_parameter_midi_channel(%i, %i, %i)", pluginId, parameterId, channel); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); if (channel >= MAX_MIDI_CHANNELS) @@ -1757,12 +1766,12 @@ void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterI return; } - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) + if (parameterId < plugin->getParameterCount()) return plugin->setParameterMidiChannel(parameterId, channel, true, false); carla_stderr2("carla_set_parameter_midi_channel(%i, %i, %i) - parameterId out of bounds", pluginId, parameterId, channel); @@ -1775,7 +1784,7 @@ void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterI void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, int16_t cc) { carla_debug("carla_set_parameter_midi_cc(%i, %i, %i)", pluginId, parameterId, cc); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); CARLA_ASSERT(cc >= -1 && cc <= 0x5F); if (cc < -1) @@ -1788,12 +1797,12 @@ void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, in return; } - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (parameterId < plugin->parameterCount()) + if (parameterId < plugin->getParameterCount()) return plugin->setParameterMidiCC(parameterId, cc, true, false); carla_stderr2("carla_set_parameter_midi_cc(%i, %i, %i) - parameterId out of bounds", pluginId, parameterId, cc); @@ -1809,14 +1818,14 @@ void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, in void carla_set_program(unsigned int pluginId, uint32_t programId) { carla_debug("carla_set_program(%i, %i)", pluginId, programId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (programId < plugin->programCount()) + if (programId < plugin->getProgramCount()) return plugin->setProgram(static_cast(programId), true, true, false); carla_stderr2("carla_set_program(%i, %i) - programId out of bounds", pluginId, programId); @@ -1829,14 +1838,14 @@ void carla_set_program(unsigned int pluginId, uint32_t programId) void carla_set_midi_program(unsigned int pluginId, uint32_t midiProgramId) { carla_debug("carla_set_midi_program(%i, %i)", pluginId, midiProgramId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (midiProgramId < plugin->midiProgramCount()) + if (midiProgramId < plugin->getMidiProgramCount()) return plugin->setMidiProgram(static_cast(midiProgramId), true, true, false); carla_stderr2("carla_set_midi_program(%i, %i) - midiProgramId out of bounds", pluginId, midiProgramId); @@ -1851,12 +1860,12 @@ void carla_set_midi_program(unsigned int pluginId, uint32_t midiProgramId) void carla_set_custom_data(unsigned int pluginId, const char* type, const char* key, const char* value) { carla_debug("carla_set_custom_data(%i, \"%s\", \"%s\", \"%s\")", pluginId, type, key, value); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->setCustomData(type, key, value, true); carla_stderr2("carla_set_custom_data(%i, \"%s\", \"%s\", \"%s\") - could not find plugin", pluginId, type, key, value); @@ -1865,14 +1874,14 @@ void carla_set_custom_data(unsigned int pluginId, const char* type, const char* void carla_set_chunk_data(unsigned int pluginId, const char* chunkData) { carla_debug("carla_set_chunk_data(%i, \"%s\")", pluginId, chunkData); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) { - if (plugin->options() & CB::PLUGIN_OPTION_USE_CHUNKS) + if (plugin->getOptions() & CB::PLUGIN_OPTION_USE_CHUNKS) return plugin->setChunkData(chunkData); carla_stderr2("carla_set_chunk_data(%i, \"%s\") - plugin does not support chunks", pluginId, chunkData); @@ -1887,12 +1896,12 @@ void carla_set_chunk_data(unsigned int pluginId, const char* chunkData) void carla_prepare_for_save(unsigned int pluginId) { carla_debug("carla_prepare_for_save(%i)", pluginId); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->prepareForSave(); carla_stderr2("carla_prepare_for_save(%i) - could not find plugin", pluginId); @@ -1902,12 +1911,12 @@ void carla_prepare_for_save(unsigned int pluginId) void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity) { carla_debug("carla_send_midi_note(%i, %i, %i, %i)", pluginId, channel, note, velocity); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr || ! standalone.engine->isRunning()) + if (gStandalone.engine == nullptr || ! gStandalone.engine->isRunning()) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->sendMidiSingleNote(channel, note, velocity, true, true, false); carla_stderr2("carla_send_midi_note(%i, %i, %i, %i) - could not find plugin", pluginId, channel, note, velocity); @@ -1917,12 +1926,12 @@ void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, void carla_show_gui(unsigned int pluginId, bool yesno) { carla_debug("carla_show_gui(%i, %s)", pluginId, bool2str(yesno)); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) return plugin->showGui(yesno); carla_stderr2("carla_show_gui(%i, %s) - could not find plugin", pluginId, bool2str(yesno)); @@ -1933,23 +1942,23 @@ void carla_show_gui(unsigned int pluginId, bool yesno) uint32_t carla_get_buffer_size() { carla_debug("carla_get_buffer_size()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0; - return standalone.engine->getBufferSize(); + return gStandalone.engine->getBufferSize(); } double carla_get_sample_rate() { carla_debug("carla_get_sample_rate()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) return 0.0; - return standalone.engine->getSampleRate(); + return gStandalone.engine->getSampleRate(); } // ------------------------------------------------------------------------------------------------------------------- @@ -1958,38 +1967,38 @@ const char* carla_get_last_error() { carla_debug("carla_get_last_error()"); - if (standalone.engine != nullptr) - return standalone.engine->getLastError(); + if (gStandalone.engine != nullptr) + return gStandalone.engine->getLastError(); - return standalone.lastError; + return gStandalone.lastError; } const char* carla_get_host_osc_url_tcp() { carla_debug("carla_get_host_osc_url_tcp()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) { - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return nullptr; } - return standalone.engine->getOscServerPathTCP(); + return gStandalone.engine->getOscServerPathTCP(); } const char* carla_get_host_osc_url_udp() { carla_debug("carla_get_host_osc_url_udp()"); - CARLA_ASSERT(standalone.engine != nullptr); + CARLA_ASSERT(gStandalone.engine != nullptr); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) { - standalone.lastError = "Engine is not started"; + gStandalone.lastError = "Engine is not started"; return nullptr; } - return standalone.engine->getOscServerPathUDP(); + return gStandalone.engine->getOscServerPathUDP(); } // ------------------------------------------------------------------------------------------------------------------- @@ -2090,8 +2099,8 @@ protected: for (int i=0; i < 60 && ! fIsReady; ++i) carla_msleep(100); - if (std::strcmp(method, "/nsm/server/announce") == 0 && standalone.callback != nullptr) - standalone.callback(standalone.callbackPtr, CB::CALLBACK_NSM_ANNOUNCE, 0, 0, 0, 0.0f, smName); + if (std::strcmp(method, "/nsm/server/announce") == 0 && gStandalone.callback != nullptr) + gStandalone.callback(gStandalone.callbackPtr, CB::CALLBACK_NSM_ANNOUNCE, 0, 0, 0, 0.0f, smName); return 0; @@ -2107,7 +2116,7 @@ protected: { carla_debug("CarlaNSM::handleOpen(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg); - if (standalone.callback == nullptr) + if (gStandalone.callback == nullptr) return 1; if (fServerThread == nullptr) return 1; @@ -2124,7 +2133,7 @@ protected: fIsOpened = false; - standalone.callback(nullptr, CB::CALLBACK_NSM_OPEN, 0, 0, 0, 0.0f, data); + gStandalone.callback(nullptr, CB::CALLBACK_NSM_OPEN, 0, 0, 0, 0.0f, data); // wait max 10 secs to open for (int i=0; i < 100 && ! fIsOpened; ++i) @@ -2150,7 +2159,7 @@ protected: { carla_debug("CarlaNSM::handleSave(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg); - if (standalone.callback == nullptr) + if (gStandalone.callback == nullptr) return 1; if (fServerThread == nullptr) return 1; @@ -2159,7 +2168,7 @@ protected: fIsSaved = false; - standalone.callback(nullptr, CB::CALLBACK_NSM_SAVE, 0, 0, 0, 0.0f, nullptr); + gStandalone.callback(nullptr, CB::CALLBACK_NSM_SAVE, 0, 0, 0, 0.0f, nullptr); // wait max 10 secs to save for (int i=0; i < 100 && ! fIsSaved; ++i) @@ -2242,53 +2251,53 @@ void carla_nsm_reply_save() #ifdef BUILD_BRIDGE CarlaEngine* carla_get_standalone_engine() { - return standalone.engine; + return gStandalone.engine; } bool carla_engine_init_bridge(const char* audioBaseName, const char* controlBaseName, const char* clientName) { carla_debug("carla_engine_init_bridge(\"%s\", \"%s\", \"%s\")", audioBaseName, controlBaseName, clientName); - CARLA_ASSERT(standalone.engine == nullptr); + CARLA_ASSERT(gStandalone.engine == nullptr); CARLA_ASSERT(audioBaseName != nullptr); CARLA_ASSERT(controlBaseName != nullptr); CARLA_ASSERT(clientName != nullptr); - standalone.engine = CarlaEngine::newBridge(audioBaseName, controlBaseName); + gStandalone.engine = CarlaEngine::newBridge(audioBaseName, controlBaseName); - if (standalone.engine == nullptr) + if (gStandalone.engine == nullptr) { - standalone.lastError = "The seleted audio driver is not available!"; + gStandalone.lastError = "The seleted audio driver is not available!"; return false; } - if (standalone.callback != nullptr) - standalone.engine->setCallback(standalone.callback, nullptr); + if (gStandalone.callback != nullptr) + gStandalone.engine->setCallback(gStandalone.callback, nullptr); - standalone.engine->setOption(CB::OPTION_PROCESS_MODE, CB::PROCESS_MODE_BRIDGE, nullptr); - standalone.engine->setOption(CB::OPTION_TRANSPORT_MODE, CB::TRANSPORT_MODE_BRIDGE, nullptr); - standalone.engine->setOption(CB::OPTION_PREFER_PLUGIN_BRIDGES, false, nullptr); - standalone.engine->setOption(CB::OPTION_PREFER_UI_BRIDGES, false, nullptr); + gStandalone.engine->setOption(CB::OPTION_PROCESS_MODE, CB::PROCESS_MODE_BRIDGE, nullptr); + gStandalone.engine->setOption(CB::OPTION_TRANSPORT_MODE, CB::TRANSPORT_MODE_BRIDGE, nullptr); + gStandalone.engine->setOption(CB::OPTION_PREFER_PLUGIN_BRIDGES, false, nullptr); + gStandalone.engine->setOption(CB::OPTION_PREFER_UI_BRIDGES, false, nullptr); // TODO - read from environment #if 0 - standalone.engine->setOption(CB::OPTION_FORCE_STEREO, standalone.options.forceStereo ? 1 : 0, nullptr); + gStandalone.engine->setOption(CB::OPTION_FORCE_STEREO, gStandalone.options.forceStereo ? 1 : 0, nullptr); # ifdef WANT_DSSI - standalone.engine->setOption(CB::OPTION_USE_DSSI_VST_CHUNKS, standalone.options.useDssiVstChunks ? 1 : 0, nullptr); + gStandalone.engine->setOption(CB::OPTION_USE_DSSI_VST_CHUNKS, gStandalone.options.useDssiVstChunks ? 1 : 0, nullptr); # endif - standalone.engine->setOption(CB::OPTION_MAX_PARAMETERS, static_cast(standalone.options.maxParameters), nullptr); + gStandalone.engine->setOption(CB::OPTION_MAX_PARAMETERS, static_cast(gStandalone.options.maxParameters), nullptr); #endif - if (standalone.engine->init(clientName)) + if (gStandalone.engine->init(clientName)) { - standalone.lastError = "no error"; - standalone.init(); + gStandalone.lastError = "no error"; + gStandalone.init(); return true; } else { - standalone.lastError = standalone.engine->getLastError(); - delete standalone.engine; - standalone.engine = nullptr; + gStandalone.lastError = gStandalone.engine->getLastError(); + delete gStandalone.engine; + gStandalone.engine = nullptr; return false; } } diff --git a/source/carla.py b/source/carla.py index fe3aebd02..448f23f6a 100755 --- a/source/carla.py +++ b/source/carla.py @@ -2353,7 +2353,6 @@ if __name__ == '__main__': # Init backend Carla.host = Host(libName) - Carla.host.set_engine_callback(engineCallback) if NSM_URL: Carla.host.nsm_announce(NSM_URL, appName, os.getpid()) @@ -2414,6 +2413,9 @@ if __name__ == '__main__': # Create GUI and start engine Carla.gui = CarlaMainW() + # Only now we're ready to handle events + Carla.host.set_engine_callback(engineCallback) + # Set-up custom signal handling setUpSignals() @@ -2427,5 +2429,10 @@ if __name__ == '__main__': # App-Loop ret = app.exec_() + # Destroy GUI + tmp = Carla.gui + Carla.gui = None + del tmp + # Exit properly sys.exit(ret) diff --git a/source/carla_backend.py b/source/carla_backend.py index 55b957c91..2a3f16c00 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -389,7 +389,7 @@ class CarlaScalePointInfo(Structure): class CarlaTransportInfo(Structure): _fields_ = [ ("playing", c_bool), - ("frame", c_uint32), + ("frame", c_uint64), ("bar", c_int32), ("beat", c_int32), ("tick", c_int32), @@ -475,7 +475,7 @@ class Host(object): self.lib.carla_transport_relocate.restype = None self.lib.carla_get_current_transport_frame.argtypes = None - self.lib.carla_get_current_transport_frame.restype = c_uint32 + self.lib.carla_get_current_transport_frame.restype = c_uint64 self.lib.carla_get_transport_info.argtypes = None self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo) diff --git a/source/modules/utils/CarlaLogThread.hpp b/source/modules/utils/CarlaLogThread.hpp index e168aca36..77907a9f1 100644 --- a/source/modules/utils/CarlaLogThread.hpp +++ b/source/modules/utils/CarlaLogThread.hpp @@ -19,21 +19,22 @@ #define CARLA_LOG_THREAD_HPP_INCLUDED #include "CarlaBackend.hpp" -#include "CarlaJuceUtils.hpp" +#include "CarlaString.hpp" #include #include -CARLA_BACKEND_START_NAMESPACE +using CarlaBackend::CallbackFunc; // ----------------------------------------------------------------------- // Log thread -class LogThread : public QThread +class CarlaLogThread : public QThread { public: - LogThread() - : fStop(false), + CarlaLogThread() + : QThread(nullptr), + fStop(false), fCallback(nullptr), fCallbackPtr(nullptr) { @@ -48,10 +49,17 @@ public: dup2(fPipe[1], STDERR_FILENO); fcntl(fPipe[0], F_SETFL, O_NONBLOCK); + + QThread::start(LowPriority); } - ~LogThread() + ~CarlaLogThread() { + fCallback = nullptr; + fCallbackPtr = nullptr; + + stop(); + fflush(stdout); fflush(stderr); @@ -59,14 +67,12 @@ public: close(fPipe[1]); } - void ready(CallbackFunc callback, void* callbackPtr) + void setCallback(CallbackFunc callback, void* callbackPtr) { CARLA_ASSERT(callback != nullptr); fCallback = callback; fCallbackPtr = callbackPtr; - - start(); } void stop() @@ -80,23 +86,23 @@ public: protected: void run() { - if (fCallback == nullptr) - return; - while (! fStop) { - int i, r, lastRead; + size_t r, lastRead; + ssize_t r2; // to avoid sign/unsign conversions static char bufTemp[1024+1] = { '\0' }; static char bufRead[1024+1]; static char bufSend[2048+1]; - while ((r = read(fPipe[0], bufRead, sizeof(char)*1024)) > 0) + while ((r2 = read(fPipe[0], bufRead, sizeof(char)*1024)) > 0) { + r = static_cast(r2); + bufRead[r] = '\0'; lastRead = 0; - for (i=0; i < r; ++i) + for (size_t i=0; i < r; ++i) { CARLA_ASSERT(bufRead[i] != '\0'); @@ -109,14 +115,24 @@ protected: lastRead = i; bufTemp[0] = '\0'; - fCallback(fCallbackPtr, CarlaBackend::CALLBACK_DEBUG, 0, 0, 0, 0.0f, bufSend); + if (fCallback != nullptr) + { + if (fOldBuffer.isNotEmpty()) + { + fCallback(fCallbackPtr, CarlaBackend::CALLBACK_DEBUG, 0, 0, 0, 0.0f, (const char*)fOldBuffer); + fOldBuffer = nullptr; + } + + fCallback(fCallbackPtr, CarlaBackend::CALLBACK_DEBUG, 0, 0, 0, 0.0f, bufSend); + } + else + fOldBuffer += bufSend; } } - CARLA_ASSERT(i == r); CARLA_ASSERT(lastRead < r); - if (lastRead > 0 && lastRead < r-1) + if (lastRead > 0 && r > 0 && lastRead+1 < r) { std::strncpy(bufTemp, bufRead+lastRead, r-lastRead); bufTemp[r-lastRead] = '\0'; @@ -133,13 +149,12 @@ private: CallbackFunc fCallback; void* fCallbackPtr; + CarlaString fOldBuffer; CARLA_PREVENT_HEAP_ALLOCATION - CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LogThread) + CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaLogThread) }; // ----------------------------------------------------------------------- -CARLA_BACKEND_END_NAMESPACE - #endif // CARLA_LOG_THREAD_HPP_INCLUDED diff --git a/source/tests/ANSI.cpp b/source/tests/ANSI.cpp index 30cf24d28..1727eee82 100644 --- a/source/tests/ANSI.cpp +++ b/source/tests/ANSI.cpp @@ -21,6 +21,9 @@ #define RING_BUFFER_SIZE 48 +#define ANSI_TEST_N 2 + +#if ANSI_TEST_N == 1 // includes #include "CarlaDefines.hpp" #include "CarlaMIDI.h" @@ -68,13 +71,21 @@ // Carla Standalone API #include "CarlaStandalone.hpp" +// ANSI_TEST_N == 1 +#endif + +#if ANSI_TEST_N == 2 +// Carla Standalone +#include "CarlaStandalone.hpp" +#include "standalone/CarlaStandalone.cpp" +#endif -// // Carla Plugin // #include "plugin/CarlaPluginThread.hpp" // #include "plugin/CarlaPluginInternal.hpp" // #include "standalone/CarlaStandalone.cpp" +#if ANSI_TEST_N == 1 // ----------------------------------------------------------------------- namespace CB = CarlaBackend; @@ -84,11 +95,13 @@ int safe_assert_return_test(bool test) CARLA_SAFE_ASSERT_RETURN(test, 1); return 0; } +#endif // ----------------------------------------------------------------------- int main() { +#if ANSI_TEST_N == 1 // ladspa rdf { LADSPA_RDF_ScalePoint a; @@ -577,6 +590,8 @@ int main() obj = ListTester::getCounter(); assert(obj.count == 2); // List fRetValue + t1 } +// ANSI_TEST_N == 1 +#endif return 0; }