diff --git a/source/backend/carla_engine.hpp b/source/backend/carla_engine.hpp index 61c6308bd..007e1a699 100644 --- a/source/backend/carla_engine.hpp +++ b/source/backend/carla_engine.hpp @@ -256,9 +256,9 @@ struct EngineOptions { forceStereo(false), preferPluginBridges(false), preferUiBridges(true), - #ifdef WANT_DSSI +#ifdef WANT_DSSI useDssiVstChunks(false), - #endif +#endif maxParameters(MAX_DEFAULT_PARAMETERS), oscUiTimeout(4000), preferredBufferSize(512), @@ -704,6 +704,21 @@ public: // m_carlaPlugins[id] = plugin; //} + // ------------------------------------------------------------------- + // Project management + + /*! + * Load \a filename session. + * \note Already loaded plugins are not removed, but added afterwards.\n + * Call removeAllPlugins() first if needed. + */ + void loadProject(const char* const filename); + + /*! + * Save current session to \a filename. + */ + void saveProject(const char* const filename); + // ------------------------------------------------------------------- // Information (base) diff --git a/source/backend/carla_plugin.hpp b/source/backend/carla_plugin.hpp index 10f5a468c..37d21960e 100644 --- a/source/backend/carla_plugin.hpp +++ b/source/backend/carla_plugin.hpp @@ -22,6 +22,9 @@ #include "carla_native.h" #include "carla_utils.hpp" +// FIXME +#include "carla_state_utils.hpp" + // Avoid including extra libs here struct LADSPA_RDF_Descriptor; typedef void* lo_address; @@ -372,6 +375,21 @@ public: */ void getParameterCountInfo(uint32_t* const ins, uint32_t* const outs, uint32_t* const total); + /*! + * Get the plugin's save state.\n + * The plugin will automatically call prepareForSave() as needed. + * + * \see loadSaveState() + */ + virtual const SaveState& getSaveState(); + + /*! + * Get the plugin's save state. + * + * \see getSaveState() + */ + virtual void loadSaveState(const SaveState& saveState); + // ------------------------------------------------------------------- // Set data (internal stuff) diff --git a/source/backend/engine/carla_engine.cpp b/source/backend/engine/carla_engine.cpp index 71d11eebe..34a31780f 100644 --- a/source/backend/engine/carla_engine.cpp +++ b/source/backend/engine/carla_engine.cpp @@ -19,6 +19,9 @@ #include "carla_backend_utils.hpp" #include "carla_midi.h" +#include +#include + CARLA_BACKEND_START_NAMESPACE // ------------------------------------------------------------------------------------------------------------------- @@ -914,7 +917,7 @@ void CarlaEngine::removeAllPlugins() fData->curPluginCount = 0; fData->maxPluginNumber = 0; - for (unsigned short i=0; i < oldCount; i++) + for (unsigned int i=0; i < oldCount; i++) { CarlaPlugin* const plugin = fData->plugins[i].plugin; @@ -945,6 +948,49 @@ void CarlaEngine::__bridgePluginRegister(const unsigned short id, CarlaPlugin* c // ----------------------------------------------------------------------- // Information (base) +void CarlaEngine::loadProject(const char* const filename) +{ + CARLA_ASSERT(filename != nullptr); + + //QFile file(filename); + + //if (! file.open(QIODevice::WriteOnly | QIODevice::Text)) + // return; + + //getSaveStateDictFromXML +} + +void CarlaEngine::saveProject(const char* const filename) +{ + CARLA_ASSERT(filename != nullptr); + + QFile file(filename); + file.open(QIODevice::WriteOnly | QIODevice::Text); + + QTextStream out(&file); + out << "\n"; + out << "\n"; + out << "\n"; + + for (unsigned int i=0; i < fData->curPluginCount; i++) + { + CarlaPlugin* const plugin = fData->plugins[i].plugin; + + if (plugin != nullptr && plugin->enabled()) + { + const SaveState& saveState = plugin->getSaveState(); + // TODO + } + } + + out << "\n"; + + file.close(); +} + +// ----------------------------------------------------------------------- +// Information (base) + float CarlaEngine::getInputPeak(const unsigned int pluginId, const unsigned short id) const { CARLA_ASSERT(pluginId < fData->curPluginCount); @@ -1202,7 +1248,7 @@ void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize) for (unsigned int i=0; i < fData->curPluginCount; i++) { - CarlaPlugin* const plugin = getPluginUnchecked(i); + CarlaPlugin* const plugin = fData->plugins[i].plugin; if (plugin != nullptr && plugin->enabled()) plugin->bufferSizeChanged(newBufferSize); @@ -1215,7 +1261,7 @@ void CarlaEngine::sampleRateChanged(const double newSampleRate) for (unsigned int i=0; i < fData->curPluginCount; i++) { - CarlaPlugin* const plugin = getPluginUnchecked(i); + CarlaPlugin* const plugin = fData->plugins[i].plugin; if (plugin != nullptr && plugin->enabled()) plugin->sampleRateChanged(newSampleRate); diff --git a/source/backend/plugin/carla_plugin.cpp b/source/backend/plugin/carla_plugin.cpp index 09a639142..1a2b7148b 100644 --- a/source/backend/plugin/carla_plugin.cpp +++ b/source/backend/plugin/carla_plugin.cpp @@ -369,6 +369,20 @@ void CarlaPlugin::getParameterCountInfo(uint32_t* const ins, uint32_t* const out } } +const SaveState& CarlaPlugin::getSaveState() +{ + static SaveState saveState; + + // TODO + return saveState; +} + +void CarlaPlugin::loadSaveState(const SaveState& saveState) +{ + // TODO + Q_UNUSED(saveState); +} + // ------------------------------------------------------------------- // Set data (internal stuff) diff --git a/source/backend/standalone/carla_standalone.cpp b/source/backend/standalone/carla_standalone.cpp index 4e59562b2..12d4cd367 100644 --- a/source/backend/standalone/carla_standalone.cpp +++ b/source/backend/standalone/carla_standalone.cpp @@ -282,7 +282,7 @@ void carla_engine_idle() { CARLA_ASSERT(standalone.engine != nullptr); - if (standalone.engine) + if (standalone.engine != nullptr) standalone.engine->idle(); } @@ -290,7 +290,7 @@ bool carla_is_engine_running() { qDebug("carla_is_engine_running()"); - return standalone.engine != nullptr && standalone.engine->isRunning(); + return (standalone.engine != nullptr && standalone.engine->isRunning()); } // ------------------------------------------------------------------------------------------------------------------- @@ -299,12 +299,18 @@ bool carla_load_project(const char* filename) { CARLA_ASSERT(standalone.engine != nullptr); CARLA_ASSERT(filename != nullptr); + + if (standalone.engine != nullptr) + standalone.engine->loadProject(filename); } bool carla_save_project(const char* filename) { CARLA_ASSERT(standalone.engine != nullptr); CARLA_ASSERT(filename != nullptr); + + if (standalone.engine != nullptr) + standalone.engine->saveProject(filename); } // ------------------------------------------------------------------------------------------------------------------- @@ -333,7 +339,7 @@ bool carla_remove_plugin(unsigned int pluginId) return false; } -CARLA_EXPORT void carla_remove_all_plugins() +void carla_remove_all_plugins() { qDebug("carla_remove_all_plugins()"); CARLA_ASSERT(standalone.engine != nullptr); diff --git a/source/bridges/qtcreator/carla-bridge-plugin.pro b/source/bridges/qtcreator/carla-bridge-plugin.pro index 4d72c2ecd..004b2c654 100644 --- a/source/bridges/qtcreator/carla-bridge-plugin.pro +++ b/source/bridges/qtcreator/carla-bridge-plugin.pro @@ -1,10 +1,6 @@ -# QtCreator project file +# QtCreator project file -contains(QT_VERSION, ^5.*) { -QT = core widgets xml -} else { QT = core gui xml -} CONFIG = debug link_pkgconfig qt warn_on PKGCONFIG = jack liblo @@ -13,29 +9,36 @@ TARGET = carla-bridge-qtcreator TEMPLATE = app VERSION = 0.5.0 -SOURCES = \ +# ----------------------------------------------------------- + +SOURCES = \ ../carla_bridge_client.cpp \ ../carla_bridge_osc.cpp \ ../carla_bridge_toolkit.cpp \ ../carla_bridge_plugin.cpp -HEADERS = \ +HEADERS = \ ../carla_bridge.hpp \ ../carla_bridge_client.hpp \ ../carla_bridge_osc.hpp \ - ../carla_bridge_toolkit.hpp \ + ../carla_bridge_toolkit.hpp + +# ----------------------------------------------------------- # carla-engine SOURCES += \ ../../backend/engine/carla_engine.cpp \ ../../backend/engine/carla_engine_osc.cpp \ ../../backend/engine/carla_engine_thread.cpp \ - ../../backend/engine/jack.cpp + ../../backend/engine/jack.cpp \ + ../../backend/engine/plugin.cpp \ + ../../backend/engine/rtaudio.cpp # carla-plugin SOURCES += \ ../../backend/plugin/carla_plugin.cpp \ ../../backend/plugin/carla_plugin_thread.cpp \ + ../../backend/plugin/native.cpp \ ../../backend/plugin/ladspa.cpp \ ../../backend/plugin/dssi.cpp \ ../../backend/plugin/lv2.cpp \ @@ -43,9 +46,11 @@ SOURCES += \ ../../backend/plugin/fluidsynth.cpp \ ../../backend/plugin/linuxsampler.cpp -# carla-utils +# carla-standalone SOURCES += \ - ../../backend/utils/Shared.cpp + ../../backend/standalone/carla_standalone.cpp + +# ----------------------------------------------------------- # common HEADERS += \ @@ -56,18 +61,18 @@ HEADERS += \ ../../backend/carla_plugin.hpp \ ../../backend/carla_standalone.hpp +# engine HEADERS += \ ../../backend/engine/carla_engine_internal.hpp \ ../../backend/engine/carla_engine_osc.hpp \ ../../backend/engine/carla_engine_thread.hpp \ + ../../backend/engine/plugin/DistrhoPluginInfo.h +# plugin HEADERS += \ ../../backend/plugin/carla_plugin_internal.hpp \ ../../backend/plugin/carla_plugin_thread.hpp -HEADERS += \ - ../../backend/utils/Shared.hpp - # includes HEADERS += \ ../../includes/carla_defines.hpp \ @@ -77,13 +82,15 @@ HEADERS += \ # utils HEADERS += \ - ../../utils/carla_backend_utils.hpp\ + ../../utils/carla_backend_utils.hpp \ ../../utils/carla_juce_utils.hpp \ ../../utils/carla_ladspa_utils.hpp \ ../../utils/carla_lib_utils.hpp \ ../../utils/carla_lv2_utils.hpp \ ../../utils/carla_osc_utils.hpp \ + ../../utils/carla_state_utils.hpp \ ../../utils/carla_vst_utils.hpp \ + ../../utils/carla_utils.hpp \ ../../utils/lv2_atom_queue.hpp \ ../../utils/rt_list.hpp @@ -96,6 +103,8 @@ INCLUDEPATH = .. \ ../../libs \ ../../utils +# ----------------------------------------------------------- + DEFINES = QTCREATOR_TEST DEFINES += DEBUG #DEFINES += VESTIGE_HEADER diff --git a/source/carla.py b/source/carla.py index 764641bfb..eda45a01a 100755 --- a/source/carla.py +++ b/source/carla.py @@ -747,6 +747,8 @@ class CarlaMainW(QMainWindow): self.fPluginCount = 0 + Carla.host.remove_all_plugins() + @pyqtSlot() def slot_fileNew(self): self.removeAllPlugins() diff --git a/source/discovery/carla-discovery.pro b/source/discovery/carla-discovery.pro index 50e2eb040..d045a83f7 100644 --- a/source/discovery/carla-discovery.pro +++ b/source/discovery/carla-discovery.pro @@ -1,17 +1,13 @@ -# QtCreator project file +# QtCreator project file QT = core -win { -CONFIG = release -} else { -CONFIG = debug -} -CONFIG += link_pkgconfig qt warn_on +CONFIG = debug link_pkgconfig qt warn_on DEFINES = DEBUG DEFINES += WANT_LADSPA WANT_DSSI WANT_LV2 WANT_VST DEFINES += WANT_FLUIDSYNTH WANT_LINUXSAMPLER + PKGCONFIG = fluidsynth linuxsampler TARGET = carla-discovery-qtcreator