From 8e219a0bb3db890ea65add5a7c95c214185ea8f5 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 1 Feb 2013 07:57:08 +0000 Subject: [PATCH] More work, move db and refresh code to shared --- source/backend/carla_engine.hpp | 18 +- source/backend/carla_standalone.hpp | 7 +- source/backend/engine/carla_engine.cpp | 27 +- .../backend/standalone/carla_standalone.cpp | 420 ++-- source/carla.py | 1023 ---------- source/carla_backend.py | 864 ++------ source/carla_shared.py | 1740 ++++++++++++++++- 7 files changed, 2044 insertions(+), 2055 deletions(-) diff --git a/source/backend/carla_engine.hpp b/source/backend/carla_engine.hpp index d4d2bbee2..25ea2fc64 100644 --- a/source/backend/carla_engine.hpp +++ b/source/backend/carla_engine.hpp @@ -627,6 +627,11 @@ public: */ virtual bool close(); + /*! + * Idle. + */ + virtual void idle(); + /*! * Check if engine is running. */ @@ -651,14 +656,6 @@ public: // ------------------------------------------------------------------- // Plugin management -#if 0 - /*! - * Get next available plugin id.\n - * Returns -1 if no more plugins can be loaded. - */ - int getNewPluginId() const; -#endif - /*! * Get plugin with id \a id. */ @@ -700,11 +697,6 @@ public: */ void removeAllPlugins(); - /*! - * Idle all plugins GUIs. - */ - void idlePluginGuis(); - // bridge, internal use only // TODO - find a better way for this //void __bridgePluginRegister(const unsigned short id, CarlaPlugin* const plugin); diff --git a/source/backend/carla_standalone.hpp b/source/backend/carla_standalone.hpp index cdcce9d10..086581aa9 100644 --- a/source/backend/carla_standalone.hpp +++ b/source/backend/carla_standalone.hpp @@ -151,6 +151,7 @@ CARLA_EXPORT const CarlaNativePluginInfo* carla_get_internal_plugin_info(unsigne CARLA_EXPORT bool carla_engine_init(const char* driverName, const char* clientName); CARLA_EXPORT bool carla_engine_close(); +CARLA_EXPORT void carla_engine_idle(); CARLA_EXPORT bool carla_is_engine_running(); CARLA_EXPORT bool carla_add_plugin(CarlaBinaryType btype, CarlaPluginType ptype, const char* filename, const char* name, const char* label, void* extraPtr); @@ -204,11 +205,9 @@ CARLA_EXPORT void carla_set_midi_program(unsigned int pluginId, uint32_t midiPro CARLA_EXPORT void carla_set_custom_data(unsigned int pluginId, const char* type, const char* key, const char* value); CARLA_EXPORT void carla_set_chunk_data(unsigned int pluginId, const char* chunkData); -CARLA_EXPORT void carla_show_gui(unsigned int pluginId, bool yesNo); -CARLA_EXPORT void carla_idle_guis(); - -CARLA_EXPORT void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity); CARLA_EXPORT void carla_prepare_for_save(unsigned int pluginId); +CARLA_EXPORT void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity); +CARLA_EXPORT void carla_show_gui(unsigned int pluginId, bool yesNo); CARLA_EXPORT uint32_t carla_get_buffer_size(); CARLA_EXPORT double carla_get_sample_rate(); diff --git a/source/backend/engine/carla_engine.cpp b/source/backend/engine/carla_engine.cpp index e21a540ca..0d4562823 100644 --- a/source/backend/engine/carla_engine.cpp +++ b/source/backend/engine/carla_engine.cpp @@ -584,6 +584,20 @@ bool CarlaEngine::close() return true; } +void CarlaEngine::idle() +{ + CARLA_ASSERT(fData->plugins != nullptr); + CARLA_ASSERT(isRunning()); + + for (unsigned int i=0; i < fData->curPluginCount; i++) + { + CarlaPlugin* const plugin = fData->plugins[i].plugin; + + if (plugin && plugin->enabled()) + plugin->idleGui(); + } +} + // ----------------------------------------------------------------------- // Plugin management @@ -929,19 +943,6 @@ void CarlaEngine::removeAllPlugins() } #if 0 -void CarlaEngine::idlePluginGuis() -{ - CARLA_ASSERT(data->maxPluginNumber > 0); - - for (unsigned short i=0; i < data->maxPluginNumber; i++) - { - CarlaPlugin* const plugin = data->carlaPlugins[i]; - - if (plugin && plugin->enabled()) - plugin->idleGui(); - } -} - void CarlaEngine::__bridgePluginRegister(const unsigned short id, CarlaPlugin* const plugin) { data->carlaPlugins[id] = plugin; diff --git a/source/backend/standalone/carla_standalone.cpp b/source/backend/standalone/carla_standalone.cpp index 7d17fdb05..4ffdb1f26 100644 --- a/source/backend/standalone/carla_standalone.cpp +++ b/source/backend/standalone/carla_standalone.cpp @@ -16,9 +16,11 @@ */ #include "carla_standalone.hpp" + #include "carla_backend_utils.hpp" #include "carla_engine.hpp" #include "carla_plugin.hpp" +#include "carla_midi.h" #include "carla_native.h" #include @@ -270,6 +272,14 @@ bool carla_engine_close() return closed; } +void carla_engine_idle() +{ + CARLA_ASSERT(standalone.engine != nullptr); + + if (standalone.engine) + standalone.engine->idle(); +} + bool carla_is_engine_running() { qDebug("carla_is_engine_running()"); @@ -656,14 +666,14 @@ const char* carla_get_chunk_data(unsigned int pluginId) qDebug("carla_get_chunk_data(%i)", pluginId); CARLA_ASSERT(standalone.engine != nullptr); + if (standalone.engine == nullptr) + return nullptr; + static CarlaString chunkData; // cleanup chunkData.clear(); - if (standalone.engine == nullptr) - return nullptr; - if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { if (plugin->hints() & CarlaBackend::PLUGIN_USES_CHUNKS) @@ -751,113 +761,88 @@ uint32_t carla_get_custom_data_count(unsigned int pluginId) return 0; } -#if 0 // ------------------------------------------------------------------------------------------------------------------- -const char* carla_get_parameter_text(unsigned int pluginId, uint32_t parameter_id) +const char* carla_get_parameter_text(unsigned int pluginId, uint32_t parameterId) { - qDebug("carla_get_parameter_text(%i, %i)", pluginId, parameter_id); + qDebug("carla_get_parameter_text(%i, %i)", pluginId, parameterId); CARLA_ASSERT(standalone.engine != nullptr); - static char textBuf[STR_MAX]; - memset(textBuf, 0, sizeof(char)*STR_MAX); - if (standalone.engine == nullptr) return nullptr; + static char textBuf[STR_MAX]; + carla_zeroMem(textBuf, sizeof(char)*STR_MAX); + if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (parameter_id < plugin->parameterCount()) + if (parameterId < plugin->parameterCount()) { - plugin->getParameterText(parameter_id, textBuf); + plugin->getParameterText(parameterId, textBuf); return textBuf; } - qCritical("carla_get_parameter_text(%i, %i) - parameter_id out of bounds", pluginId, parameter_id); + qCritical("carla_get_parameter_text(%i, %i) - parameterId out of bounds", pluginId, parameterId); return nullptr; } - qCritical("carla_get_parameter_text(%i, %i) - could not find plugin", pluginId, parameter_id); + qCritical("carla_get_parameter_text(%i, %i) - could not find plugin", pluginId, parameterId); return nullptr; } -const char* carla_get_program_name(unsigned int pluginId, uint32_t program_id) +const char* carla_get_program_name(unsigned int pluginId, uint32_t programId) { - qDebug("carla_get_program_name(%i, %i)", pluginId, program_id); + qDebug("carla_get_program_name(%i, %i)", pluginId, programId); CARLA_ASSERT(standalone.engine != nullptr); - static const char* program_name = nullptr; - - // cleanup - if (program_name) - { - free((void*)program_name); - program_name = nullptr; - } - if (standalone.engine == nullptr) return nullptr; - if (! standalone.started) - return nullptr; + static char programName[STR_MAX]; + carla_zeroMem(programName, sizeof(char)*STR_MAX); if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (program_id < plugin->programCount()) + if (programId < plugin->programCount()) { - char strBuf[STR_MAX] = { 0 }; - - plugin->getProgramName(program_id, strBuf); - program_name = strdup(strBuf); + plugin->getProgramName(programId, programName); - return program_name; + return programName; } - qCritical("carla_get_program_name(%i, %i) - program_id out of bounds", pluginId, program_id); + qCritical("carla_get_program_name(%i, %i) - programId out of bounds", pluginId, programId); return nullptr; } - qCritical("carla_get_program_name(%i, %i) - could not find plugin", pluginId, program_id); + qCritical("carla_get_program_name(%i, %i) - could not find plugin", pluginId, programId); return nullptr; } -const char* carla_get_midi_program_name(unsigned int pluginId, uint32_t midi_program_id) +const char* carla_get_midi_program_name(unsigned int pluginId, uint32_t midiProgramId) { - qDebug("carla_get_midi_program_name(%i, %i)", pluginId, midi_program_id); + qDebug("carla_get_midi_program_name(%i, %i)", pluginId, midiProgramId); CARLA_ASSERT(standalone.engine != nullptr); - static const char* midi_program_name = nullptr; - - // cleanup - if (midi_program_name) - { - free((void*)midi_program_name); - midi_program_name = nullptr; - } - if (standalone.engine == nullptr) return nullptr; - if (! standalone.started) - return nullptr; + static char midiProgramName[STR_MAX]; + carla_zeroMem(midiProgramName, sizeof(char)*STR_MAX); if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (midi_program_id < plugin->midiProgramCount()) + if (midiProgramId < plugin->midiProgramCount()) { - char strBuf[STR_MAX] = { 0 }; - - plugin->getMidiProgramName(midi_program_id, strBuf); - midi_program_name = strdup(strBuf); + plugin->getMidiProgramName(midiProgramId, midiProgramName); - return midi_program_name; + return midiProgramName; } - qCritical("carla_get_midi_program_name(%i, %i) - program_id out of bounds", pluginId, midi_program_id); + qCritical("carla_get_midi_program_name(%i, %i) - midiProgramId out of bounds", pluginId, midiProgramId); return nullptr; } - qCritical("carla_get_midi_program_name(%i, %i) - could not find plugin", pluginId, midi_program_id); + qCritical("carla_get_midi_program_name(%i, %i) - could not find plugin", pluginId, midiProgramId); return nullptr; } @@ -866,29 +851,17 @@ const char* carla_get_real_plugin_name(unsigned int pluginId) qDebug("carla_get_real_plugin_name(%i)", pluginId); CARLA_ASSERT(standalone.engine != nullptr); - static const char* real_plugin_name = nullptr; - - // cleanup - if (real_plugin_name) - { - free((void*)real_plugin_name); - real_plugin_name = nullptr; - } - if (standalone.engine == nullptr) return nullptr; - if (! standalone.started) - return nullptr; + static char realPluginName[STR_MAX]; + carla_zeroMem(realPluginName, sizeof(char)*STR_MAX); if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - char strBuf[STR_MAX] = { 0 }; - - plugin->getRealName(strBuf); - real_plugin_name = strdup(strBuf); + plugin->getRealName(realPluginName); - return real_plugin_name; + return realPluginName; } qCritical("carla_get_real_plugin_name(%i) - could not find plugin", pluginId); @@ -929,94 +902,90 @@ int32_t carla_get_current_midi_program_index(unsigned int pluginId) // ------------------------------------------------------------------------------------------------------------------- -double carla_get_default_parameter_value(unsigned int pluginId, uint32_t parameter_id) +float carla_get_default_parameter_value(unsigned int pluginId, uint32_t parameterId) { - qDebug("carla_get_default_parameter_value(%i, %i)", pluginId, parameter_id); + qDebug("carla_get_default_parameter_value(%i, %i)", pluginId, parameterId); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) - return 0.0; + return 0.0f; if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (parameter_id < plugin->parameterCount()) - return plugin->parameterRanges(parameter_id)->def; + if (parameterId < plugin->parameterCount()) + return plugin->parameterRanges(parameterId).def; - qCritical("carla_get_default_parameter_value(%i, %i) - parameter_id out of bounds", pluginId, parameter_id); - return 0.0; + qCritical("carla_get_default_parameter_value(%i, %i) - parameterId out of bounds", pluginId, parameterId); + return 0.0f; } - qCritical("carla_get_default_parameter_value(%i, %i) - could not find plugin", pluginId, parameter_id); - return 0.0; + qCritical("carla_get_default_parameter_value(%i, %i) - could not find plugin", pluginId, parameterId); + return 0.0f; } -double carla_get_current_parameter_value(unsigned int pluginId, uint32_t parameter_id) +float carla_get_current_parameter_value(unsigned int pluginId, uint32_t parameterId) { - qDebug("carla_get_current_parameter_value(%i, %i)", pluginId, parameter_id); + qDebug("carla_get_current_parameter_value(%i, %i)", pluginId, parameterId); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) - return 0.0; + return 0.0f; if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (parameter_id < plugin->parameterCount()) - return plugin->getParameterValue(parameter_id); + if (parameterId < plugin->parameterCount()) + return plugin->getParameterValue(parameterId); - qCritical("carla_get_current_parameter_value(%i, %i) - parameter_id out of bounds", pluginId, parameter_id); - return 0.0; + qCritical("carla_get_current_parameter_value(%i, %i) - parameterId out of bounds", pluginId, parameterId); + return 0.0f; } - qCritical("carla_get_current_parameter_value(%i, %i) - could not find plugin", pluginId, parameter_id); - return 0.0; + qCritical("carla_get_current_parameter_value(%i, %i) - could not find plugin", pluginId, parameterId); + return 0.0f; } // ------------------------------------------------------------------------------------------------------------------- -double carla_get_input_peak_value(unsigned int pluginId, unsigned short port_id) +float carla_get_input_peak_value(unsigned int pluginId, unsigned short portId) { CARLA_ASSERT(standalone.engine != nullptr); - CARLA_ASSERT(port_id == 1 || port_id == 2); + CARLA_ASSERT(portId == 1 || portId == 2); if (standalone.engine == nullptr) - return 0.0; + return 0.0f; -#if 0 - if (pluginId >= standalone.engine->maxPluginNumber()) + if (pluginId >= standalone.engine->currentPluginCount()) { - qCritical("carla_get_input_peak_value(%i, %i) - invalid plugin value", pluginId, port_id); - return 0.0; + qCritical("carla_get_input_peak_value(%i, %i) - invalid plugin value", pluginId, portId); + return 0.0f; } -#endif - if (port_id == 1 || port_id == 2) - return standalone.engine->getInputPeak(pluginId, port_id-1); + //if (portId == 1 || portId == 2) + // return standalone.engine->getInputPeak(pluginId, portId-1); - qCritical("carla_get_input_peak_value(%i, %i) - invalid port value", pluginId, port_id); - return 0.0; + qCritical("carla_get_input_peak_value(%i, %i) - invalid port value", pluginId, portId); + return 0.0f; } -double carla_get_output_peak_value(unsigned int pluginId, unsigned short port_id) +float carla_get_output_peak_value(unsigned int pluginId, unsigned short portId) { CARLA_ASSERT(standalone.engine != nullptr); - CARLA_ASSERT(port_id == 1 || port_id == 2); + CARLA_ASSERT(portId == 1 || portId == 2); if (standalone.engine == nullptr) - return 0.0; + return 0.0f; -#if 0 - if (pluginId >= standalone.engine->maxPluginNumber()) + if (pluginId >= standalone.engine->currentPluginCount()) { - qCritical("carla_get_input_peak_value(%i, %i) - invalid plugin value", pluginId, port_id); - return 0.0; + qCritical("carla_get_input_peak_value(%i, %i) - invalid plugin value", pluginId, portId); + return 0.0f; } -#endif - if (port_id == 1 || port_id == 2) - return standalone.engine->getOutputPeak(pluginId, port_id-1); + //if (portId == 1 || portId == 2) + // return standalone.engine->getOutputPeak(pluginId, portId-1); - qCritical("carla_get_output_peak_value(%i, %i) - invalid port value", pluginId, port_id); - return 0.0; + qCritical("carla_get_output_peak_value(%i, %i) - invalid port value", pluginId, portId); + return 0.0f; } // ------------------------------------------------------------------------------------------------------------------- @@ -1035,9 +1004,9 @@ void carla_set_active(unsigned int pluginId, bool onOff) qCritical("carla_set_active(%i, %s) - could not find plugin", pluginId, bool2str(onOff)); } -void carla_set_drywet(unsigned int pluginId, double value) +void carla_set_drywet(unsigned int pluginId, float value) { - qDebug("carla_set_drywet(%i, %g)", pluginId, value); + qDebug("carla_set_drywet(%i, %f)", pluginId, value); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1046,12 +1015,12 @@ void carla_set_drywet(unsigned int pluginId, double value) if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) return plugin->setDryWet(value, true, false); - qCritical("carla_set_drywet(%i, %g) - could not find plugin", pluginId, value); + qCritical("carla_set_drywet(%i, %f) - could not find plugin", pluginId, value); } -void carla_set_volume(unsigned int pluginId, double value) +void carla_set_volume(unsigned int pluginId, float value) { - qDebug("carla_set_volume(%i, %g)", pluginId, value); + qDebug("carla_set_volume(%i, %f)", pluginId, value); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1060,12 +1029,12 @@ void carla_set_volume(unsigned int pluginId, double value) if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) return plugin->setVolume(value, true, false); - qCritical("carla_set_volume(%i, %g) - could not find plugin", pluginId, value); + qCritical("carla_set_volume(%i, %f) - could not find plugin", pluginId, value); } -void carla_set_balance_left(unsigned int pluginId, double value) +void carla_set_balance_left(unsigned int pluginId, float value) { - qDebug("carla_set_balance_left(%i, %g)", pluginId, value); + qDebug("carla_set_balance_left(%i, %f)", pluginId, value); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1074,12 +1043,12 @@ void carla_set_balance_left(unsigned int pluginId, double value) if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) return plugin->setBalanceLeft(value, true, false); - qCritical("carla_set_balance_left(%i, %g) - could not find plugin", pluginId, value); + qCritical("carla_set_balance_left(%i, %f) - could not find plugin", pluginId, value); } -void carla_set_balance_right(unsigned int pluginId, double value) +void carla_set_balance_right(unsigned int pluginId, float value) { - qDebug("carla_set_balance_right(%i, %g)", pluginId, value); + qDebug("carla_set_balance_right(%i, %f)", pluginId, value); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1088,14 +1057,28 @@ void carla_set_balance_right(unsigned int pluginId, double value) if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) return plugin->setBalanceRight(value, true, false); - qCritical("carla_set_balance_right(%i, %g) - could not find plugin", pluginId, value); + qCritical("carla_set_balance_right(%i, %f) - could not find plugin", pluginId, value); +} + +void carla_set_panning(unsigned int pluginId, float value) +{ + qDebug("carla_set_panning(%i, %f)", pluginId, value); + CARLA_ASSERT(standalone.engine != nullptr); + + if (standalone.engine == nullptr) + return; + + if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) + return plugin->setPanning(value, true, false); + + qCritical("carla_set_panning(%i, %f) - could not find plugin", pluginId, value); } // ------------------------------------------------------------------------------------------------------------------- -void carla_set_parameter_value(unsigned int pluginId, uint32_t parameter_id, double value) +void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, float value) { - qDebug("carla_set_parameter_value(%i, %i, %g)", pluginId, parameter_id, value); + qDebug("carla_set_parameter_value(%i, %i, %f)", pluginId, parameterId, value); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1103,25 +1086,25 @@ void carla_set_parameter_value(unsigned int pluginId, uint32_t parameter_id, dou if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (parameter_id < plugin->parameterCount()) - return plugin->setParameterValue(parameter_id, value, true, true, false); + if (parameterId < plugin->parameterCount()) + return plugin->setParameterValue(parameterId, value, true, true, false); - qCritical("carla_set_parameter_value(%i, %i, %g) - parameter_id out of bounds", pluginId, parameter_id, value); + qCritical("carla_set_parameter_value(%i, %i, %f) - parameterId out of bounds", pluginId, parameterId, value); return; } - qCritical("carla_set_parameter_value(%i, %i, %g) - could not find plugin", pluginId, parameter_id, value); + qCritical("carla_set_parameter_value(%i, %i, %f) - could not find plugin", pluginId, parameterId, value); } -void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameter_id, uint8_t channel) +void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterId, uint8_t channel) { - qDebug("carla_set_parameter_midi_channel(%i, %i, %i)", pluginId, parameter_id, channel); + qDebug("carla_set_parameter_midi_channel(%i, %i, %i)", pluginId, parameterId, channel); CARLA_ASSERT(standalone.engine != nullptr); CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); if (channel >= MAX_MIDI_CHANNELS) { - qCritical("carla_set_parameter_midi_channel(%i, %i, %i) - invalid channel number", pluginId, parameter_id, channel); + qCritical("carla_set_parameter_midi_channel(%i, %i, %i) - invalid channel number", pluginId, parameterId, channel); return; } @@ -1130,19 +1113,19 @@ void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameter_ if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (parameter_id < plugin->parameterCount()) - return plugin->setParameterMidiChannel(parameter_id, channel, true, false); + if (parameterId < plugin->parameterCount()) + return plugin->setParameterMidiChannel(parameterId, channel, true, false); - qCritical("carla_set_parameter_midi_channel(%i, %i, %i) - parameter_id out of bounds", pluginId, parameter_id, channel); + qCritical("carla_set_parameter_midi_channel(%i, %i, %i) - parameterId out of bounds", pluginId, parameterId, channel); return; } - qCritical("carla_set_parameter_midi_channel(%i, %i, %i) - could not find plugin", pluginId, parameter_id, channel); + qCritical("carla_set_parameter_midi_channel(%i, %i, %i) - could not find plugin", pluginId, parameterId, channel); } -void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameter_id, int16_t cc) +void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, int16_t cc) { - qDebug("carla_set_parameter_midi_cc(%i, %i, %i)", pluginId, parameter_id, cc); + qDebug("carla_set_parameter_midi_cc(%i, %i, %i)", pluginId, parameterId, cc); CARLA_ASSERT(standalone.engine != nullptr); CARLA_ASSERT(cc >= -1 && cc <= 0x5F); @@ -1152,7 +1135,7 @@ void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameter_id, i } else if (cc > 0x5F) // 95 { - qCritical("carla_set_parameter_midi_cc(%i, %i, %i) - invalid cc number", pluginId, parameter_id, cc); + qCritical("carla_set_parameter_midi_cc(%i, %i, %i) - invalid cc number", pluginId, parameterId, cc); return; } @@ -1161,19 +1144,19 @@ void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameter_id, i if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (parameter_id < plugin->parameterCount()) - return plugin->setParameterMidiCC(parameter_id, cc, true, false); + if (parameterId < plugin->parameterCount()) + return plugin->setParameterMidiCC(parameterId, cc, true, false); - qCritical("carla_set_parameter_midi_cc(%i, %i, %i) - parameter_id out of bounds", pluginId, parameter_id, cc); + qCritical("carla_set_parameter_midi_cc(%i, %i, %i) - parameterId out of bounds", pluginId, parameterId, cc); return; } - qCritical("carla_set_parameter_midi_cc(%i, %i, %i) - could not find plugin", pluginId, parameter_id, cc); + qCritical("carla_set_parameter_midi_cc(%i, %i, %i) - could not find plugin", pluginId, parameterId, cc); } -void carla_set_program(unsigned int pluginId, uint32_t program_id) +void carla_set_program(unsigned int pluginId, uint32_t programId) { - qDebug("carla_set_program(%i, %i)", pluginId, program_id); + qDebug("carla_set_program(%i, %i)", pluginId, programId); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1181,19 +1164,19 @@ void carla_set_program(unsigned int pluginId, uint32_t program_id) if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (program_id < plugin->programCount()) - return plugin->setProgram(program_id, true, true, false, true); + if (programId < plugin->programCount()) + return plugin->setProgram(programId, true, true, false, true); - qCritical("carla_set_program(%i, %i) - program_id out of bounds", pluginId, program_id); + qCritical("carla_set_program(%i, %i) - programId out of bounds", pluginId, programId); return; } - qCritical("carla_set_program(%i, %i) - could not find plugin", pluginId, program_id); + qCritical("carla_set_program(%i, %i) - could not find plugin", pluginId, programId); } -void carla_set_midi_program(unsigned int pluginId, uint32_t midi_program_id) +void carla_set_midi_program(unsigned int pluginId, uint32_t midiProgramId) { - qDebug("carla_set_midi_program(%i, %i)", pluginId, midi_program_id); + qDebug("carla_set_midi_program(%i, %i)", pluginId, midiProgramId); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1201,14 +1184,14 @@ void carla_set_midi_program(unsigned int pluginId, uint32_t midi_program_id) if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { - if (midi_program_id < plugin->midiProgramCount()) - return plugin->setMidiProgram(midi_program_id, true, true, false, true); + if (midiProgramId < plugin->midiProgramCount()) + return plugin->setMidiProgram(midiProgramId, true, true, false, true); - qCritical("carla_set_midi_program(%i, %i) - midi_program_id out of bounds", pluginId, midi_program_id); + qCritical("carla_set_midi_program(%i, %i) - midiProgramId out of bounds", pluginId, midiProgramId); return; } - qCritical("carla_set_midi_program(%i, %i) - could not find plugin", pluginId, midi_program_id); + qCritical("carla_set_midi_program(%i, %i) - could not find plugin", pluginId, midiProgramId); } // ------------------------------------------------------------------------------------------------------------------- @@ -1227,9 +1210,9 @@ void carla_set_custom_data(unsigned int pluginId, const char* type, const char* qCritical("carla_set_custom_data(%i, \"%s\", \"%s\", \"%s\") - could not find plugin", pluginId, type, key, value); } -void carla_set_chunk_data(unsigned int pluginId, const char* chunk_data) +void carla_set_chunk_data(unsigned int pluginId, const char* chunkData) { - qDebug("carla_set_chunk_data(%i, \"%s\")", pluginId, chunk_data); + qDebug("carla_set_chunk_data(%i, \"%s\")", pluginId, chunkData); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) @@ -1238,47 +1221,37 @@ void carla_set_chunk_data(unsigned int pluginId, const char* chunk_data) if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) { if (plugin->hints() & CarlaBackend::PLUGIN_USES_CHUNKS) - return plugin->setChunkData(chunk_data); + return plugin->setChunkData(chunkData); - qCritical("carla_set_chunk_data(%i, \"%s\") - plugin does not support chunks", pluginId, chunk_data); + qCritical("carla_set_chunk_data(%i, \"%s\") - plugin does not support chunks", pluginId, chunkData); return; } - qCritical("carla_set_chunk_data(%i, \"%s\") - could not find plugin", pluginId, chunk_data); + qCritical("carla_set_chunk_data(%i, \"%s\") - could not find plugin", pluginId, chunkData); } // ------------------------------------------------------------------------------------------------------------------- -void carla_show_gui(unsigned int pluginId, bool yesno) +void carla_prepare_for_save(unsigned int pluginId) { - qDebug("carla_show_gui(%i, %s)", pluginId, bool2str(yesno)); + qDebug("carla_prepare_for_save(%i)", pluginId); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) return; if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->showGui(yesno); - - qCritical("carla_show_gui(%i, %s) - could not find plugin", pluginId, bool2str(yesno)); -} - -void carla_idle_guis() -{ - CARLA_ASSERT(standalone.engine != nullptr); + return plugin->prepareForSave(); - if (standalone.engine) - standalone.engine->idlePluginGuis(); + qCritical("carla_prepare_for_save(%i) - could not find plugin", pluginId); } -// ------------------------------------------------------------------------------------------------------------------- - void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity) { qDebug("carla_send_midi_note(%i, %i, %i, %i)", pluginId, channel, note, velocity); CARLA_ASSERT(standalone.engine != nullptr); - if (! (standalone.engine && standalone.engine->isRunning())) + if (standalone.engine == nullptr || ! standalone.engine->isRunning()) return; if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) @@ -1287,18 +1260,18 @@ void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, qCritical("carla_send_midi_note(%i, %i, %i, %i) - could not find plugin", pluginId, channel, note, velocity); } -void carla_prepare_for_save(unsigned int pluginId) +void carla_show_gui(unsigned int pluginId, bool yesno) { - qDebug("carla_prepare_for_save(%i)", pluginId); + qDebug("carla_show_gui(%i, %s)", pluginId, bool2str(yesno)); CARLA_ASSERT(standalone.engine != nullptr); if (standalone.engine == nullptr) return; if (CarlaPlugin* const plugin = standalone.engine->getPlugin(pluginId)) - return plugin->prepareForSave(); + return plugin->showGui(yesno); - qCritical("carla_prepare_for_save(%i) - could not find plugin", pluginId); + qCritical("carla_show_gui(%i, %s) - could not find plugin", pluginId, bool2str(yesno)); } // ------------------------------------------------------------------------------------------------------------------- @@ -1331,7 +1304,7 @@ const char* carla_get_last_error() { qDebug("carla_get_last_error()"); - if (standalone.engine) + if (standalone.engine != nullptr) return standalone.engine->getLastError(); return standalone.lastError; @@ -1360,109 +1333,114 @@ void carla_set_callback_function(CarlaBackend::CallbackFunc func) standalone.engine->setCallback(func, nullptr); } -void carla_set_option(CarlaBackend::OptionsType option, int value, const char* value_str) +void carla_set_option(CarlaBackend::OptionsType option, int value, const char* valueStr) { - qDebug("carla_set_option(%s, %i, \"%s\")", CarlaBackend::OptionsType2Str(option), value, value_str); + qDebug("carla_set_option(%s, %i, \"%s\")", CarlaBackend::OptionsType2Str(option), value, valueStr); if (standalone.engine) - standalone.engine->setOption(option, value, value_str); + standalone.engine->setOption(option, value, valueStr); switch (option) { case CarlaBackend::OPTION_PROCESS_NAME: - standalone.procName = value_str; + standalone.procName = valueStr; break; case CarlaBackend::OPTION_PROCESS_MODE: if (value < CarlaBackend::PROCESS_MODE_SINGLE_CLIENT || value > CarlaBackend::PROCESS_MODE_PATCHBAY) - return qCritical("carla_set_option(%s, %i, \"%s\") - invalid value", OptionsType2Str(option), value, value_str); + return qCritical("carla_set_option(OPTION_PROCESS_MODE, %i, \"%s\") - invalid value", value, valueStr); standalone.options.processMode = static_cast(value); break; - case CarlaBackend::OPTION_PROCESS_HIGH_PRECISION: - standalone.options.processHighPrecision = value; + case CarlaBackend::OPTION_FORCE_STEREO: + standalone.options.forceStereo = value; break; - case CarlaBackend::OPTION_MAX_PARAMETERS: - standalone.options.maxParameters = (value > 0) ? value : CarlaBackend::MAX_PARAMETERS; + case CarlaBackend::OPTION_PREFER_PLUGIN_BRIDGES: + standalone.options.preferPluginBridges = value; break; - case CarlaBackend::OPTION_PREFERRED_BUFFER_SIZE: - standalone.options.preferredBufferSize = value; + case CarlaBackend::OPTION_PREFER_UI_BRIDGES: + standalone.options.preferUiBridges = value; break; - case CarlaBackend::OPTION_PREFERRED_SAMPLE_RATE: - standalone.options.preferredSampleRate = value; +#ifdef WANT_DSSI + case CarlaBackend::OPTION_USE_DSSI_VST_CHUNKS: + standalone.options.useDssiVstChunks = value; break; +#endif - case CarlaBackend::OPTION_FORCE_STEREO: - standalone.options.forceStereo = value; + case CarlaBackend::OPTION_MAX_PARAMETERS: + standalone.options.maxParameters = (value > 0) ? value : CarlaBackend::MAX_DEFAULT_PARAMETERS; break; - case CarlaBackend::OPTION_USE_DSSI_VST_CHUNKS: - standalone.options.useDssiVstChunks = value; + case CarlaBackend::OPTION_OSC_UI_TIMEOUT: + standalone.options.oscUiTimeout = value; break; - case CarlaBackend::OPTION_PREFER_PLUGIN_BRIDGES: - standalone.options.preferPluginBridges = value; + case CarlaBackend::OPTION_PREFERRED_BUFFER_SIZE: + standalone.options.preferredBufferSize = value; break; - case CarlaBackend::OPTION_PREFER_UI_BRIDGES: - standalone.options.preferUiBridges = value; + case CarlaBackend::OPTION_PREFERRED_SAMPLE_RATE: + standalone.options.preferredSampleRate = value; break; - case CarlaBackend::OPTION_OSC_UI_TIMEOUT: - standalone.options.oscUiTimeout = value; + case CarlaBackend::OPTION_PATH_BRIDGE_NATIVE: + standalone.options.bridge_native = valueStr; break; - case CarlaBackend::OPTION_PATH_BRIDGE_POSIX32: - standalone.options.bridge_posix32 = value_str; + standalone.options.bridge_posix32 = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_POSIX64: - standalone.options.bridge_posix64 = value_str; + standalone.options.bridge_posix64 = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_WIN32: - standalone.options.bridge_win32 = value_str; + standalone.options.bridge_win32 = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_WIN64: - standalone.options.bridge_win64 = value_str; + standalone.options.bridge_win64 = valueStr; break; +#ifdef WANT_LV2 case CarlaBackend::OPTION_PATH_BRIDGE_LV2_GTK2: - standalone.options.bridge_lv2gtk2 = value_str; + standalone.options.bridge_lv2gtk2 = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_LV2_GTK3: - standalone.options.bridge_lv2gtk3 = value_str; + standalone.options.bridge_lv2gtk3 = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_LV2_QT4: - standalone.options.bridge_lv2qt4 = value_str; + standalone.options.bridge_lv2qt4 = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_LV2_QT5: - standalone.options.bridge_lv2qt5 = value_str; + standalone.options.bridge_lv2qt5 = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_LV2_COCOA: - standalone.options.bridge_lv2cocoa = value_str; + standalone.options.bridge_lv2cocoa = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_LV2_WINDOWS: - standalone.options.bridge_lv2win = value_str; + standalone.options.bridge_lv2win = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_LV2_X11: - standalone.options.bridge_lv2x11 = value_str; + standalone.options.bridge_lv2x11 = valueStr; break; - +#endif +#ifdef WANT_VST case CarlaBackend::OPTION_PATH_BRIDGE_VST_COCOA: - standalone.options.bridge_vstcocoa = value_str; + standalone.options.bridge_vstcocoa = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_VST_HWND: - standalone.options.bridge_vsthwnd = value_str; + standalone.options.bridge_vsthwnd = valueStr; break; case CarlaBackend::OPTION_PATH_BRIDGE_VST_X11: - standalone.options.bridge_vstx11 = value_str; + standalone.options.bridge_vstx11 = valueStr; break; +#endif } } +#if 0 // ------------------------------------------------------------------------------------------------------------------- #define NSM_API_VERSION_MAJOR 1 diff --git a/source/carla.py b/source/carla.py index 245788a47..43c007bb6 100755 --- a/source/carla.py +++ b/source/carla.py @@ -18,7 +18,6 @@ # Imports (Global) import json -from PyQt4.QtCore import QThread from PyQt4.QtGui import QApplication, QMainWindow, QTableWidgetItem # Imports (Custom Stuff) @@ -31,1028 +30,6 @@ DEFAULT_PROJECT_FOLDER = HOME #setDefaultProjectFolder(DEFAULT_PROJECT_FOLDER) #setDefaultPluginsPaths(LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, GIG_PATH, SF2_PATH, SFZ_PATH) -# Separate Thread for Plugin Search -class SearchPluginsThread(QThread): - def __init__(self, parent): - QThread.__init__(self, parent) - - self.settings_db = self.parent().settings_db - - self.check_native = False - self.check_posix32 = False - self.check_posix64 = False - self.check_win32 = False - self.check_win64 = False - - self.check_ladspa = False - self.check_dssi = False - self.check_lv2 = False - self.check_vst = False - self.check_gig = False - self.check_sf2 = False - self.check_sfz = False - - self.tool_native = carla_discovery_native - - def skipPlugin(self): - # TODO - windows and mac support - apps = "" - apps += " carla-discovery" - apps += " carla-discovery-native" - apps += " carla-discovery-posix32" - apps += " carla-discovery-posix64" - apps += " carla-discovery-win32.exe" - apps += " carla-discovery-win64.exe" - - if LINUX: - os.system("killall -KILL %s" % apps) - - def pluginLook(self, percent, plugin): - self.emit(SIGNAL("PluginLook(int, QString)"), percent, plugin) - - def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64): - self.check_native = native - self.check_posix32 = posix32 - self.check_posix64 = posix64 - self.check_win32 = win32 - self.check_win64 = win64 - - def setSearchPluginTypes(self, ladspa, dssi, lv2, vst, gig, sf2, sfz): - self.check_ladspa = ladspa - self.check_dssi = dssi - self.check_lv2 = lv2 - self.check_vst = vst - self.check_gig = gig - self.check_sf2 = sf2 - self.check_sfz = sfz - - def setSearchToolNative(self, tool): - self.tool_native = tool - - def setLastLoadedBinary(self, binary): - self.settings_db.setValue("Plugins/LastLoadedBinary", binary) - - def checkLADSPA(self, OS, tool, isWine=False): - global LADSPA_PATH - ladspa_binaries = [] - self.ladspa_plugins = [] - - for iPATH in LADSPA_PATH: - binaries = findBinaries(iPATH, OS) - for binary in binaries: - if binary not in ladspa_binaries: - ladspa_binaries.append(binary) - - ladspa_binaries.sort() - - for i in range(len(ladspa_binaries)): - ladspa = ladspa_binaries[i] - if os.path.basename(ladspa) in self.blacklist: - print("plugin %s is blacklisted, skip it" % ladspa) - continue - else: - percent = ( float(i) / len(ladspa_binaries) ) * self.m_percent_value - self.pluginLook((self.m_last_value + percent) * 0.9, ladspa) - self.setLastLoadedBinary(ladspa) - - plugins = checkPluginLADSPA(ladspa, tool, isWine) - if plugins: - self.ladspa_plugins.append(plugins) - - self.m_last_value += self.m_percent_value - self.setLastLoadedBinary("") - - def checkDSSI(self, OS, tool, isWine=False): - global DSSI_PATH - dssi_binaries = [] - self.dssi_plugins = [] - - for iPATH in DSSI_PATH: - binaries = findBinaries(iPATH, OS) - for binary in binaries: - if binary not in dssi_binaries: - dssi_binaries.append(binary) - - dssi_binaries.sort() - - for i in range(len(dssi_binaries)): - dssi = dssi_binaries[i] - if os.path.basename(dssi) in self.blacklist: - print("plugin %s is blacklisted, skip it" % dssi) - continue - else: - percent = ( float(i) / len(dssi_binaries) ) * self.m_percent_value - self.pluginLook(self.m_last_value + percent, dssi) - self.setLastLoadedBinary(dssi) - - plugins = checkPluginDSSI(dssi, tool, isWine) - if plugins: - self.dssi_plugins.append(plugins) - - self.m_last_value += self.m_percent_value - self.setLastLoadedBinary("") - - def checkLV2(self, tool, isWine=False): - global LV2_PATH - lv2_bundles = [] - self.lv2_plugins = [] - - self.pluginLook(self.m_last_value, "LV2 bundles...") - - for iPATH in LV2_PATH: - bundles = findLV2Bundles(iPATH) - for bundle in bundles: - if bundle not in lv2_bundles: - lv2_bundles.append(bundle) - - lv2_bundles.sort() - - for i in range(len(lv2_bundles)): - lv2 = lv2_bundles[i] - if (os.path.basename(lv2) in self.blacklist): - print("bundle %s is blacklisted, skip it" % lv2) - continue - else: - percent = ( float(i) / len(lv2_bundles) ) * self.m_percent_value - self.pluginLook(self.m_last_value + percent, lv2) - self.setLastLoadedBinary(lv2) - - plugins = checkPluginLV2(lv2, tool, isWine) - if plugins: - self.lv2_plugins.append(plugins) - - self.m_last_value += self.m_percent_value - self.setLastLoadedBinary("") - - def checkVST(self, OS, tool, isWine=False): - global VST_PATH - vst_binaries = [] - self.vst_plugins = [] - - for iPATH in VST_PATH: - binaries = findBinaries(iPATH, OS) - for binary in binaries: - if binary not in vst_binaries: - vst_binaries.append(binary) - - vst_binaries.sort() - - for i in range(len(vst_binaries)): - vst = vst_binaries[i] - if os.path.basename(vst) in self.blacklist: - print("plugin %s is blacklisted, skip it" % vst) - continue - else: - percent = ( float(i) / len(vst_binaries) ) * self.m_percent_value - self.pluginLook(self.m_last_value + percent, vst) - self.setLastLoadedBinary(vst) - - plugins = checkPluginVST(vst, tool, isWine) - if plugins: - self.vst_plugins.append(plugins) - - self.m_last_value += self.m_percent_value - self.setLastLoadedBinary("") - - def checkKIT(self, kPATH, kType): - kit_files = [] - self.kit_plugins = [] - - for iPATH in kPATH: - files = findSoundKits(iPATH, kType) - for file_ in files: - if file_ not in kit_files: - kit_files.append(file_) - - kit_files.sort() - - for i in range(len(kit_files)): - kit = kit_files[i] - if os.path.basename(kit) in self.blacklist: - print("plugin %s is blacklisted, skip it" % kit) - continue - else: - percent = ( float(i) / len(kit_files) ) * self.m_percent_value - self.pluginLook(self.m_last_value + percent, kit) - self.setLastLoadedBinary(kit) - - if kType == "gig": - plugins = checkPluginGIG(kit, self.tool_native) - elif kType == "sf2": - plugins = checkPluginSF2(kit, self.tool_native) - elif kType == "sfz": - plugins = checkPluginSFZ(kit, self.tool_native) - else: - plugins = None - - if plugins: - self.kit_plugins.append(plugins) - - self.m_last_value += self.m_percent_value - self.setLastLoadedBinary("") - - def run(self): - global LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, GIG_PATH, SF2_PATH, SFZ_PATH - - self.blacklist = toList(self.settings_db.value("Plugins/Blacklisted", [])) - - self.m_count = 0 - plugin_count = 0 - - if self.check_ladspa: plugin_count += 1 - if self.check_dssi: plugin_count += 1 - if self.check_lv2: plugin_count += 1 - if self.check_vst: plugin_count += 1 - - if self.check_native: - self.m_count += plugin_count - if self.check_posix32: - self.m_count += plugin_count - if self.check_posix64: - self.m_count += plugin_count - if self.check_win32: - self.m_count += plugin_count - if self.check_win64: - self.m_count += plugin_count - - if self.tool_native: - if self.check_gig: self.m_count += 1 - if self.check_sf2: self.m_count += 1 - if self.check_sfz: self.m_count += 1 - else: - self.check_gig = False - self.check_sf2 = False - self.check_sfz = False - - if self.m_count == 0: - return - - self.m_last_value = 0 - self.m_percent_value = 100 / self.m_count - - if HAIKU: - OS = "HAIKU" - elif LINUX: - OS = "LINUX" - elif MACOS: - OS = "MACOS" - elif WINDOWS: - OS = "WINDOWS" - else: - OS = "UNKNOWN" - - if self.check_ladspa: - m_value = 0 - if haveLRDF: - if self.check_native: m_value += 0.1 - if self.check_posix32: m_value += 0.1 - if self.check_posix64: m_value += 0.1 - if self.check_win32: m_value += 0.1 - if self.check_win64: m_value += 0.1 - rdf_pad_value = self.m_percent_value * m_value - - if self.check_native: - self.checkLADSPA(OS, carla_discovery_native) - self.settings_db.setValue("Plugins/LADSPA_native", self.ladspa_plugins) - self.settings_db.sync() - - if self.check_posix32: - self.checkLADSPA(OS, carla_discovery_posix32) - self.settings_db.setValue("Plugins/LADSPA_posix32", self.ladspa_plugins) - self.settings_db.sync() - - if self.check_posix64: - self.checkLADSPA(OS, carla_discovery_posix64) - self.settings_db.setValue("Plugins/LADSPA_posix64", self.ladspa_plugins) - self.settings_db.sync() - - if self.check_win32: - self.checkLADSPA("WINDOWS", carla_discovery_win32, not WINDOWS) - self.settings_db.setValue("Plugins/LADSPA_win32", self.ladspa_plugins) - self.settings_db.sync() - - if self.check_win64: - self.checkLADSPA("WINDOWS", carla_discovery_win64, not WINDOWS) - self.settings_db.setValue("Plugins/LADSPA_win64", self.ladspa_plugins) - self.settings_db.sync() - - if haveLRDF: - if m_value > 0: - start_value = self.m_last_value - rdf_pad_value - - self.pluginLook(start_value, "LADSPA RDFs...") - ladspa_rdf_info = ladspa_rdf.recheck_all_plugins(self, start_value, self.m_percent_value, m_value) - - SettingsDir = os.path.join(HOME, ".config", "Cadence") - - f_ladspa = open(os.path.join(SettingsDir, "ladspa_rdf.db"), 'w') - json.dump(ladspa_rdf_info, f_ladspa) - f_ladspa.close() - - if self.check_dssi: - if self.check_native: - self.checkDSSI(OS, carla_discovery_native) - self.settings_db.setValue("Plugins/DSSI_native", self.dssi_plugins) - self.settings_db.sync() - - if self.check_posix32: - self.checkDSSI(OS, carla_discovery_posix32) - self.settings_db.setValue("Plugins/DSSI_posix32", self.dssi_plugins) - self.settings_db.sync() - - if self.check_posix64: - self.checkDSSI(OS, carla_discovery_posix64) - self.settings_db.setValue("Plugins/DSSI_posix64", self.dssi_plugins) - self.settings_db.sync() - - if self.check_win32: - self.checkDSSI("WINDOWS", carla_discovery_win32, not WINDOWS) - self.settings_db.setValue("Plugins/DSSI_win32", self.dssi_plugins) - self.settings_db.sync() - - if self.check_win64: - self.checkDSSI("WINDOWS", carla_discovery_win64, not WINDOWS) - self.settings_db.setValue("Plugins/DSSI_win64", self.dssi_plugins) - self.settings_db.sync() - - if self.check_lv2: - if self.check_native: - self.checkLV2(carla_discovery_native) - self.settings_db.setValue("Plugins/LV2_native", self.lv2_plugins) - self.settings_db.sync() - - if self.check_posix32: - self.checkLV2(carla_discovery_posix32) - self.settings_db.setValue("Plugins/LV2_posix32", self.lv2_plugins) - self.settings_db.sync() - - if self.check_posix64: - self.checkLV2(carla_discovery_posix64) - self.settings_db.setValue("Plugins/LV2_posix64", self.lv2_plugins) - self.settings_db.sync() - - if self.check_win32: - self.checkLV2(carla_discovery_win32, not WINDOWS) - self.settings_db.setValue("Plugins/LV2_win32", self.lv2_plugins) - self.settings_db.sync() - - if self.check_win64: - self.checkLV2(carla_discovery_win64, not WINDOWS) - self.settings_db.setValue("Plugins/LV2_win64", self.lv2_plugins) - self.settings_db.sync() - - if self.check_vst: - if self.check_native: - self.checkVST(OS, carla_discovery_native) - self.settings_db.setValue("Plugins/VST_native", self.vst_plugins) - self.settings_db.sync() - - if self.check_posix32: - self.checkVST(OS, carla_discovery_posix32) - self.settings_db.setValue("Plugins/VST_posix32", self.vst_plugins) - self.settings_db.sync() - - if self.check_posix64: - self.checkVST(OS, carla_discovery_posix64) - self.settings_db.setValue("Plugins/VST_posix64", self.vst_plugins) - self.settings_db.sync() - - if self.check_win32: - self.checkVST("WINDOWS", carla_discovery_win32, not WINDOWS) - self.settings_db.setValue("Plugins/VST_win32", self.vst_plugins) - self.settings_db.sync() - - if self.check_win64: - self.checkVST("WINDOWS", carla_discovery_win64, not WINDOWS) - self.settings_db.setValue("Plugins/VST_win64", self.vst_plugins) - self.settings_db.sync() - - if self.check_gig: - self.checkKIT(GIG_PATH, "gig") - self.settings_db.setValue("Plugins/GIG", self.kit_plugins) - self.settings_db.sync() - - if self.check_sf2: - self.checkKIT(SF2_PATH, "sf2") - self.settings_db.setValue("Plugins/SF2", self.kit_plugins) - self.settings_db.sync() - - if self.check_sfz: - self.checkKIT(SFZ_PATH, "sfz") - self.settings_db.setValue("Plugins/SFZ", self.kit_plugins) - self.settings_db.sync() - -# Plugin Refresh Dialog -class PluginRefreshW(QDialog, ui_carla_refresh.Ui_PluginRefreshW): - def __init__(self, parent): - QDialog.__init__(self, parent) - self.setupUi(self) - - self.b_skip.setVisible(False) - - if HAIKU: - self.ch_posix32.setText("Haiku 32bit") - self.ch_posix64.setText("Haiku 64bit") - elif LINUX: - self.ch_posix32.setText("Linux 32bit") - self.ch_posix64.setText("Linux 64bit") - elif MACOS: - self.ch_posix32.setText("MacOS 32bit") - self.ch_posix64.setText("MacOS 64bit") - - self.settings = self.parent().settings - self.settings_db = self.parent().settings_db - self.loadSettings() - - self.pThread = SearchPluginsThread(self) - - if carla_discovery_posix32 and not WINDOWS: - self.ico_posix32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) - else: - self.ico_posix32.setPixmap(getIcon("dialog-error").pixmap(16, 16)) - self.ch_posix32.setChecked(False) - self.ch_posix32.setEnabled(False) - - if carla_discovery_posix64 and not WINDOWS: - self.ico_posix64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) - else: - self.ico_posix64.setPixmap(getIcon("dialog-error").pixmap(16, 16)) - self.ch_posix64.setChecked(False) - self.ch_posix64.setEnabled(False) - - if carla_discovery_win32: - self.ico_win32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) - else: - self.ico_win32.setPixmap(getIcon("dialog-error").pixmap(16, 16)) - self.ch_win32.setChecked(False) - self.ch_win32.setEnabled(False) - - if carla_discovery_win64: - self.ico_win64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) - else: - self.ico_win64.setPixmap(getIcon("dialog-error").pixmap(16, 16)) - self.ch_win64.setChecked(False) - self.ch_win64.setEnabled(False) - - if haveLRDF: - self.ico_rdflib.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) - else: - self.ico_rdflib.setPixmap(getIcon("dialog-error").pixmap(16, 16)) - - hasNative = bool(carla_discovery_native) - hasNonNative = False - - if WINDOWS: - if kIs64bit: - hasNative = bool(carla_discovery_win64) - hasNonNative = bool(carla_discovery_win32) - self.pThread.setSearchToolNative(carla_discovery_win64) - self.ch_win64.setChecked(False) - self.ch_win64.setVisible(False) - self.ico_win64.setVisible(False) - self.label_win64.setVisible(False) - else: - hasNative = bool(carla_discovery_win32) - hasNonNative = bool(carla_discovery_win64) - self.pThread.setSearchToolNative(carla_discovery_win32) - self.ch_win32.setChecked(False) - self.ch_win32.setVisible(False) - self.ico_win32.setVisible(False) - self.label_win32.setVisible(False) - elif LINUX or MACOS: - if kIs64bit: - hasNonNative = bool(carla_discovery_posix32 or carla_discovery_win32 or carla_discovery_win64) - self.ch_posix64.setChecked(False) - self.ch_posix64.setVisible(False) - self.ico_posix64.setVisible(False) - self.label_posix64.setVisible(False) - else: - hasNonNative = bool(carla_discovery_posix64 or carla_discovery_win32 or carla_discovery_win64) - self.ch_posix32.setChecked(False) - self.ch_posix32.setVisible(False) - self.ico_posix32.setVisible(False) - self.label_posix32.setVisible(False) - - if hasNative: - self.ico_native.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) - else: - self.ico_native.setPixmap(getIcon("dialog-error").pixmap(16, 16)) - self.ch_native.setChecked(False) - self.ch_native.setEnabled(False) - self.ch_gig.setChecked(False) - self.ch_gig.setEnabled(False) - self.ch_sf2.setChecked(False) - self.ch_sf2.setEnabled(False) - self.ch_sfz.setChecked(False) - self.ch_sfz.setEnabled(False) - if not hasNonNative: - self.ch_ladspa.setChecked(False) - self.ch_ladspa.setEnabled(False) - self.ch_dssi.setChecked(False) - self.ch_dssi.setEnabled(False) - self.ch_vst.setChecked(False) - self.ch_vst.setEnabled(False) - self.b_start.setEnabled(False) - - self.connect(self.b_start, SIGNAL("clicked()"), SLOT("slot_start()")) - self.connect(self.b_skip, SIGNAL("clicked()"), SLOT("slot_skip()")) - self.connect(self.pThread, SIGNAL("PluginLook(int, QString)"), SLOT("slot_handlePluginLook(int, QString)")) - self.connect(self.pThread, SIGNAL("finished()"), SLOT("slot_handlePluginThreadFinished()")) - - @pyqtSlot() - def slot_start(self): - self.progressBar.setMinimum(0) - self.progressBar.setMaximum(100) - self.progressBar.setValue(0) - self.b_start.setEnabled(False) - self.b_skip.setVisible(True) - self.b_close.setVisible(False) - - native, posix32, posix64, win32, win64 = (self.ch_native.isChecked(), self.ch_posix32.isChecked(), self.ch_posix64.isChecked(), self.ch_win32.isChecked(), self.ch_win64.isChecked()) - ladspa, dssi, lv2, vst, gig, sf2, sfz = (self.ch_ladspa.isChecked(), self.ch_dssi.isChecked(), self.ch_lv2.isChecked(), self.ch_vst.isChecked(), - self.ch_gig.isChecked(), self.ch_sf2.isChecked(), self.ch_sfz.isChecked()) - - self.pThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64) - self.pThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, gig, sf2, sfz) - self.pThread.start() - - @pyqtSlot() - def slot_skip(self): - self.pThread.skipPlugin() - - @pyqtSlot(int, str) - def slot_handlePluginLook(self, percent, plugin): - self.progressBar.setFormat("%s" % plugin) - self.progressBar.setValue(percent) - - @pyqtSlot() - def slot_handlePluginThreadFinished(self): - self.progressBar.setMinimum(0) - self.progressBar.setMaximum(1) - self.progressBar.setValue(1) - self.progressBar.setFormat(self.tr("Done")) - self.b_start.setEnabled(True) - self.b_skip.setVisible(False) - self.b_close.setVisible(True) - - def saveSettings(self): - self.settings.setValue("PluginDatabase/SearchLADSPA", self.ch_ladspa.isChecked()) - self.settings.setValue("PluginDatabase/SearchDSSI", self.ch_dssi.isChecked()) - self.settings.setValue("PluginDatabase/SearchLV2", self.ch_lv2.isChecked()) - self.settings.setValue("PluginDatabase/SearchVST", self.ch_vst.isChecked()) - self.settings.setValue("PluginDatabase/SearchGIG", self.ch_gig.isChecked()) - self.settings.setValue("PluginDatabase/SearchSF2", self.ch_sf2.isChecked()) - self.settings.setValue("PluginDatabase/SearchSFZ", self.ch_sfz.isChecked()) - self.settings.setValue("PluginDatabase/SearchNative", self.ch_native.isChecked()) - self.settings.setValue("PluginDatabase/SearchPOSIX32", self.ch_posix32.isChecked()) - self.settings.setValue("PluginDatabase/SearchPOSIX64", self.ch_posix64.isChecked()) - self.settings.setValue("PluginDatabase/SearchWin32", self.ch_win32.isChecked()) - self.settings.setValue("PluginDatabase/SearchWin64", self.ch_win64.isChecked()) - self.settings_db.setValue("Plugins/LastLoadedBinary", "") - - def loadSettings(self): - self.ch_ladspa.setChecked(self.settings.value("PluginDatabase/SearchLADSPA", True, type=bool)) - self.ch_dssi.setChecked(self.settings.value("PluginDatabase/SearchDSSI", True, type=bool)) - self.ch_lv2.setChecked(self.settings.value("PluginDatabase/SearchLV2", True, type=bool)) - self.ch_vst.setChecked(self.settings.value("PluginDatabase/SearchVST", True, type=bool)) - self.ch_gig.setChecked(self.settings.value("PluginDatabase/SearchGIG", True, type=bool)) - self.ch_sf2.setChecked(self.settings.value("PluginDatabase/SearchSF2", True, type=bool)) - self.ch_sfz.setChecked(self.settings.value("PluginDatabase/SearchSFZ", True, type=bool)) - self.ch_native.setChecked(self.settings.value("PluginDatabase/SearchNative", True, type=bool)) - self.ch_posix32.setChecked(self.settings.value("PluginDatabase/SearchPOSIX32", False, type=bool)) - self.ch_posix64.setChecked(self.settings.value("PluginDatabase/SearchPOSIX64", False, type=bool)) - self.ch_win32.setChecked(self.settings.value("PluginDatabase/SearchWin32", False, type=bool)) - self.ch_win64.setChecked(self.settings.value("PluginDatabase/SearchWin64", False, type=bool)) - - def closeEvent(self, event): - if self.pThread.isRunning(): - self.pThread.terminate() - self.pThread.wait() - self.saveSettings() - QDialog.closeEvent(self, event) - - def done(self, r): - QDialog.done(self, r) - self.close() - -# Plugin Database Dialog -class PluginDatabaseW(QDialog, ui_carla_database.Ui_PluginDatabaseW): - def __init__(self, parent): - QDialog.__init__(self, parent) - self.setupUi(self) - - self.m_showOldWarning = False - - self.settings = self.parent().settings - self.settings_db = self.parent().settings_db - self.loadSettings() - - self.b_add.setEnabled(False) - - if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32): - self.ch_bridged.setText(self.tr("Bridged (64bit)")) - else: - self.ch_bridged.setText(self.tr("Bridged (32bit)")) - - if not (LINUX or MACOS): - self.ch_bridged_wine.setChecked(False) - self.ch_bridged_wine.setEnabled(False) - - # Blacklist plugins - if not self.settings_db.contains("Plugins/Blacklisted"): - blacklist = [] # FIXME - # Broken or useless plugins - #blacklist.append("dssi-vst.so") - blacklist.append("liteon_biquad-vst.so") - blacklist.append("liteon_biquad-vst_64bit.so") - blacklist.append("fx_blur-vst.so") - blacklist.append("fx_blur-vst_64bit.so") - blacklist.append("fx_tempodelay-vst.so") - blacklist.append("Scrubby_64bit.so") - blacklist.append("Skidder_64bit.so") - blacklist.append("libwormhole2_64bit.so") - blacklist.append("vexvst.so") - #blacklist.append("deckadance.dll") - self.settings_db.setValue("Plugins/Blacklisted", blacklist) - - self.connect(self.b_add, SIGNAL("clicked()"), SLOT("slot_add_plugin()")) - self.connect(self.b_refresh, SIGNAL("clicked()"), SLOT("slot_refresh_plugins()")) - self.connect(self.tb_filters, SIGNAL("clicked()"), SLOT("slot_maybe_show_filters()")) - self.connect(self.tableWidget, SIGNAL("currentCellChanged(int, int, int, int)"), SLOT("slot_checkPlugin(int)")) - self.connect(self.tableWidget, SIGNAL("cellDoubleClicked(int, int)"), SLOT("slot_add_plugin()")) - - self.connect(self.lineEdit, SIGNAL("textChanged(QString)"), SLOT("slot_checkFilters()")) - self.connect(self.ch_effects, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_instruments, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_midi, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_other, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_kits, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_internal, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_native, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_bridged, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_bridged_wine, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_gui, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - self.connect(self.ch_stereo, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) - - self.ret_plugin = None - - if self.m_showOldWarning: - QTimer.singleShot(0, self, SLOT("slot_showOldWarning()")) - - def showFilters(self, yesno): - self.tb_filters.setArrowType(Qt.UpArrow if yesno else Qt.DownArrow) - self.frame.setVisible(yesno) - - def checkInternalPlugins(self): - internals = toList(self.settings_db.value("Plugins/Internal", [])) - - count = 0 - - for plugins in internals: - for x in plugins: - count += 1 - - #if count != Carla.host.get_internal_plugin_count(): - #internal_plugins = [] - - #for i in range(Carla.host.get_internal_plugin_count()): - #descInfo = Carla.host.get_internal_plugin_info(i) - #plugins = checkPluginInternal(descInfo) - - #if plugins: - #internal_plugins.append(plugins) - - #self.settings_db.setValue("Plugins/Internal", internal_plugins) - #self.settings_db.sync() - - def reAddPlugins(self): - row_count = self.tableWidget.rowCount() - for x in range(row_count): - self.tableWidget.removeRow(0) - - self.last_table_index = 0 - self.tableWidget.setSortingEnabled(False) - - self.checkInternalPlugins() - - internals = toList(self.settings_db.value("Plugins/Internal", [])) - - ladspa_plugins = [] - ladspa_plugins += toList(self.settings_db.value("Plugins/LADSPA_native", [])) - ladspa_plugins += toList(self.settings_db.value("Plugins/LADSPA_posix32", [])) - ladspa_plugins += toList(self.settings_db.value("Plugins/LADSPA_posix64", [])) - ladspa_plugins += toList(self.settings_db.value("Plugins/LADSPA_win32", [])) - ladspa_plugins += toList(self.settings_db.value("Plugins/LADSPA_win64", [])) - - dssi_plugins = [] - dssi_plugins += toList(self.settings_db.value("Plugins/DSSI_native", [])) - dssi_plugins += toList(self.settings_db.value("Plugins/DSSI_posix32", [])) - dssi_plugins += toList(self.settings_db.value("Plugins/DSSI_posix64", [])) - dssi_plugins += toList(self.settings_db.value("Plugins/DSSI_win32", [])) - dssi_plugins += toList(self.settings_db.value("Plugins/DSSI_win64", [])) - - lv2_plugins = [] - lv2_plugins += toList(self.settings_db.value("Plugins/LV2_native", [])) - lv2_plugins += toList(self.settings_db.value("Plugins/LV2_posix32", [])) - lv2_plugins += toList(self.settings_db.value("Plugins/LV2_posix64", [])) - lv2_plugins += toList(self.settings_db.value("Plugins/LV2_win32", [])) - lv2_plugins += toList(self.settings_db.value("Plugins/LV2_win64", [])) - - vst_plugins = [] - vst_plugins += toList(self.settings_db.value("Plugins/VST_native", [])) - vst_plugins += toList(self.settings_db.value("Plugins/VST_posix32", [])) - vst_plugins += toList(self.settings_db.value("Plugins/VST_posix64", [])) - vst_plugins += toList(self.settings_db.value("Plugins/VST_win32", [])) - vst_plugins += toList(self.settings_db.value("Plugins/VST_win64", [])) - - gigs = toList(self.settings_db.value("Plugins/GIG", [])) - sf2s = toList(self.settings_db.value("Plugins/SF2", [])) - sfzs = toList(self.settings_db.value("Plugins/SFZ", [])) - - internal_count = 0 - ladspa_count = 0 - dssi_count = 0 - lv2_count = 0 - vst_count = 0 - kit_count = 0 - - for plugins in internals: - for plugin in plugins: - self.addPluginToTable(plugin, self.tr("Internal")) - internal_count += 1 - - for plugins in ladspa_plugins: - for plugin in plugins: - self.addPluginToTable(plugin, "LADSPA") - ladspa_count += 1 - - for plugins in dssi_plugins: - for plugin in plugins: - self.addPluginToTable(plugin, "DSSI") - dssi_count += 1 - - for plugins in lv2_plugins: - for plugin in plugins: - self.addPluginToTable(plugin, "LV2") - lv2_count += 1 - - for plugins in vst_plugins: - for plugin in plugins: - self.addPluginToTable(plugin, "VST") - vst_count += 1 - - for gig in gigs: - for gig_i in gig: - self.addPluginToTable(gig_i, "GIG") - kit_count += 1 - - for sf2 in sf2s: - for sf2_i in sf2: - self.addPluginToTable(sf2_i, "SF2") - kit_count += 1 - - for sfz in sfzs: - for sfz_i in sfz: - self.addPluginToTable(sfz_i, "SFZ") - kit_count += 1 - - self.slot_checkFilters() - self.tableWidget.setSortingEnabled(True) - self.tableWidget.sortByColumn(0, Qt.AscendingOrder) - - self.label.setText(self.tr("Have %i %s, %i LADSPA, %i DSSI, %i LV2, %i VST and %i Sound Kits" % (internal_count, self.tr("Internal"), ladspa_count, dssi_count, lv2_count, vst_count, kit_count))) - - def addPluginToTable(self, plugin, ptype): - index = self.last_table_index - - if self.m_showOldWarning or 'API' not in plugin.keys() or plugin['API'] < PLUGIN_QUERY_API_VERSION: - self.m_showOldWarning = True - return - - if plugin['build'] == BINARY_NATIVE: - bridge_text = self.tr("No") - else: - type_text = self.tr("Unknown") - if LINUX or MACOS: - if plugin['build'] == BINARY_POSIX32: - type_text = "32bit" - elif plugin['build'] == BINARY_POSIX64: - type_text = "64bit" - elif plugin['build'] == BINARY_WIN32: - type_text = "Windows 32bit" - elif plugin['build'] == BINARY_WIN64: - type_text = "Windows 64bit" - elif WINDOWS: - if plugin['build'] == BINARY_WIN32: - type_text = "32bit" - elif plugin['build'] == BINARY_WIN64: - type_text = "64bit" - bridge_text = self.tr("Yes (%s)" % type_text) - - self.tableWidget.insertRow(index) - self.tableWidget.setItem(index, 0, QTableWidgetItem(plugin['name'])) - self.tableWidget.setItem(index, 1, QTableWidgetItem(plugin['label'])) - self.tableWidget.setItem(index, 2, QTableWidgetItem(plugin['maker'])) - self.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['unique_id']))) - self.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins']))) - self.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs']))) - self.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins']))) - self.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs']))) - self.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total']))) - self.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_GUI) else self.tr("No"))) - self.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No"))) - self.tableWidget.setItem(index, 11, QTableWidgetItem(bridge_text)) - self.tableWidget.setItem(index, 12, QTableWidgetItem(ptype)) - self.tableWidget.setItem(index, 13, QTableWidgetItem(plugin['binary'])) - self.tableWidget.item(self.last_table_index, 0).plugin_data = plugin - self.last_table_index += 1 - - @pyqtSlot() - def slot_add_plugin(self): - if self.tableWidget.currentRow() >= 0: - self.ret_plugin = self.tableWidget.item(self.tableWidget.currentRow(), 0).plugin_data - self.accept() - else: - self.reject() - - @pyqtSlot() - def slot_refresh_plugins(self): - lastLoadedPlugin = self.settings_db.value("Plugins/LastLoadedBinary", "", type=str) - if lastLoadedPlugin: - lastLoadedPlugin = os.path.basename(lastLoadedPlugin) - ask = QMessageBox.question(self, self.tr("Warning"), self.tr("There was an error while checking the plugin %s.\n" - "Do you want to blacklist it?" % lastLoadedPlugin), - QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) - - if ask == QMessageBox.Yes: - blacklist = toList(self.settings_db.value("Plugins/Blacklisted", [])) - blacklist.append(lastLoadedPlugin) - self.settings_db.setValue("Plugins/Blacklisted", blacklist) - - #self.label.setText(self.tr("Looking for plugins...")) - PluginRefreshW(self).exec_() - - self.reAddPlugins() - self.parent().loadRDFs() - - @pyqtSlot() - def slot_maybe_show_filters(self): - self.showFilters(not self.frame.isVisible()) - - @pyqtSlot(int) - def slot_checkPlugin(self, row): - self.b_add.setEnabled(row >= 0) - - @pyqtSlot() - def slot_checkFilters(self): - text = self.lineEdit.text().lower() - - hide_effects = not self.ch_effects.isChecked() - hide_instruments = not self.ch_instruments.isChecked() - hide_midi = not self.ch_midi.isChecked() - hide_other = not self.ch_other.isChecked() - - hide_internal = not self.ch_internal.isChecked() - hide_ladspa = not self.ch_ladspa.isChecked() - hide_dssi = not self.ch_dssi.isChecked() - hide_lv2 = not self.ch_lv2.isChecked() - hide_vst = not self.ch_vst.isChecked() - hide_kits = not self.ch_kits.isChecked() - - hide_native = not self.ch_native.isChecked() - hide_bridged = not self.ch_bridged.isChecked() - hide_bridged_wine = not self.ch_bridged_wine.isChecked() - - hide_non_gui = self.ch_gui.isChecked() - hide_non_stereo = self.ch_stereo.isChecked() - - if HAIKU or LINUX or MACOS: - native_bins = [BINARY_POSIX32, BINARY_POSIX64] - wine_bins = [BINARY_WIN32, BINARY_WIN64] - elif WINDOWS: - native_bins = [BINARY_WIN32, BINARY_WIN64] - wine_bins = [] - else: - native_bins = [] - wine_bins = [] - - row_count = self.tableWidget.rowCount() - for i in range(row_count): - self.tableWidget.showRow(i) - - plugin = self.tableWidget.item(i, 0).plugin_data - ains = plugin['audio.ins'] - aouts = plugin['audio.outs'] - mins = plugin['midi.ins'] - mouts = plugin['midi.outs'] - ptype = self.tableWidget.item(i, 12).text() - is_synth = bool(plugin['hints'] & PLUGIN_IS_SYNTH) - is_effect = bool(ains > 0 < aouts and not is_synth) - is_midi = bool(ains == 0 and aouts == 0 and mins > 0 < mouts) - is_kit = bool(ptype in ("GIG", "SF2", "SFZ")) - is_other = bool(not (is_effect or is_synth or is_midi or is_kit)) - is_native = bool(plugin['build'] == BINARY_NATIVE) - is_stereo = bool(ains == 2 and aouts == 2) or (is_synth and aouts == 2) - has_gui = bool(plugin['hints'] & PLUGIN_HAS_GUI) - - is_bridged = bool(not is_native and plugin['build'] in native_bins) - is_bridged_wine = bool(not is_native and plugin['build'] in wine_bins) - - if (hide_effects and is_effect): - self.tableWidget.hideRow(i) - elif (hide_instruments and is_synth): - self.tableWidget.hideRow(i) - elif (hide_midi and is_midi): - self.tableWidget.hideRow(i) - elif (hide_other and is_other): - self.tableWidget.hideRow(i) - elif (hide_kits and is_kit): - self.tableWidget.hideRow(i) - elif (hide_internal and ptype == self.tr("Internal")): - self.tableWidget.hideRow(i) - elif (hide_ladspa and ptype == "LADSPA"): - self.tableWidget.hideRow(i) - elif (hide_dssi and ptype == "DSSI"): - self.tableWidget.hideRow(i) - elif (hide_lv2 and ptype == "LV2"): - self.tableWidget.hideRow(i) - elif (hide_vst and ptype == "VST"): - self.tableWidget.hideRow(i) - elif (hide_native and is_native): - self.tableWidget.hideRow(i) - elif (hide_bridged and is_bridged): - self.tableWidget.hideRow(i) - elif (hide_bridged_wine and is_bridged_wine): - self.tableWidget.hideRow(i) - elif (hide_non_gui and not has_gui): - self.tableWidget.hideRow(i) - elif (hide_non_stereo and not is_stereo): - self.tableWidget.hideRow(i) - elif (text and not ( - text in self.tableWidget.item(i, 0).text().lower() or - text in self.tableWidget.item(i, 1).text().lower() or - text in self.tableWidget.item(i, 2).text().lower() or - text in self.tableWidget.item(i, 3).text().lower() or - text in self.tableWidget.item(i, 13).text().lower())): - self.tableWidget.hideRow(i) - - @pyqtSlot() - def slot_showOldWarning(self): - QMessageBox.warning(self, self.tr("Warning"), self.tr("You're using a Carla-Database from an old version of Carla, please update *all* the plugins")) - - def saveSettings(self): - self.settings.setValue("PluginDatabase/Geometry", self.saveGeometry()) - self.settings.setValue("PluginDatabase/TableGeometry", self.tableWidget.horizontalHeader().saveState()) - self.settings.setValue("PluginDatabase/ShowFilters", (self.tb_filters.arrowType() == Qt.UpArrow)) - self.settings.setValue("PluginDatabase/ShowEffects", self.ch_effects.isChecked()) - self.settings.setValue("PluginDatabase/ShowInstruments", self.ch_instruments.isChecked()) - self.settings.setValue("PluginDatabase/ShowMIDI", self.ch_midi.isChecked()) - self.settings.setValue("PluginDatabase/ShowOther", self.ch_other.isChecked()) - self.settings.setValue("PluginDatabase/ShowInternal", self.ch_internal.isChecked()) - self.settings.setValue("PluginDatabase/ShowLADSPA", self.ch_ladspa.isChecked()) - self.settings.setValue("PluginDatabase/ShowDSSI", self.ch_dssi.isChecked()) - self.settings.setValue("PluginDatabase/ShowLV2", self.ch_lv2.isChecked()) - self.settings.setValue("PluginDatabase/ShowVST", self.ch_vst.isChecked()) - self.settings.setValue("PluginDatabase/ShowKits", self.ch_kits.isChecked()) - self.settings.setValue("PluginDatabase/ShowNative", self.ch_native.isChecked()) - self.settings.setValue("PluginDatabase/ShowBridged", self.ch_bridged.isChecked()) - self.settings.setValue("PluginDatabase/ShowBridgedWine", self.ch_bridged_wine.isChecked()) - self.settings.setValue("PluginDatabase/ShowHasGUI", self.ch_gui.isChecked()) - self.settings.setValue("PluginDatabase/ShowStereoOnly", self.ch_stereo.isChecked()) - - def loadSettings(self): - self.restoreGeometry(self.settings.value("PluginDatabase/Geometry", "")) - self.tableWidget.horizontalHeader().restoreState(self.settings.value("PluginDatabase/TableGeometry", "")) - self.showFilters(self.settings.value("PluginDatabase/ShowFilters", False, type=bool)) - self.ch_effects.setChecked(self.settings.value("PluginDatabase/ShowEffects", True, type=bool)) - self.ch_instruments.setChecked(self.settings.value("PluginDatabase/ShowInstruments", True, type=bool)) - self.ch_midi.setChecked(self.settings.value("PluginDatabase/ShowMIDI", True, type=bool)) - self.ch_other.setChecked(self.settings.value("PluginDatabase/ShowOther", True, type=bool)) - self.ch_internal.setChecked(self.settings.value("PluginDatabase/ShowInternal", True, type=bool)) - self.ch_ladspa.setChecked(self.settings.value("PluginDatabase/ShowLADSPA", True, type=bool)) - self.ch_dssi.setChecked(self.settings.value("PluginDatabase/ShowDSSI", True, type=bool)) - self.ch_lv2.setChecked(self.settings.value("PluginDatabase/ShowLV2", True, type=bool)) - self.ch_vst.setChecked(self.settings.value("PluginDatabase/ShowVST", True, type=bool)) - self.ch_kits.setChecked(self.settings.value("PluginDatabase/ShowKits", True, type=bool)) - self.ch_native.setChecked(self.settings.value("PluginDatabase/ShowNative", True, type=bool)) - self.ch_bridged.setChecked(self.settings.value("PluginDatabase/ShowBridged", True, type=bool)) - self.ch_bridged_wine.setChecked(self.settings.value("PluginDatabase/ShowBridgedWine", True, type=bool)) - self.ch_gui.setChecked(self.settings.value("PluginDatabase/ShowHasGUI", False, type=bool)) - self.ch_stereo.setChecked(self.settings.value("PluginDatabase/ShowStereoOnly", False, type=bool)) - self.reAddPlugins() - - def closeEvent(self, event): - self.saveSettings() - QDialog.closeEvent(self, event) - - def done(self, r): - QDialog.done(self, r) - self.close() - # Main Window class CarlaMainW(QMainWindow, ui_carla.Ui_CarlaMainW): def __init__(self, parent=None): diff --git a/source/carla_backend.py b/source/carla_backend.py index 95700915f..ae8fbbbcd 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -20,551 +20,18 @@ # Imports (Global) from ctypes import * -from subprocess import Popen, PIPE # ------------------------------------------------------------------------------------------------------------ # Imports (Custom) from carla_shared import * -try: - import ladspa_rdf - haveLRDF = True -except: - print("LRDF Support not available (LADSPA-RDF will be disabled)") - haveLRDF = False - # ------------------------------------------------------------------------------------------------------------ # Convert a ctypes struct into a python dict def structToDict(struct): return dict((attr, getattr(struct, attr)) for attr, value in struct._fields_) -# ------------------------------------------------------------------------------------------------------------ -# Default Plugin Folders - -if WINDOWS: - splitter = ";" - APPDATA = os.getenv("APPDATA") - PROGRAMFILES = os.getenv("PROGRAMFILES") - PROGRAMFILESx86 = os.getenv("PROGRAMFILES(x86)") - COMMONPROGRAMFILES = os.getenv("COMMONPROGRAMFILES") - - # Small integrity tests - if not APPDATA: - print("APPDATA variable not set, cannot continue") - sys.exit(1) - - if not PROGRAMFILES: - print("PROGRAMFILES variable not set, cannot continue") - sys.exit(1) - - if not COMMONPROGRAMFILES: - print("COMMONPROGRAMFILES variable not set, cannot continue") - sys.exit(1) - - DEFAULT_LADSPA_PATH = [ - os.path.join(APPDATA, "LADSPA"), - os.path.join(PROGRAMFILES, "LADSPA") - ] - - DEFAULT_DSSI_PATH = [ - os.path.join(APPDATA, "DSSI"), - os.path.join(PROGRAMFILES, "DSSI") - ] - - DEFAULT_LV2_PATH = [ - os.path.join(APPDATA, "LV2"), - os.path.join(COMMONPROGRAMFILES, "LV2") - ] - - DEFAULT_VST_PATH = [ - os.path.join(PROGRAMFILES, "VstPlugins"), - os.path.join(PROGRAMFILES, "Steinberg", "VstPlugins") - ] - - DEFAULT_GIG_PATH = [ - os.path.join(APPDATA, "GIG") - ] - - DEFAULT_SF2_PATH = [ - os.path.join(APPDATA, "SF2") - ] - - DEFAULT_SFZ_PATH = [ - os.path.join(APPDATA, "SFZ") - ] - - if PROGRAMFILESx86: - DEFAULT_LADSPA_PATH.append(os.path.join(PROGRAMFILESx86, "LADSPA")) - DEFAULT_DSSI_PATH.append(os.path.join(PROGRAMFILESx86, "DSSI")) - DEFAULT_VST_PATH.append(os.path.join(PROGRAMFILESx86, "VstPlugins")) - DEFAULT_VST_PATH.append(os.path.join(PROGRAMFILESx86, "Steinberg", "VstPlugins")) - -elif HAIKU: - splitter = ":" - - DEFAULT_LADSPA_PATH = [ - # TODO - ] - - DEFAULT_DSSI_PATH = [ - # TODO - ] - - DEFAULT_LV2_PATH = [ - # TODO - ] - - DEFAULT_VST_PATH = [ - # TODO - ] - - DEFAULT_GIG_PATH = [ - # TODO - ] - - DEFAULT_SF2_PATH = [ - # TODO - ] - - DEFAULT_SFZ_PATH = [ - # TODO - ] - -elif MACOS: - splitter = ":" - - DEFAULT_LADSPA_PATH = [ - os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LADSPA"), - os.path.join("/", "Library", "Audio", "Plug-Ins", "LADSPA") - ] - - DEFAULT_DSSI_PATH = [ - os.path.join(HOME, "Library", "Audio", "Plug-Ins", "DSSI"), - os.path.join("/", "Library", "Audio", "Plug-Ins", "DSSI") - ] - - DEFAULT_LV2_PATH = [ - os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LV2"), - os.path.join("/", "Library", "Audio", "Plug-Ins", "LV2") - ] - - DEFAULT_VST_PATH = [ - os.path.join(HOME, "Library", "Audio", "Plug-Ins", "VST"), - os.path.join("/", "Library", "Audio", "Plug-Ins", "VST") - ] - - DEFAULT_GIG_PATH = [ - # TODO - ] - - DEFAULT_SF2_PATH = [ - # TODO - ] - - DEFAULT_SFZ_PATH = [ - # TODO - ] - -else: - splitter = ":" - - DEFAULT_LADSPA_PATH = [ - os.path.join(HOME, ".ladspa"), - os.path.join("/", "usr", "lib", "ladspa"), - os.path.join("/", "usr", "local", "lib", "ladspa") - ] - - DEFAULT_DSSI_PATH = [ - os.path.join(HOME, ".dssi"), - os.path.join("/", "usr", "lib", "dssi"), - os.path.join("/", "usr", "local", "lib", "dssi") - ] - - DEFAULT_LV2_PATH = [ - os.path.join(HOME, ".lv2"), - os.path.join("/", "usr", "lib", "lv2"), - os.path.join("/", "usr", "local", "lib", "lv2") - ] - - DEFAULT_VST_PATH = [ - os.path.join(HOME, ".vst"), - os.path.join("/", "usr", "lib", "vst"), - os.path.join("/", "usr", "local", "lib", "vst") - ] - - DEFAULT_GIG_PATH = [ - os.path.join(HOME, ".sounds"), - os.path.join("/", "usr", "share", "sounds", "gig") - ] - - DEFAULT_SF2_PATH = [ - os.path.join(HOME, ".sounds"), - os.path.join("/", "usr", "share", "sounds", "sf2") - ] - - DEFAULT_SFZ_PATH = [ - os.path.join(HOME, ".sounds"), - os.path.join("/", "usr", "share", "sounds", "sfz") - ] - -# ------------------------------------------------------------------------------------------------------------ -# Default Plugin Folders (set) - -global LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, GIG_PATH, SF2_PATH, SFZ_PATH - -LADSPA_PATH = os.getenv("LADSPA_PATH", DEFAULT_LADSPA_PATH) -DSSI_PATH = os.getenv("DSSI_PATH", DEFAULT_DSSI_PATH) -LV2_PATH = os.getenv("LV2_PATH", DEFAULT_LV2_PATH) -VST_PATH = os.getenv("VST_PATH", DEFAULT_VST_PATH) -GIG_PATH = os.getenv("GIG_PATH", DEFAULT_GIG_PATH) -SF2_PATH = os.getenv("SF2_PATH", DEFAULT_SF2_PATH) -SFZ_PATH = os.getenv("SFZ_PATH", DEFAULT_SFZ_PATH) - -if haveLRDF: - LADSPA_RDF_PATH_env = os.getenv("LADSPA_RDF_PATH") - if LADSPA_RDF_PATH_env: - ladspa_rdf.set_rdf_path(LADSPA_RDF_PATH_env.split(splitter)) - del LADSPA_RDF_PATH_env - -# ------------------------------------------------------------------------------------------------------------ -# Search for Carla library and tools - -global carla_library_path -carla_library_path = "" - -carla_discovery_native = "" -carla_discovery_posix32 = "" -carla_discovery_posix64 = "" -carla_discovery_win32 = "" -carla_discovery_win64 = "" - -carla_bridge_native = "" -carla_bridge_posix32 = "" -carla_bridge_posix64 = "" -carla_bridge_win32 = "" -carla_bridge_win64 = "" - -carla_bridge_lv2_gtk2 = "" -carla_bridge_lv2_gtk3 = "" -carla_bridge_lv2_qt4 = "" -carla_bridge_lv2_qt5 = "" -carla_bridge_lv2_cocoa = "" -carla_bridge_lv2_windows = "" -carla_bridge_lv2_x11 = "" - -carla_bridge_vst_cocoa = "" -carla_bridge_vst_hwnd = "" -carla_bridge_vst_x11 = "" - -if WINDOWS: - carla_libname = "libcarla_standalone.dll" -elif MACOS: - carla_libname = "libcarla_standalone.dylib" -else: - carla_libname = "libcarla_standalone.so" - -CWD = sys.path[0] - -# make it work with cxfreeze -if CWD.endswith("%scarla" % os.sep): - CWD = CWD.rsplit("%scarla" % os.sep, 1)[0] - -# find carla_library_path -if os.path.exists(os.path.join(CWD, "backend", carla_libname)): - carla_library_path = os.path.join(CWD, "backend", carla_libname) -else: - if WINDOWS: - CARLA_PATH = (os.path.join(PROGRAMFILES, "Carla"),) - elif MACOS: - CARLA_PATH = ("/opt/local/lib", "/usr/local/lib/", "/usr/lib") - else: - CARLA_PATH = ("/usr/local/lib/", "/usr/lib") - - for path in CARLA_PATH: - if os.path.exists(os.path.join(path, "carla", carla_libname)): - carla_library_path = os.path.join(path, "carla", carla_libname) - break - -# find any tool -def findTool(tdir, tname): - if os.path.exists(os.path.join(CWD, tdir, tname)): - return os.path.join(CWD, tdir, tname) - - for p in PATH: - if os.path.exists(os.path.join(p, tname)): - return os.path.join(p, tname) - - return "" - -# find wine/windows tools -carla_discovery_win32 = findTool("carla-discovery", "carla-discovery-win32.exe") -carla_discovery_win64 = findTool("carla-discovery", "carla-discovery-win64.exe") -carla_bridge_win32 = findTool("carla-bridge", "carla-bridge-win32.exe") -carla_bridge_win64 = findTool("carla-bridge", "carla-bridge-win64.exe") - -# find native and posix tools -if not WINDOWS: - carla_discovery_native = findTool("carla-discovery", "carla-discovery-native") - carla_discovery_posix32 = findTool("carla-discovery", "carla-discovery-posix32") - carla_discovery_posix64 = findTool("carla-discovery", "carla-discovery-posix64") - carla_bridge_native = findTool("carla-bridge", "carla-bridge-native") - carla_bridge_posix32 = findTool("carla-bridge", "carla-bridge-posix32") - carla_bridge_posix64 = findTool("carla-bridge", "carla-bridge-posix64") - -# find windows only tools -if WINDOWS: - carla_bridge_lv2_windows = findTool("carla-bridge", "carla-bridge-lv2-windows.exe") - carla_bridge_vst_hwnd = findTool("carla-bridge", "carla-bridge-vst-hwnd.exe") - -# find mac os only tools -elif MACOS: - carla_bridge_lv2_cocoa = findTool("carla-bridge", "carla-bridge-lv2-cocoa") - carla_bridge_vst_cocoa = findTool("carla-bridge", "carla-bridge-vst-cocoa") - -# find generic tools -else: - carla_bridge_lv2_gtk2 = findTool("carla-bridge", "carla-bridge-lv2-gtk2") - carla_bridge_lv2_gtk3 = findTool("carla-bridge", "carla-bridge-lv2-gtk3") - carla_bridge_lv2_qt4 = findTool("carla-bridge", "carla-bridge-lv2-qt4") - carla_bridge_lv2_qt5 = findTool("carla-bridge", "carla-bridge-lv2-qt5") - -# find linux only tools -if LINUX: - carla_bridge_lv2_x11 = os.path.join("carla-bridge", "carla-bridge-lv2-x11") - carla_bridge_vst_x11 = os.path.join("carla-bridge", "carla-bridge-vst-x11") - -# ------------------------------------------------------------------------------------------------------------ -# Plugin Query (helper functions) - -def findBinaries(bPATH, OS): - binaries = [] - - if OS == "WINDOWS": - extensions = (".dll",) - elif OS == "MACOS": - extensions = (".dylib", ".so") - else: - extensions = (".so", ".sO", ".SO", ".So") - - for root, dirs, files in os.walk(bPATH): - for name in [name for name in files if name.endswith(extensions)]: - binaries.append(os.path.join(root, name)) - - return binaries - -# FIXME - may use any extension, just needs to have manifest.ttl -def findLV2Bundles(bPATH): - bundles = [] - extensions = (".lv2", ".lV2", ".LV2", ".Lv2") if not WINDOWS else (".lv2",) - - for root, dirs, files in os.walk(bPATH): - for dir_ in [dir_ for dir_ in dirs if dir_.endswith(extensions)]: - bundles.append(os.path.join(root, dir_)) - - return bundles - -def findSoundKits(bPATH, stype): - soundfonts = [] - - if stype == "gig": - extensions = (".gig", ".giG", ".gIG", ".GIG", ".GIg", ".Gig") if not WINDOWS else (".gig",) - elif stype == "sf2": - extensions = (".sf2", ".sF2", ".SF2", ".Sf2") if not WINDOWS else (".sf2",) - elif stype == "sfz": - extensions = (".sfz", ".sfZ", ".sFZ", ".SFZ", ".SFz", ".Sfz") if not WINDOWS else (".sfz",) - else: - return [] - - for root, dirs, files in os.walk(bPATH): - for name in [name for name in files if name.endswith(extensions)]: - soundfonts.append(os.path.join(root, name)) - - return soundfonts - -def findDSSIGUI(filename, name, label): - pluginDir = filename.rsplit(".", 1)[0] - shortName = os.path.basename(pluginDir) - guiFilename = "" - - checkName = name.replace(" ", "_") - checkLabel = label - checkSName = shortName - - if checkName[-1] != "_": checkName += "_" - if checkLabel[-1] != "_": checkLabel += "_" - if checkSName[-1] != "_": checkSName += "_" - - for root, dirs, files in os.walk(pluginDir): - guiFiles = files - break - else: - guiFiles = [] - - for gui in guiFiles: - if gui.startswith(checkName) or gui.startswith(checkLabel) or gui.startswith(checkSName): - guiFilename = os.path.join(pluginDir, gui) - break - - return guiFilename - -# ------------------------------------------------------------------------------------------------------------ -# Plugin Query - -PLUGIN_QUERY_API_VERSION = 1 - -PyPluginInfo = { - 'API': PLUGIN_QUERY_API_VERSION, - 'build': 0, # BINARY_NONE - 'type': 0, # PLUGIN_NONE - 'hints': 0x0, - 'binary': "", - 'name': "", - 'label': "", - 'maker': "", - 'copyright': "", - 'uniqueId': 0, - 'audio.ins': 0, - 'audio.outs': 0, - 'audio.totals': 0, - 'midi.ins': 0, - 'midi.outs': 0, - 'midi.totals': 0, - 'parameters.ins': 0, - 'parameters.outs': 0, - 'parameters.total': 0, - 'programs.total': 0 -} - -def runCarlaDiscovery(itype, stype, filename, tool, isWine=False): - fakeLabel = os.path.basename(filename).rsplit(".", 1)[0] - plugins = [] - command = [] - - if LINUX or MACOS: - command.append("env") - command.append("LANG=C") - if isWine: - command.append("WINEDEBUG=-all") - - command.append(tool) - command.append(stype) - command.append(filename) - - Ps = Popen(command, stdout=PIPE) - Ps.wait() - output = Ps.stdout.read().decode("utf-8", errors="ignore").split("\n") - - pinfo = None - - for line in output: - line = line.strip() - if line == "carla-discovery::init::-----------": - pinfo = deepcopy(PyPluginInfo) - pinfo['type'] = itype - pinfo['binary'] = filename - - elif line == "carla-discovery::end::------------": - if pinfo != None: - plugins.append(pinfo) - pinfo = None - - elif line == "Segmentation fault": - print("carla-discovery::crash::%s crashed during discovery" % filename) - - elif line.startswith("err:module:import_dll Library"): - print(line) - - elif line.startswith("carla-discovery::error::"): - print("%s - %s" % (line, filename)) - - elif line.startswith("carla-discovery::"): - if pinfo == None: - continue - - prop, value = line.replace("carla-discovery::", "").split("::", 1) - - if prop == "name": - pinfo['name'] = value if value else fakeLabel - elif prop == "label": - pinfo['label'] = value if value else fakeLabel - elif prop == "maker": - pinfo['maker'] = value - elif prop == "copyright": - pinfo['copyright'] = value - elif prop == "uniqueId": - if value.isdigit(): pinfo['uniqueId'] = int(value) - elif prop == "hints": - if value.isdigit(): pinfo['hints'] = int(value) - elif prop == "audio.ins": - if value.isdigit(): pinfo['audio.ins'] = int(value) - elif prop == "audio.outs": - if value.isdigit(): pinfo['audio.outs'] = int(value) - elif prop == "audio.total": - if value.isdigit(): pinfo['audio.total'] = int(value) - elif prop == "midi.ins": - if value.isdigit(): pinfo['midi.ins'] = int(value) - elif prop == "midi.outs": - if value.isdigit(): pinfo['midi.outs'] = int(value) - elif prop == "midi.total": - if value.isdigit(): pinfo['midi.total'] = int(value) - elif prop == "parameters.ins": - if value.isdigit(): pinfo['parameters.ins'] = int(value) - elif prop == "parameters.outs": - if value.isdigit(): pinfo['parameters.outs'] = int(value) - elif prop == "parameters.total": - if value.isdigit(): pinfo['parameters.total'] = int(value) - elif prop == "programs.total": - if value.isdigit(): pinfo['programs.total'] = int(value) - elif prop == "build": - if value.isdigit(): pinfo['build'] = int(value) - - # Additional checks - for pinfo in plugins: - if itype == PLUGIN_DSSI: - if findDSSIGUI(pinfo['binary'], pinfo['name'], pinfo['label']): - pinfo['hints'] |= PLUGIN_HAS_GUI - - return plugins - -def checkPluginInternal(desc): - plugins = [] - - pinfo = deepcopy(PyPluginInfo) - pinfo['type'] = PLUGIN_INTERNAL - pinfo['name'] = cString(desc['name']) - pinfo['label'] = cString(desc['label']) - pinfo['maker'] = cString(desc['maker']) - pinfo['copyright'] = cString(desc['copyright']) - pinfo['hints'] = int(desc['hints']) - pinfo['build'] = BINARY_NATIVE - - plugins.append(pinfo) - - return plugins - -def checkPluginLADSPA(filename, tool, isWine=False): - return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, isWine) - -def checkPluginDSSI(filename, tool, isWine=False): - return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, isWine) - -def checkPluginLV2(filename, tool, isWine=False): - return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, isWine) - -def checkPluginVST(filename, tool, isWine=False): - return runCarlaDiscovery(PLUGIN_VST, "VST", filename, tool, isWine) - -def checkPluginGIG(filename, tool): - return runCarlaDiscovery(PLUGIN_GIG, "GIG", filename, tool) - -def checkPluginSF2(filename, tool): - return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool) - -def checkPluginSFZ(filename, tool): - return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool) - # ------------------------------------------------------------------------------------------------------------ # Backend C++ -> Python variables @@ -705,6 +172,9 @@ class Host(object): self.lib.carla_engine_close.argtypes = None self.lib.carla_engine_close.restype = c_bool + self.lib.carla_engine_idle.argtypes = None + self.lib.carla_engine_idle.restype = None + self.lib.carla_is_engine_running.argtypes = None self.lib.carla_is_engine_running.restype = c_bool @@ -759,104 +229,103 @@ class Host(object): self.lib.carla_get_custom_data_count.argtypes = [c_uint] self.lib.carla_get_custom_data_count.restype = c_uint32 - #self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32] - #self.lib.carla_get_parameter_text.restype = c_char_p - - #self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32] - #self.lib.carla_get_program_name.restype = c_char_p + self.lib.carla_get_parameter_text.argtypes = [c_uint, c_uint32] + self.lib.carla_get_parameter_text.restype = c_char_p - #self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32] - #self.lib.carla_get_midi_program_name.restype = c_char_p + self.lib.carla_get_program_name.argtypes = [c_uint, c_uint32] + self.lib.carla_get_program_name.restype = c_char_p - #self.lib.carla_get_real_plugin_name.argtypes = [c_uint] - #self.lib.carla_get_real_plugin_name.restype = c_char_p + self.lib.carla_get_midi_program_name.argtypes = [c_uint, c_uint32] + self.lib.carla_get_midi_program_name.restype = c_char_p - #self.lib.carla_get_current_program_index.argtypes = [c_uint] - #self.lib.carla_get_current_program_index.restype = c_int32 + self.lib.carla_get_real_plugin_name.argtypes = [c_uint] + self.lib.carla_get_real_plugin_name.restype = c_char_p - #self.lib.carla_get_current_midi_program_index.argtypes = [c_uint] - #self.lib.carla_get_current_midi_program_index.restype = c_int32 + self.lib.carla_get_current_program_index.argtypes = [c_uint] + self.lib.carla_get_current_program_index.restype = c_int32 - #self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32] - #self.lib.carla_get_default_parameter_value.restype = c_double + self.lib.carla_get_current_midi_program_index.argtypes = [c_uint] + self.lib.carla_get_current_midi_program_index.restype = c_int32 - #self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32] - #self.lib.carla_get_current_parameter_value.restype = c_double + # TODO - consider removal + self.lib.carla_get_default_parameter_value.argtypes = [c_uint, c_uint32] + self.lib.carla_get_default_parameter_value.restype = c_float - #self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort] - #self.lib.carla_get_input_peak_value.restype = c_double + # TODO - consider removal + self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32] + self.lib.carla_get_current_parameter_value.restype = c_float - #self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort] - #self.lib.carla_get_output_peak_value.restype = c_double + self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_ushort] + self.lib.carla_get_input_peak_value.restype = c_float - #self.lib.carla_set_active.argtypes = [c_uint, c_bool] - #self.lib.carla_set_active.restype = None + self.lib.carla_get_output_peak_value.argtypes = [c_uint, c_ushort] + self.lib.carla_get_output_peak_value.restype = c_float - #self.lib.carla_set_drywet.argtypes = [c_uint, c_double] - #self.lib.carla_set_drywet.restype = None + self.lib.carla_set_active.argtypes = [c_uint, c_bool] + self.lib.carla_set_active.restype = None - #self.lib.carla_set_volume.argtypes = [c_uint, c_double] - #self.lib.carla_set_volume.restype = None + self.lib.carla_set_drywet.argtypes = [c_uint, c_float] + self.lib.carla_set_drywet.restype = None - #self.lib.carla_set_balance_left.argtypes = [c_uint, c_double] - #self.lib.carla_set_balance_left.restype = None + self.lib.carla_set_volume.argtypes = [c_uint, c_float] + self.lib.carla_set_volume.restype = None - #self.lib.carla_set_balance_right.argtypes = [c_uint, c_double] - #self.lib.carla_set_balance_right.restype = None + self.lib.carla_set_balance_left.argtypes = [c_uint, c_float] + self.lib.carla_set_balance_left.restype = None - #self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_double] - #self.lib.carla_set_parameter_value.restype = None + self.lib.carla_set_balance_right.argtypes = [c_uint, c_float] + self.lib.carla_set_balance_right.restype = None - #self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16] - #self.lib.carla_set_parameter_midi_cc.restype = None + self.lib.carla_set_panning.argtypes = [c_uint, c_float] + self.lib.carla_set_panning.restype = None - #self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8] - #self.lib.carla_set_parameter_midi_channel.restype = None + self.lib.carla_set_parameter_value.argtypes = [c_uint, c_uint32, c_float] + self.lib.carla_set_parameter_value.restype = None - #self.lib.carla_set_program.argtypes = [c_uint, c_uint32] - #self.lib.carla_set_program.restype = None + self.lib.carla_set_parameter_midi_cc.argtypes = [c_uint, c_uint32, c_int16] + self.lib.carla_set_parameter_midi_cc.restype = None - #self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32] - #self.lib.carla_set_midi_program.restype = None + self.lib.carla_set_parameter_midi_channel.argtypes = [c_uint, c_uint32, c_uint8] + self.lib.carla_set_parameter_midi_channel.restype = None - #self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p] - #self.lib.carla_set_custom_data.restype = None + self.lib.carla_set_program.argtypes = [c_uint, c_uint32] + self.lib.carla_set_program.restype = None - #self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p] - #self.lib.carla_set_chunk_data.restype = None + self.lib.carla_set_midi_program.argtypes = [c_uint, c_uint32] + self.lib.carla_set_midi_program.restype = None - #self.lib.carla_set_gui_container.argtypes = [c_uint, c_uintptr] - #self.lib.carla_set_gui_container.restype = None + self.lib.carla_set_custom_data.argtypes = [c_uint, c_char_p, c_char_p, c_char_p] + self.lib.carla_set_custom_data.restype = None - #self.lib.show_gui.argtypes = [c_uint, c_bool] - #self.lib.show_gui.restype = None + self.lib.carla_set_chunk_data.argtypes = [c_uint, c_char_p] + self.lib.carla_set_chunk_data.restype = None - #self.lib.idle_guis.argtypes = None - #self.lib.idle_guis.restype = None + self.lib.carla_prepare_for_save.argtypes = [c_uint] + self.lib.carla_prepare_for_save.restype = None - #self.lib.send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8] - #self.lib.send_midi_note.restype = None + self.lib.carla_send_midi_note.argtypes = [c_uint, c_uint8, c_uint8, c_uint8] + self.lib.carla_send_midi_note.restype = None - #self.lib.prepare_for_save.argtypes = [c_uint] - #self.lib.prepare_for_save.restype = None + self.lib.carla_show_gui.argtypes = [c_uint, c_bool] + self.lib.carla_show_gui.restype = None - #self.lib.carla_get_buffer_size.argtypes = None - #self.lib.carla_get_buffer_size.restype = c_uint32 + self.lib.carla_get_buffer_size.argtypes = None + self.lib.carla_get_buffer_size.restype = c_uint32 - #self.lib.carla_get_sample_rate.argtypes = None - #self.lib.carla_get_sample_rate.restype = c_double + self.lib.carla_get_sample_rate.argtypes = None + self.lib.carla_get_sample_rate.restype = c_double - #self.lib.carla_get_last_error.argtypes = None - #self.lib.carla_get_last_error.restype = c_char_p + self.lib.carla_get_last_error.argtypes = None + self.lib.carla_get_last_error.restype = c_char_p - #self.lib.carla_get_host_osc_url.argtypes = None - #self.lib.carla_get_host_osc_url.restype = c_char_p + self.lib.carla_get_host_osc_url.argtypes = None + self.lib.carla_get_host_osc_url.restype = c_char_p - #self.lib.carla_set_callback_function.argtypes = [CallbackFunc] - #self.lib.carla_set_callback_function.restype = None + self.lib.carla_set_callback_function.argtypes = [CallbackFunc] + self.lib.carla_set_callback_function.restype = None - #self.lib.carla_set_option.argtypes = [c_enum, c_int, c_char_p] - #self.lib.carla_set_option.restype = None + self.lib.carla_set_option.argtypes = [c_enum, c_int, c_char_p] + self.lib.carla_set_option.restype = None #self.lib.nsm_announce.argtypes = [c_char_p, c_int] #self.lib.nsm_announce.restype = None @@ -888,6 +357,9 @@ class Host(object): def engine_close(self): return self.lib.carla_engine_close() + def engine_idle(self): + return self.lib.carla_engine_idle() + def is_engine_running(self): return self.lib.carla_is_engine_running() @@ -925,126 +397,120 @@ class Host(object): def get_midi_program_data(self, pluginId, midiProgramId): return structToDict(self.lib.carla_get_midi_program_data(pluginId, midiProgramId).contents) - #def get_custom_data(self, pluginId, customDataId): - #return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents) - - #def get_chunk_data(self, pluginId): - #return self.lib.carla_get_chunk_data(pluginId) - - #def get_gui_info(self, pluginId): - #return structToDict(self.lib.carla_get_gui_info(pluginId).contents) + def get_custom_data(self, pluginId, customDataId): + return structToDict(self.lib.carla_get_custom_data(pluginId, customDataId).contents) - #def get_parameter_count(self, pluginId): - #return self.lib.carla_get_parameter_count(pluginId) + def get_chunk_data(self, pluginId): + return self.lib.carla_get_chunk_data(pluginId) - #def get_program_count(self, pluginId): - #return self.lib.carla_get_program_count(pluginId) + def get_parameter_count(self, pluginId): + return self.lib.carla_get_parameter_count(pluginId) - #def get_midi_program_count(self, pluginId): - #return self.lib.carla_get_midi_program_count(pluginId) + def get_program_count(self, pluginId): + return self.lib.carla_get_program_count(pluginId) - #def get_custom_data_count(self, pluginId): - #return self.lib.carla_get_custom_data_count(pluginId) + def get_midi_program_count(self, pluginId): + return self.lib.carla_get_midi_program_count(pluginId) - #def get_parameter_text(self, pluginId, parameterId): - #return self.lib.carla_get_parameter_text(pluginId, parameterId) + def get_custom_data_count(self, pluginId): + return self.lib.carla_get_custom_data_count(pluginId) - #def get_program_name(self, pluginId, programId): - #return self.lib.carla_get_program_name(pluginId, programId) + def get_parameter_text(self, pluginId, parameterId): + return self.lib.carla_get_parameter_text(pluginId, parameterId) - #def get_midi_program_name(self, pluginId, midiProgramId): - #return self.lib.carla_get_midi_program_name(pluginId, midiProgramId) + def get_program_name(self, pluginId, programId): + return self.lib.carla_get_program_name(pluginId, programId) - #def get_real_plugin_name(self, pluginId): - #return self.lib.carla_get_real_plugin_name(pluginId) + def get_midi_program_name(self, pluginId, midiProgramId): + return self.lib.carla_get_midi_program_name(pluginId, midiProgramId) - #def get_current_program_index(self, pluginId): - #return self.lib.carla_get_current_program_index(pluginId) + def get_real_plugin_name(self, pluginId): + return self.lib.carla_get_real_plugin_name(pluginId) - #def get_current_midi_program_index(self, pluginId): - #return self.lib.carla_get_current_midi_program_index(pluginId) + def get_current_program_index(self, pluginId): + return self.lib.carla_get_current_program_index(pluginId) - #def get_default_parameter_value(self, pluginId, parameterId): - #return self.lib.carla_get_default_parameter_value(pluginId, parameterId) + def get_current_midi_program_index(self, pluginId): + return self.lib.carla_get_current_midi_program_index(pluginId) - #def get_current_parameter_value(self, pluginId, parameterId): - #return self.lib.carla_get_current_parameter_value(pluginId, parameterId) + def get_default_parameter_value(self, pluginId, parameterId): + return self.lib.carla_get_default_parameter_value(pluginId, parameterId) - #def get_input_peak_value(self, pluginId, portId): - #return self.lib.carla_get_input_peak_value(pluginId, portId) + def get_current_parameter_value(self, pluginId, parameterId): + return self.lib.carla_get_current_parameter_value(pluginId, parameterId) - #def get_output_peak_value(self, pluginId, portId): - #return self.lib.carla_get_output_peak_value(pluginId, portId) + def get_input_peak_value(self, pluginId, portId): + return self.lib.carla_get_input_peak_value(pluginId, portId) - #def set_active(self, pluginId, onOff): - #self.lib.carla_set_active(pluginId, onOff) + def get_output_peak_value(self, pluginId, portId): + return self.lib.carla_get_output_peak_value(pluginId, portId) - #def set_drywet(self, pluginId, value): - #self.lib.carla_set_drywet(pluginId, value) + def set_active(self, pluginId, onOff): + self.lib.carla_set_active(pluginId, onOff) - #def set_volume(self, pluginId, value): - #self.lib.carla_set_volume(pluginId, value) + def set_drywet(self, pluginId, value): + self.lib.carla_set_drywet(pluginId, value) - #def set_balance_left(self, pluginId, value): - #self.lib.carla_set_balance_left(pluginId, value) + def set_volume(self, pluginId, value): + self.lib.carla_set_volume(pluginId, value) - #def set_balance_right(self, pluginId, value): - #self.lib.carla_set_balance_right(pluginId, value) + def set_balance_left(self, pluginId, value): + self.lib.carla_set_balance_left(pluginId, value) - #def set_parameter_value(self, pluginId, parameterId, value): - #self.lib.carla_set_parameter_value(pluginId, parameterId, value) + def set_balance_right(self, pluginId, value): + self.lib.carla_set_balance_right(pluginId, value) - #def set_parameter_midi_cc(self, pluginId, parameterId, cc): - #self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc) + def set_panning(self, pluginId, value): + self.lib.carla_set_panning(pluginId, value) - #def set_parameter_midi_channel(self, pluginId, parameterId, channel): - #self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel) + def set_parameter_value(self, pluginId, parameterId, value): + self.lib.carla_set_parameter_value(pluginId, parameterId, value) - #def set_program(self, pluginId, programId): - #self.lib.carla_set_program(pluginId, programId) + def set_parameter_midi_cc(self, pluginId, parameterId, cc): + self.lib.carla_set_parameter_midi_cc(pluginId, parameterId, cc) - #def set_midi_program(self, pluginId, midiProgramId): - #self.lib.carla_set_midi_program(pluginId, midiProgramId) + def set_parameter_midi_channel(self, pluginId, parameterId, channel): + self.lib.carla_set_parameter_midi_channel(pluginId, parameterId, channel) - #def set_custom_data(self, pluginId, type_, key, value): - #self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8")) + def set_program(self, pluginId, programId): + self.lib.carla_set_program(pluginId, programId) - #def set_chunk_data(self, pluginId, chunkData): - #self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8")) + def set_midi_program(self, pluginId, midiProgramId): + self.lib.carla_set_midi_program(pluginId, midiProgramId) - #def set_gui_container(self, pluginId, guiAddr): - #self.lib.carla_set_gui_container(pluginId, guiAddr) + def set_custom_data(self, pluginId, type_, key, value): + self.lib.carla_set_custom_data(pluginId, type_.encode("utf-8"), key.encode("utf-8"), value.encode("utf-8")) - #def show_gui(self, pluginId, yesNo): - #self.lib.show_gui(pluginId, yesNo) + def set_chunk_data(self, pluginId, chunkData): + self.lib.carla_set_chunk_data(pluginId, chunkData.encode("utf-8")) - #def idle_guis(self): - #self.lib.idle_guis() + def prepare_for_save(self, pluginId): + self.lib.carla_prepare_for_save(pluginId) - #def send_midi_note(self, pluginId, channel, note, velocity): - #self.lib.send_midi_note(pluginId, channel, note, velocity) + def send_midi_note(self, pluginId, channel, note, velocity): + self.lib.carla_send_midi_note(pluginId, channel, note, velocity) - #def prepare_for_save(self, pluginId): - #self.lib.prepare_for_save(pluginId) + def show_gui(self, pluginId, yesNo): + self.lib.carla_show_gui(pluginId, yesNo) - #def set_callback_function(self, func): - #self.callback = CallbackFunc(func) - #self.lib.carla_set_callback_function(self.callback) + def get_last_error(self): + return self.lib.carla_get_last_error() - #def set_option(self, option, value, valueStr): - #self.lib.carla_set_option(option, value, valueStr.encode("utf-8")) + def get_host_osc_url(self): + return self.lib.carla_get_host_osc_url() - #def get_last_error(self): - #return self.lib.carla_get_last_error() + def get_buffer_size(self): + return self.lib.carla_get_buffer_size() - #def get_host_osc_url(self): - #return self.lib.carla_get_host_osc_url() + def get_sample_rate(self): + return self.lib.carla_get_sample_rate() - #def get_buffer_size(self): - #return self.lib.carla_get_buffer_size() + def set_callback_function(self, func): + self._callback = CallbackFunc(func) + self.lib.carla_set_callback_function(self._callback) - #def get_sample_rate(self): - #return self.lib.carla_get_sample_rate() + def set_option(self, option, value, valueStr): + self.lib.carla_set_option(option, value, valueStr.encode("utf-8")) #def nsm_announce(self, url, pid): #self.lib.nsm_announce(url.encode("utf-8"), pid) @@ -1055,19 +521,19 @@ class Host(object): #def nsm_reply_save(self): #self.lib.nsm_reply_save() -Carla.host = Host(None) - -# Test available drivers -driverCount = Carla.host.get_engine_driver_count() -driverList = [] -for i in range(driverCount): - driver = cString(Carla.host.get_engine_driver_name(i)) - if driver: - driverList.append(driver) - print(i, driver) - -# Test available internal plugins -pluginCount = Carla.host.get_internal_plugin_count() -for i in range(pluginCount): - plugin = Carla.host.get_internal_plugin_info(i) - print(plugin) +#Carla.host = Host(None) + +## Test available drivers +#driverCount = Carla.host.get_engine_driver_count() +#driverList = [] +#for i in range(driverCount): + #driver = cString(Carla.host.get_engine_driver_name(i)) + #if driver: + #driverList.append(driver) + #print(i, driver) + +## Test available internal plugins +#pluginCount = Carla.host.get_internal_plugin_count() +#for i in range(pluginCount): + #plugin = Carla.host.get_internal_plugin_info(i) + #print(plugin) diff --git a/source/carla_shared.py b/source/carla_shared.py index 8f008946b..229aedf11 100644 --- a/source/carla_shared.py +++ b/source/carla_shared.py @@ -25,9 +25,10 @@ import sys from codecs import open as codecopen from copy import deepcopy #from decimal import Decimal -from PyQt4.QtCore import pyqtSlot, qWarning, Qt, QByteArray, QSettings, QTimer, SIGNAL, SLOT -#pyqtSlot, qFatal, -from PyQt4.QtGui import QColor, QDialog, QIcon, QFontMetrics, QFrame, QMessageBox, QPainter, QPainterPath, QVBoxLayout, QWidget +from subprocess import Popen, PIPE +from PyQt4.QtCore import pyqtSlot, qWarning, Qt, QByteArray, QSettings, QThread, QTimer, SIGNAL, SLOT +from PyQt4.QtGui import QColor, QDialog, QIcon, QFontMetrics, QFrame, QMessageBox +from PyQt4.QtGui import QPainter, QPainterPath, QTableWidgetItem, QVBoxLayout, QWidget #from PyQt4.QtGui import QCursor, QGraphicsScene, QInputDialog, QLinearGradient, QMenu, #from PyQt4.QtXml import QDomDocument @@ -35,9 +36,21 @@ from PyQt4.QtGui import QColor, QDialog, QIcon, QFontMetrics, QFrame, QMessageBo # Imports (Custom) import ui_carla_about +import ui_carla_database import ui_carla_edit import ui_carla_parameter import ui_carla_plugin +import ui_carla_refresh + +# ------------------------------------------------------------------------------------------------------------ +# Try Import LADSPA-RDF + +try: + import ladspa_rdf + haveLRDF = True +except: + print("LRDF Support not available (LADSPA-RDF will be disabled)") + haveLRDF = False # ------------------------------------------------------------------------------------------------------------ # Try Import Signal @@ -135,62 +148,6 @@ else: kIs64bit = bool(platform.architecture()[0] == "64bit" and sys.maxsize > 2**32) -# ------------------------------------------------------------------------------------------------------------ -# Convert a ctypes c_char_p into a python string - -def cString(value): - if not value: - return "" - if isinstance(value, str): - return value - return value.decode("utf-8", errors="ignore") - -# ------------------------------------------------------------------------------------------------------------ -# Check if a value is a number (float support) - -def isNumber(value): - try: - float(value) - return True - except: - return False - -# ------------------------------------------------------------------------------------------------------------ -# Convert a value to a list - -def toList(value): - if value is None: - return [] - elif not isinstance(value, list): - return [value] - else: - return value - -# ------------------------------------------------------------------------------------------------------------ -# Unicode open - -def uopen(filename, mode="r"): - return codecopen(filename, encoding="utf-8", mode=mode) - -# ------------------------------------------------------------------------------------------------------------ -# Get Icon from user theme, using our own as backup (Oxygen) - -def getIcon(icon, size=16): - return QIcon.fromTheme(icon, QIcon(":/%ix%i/%s.png" % (size, size, icon))) - -# ------------------------------------------------------------------------------------------------------------ -# Custom MessageBox - -def CustomMessageBox(self_, icon, title, text, extraText="", buttons=QMessageBox.Yes|QMessageBox.No, defButton=QMessageBox.No): - msgBox = QMessageBox(self_) - msgBox.setIcon(icon) - msgBox.setWindowTitle(title) - msgBox.setText(text) - msgBox.setInformativeText(extraText) - msgBox.setStandardButtons(buttons) - msgBox.setDefaultButton(defButton) - return msgBox.exec_() - # ------------------------------------------------------------------------------------------------ # Backend defines @@ -520,6 +477,587 @@ MIDI_CC_LIST = ( "0x5F FX 5 Depth [Phaser]" ) +# ------------------------------------------------------------------------------------------------------------ +# Default Plugin Folders + +if WINDOWS: + splitter = ";" + APPDATA = os.getenv("APPDATA") + PROGRAMFILES = os.getenv("PROGRAMFILES") + PROGRAMFILESx86 = os.getenv("PROGRAMFILES(x86)") + COMMONPROGRAMFILES = os.getenv("COMMONPROGRAMFILES") + + # Small integrity tests + if not APPDATA: + print("APPDATA variable not set, cannot continue") + sys.exit(1) + + if not PROGRAMFILES: + print("PROGRAMFILES variable not set, cannot continue") + sys.exit(1) + + if not COMMONPROGRAMFILES: + print("COMMONPROGRAMFILES variable not set, cannot continue") + sys.exit(1) + + DEFAULT_LADSPA_PATH = [ + os.path.join(APPDATA, "LADSPA"), + os.path.join(PROGRAMFILES, "LADSPA") + ] + + DEFAULT_DSSI_PATH = [ + os.path.join(APPDATA, "DSSI"), + os.path.join(PROGRAMFILES, "DSSI") + ] + + DEFAULT_LV2_PATH = [ + os.path.join(APPDATA, "LV2"), + os.path.join(COMMONPROGRAMFILES, "LV2") + ] + + DEFAULT_VST_PATH = [ + os.path.join(PROGRAMFILES, "VstPlugins"), + os.path.join(PROGRAMFILES, "Steinberg", "VstPlugins") + ] + + DEFAULT_GIG_PATH = [ + os.path.join(APPDATA, "GIG") + ] + + DEFAULT_SF2_PATH = [ + os.path.join(APPDATA, "SF2") + ] + + DEFAULT_SFZ_PATH = [ + os.path.join(APPDATA, "SFZ") + ] + + if PROGRAMFILESx86: + DEFAULT_LADSPA_PATH.append(os.path.join(PROGRAMFILESx86, "LADSPA")) + DEFAULT_DSSI_PATH.append(os.path.join(PROGRAMFILESx86, "DSSI")) + DEFAULT_VST_PATH.append(os.path.join(PROGRAMFILESx86, "VstPlugins")) + DEFAULT_VST_PATH.append(os.path.join(PROGRAMFILESx86, "Steinberg", "VstPlugins")) + +elif HAIKU: + splitter = ":" + + DEFAULT_LADSPA_PATH = [ + # TODO + ] + + DEFAULT_DSSI_PATH = [ + # TODO + ] + + DEFAULT_LV2_PATH = [ + # TODO + ] + + DEFAULT_VST_PATH = [ + # TODO + ] + + DEFAULT_GIG_PATH = [ + # TODO + ] + + DEFAULT_SF2_PATH = [ + # TODO + ] + + DEFAULT_SFZ_PATH = [ + # TODO + ] + +elif MACOS: + splitter = ":" + + DEFAULT_LADSPA_PATH = [ + os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LADSPA"), + os.path.join("/", "Library", "Audio", "Plug-Ins", "LADSPA") + ] + + DEFAULT_DSSI_PATH = [ + os.path.join(HOME, "Library", "Audio", "Plug-Ins", "DSSI"), + os.path.join("/", "Library", "Audio", "Plug-Ins", "DSSI") + ] + + DEFAULT_LV2_PATH = [ + os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LV2"), + os.path.join("/", "Library", "Audio", "Plug-Ins", "LV2") + ] + + DEFAULT_VST_PATH = [ + os.path.join(HOME, "Library", "Audio", "Plug-Ins", "VST"), + os.path.join("/", "Library", "Audio", "Plug-Ins", "VST") + ] + + DEFAULT_GIG_PATH = [ + # TODO + ] + + DEFAULT_SF2_PATH = [ + # TODO + ] + + DEFAULT_SFZ_PATH = [ + # TODO + ] + +else: + splitter = ":" + + DEFAULT_LADSPA_PATH = [ + os.path.join(HOME, ".ladspa"), + os.path.join("/", "usr", "lib", "ladspa"), + os.path.join("/", "usr", "local", "lib", "ladspa") + ] + + DEFAULT_DSSI_PATH = [ + os.path.join(HOME, ".dssi"), + os.path.join("/", "usr", "lib", "dssi"), + os.path.join("/", "usr", "local", "lib", "dssi") + ] + + DEFAULT_LV2_PATH = [ + os.path.join(HOME, ".lv2"), + os.path.join("/", "usr", "lib", "lv2"), + os.path.join("/", "usr", "local", "lib", "lv2") + ] + + DEFAULT_VST_PATH = [ + os.path.join(HOME, ".vst"), + os.path.join("/", "usr", "lib", "vst"), + os.path.join("/", "usr", "local", "lib", "vst") + ] + + DEFAULT_GIG_PATH = [ + os.path.join(HOME, ".sounds"), + os.path.join("/", "usr", "share", "sounds", "gig") + ] + + DEFAULT_SF2_PATH = [ + os.path.join(HOME, ".sounds"), + os.path.join("/", "usr", "share", "sounds", "sf2") + ] + + DEFAULT_SFZ_PATH = [ + os.path.join(HOME, ".sounds"), + os.path.join("/", "usr", "share", "sounds", "sfz") + ] + +# ------------------------------------------------------------------------------------------------------------ +# Default Plugin Folders (set) + +global LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, GIG_PATH, SF2_PATH, SFZ_PATH + +LADSPA_PATH = os.getenv("LADSPA_PATH", DEFAULT_LADSPA_PATH) +DSSI_PATH = os.getenv("DSSI_PATH", DEFAULT_DSSI_PATH) +LV2_PATH = os.getenv("LV2_PATH", DEFAULT_LV2_PATH) +VST_PATH = os.getenv("VST_PATH", DEFAULT_VST_PATH) +GIG_PATH = os.getenv("GIG_PATH", DEFAULT_GIG_PATH) +SF2_PATH = os.getenv("SF2_PATH", DEFAULT_SF2_PATH) +SFZ_PATH = os.getenv("SFZ_PATH", DEFAULT_SFZ_PATH) + +if haveLRDF: + LADSPA_RDF_PATH_env = os.getenv("LADSPA_RDF_PATH") + if LADSPA_RDF_PATH_env: + ladspa_rdf.set_rdf_path(LADSPA_RDF_PATH_env.split(splitter)) + del LADSPA_RDF_PATH_env + +# ------------------------------------------------------------------------------------------------------------ +# Search for Carla library and tools + +global carla_library_path +carla_library_path = "" + +carla_discovery_native = "" +carla_discovery_posix32 = "" +carla_discovery_posix64 = "" +carla_discovery_win32 = "" +carla_discovery_win64 = "" + +carla_bridge_native = "" +carla_bridge_posix32 = "" +carla_bridge_posix64 = "" +carla_bridge_win32 = "" +carla_bridge_win64 = "" + +carla_bridge_lv2_gtk2 = "" +carla_bridge_lv2_gtk3 = "" +carla_bridge_lv2_qt4 = "" +carla_bridge_lv2_qt5 = "" +carla_bridge_lv2_cocoa = "" +carla_bridge_lv2_windows = "" +carla_bridge_lv2_x11 = "" + +carla_bridge_vst_cocoa = "" +carla_bridge_vst_hwnd = "" +carla_bridge_vst_x11 = "" + +if WINDOWS: + carla_libname = "libcarla_standalone.dll" +elif MACOS: + carla_libname = "libcarla_standalone.dylib" +else: + carla_libname = "libcarla_standalone.so" + +CWD = sys.path[0] + +# make it work with cxfreeze +if CWD.endswith("%scarla" % os.sep): + CWD = CWD.rsplit("%scarla" % os.sep, 1)[0] + +# find carla_library_path +if os.path.exists(os.path.join(CWD, "backend", carla_libname)): + carla_library_path = os.path.join(CWD, "backend", carla_libname) +else: + if WINDOWS: + CARLA_PATH = (os.path.join(PROGRAMFILES, "Carla"),) + elif MACOS: + CARLA_PATH = ("/opt/local/lib", "/usr/local/lib/", "/usr/lib") + else: + CARLA_PATH = ("/usr/local/lib/", "/usr/lib") + + for path in CARLA_PATH: + if os.path.exists(os.path.join(path, "carla", carla_libname)): + carla_library_path = os.path.join(path, "carla", carla_libname) + break + +# find any tool +def findTool(tdir, tname): + if os.path.exists(os.path.join(CWD, tdir, tname)): + return os.path.join(CWD, tdir, tname) + + for p in PATH: + if os.path.exists(os.path.join(p, tname)): + return os.path.join(p, tname) + + return "" + +# find wine/windows tools +carla_discovery_win32 = findTool("carla-discovery", "carla-discovery-win32.exe") +carla_discovery_win64 = findTool("carla-discovery", "carla-discovery-win64.exe") +carla_bridge_win32 = findTool("carla-bridge", "carla-bridge-win32.exe") +carla_bridge_win64 = findTool("carla-bridge", "carla-bridge-win64.exe") + +# find native and posix tools +if not WINDOWS: + carla_discovery_native = findTool("carla-discovery", "carla-discovery-native") + carla_discovery_posix32 = findTool("carla-discovery", "carla-discovery-posix32") + carla_discovery_posix64 = findTool("carla-discovery", "carla-discovery-posix64") + carla_bridge_native = findTool("carla-bridge", "carla-bridge-native") + carla_bridge_posix32 = findTool("carla-bridge", "carla-bridge-posix32") + carla_bridge_posix64 = findTool("carla-bridge", "carla-bridge-posix64") + +# find windows only tools +if WINDOWS: + carla_bridge_lv2_windows = findTool("carla-bridge", "carla-bridge-lv2-windows.exe") + carla_bridge_vst_hwnd = findTool("carla-bridge", "carla-bridge-vst-hwnd.exe") + +# find mac os only tools +elif MACOS: + carla_bridge_lv2_cocoa = findTool("carla-bridge", "carla-bridge-lv2-cocoa") + carla_bridge_vst_cocoa = findTool("carla-bridge", "carla-bridge-vst-cocoa") + +# find generic tools +else: + carla_bridge_lv2_gtk2 = findTool("carla-bridge", "carla-bridge-lv2-gtk2") + carla_bridge_lv2_gtk3 = findTool("carla-bridge", "carla-bridge-lv2-gtk3") + carla_bridge_lv2_qt4 = findTool("carla-bridge", "carla-bridge-lv2-qt4") + carla_bridge_lv2_qt5 = findTool("carla-bridge", "carla-bridge-lv2-qt5") + +# find linux only tools +if LINUX: + carla_bridge_lv2_x11 = os.path.join("carla-bridge", "carla-bridge-lv2-x11") + carla_bridge_vst_x11 = os.path.join("carla-bridge", "carla-bridge-vst-x11") + +# ------------------------------------------------------------------------------------------------------------ +# Plugin Query (helper functions) + +def findBinaries(bPATH, OS): + binaries = [] + + if OS == "WINDOWS": + extensions = (".dll",) + elif OS == "MACOS": + extensions = (".dylib", ".so") + else: + extensions = (".so", ".sO", ".SO", ".So") + + for root, dirs, files in os.walk(bPATH): + for name in [name for name in files if name.endswith(extensions)]: + binaries.append(os.path.join(root, name)) + + return binaries + +# FIXME - may use any extension, just needs to have manifest.ttl +def findLV2Bundles(bPATH): + bundles = [] + extensions = (".lv2", ".lV2", ".LV2", ".Lv2") if not WINDOWS else (".lv2",) + + for root, dirs, files in os.walk(bPATH): + for dir_ in [dir_ for dir_ in dirs if dir_.endswith(extensions)]: + bundles.append(os.path.join(root, dir_)) + + return bundles + +def findSoundKits(bPATH, stype): + soundfonts = [] + + if stype == "gig": + extensions = (".gig", ".giG", ".gIG", ".GIG", ".GIg", ".Gig") if not WINDOWS else (".gig",) + elif stype == "sf2": + extensions = (".sf2", ".sF2", ".SF2", ".Sf2") if not WINDOWS else (".sf2",) + elif stype == "sfz": + extensions = (".sfz", ".sfZ", ".sFZ", ".SFZ", ".SFz", ".Sfz") if not WINDOWS else (".sfz",) + else: + return [] + + for root, dirs, files in os.walk(bPATH): + for name in [name for name in files if name.endswith(extensions)]: + soundfonts.append(os.path.join(root, name)) + + return soundfonts + +def findDSSIGUI(filename, name, label): + pluginDir = filename.rsplit(".", 1)[0] + shortName = os.path.basename(pluginDir) + guiFilename = "" + + checkName = name.replace(" ", "_") + checkLabel = label + checkSName = shortName + + if checkName[-1] != "_": checkName += "_" + if checkLabel[-1] != "_": checkLabel += "_" + if checkSName[-1] != "_": checkSName += "_" + + for root, dirs, files in os.walk(pluginDir): + guiFiles = files + break + else: + guiFiles = [] + + for guiFile in guiFiles: + if guiFile.startswith(checkName) or guiFile.startswith(checkLabel) or guiFile.startswith(checkSName): + guiFilename = os.path.join(pluginDir, guiFile) + break + + return guiFilename + +# ------------------------------------------------------------------------------------------------------------ +# Plugin Query + +PLUGIN_QUERY_API_VERSION = 1 + +PyPluginInfo = { + 'API': PLUGIN_QUERY_API_VERSION, + 'build': 0, # BINARY_NONE + 'type': 0, # PLUGIN_NONE + 'hints': 0x0, + 'binary': "", + 'name': "", + 'label': "", + 'maker': "", + 'copyright': "", + 'uniqueId': 0, + 'audio.ins': 0, + 'audio.outs': 0, + 'audio.totals': 0, + 'midi.ins': 0, + 'midi.outs': 0, + 'midi.totals': 0, + 'parameters.ins': 0, + 'parameters.outs': 0, + 'parameters.total': 0, + 'programs.total': 0 +} + +def runCarlaDiscovery(itype, stype, filename, tool, isWine=False): + fakeLabel = os.path.basename(filename).rsplit(".", 1)[0] + plugins = [] + command = [] + + if LINUX or MACOS: + command.append("env") + command.append("LANG=C") + if isWine: + command.append("WINEDEBUG=-all") + + command.append(tool) + command.append(stype) + command.append(filename) + + Ps = Popen(command, stdout=PIPE) + Ps.wait() + output = Ps.stdout.read().decode("utf-8", errors="ignore").split("\n") + + pinfo = None + + for line in output: + line = line.strip() + if line == "carla-discovery::init::-----------": + pinfo = deepcopy(PyPluginInfo) + pinfo['type'] = itype + pinfo['binary'] = filename + + elif line == "carla-discovery::end::------------": + if pinfo != None: + plugins.append(pinfo) + pinfo = None + + elif line == "Segmentation fault": + print("carla-discovery::crash::%s crashed during discovery" % filename) + + elif line.startswith("err:module:import_dll Library"): + print(line) + + elif line.startswith("carla-discovery::error::"): + print("%s - %s" % (line, filename)) + + elif line.startswith("carla-discovery::"): + if pinfo == None: + continue + + prop, value = line.replace("carla-discovery::", "").split("::", 1) + + if prop == "name": + pinfo['name'] = value if value else fakeLabel + elif prop == "label": + pinfo['label'] = value if value else fakeLabel + elif prop == "maker": + pinfo['maker'] = value + elif prop == "copyright": + pinfo['copyright'] = value + elif prop == "uniqueId": + if value.isdigit(): pinfo['uniqueId'] = int(value) + elif prop == "hints": + if value.isdigit(): pinfo['hints'] = int(value) + elif prop == "audio.ins": + if value.isdigit(): pinfo['audio.ins'] = int(value) + elif prop == "audio.outs": + if value.isdigit(): pinfo['audio.outs'] = int(value) + elif prop == "audio.total": + if value.isdigit(): pinfo['audio.total'] = int(value) + elif prop == "midi.ins": + if value.isdigit(): pinfo['midi.ins'] = int(value) + elif prop == "midi.outs": + if value.isdigit(): pinfo['midi.outs'] = int(value) + elif prop == "midi.total": + if value.isdigit(): pinfo['midi.total'] = int(value) + elif prop == "parameters.ins": + if value.isdigit(): pinfo['parameters.ins'] = int(value) + elif prop == "parameters.outs": + if value.isdigit(): pinfo['parameters.outs'] = int(value) + elif prop == "parameters.total": + if value.isdigit(): pinfo['parameters.total'] = int(value) + elif prop == "programs.total": + if value.isdigit(): pinfo['programs.total'] = int(value) + elif prop == "build": + if value.isdigit(): pinfo['build'] = int(value) + + # Additional checks + for pinfo in plugins: + if itype == PLUGIN_DSSI: + if findDSSIGUI(pinfo['binary'], pinfo['name'], pinfo['label']): + pinfo['hints'] |= PLUGIN_HAS_GUI + + return plugins + +def checkPluginInternal(desc): + plugins = [] + + pinfo = deepcopy(PyPluginInfo) + pinfo['type'] = PLUGIN_INTERNAL + pinfo['name'] = cString(desc['name']) + pinfo['label'] = cString(desc['label']) + pinfo['maker'] = cString(desc['maker']) + pinfo['copyright'] = cString(desc['copyright']) + pinfo['hints'] = int(desc['hints']) + pinfo['build'] = BINARY_NATIVE + + plugins.append(pinfo) + + return plugins + +def checkPluginLADSPA(filename, tool, isWine=False): + return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, isWine) + +def checkPluginDSSI(filename, tool, isWine=False): + return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, isWine) + +def checkPluginLV2(filename, tool, isWine=False): + return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, isWine) + +def checkPluginVST(filename, tool, isWine=False): + return runCarlaDiscovery(PLUGIN_VST, "VST", filename, tool, isWine) + +def checkPluginGIG(filename, tool): + return runCarlaDiscovery(PLUGIN_GIG, "GIG", filename, tool) + +def checkPluginSF2(filename, tool): + return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool) + +def checkPluginSFZ(filename, tool): + return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool) + +# ------------------------------------------------------------------------------------------------------------ +# Convert a ctypes c_char_p into a python string + +def cString(value): + if not value: + return "" + if isinstance(value, str): + return value + return value.decode("utf-8", errors="ignore") + +# ------------------------------------------------------------------------------------------------------------ +# Check if a value is a number (float support) + +def isNumber(value): + try: + float(value) + return True + except: + return False + +# ------------------------------------------------------------------------------------------------------------ +# Convert a value to a list + +def toList(value): + if value is None: + return [] + elif not isinstance(value, list): + return [value] + else: + return value + +# ------------------------------------------------------------------------------------------------------------ +# Unicode open + +def uopen(filename, mode="r"): + return codecopen(filename, encoding="utf-8", mode=mode) + +# ------------------------------------------------------------------------------------------------------------ +# Get Icon from user theme, using our own as backup (Oxygen) + +def getIcon(icon, size=16): + return QIcon.fromTheme(icon, QIcon(":/%ix%i/%s.png" % (size, size, icon))) + +# ------------------------------------------------------------------------------------------------------------ +# Custom MessageBox + +def CustomMessageBox(self_, icon, title, text, extraText="", buttons=QMessageBox.Yes|QMessageBox.No, defButton=QMessageBox.No): + msgBox = QMessageBox(self_) + msgBox.setIcon(icon) + msgBox.setWindowTitle(title) + msgBox.setText(text) + msgBox.setInformativeText(extraText) + msgBox.setStandardButtons(buttons) + msgBox.setDefaultButton(defButton) + return msgBox.exec_() + # ------------------------------------------------------------------------------------------------------------ # Carla XML helpers @@ -695,7 +1233,7 @@ class CarlaAboutW(QDialog): else: self.ui.l_extended.setText(cString(Carla.host.get_extended_license_text())) - #self.ui.le_osc_url.setText(cString(Carla.host.get_host_osc_url()) if Carla.host.is_engine_running() else self.tr("(Engine not running)")) + self.ui.le_osc_url.setText(cString(Carla.host.get_host_osc_url()) if Carla.host.is_engine_running() else self.tr("(Engine not running)")) self.ui.l_osc_cmds.setText( " /set_active \n" @@ -939,7 +1477,7 @@ class PluginEdit(QDialog): self.connect(self, SIGNAL("finished(int)"), SLOT("slot_finished()")) - #self.reloadAll() + self.reloadAll() def reloadAll(self): self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId) @@ -1016,7 +1554,7 @@ class PluginEdit(QDialog): self.fRealParent.recheckPluginHints(pluginHints) def reloadParameters(self): - parameterCount = Carla.host.get_parameter_count(self.m_pluginId) + parameterCount = Carla.host.get_parameter_count(self.fPluginId) # Reset self.fParameterCount = 0 @@ -1152,7 +1690,7 @@ class PluginEdit(QDialog): paramFakeList.append(parameter) paramFakeListFull.append((paramFakeList, paramFakeWidth)) - self.createParameterWidgets(PARAMETER_UNKNOWN, paramFakeListFull, self.tr("Information")) + self._createParameterWidgets(PARAMETER_UNKNOWN, paramFakeListFull, self.tr("Information")) def reloadPrograms(self): # Programs @@ -1306,12 +1844,12 @@ class PluginWidget(QFrame): self.ui.setupUi(self) self.fPluginId = pluginId - #self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId) - #self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"]) - #self.fPluginInfo["name"] = cString(self.fPluginInfo["name"]) - #self.fPluginInfo["label"] = cString(self.fPluginInfo["label"]) - #self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"]) - #self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"]) + self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId) + self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"]) + self.fPluginInfo["name"] = cString(self.fPluginInfo["name"]) + self.fPluginInfo["label"] = cString(self.fPluginInfo["label"]) + self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"]) + self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"]) self.fParameterIconTimer = ICON_STATE_NULL @@ -1397,7 +1935,7 @@ class PluginWidget(QFrame): self.ui.peak_in.setChannels(self.fPeaksInputCount) self.ui.peak_out.setChannels(self.fPeaksOutputCount) - #self.ui.label_name.setText(self.fPluginInfo['name']) + self.ui.label_name.setText(self.fPluginInfo['name']) self.ui.edit_dialog = PluginEdit(self, self.fPluginId) self.ui.edit_dialog.hide() @@ -1479,12 +2017,1048 @@ class PluginWidget(QFrame): def slot_editClicked(self, show): self.ui.edit_dialog.setVisible(show) +# ------------------------------------------------------------------------------------------------------------ +# Separate Thread for Plugin Search + +class SearchPluginsThread(QThread): + def __init__(self, parent): + QThread.__init__(self, parent) + + self.fCheckNative = False + self.fCheckPosix32 = False + self.fCheckPosix64 = False + self.fCheckWin32 = False + self.fCheckWin64 = False + + self.fCheckLADSPA = False + self.fCheckDSSI = False + self.fCheckLV2 = False + self.fCheckVST = False + self.fCheckGIG = False + self.fCheckSF2 = False + self.fCheckSFZ = False + + #def skipPlugin(self): + ## TODO - windows and mac support + #apps = "" + #apps += " carla-discovery" + #apps += " carla-discovery-native" + #apps += " carla-discovery-posix32" + #apps += " carla-discovery-posix64" + #apps += " carla-discovery-win32.exe" + #apps += " carla-discovery-win64.exe" + + #if LINUX: + #os.system("killall -KILL %s" % apps) + + #def pluginLook(self, percent, plugin): + #self.emit(SIGNAL("PluginLook(int, QString)"), percent, plugin) + + #def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64): + #self.check_native = native + #self.check_posix32 = posix32 + #self.check_posix64 = posix64 + #self.check_win32 = win32 + #self.check_win64 = win64 + + #def setSearchPluginTypes(self, ladspa, dssi, lv2, vst, gig, sf2, sfz): + #self.check_ladspa = ladspa + #self.check_dssi = dssi + #self.check_lv2 = lv2 + #self.check_vst = vst + #self.check_gig = gig + #self.check_sf2 = sf2 + #self.check_sfz = sfz + + #def setSearchToolNative(self, tool): + #self.tool_native = tool + + #def setLastLoadedBinary(self, binary): + #settings_db.setValue("Plugins/LastLoadedBinary", binary) + + #def checkLADSPA(self, OS, tool, isWine=False): + #global LADSPA_PATH + #ladspa_binaries = [] + #self.ladspa_plugins = [] + + #for iPATH in LADSPA_PATH: + #binaries = findBinaries(iPATH, OS) + #for binary in binaries: + #if binary not in ladspa_binaries: + #ladspa_binaries.append(binary) + + #ladspa_binaries.sort() + + #for i in range(len(ladspa_binaries)): + #ladspa = ladspa_binaries[i] + #if os.path.basename(ladspa) in self.blacklist: + #print("plugin %s is blacklisted, skip it" % ladspa) + #continue + #else: + #percent = ( float(i) / len(ladspa_binaries) ) * self.m_percent_value + #self.pluginLook((self.m_last_value + percent) * 0.9, ladspa) + #self.setLastLoadedBinary(ladspa) + + #plugins = checkPluginLADSPA(ladspa, tool, isWine) + #if plugins: + #self.ladspa_plugins.append(plugins) + + #self.m_last_value += self.m_percent_value + #self.setLastLoadedBinary("") + + #def checkDSSI(self, OS, tool, isWine=False): + #global DSSI_PATH + #dssi_binaries = [] + #self.dssi_plugins = [] + + #for iPATH in DSSI_PATH: + #binaries = findBinaries(iPATH, OS) + #for binary in binaries: + #if binary not in dssi_binaries: + #dssi_binaries.append(binary) + + #dssi_binaries.sort() + + #for i in range(len(dssi_binaries)): + #dssi = dssi_binaries[i] + #if os.path.basename(dssi) in self.blacklist: + #print("plugin %s is blacklisted, skip it" % dssi) + #continue + #else: + #percent = ( float(i) / len(dssi_binaries) ) * self.m_percent_value + #self.pluginLook(self.m_last_value + percent, dssi) + #self.setLastLoadedBinary(dssi) + + #plugins = checkPluginDSSI(dssi, tool, isWine) + #if plugins: + #self.dssi_plugins.append(plugins) + + #self.m_last_value += self.m_percent_value + #self.setLastLoadedBinary("") + + #def checkLV2(self, tool, isWine=False): + #global LV2_PATH + #lv2_bundles = [] + #self.lv2_plugins = [] + + #self.pluginLook(self.m_last_value, "LV2 bundles...") + + #for iPATH in LV2_PATH: + #bundles = findLV2Bundles(iPATH) + #for bundle in bundles: + #if bundle not in lv2_bundles: + #lv2_bundles.append(bundle) + + #lv2_bundles.sort() + + #for i in range(len(lv2_bundles)): + #lv2 = lv2_bundles[i] + #if (os.path.basename(lv2) in self.blacklist): + #print("bundle %s is blacklisted, skip it" % lv2) + #continue + #else: + #percent = ( float(i) / len(lv2_bundles) ) * self.m_percent_value + #self.pluginLook(self.m_last_value + percent, lv2) + #self.setLastLoadedBinary(lv2) + + #plugins = checkPluginLV2(lv2, tool, isWine) + #if plugins: + #self.lv2_plugins.append(plugins) + + #self.m_last_value += self.m_percent_value + #self.setLastLoadedBinary("") + + #def checkVST(self, OS, tool, isWine=False): + #global VST_PATH + #vst_binaries = [] + #self.vst_plugins = [] + + #for iPATH in VST_PATH: + #binaries = findBinaries(iPATH, OS) + #for binary in binaries: + #if binary not in vst_binaries: + #vst_binaries.append(binary) + + #vst_binaries.sort() + + #for i in range(len(vst_binaries)): + #vst = vst_binaries[i] + #if os.path.basename(vst) in self.blacklist: + #print("plugin %s is blacklisted, skip it" % vst) + #continue + #else: + #percent = ( float(i) / len(vst_binaries) ) * self.m_percent_value + #self.pluginLook(self.m_last_value + percent, vst) + #self.setLastLoadedBinary(vst) + + #plugins = checkPluginVST(vst, tool, isWine) + #if plugins: + #self.vst_plugins.append(plugins) + + #self.m_last_value += self.m_percent_value + #self.setLastLoadedBinary("") + + #def checkKIT(self, kPATH, kType): + #kit_files = [] + #self.kit_plugins = [] + + #for iPATH in kPATH: + #files = findSoundKits(iPATH, kType) + #for file_ in files: + #if file_ not in kit_files: + #kit_files.append(file_) + + #kit_files.sort() + + #for i in range(len(kit_files)): + #kit = kit_files[i] + #if os.path.basename(kit) in self.blacklist: + #print("plugin %s is blacklisted, skip it" % kit) + #continue + #else: + #percent = ( float(i) / len(kit_files) ) * self.m_percent_value + #self.pluginLook(self.m_last_value + percent, kit) + #self.setLastLoadedBinary(kit) + + #if kType == "gig": + #plugins = checkPluginGIG(kit, self.tool_native) + #elif kType == "sf2": + #plugins = checkPluginSF2(kit, self.tool_native) + #elif kType == "sfz": + #plugins = checkPluginSFZ(kit, self.tool_native) + #else: + #plugins = None + + #if plugins: + #self.kit_plugins.append(plugins) + + #self.m_last_value += self.m_percent_value + #self.setLastLoadedBinary("") + + def run(self): + global LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, GIG_PATH, SF2_PATH, SFZ_PATH + + #self.blacklist = toList(settingsDB.value("Plugins/Blacklisted", [])) + + #self.m_count = 0 + #plugin_count = 0 + + #if self.check_ladspa: plugin_count += 1 + #if self.check_dssi: plugin_count += 1 + #if self.check_lv2: plugin_count += 1 + #if self.check_vst: plugin_count += 1 + + #if self.check_native: + #self.m_count += plugin_count + #if self.check_posix32: + #self.m_count += plugin_count + #if self.check_posix64: + #self.m_count += plugin_count + #if self.check_win32: + #self.m_count += plugin_count + #if self.check_win64: + #self.m_count += plugin_count + + #if self.tool_native: + #if self.check_gig: self.m_count += 1 + #if self.check_sf2: self.m_count += 1 + #if self.check_sfz: self.m_count += 1 + #else: + #self.check_gig = False + #self.check_sf2 = False + #self.check_sfz = False + + #if self.m_count == 0: + #return + + #self.m_last_value = 0 + #self.m_percent_value = 100 / self.m_count + + #if HAIKU: + #OS = "HAIKU" + #elif LINUX: + #OS = "LINUX" + #elif MACOS: + #OS = "MACOS" + #elif WINDOWS: + #OS = "WINDOWS" + #else: + #OS = "UNKNOWN" + + #if self.check_ladspa: + #m_value = 0 + #if haveLRDF: + #if self.check_native: m_value += 0.1 + #if self.check_posix32: m_value += 0.1 + #if self.check_posix64: m_value += 0.1 + #if self.check_win32: m_value += 0.1 + #if self.check_win64: m_value += 0.1 + #rdf_pad_value = self.m_percent_value * m_value + + #if self.check_native: + #self.checkLADSPA(OS, carla_discovery_native) + #settings_db.setValue("Plugins/LADSPA_native", self.ladspa_plugins) + #settings_db.sync() + + #if self.check_posix32: + #self.checkLADSPA(OS, carla_discovery_posix32) + #settings_db.setValue("Plugins/LADSPA_posix32", self.ladspa_plugins) + #settings_db.sync() + + #if self.check_posix64: + #self.checkLADSPA(OS, carla_discovery_posix64) + #settings_db.setValue("Plugins/LADSPA_posix64", self.ladspa_plugins) + #settings_db.sync() + + #if self.check_win32: + #self.checkLADSPA("WINDOWS", carla_discovery_win32, not WINDOWS) + #settings_db.setValue("Plugins/LADSPA_win32", self.ladspa_plugins) + #settings_db.sync() + + #if self.check_win64: + #self.checkLADSPA("WINDOWS", carla_discovery_win64, not WINDOWS) + #settings_db.setValue("Plugins/LADSPA_win64", self.ladspa_plugins) + #settings_db.sync() + + #if haveLRDF: + #if m_value > 0: + #start_value = self.m_last_value - rdf_pad_value + + #self.pluginLook(start_value, "LADSPA RDFs...") + #ladspa_rdf_info = ladspa_rdf.recheck_all_plugins(self, start_value, self.m_percent_value, m_value) + + #SettingsDir = os.path.join(HOME, ".config", "Cadence") + + #f_ladspa = open(os.path.join(SettingsDir, "ladspa_rdf.db"), 'w') + #json.dump(ladspa_rdf_info, f_ladspa) + #f_ladspa.close() + + #if self.check_dssi: + #if self.check_native: + #self.checkDSSI(OS, carla_discovery_native) + #settings_db.setValue("Plugins/DSSI_native", self.dssi_plugins) + #settings_db.sync() + + #if self.check_posix32: + #self.checkDSSI(OS, carla_discovery_posix32) + #settings_db.setValue("Plugins/DSSI_posix32", self.dssi_plugins) + #settings_db.sync() + + #if self.check_posix64: + #self.checkDSSI(OS, carla_discovery_posix64) + #settings_db.setValue("Plugins/DSSI_posix64", self.dssi_plugins) + #settings_db.sync() + + #if self.check_win32: + #self.checkDSSI("WINDOWS", carla_discovery_win32, not WINDOWS) + #settings_db.setValue("Plugins/DSSI_win32", self.dssi_plugins) + #settings_db.sync() + + #if self.check_win64: + #self.checkDSSI("WINDOWS", carla_discovery_win64, not WINDOWS) + #settings_db.setValue("Plugins/DSSI_win64", self.dssi_plugins) + #settings_db.sync() + + #if self.check_lv2: + #if self.check_native: + #self.checkLV2(carla_discovery_native) + #settings_db.setValue("Plugins/LV2_native", self.lv2_plugins) + #settings_db.sync() + + #if self.check_posix32: + #self.checkLV2(carla_discovery_posix32) + #settings_db.setValue("Plugins/LV2_posix32", self.lv2_plugins) + #settings_db.sync() + + #if self.check_posix64: + #self.checkLV2(carla_discovery_posix64) + #settings_db.setValue("Plugins/LV2_posix64", self.lv2_plugins) + #settings_db.sync() + + #if self.check_win32: + #self.checkLV2(carla_discovery_win32, not WINDOWS) + #settings_db.setValue("Plugins/LV2_win32", self.lv2_plugins) + #settings_db.sync() + + #if self.check_win64: + #self.checkLV2(carla_discovery_win64, not WINDOWS) + #settings_db.setValue("Plugins/LV2_win64", self.lv2_plugins) + #settings_db.sync() + + #if self.check_vst: + #if self.check_native: + #self.checkVST(OS, carla_discovery_native) + #settings_db.setValue("Plugins/VST_native", self.vst_plugins) + #settings_db.sync() + + #if self.check_posix32: + #self.checkVST(OS, carla_discovery_posix32) + #settings_db.setValue("Plugins/VST_posix32", self.vst_plugins) + #settings_db.sync() + + #if self.check_posix64: + #self.checkVST(OS, carla_discovery_posix64) + #settings_db.setValue("Plugins/VST_posix64", self.vst_plugins) + #settings_db.sync() + + #if self.check_win32: + #self.checkVST("WINDOWS", carla_discovery_win32, not WINDOWS) + #settings_db.setValue("Plugins/VST_win32", self.vst_plugins) + #settings_db.sync() + + #if self.check_win64: + #self.checkVST("WINDOWS", carla_discovery_win64, not WINDOWS) + #settings_db.setValue("Plugins/VST_win64", self.vst_plugins) + #settings_db.sync() + + #if self.check_gig: + #self.checkKIT(GIG_PATH, "gig") + #settings_db.setValue("Plugins/GIG", self.kit_plugins) + #settings_db.sync() + + #if self.check_sf2: + #self.checkKIT(SF2_PATH, "sf2") + #settings_db.setValue("Plugins/SF2", self.kit_plugins) + #settings_db.sync() + + #if self.check_sfz: + #self.checkKIT(SFZ_PATH, "sfz") + #settings_db.setValue("Plugins/SFZ", self.kit_plugins) + #settings_db.sync() + +# ------------------------------------------------------------------------------------------------------------ +# Plugin Refresh Dialog + +class PluginRefreshW(QDialog): + def __init__(self, parent): + QDialog.__init__(self, parent) + self.ui = ui_carla_refresh.Ui_PluginRefreshW() + self.ui.setupUi(self) + + self.ui.b_skip.setVisible(False) + + if HAIKU: + self.ui.ch_posix32.setText("Haiku 32bit") + self.ui.ch_posix64.setText("Haiku 64bit") + elif LINUX: + self.ui.ch_posix32.setText("Linux 32bit") + self.ui.ch_posix64.setText("Linux 64bit") + elif MACOS: + self.ui.ch_posix32.setText("MacOS 32bit") + self.ui.ch_posix64.setText("MacOS 64bit") + + #settings = self.parent().settings + #settings_db = self.parent().settings_db + #self.loadSettings() + + self.fThread = SearchPluginsThread(self) + + if carla_discovery_posix32 and not WINDOWS: + self.ui.ico_posix32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) + else: + self.ui.ico_posix32.setPixmap(getIcon("dialog-error").pixmap(16, 16)) + self.ui.ch_posix32.setChecked(False) + self.ui.ch_posix32.setEnabled(False) + + if carla_discovery_posix64 and not WINDOWS: + self.ui.ico_posix64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) + else: + self.ui.ico_posix64.setPixmap(getIcon("dialog-error").pixmap(16, 16)) + self.ui.ch_posix64.setChecked(False) + self.ui.ch_posix64.setEnabled(False) + + if carla_discovery_win32: + self.ui.ico_win32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) + else: + self.ui.ico_win32.setPixmap(getIcon("dialog-error").pixmap(16, 16)) + self.ui.ch_win32.setChecked(False) + self.ui.ch_win32.setEnabled(False) + + if carla_discovery_win64: + self.ui.ico_win64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) + else: + self.ui.ico_win64.setPixmap(getIcon("dialog-error").pixmap(16, 16)) + self.ui.ch_win64.setChecked(False) + self.ui.ch_win64.setEnabled(False) + + if haveLRDF: + self.ui.ico_rdflib.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) + else: + self.ui.ico_rdflib.setPixmap(getIcon("dialog-error").pixmap(16, 16)) + + hasNative = bool(carla_discovery_native) + hasNonNative = False + + if WINDOWS: + if kIs64bit: + hasNative = bool(carla_discovery_win64) + hasNonNative = bool(carla_discovery_win32) + #self.fThread.setSearchToolNative(carla_discovery_win64) + self.ui.ch_win64.setChecked(False) + self.ui.ch_win64.setVisible(False) + self.ui.ico_win64.setVisible(False) + self.ui.label_win64.setVisible(False) + else: + hasNative = bool(carla_discovery_win32) + hasNonNative = bool(carla_discovery_win64) + #self.fThread.setSearchToolNative(carla_discovery_win32) + self.ui.ch_win32.setChecked(False) + self.ui.ch_win32.setVisible(False) + self.ui.ico_win32.setVisible(False) + self.ui.label_win32.setVisible(False) + elif LINUX or MACOS: + if kIs64bit: + hasNonNative = bool(carla_discovery_posix32 or carla_discovery_win32 or carla_discovery_win64) + self.ui.ch_posix64.setChecked(False) + self.ui.ch_posix64.setVisible(False) + self.ui.ico_posix64.setVisible(False) + self.ui.label_posix64.setVisible(False) + else: + hasNonNative = bool(carla_discovery_posix64 or carla_discovery_win32 or carla_discovery_win64) + self.ui.ch_posix32.setChecked(False) + self.ui.ch_posix32.setVisible(False) + self.ui.ico_posix32.setVisible(False) + self.ui.label_posix32.setVisible(False) + + if hasNative: + self.ui.ico_native.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16)) + else: + self.ui.ico_native.setPixmap(getIcon("dialog-error").pixmap(16, 16)) + self.ui.ch_native.setChecked(False) + self.ui.ch_native.setEnabled(False) + self.ui.ch_gig.setChecked(False) + self.ui.ch_gig.setEnabled(False) + self.ui.ch_sf2.setChecked(False) + self.ui.ch_sf2.setEnabled(False) + self.ui.ch_sfz.setChecked(False) + self.ui.ch_sfz.setEnabled(False) + if not hasNonNative: + self.ui.ch_ladspa.setChecked(False) + self.ui.ch_ladspa.setEnabled(False) + self.ui.ch_dssi.setChecked(False) + self.ui.ch_dssi.setEnabled(False) + self.ui.ch_vst.setChecked(False) + self.ui.ch_vst.setEnabled(False) + self.ui.b_start.setEnabled(False) + + #self.connect(self.b_start, SIGNAL("clicked()"), SLOT("slot_start()")) + #self.connect(self.b_skip, SIGNAL("clicked()"), SLOT("slot_skip()")) + #self.connect(self.pThread, SIGNAL("PluginLook(int, QString)"), SLOT("slot_handlePluginLook(int, QString)")) + #self.connect(self.pThread, SIGNAL("finished()"), SLOT("slot_handlePluginThreadFinished()")) + + #@pyqtSlot() + #def slot_start(self): + #self.progressBar.setMinimum(0) + #self.progressBar.setMaximum(100) + #self.progressBar.setValue(0) + #self.b_start.setEnabled(False) + #self.b_skip.setVisible(True) + #self.b_close.setVisible(False) + + #native, posix32, posix64, win32, win64 = (self.ch_native.isChecked(), self.ch_posix32.isChecked(), self.ch_posix64.isChecked(), self.ch_win32.isChecked(), self.ch_win64.isChecked()) + #ladspa, dssi, lv2, vst, gig, sf2, sfz = (self.ch_ladspa.isChecked(), self.ch_dssi.isChecked(), self.ch_lv2.isChecked(), self.ch_vst.isChecked(), + #self.ch_gig.isChecked(), self.ch_sf2.isChecked(), self.ch_sfz.isChecked()) + + #self.pThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64) + #self.pThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, gig, sf2, sfz) + #self.pThread.start() + + #@pyqtSlot() + #def slot_skip(self): + #self.pThread.skipPlugin() + + #@pyqtSlot(int, str) + #def slot_handlePluginLook(self, percent, plugin): + #self.progressBar.setFormat("%s" % plugin) + #self.progressBar.setValue(percent) + + #@pyqtSlot() + #def slot_handlePluginThreadFinished(self): + #self.progressBar.setMinimum(0) + #self.progressBar.setMaximum(1) + #self.progressBar.setValue(1) + #self.progressBar.setFormat(self.tr("Done")) + #self.b_start.setEnabled(True) + #self.b_skip.setVisible(False) + #self.b_close.setVisible(True) + + #def saveSettings(self): + #settings.setValue("PluginDatabase/SearchLADSPA", self.ch_ladspa.isChecked()) + #settings.setValue("PluginDatabase/SearchDSSI", self.ch_dssi.isChecked()) + #settings.setValue("PluginDatabase/SearchLV2", self.ch_lv2.isChecked()) + #settings.setValue("PluginDatabase/SearchVST", self.ch_vst.isChecked()) + #settings.setValue("PluginDatabase/SearchGIG", self.ch_gig.isChecked()) + #settings.setValue("PluginDatabase/SearchSF2", self.ch_sf2.isChecked()) + #settings.setValue("PluginDatabase/SearchSFZ", self.ch_sfz.isChecked()) + #settings.setValue("PluginDatabase/SearchNative", self.ch_native.isChecked()) + #settings.setValue("PluginDatabase/SearchPOSIX32", self.ch_posix32.isChecked()) + #settings.setValue("PluginDatabase/SearchPOSIX64", self.ch_posix64.isChecked()) + #settings.setValue("PluginDatabase/SearchWin32", self.ch_win32.isChecked()) + #settings.setValue("PluginDatabase/SearchWin64", self.ch_win64.isChecked()) + #settings_db.setValue("Plugins/LastLoadedBinary", "") + + #def loadSettings(self): + #self.ch_ladspa.setChecked(settings.value("PluginDatabase/SearchLADSPA", True, type=bool)) + #self.ch_dssi.setChecked(settings.value("PluginDatabase/SearchDSSI", True, type=bool)) + #self.ch_lv2.setChecked(settings.value("PluginDatabase/SearchLV2", True, type=bool)) + #self.ch_vst.setChecked(settings.value("PluginDatabase/SearchVST", True, type=bool)) + #self.ch_gig.setChecked(settings.value("PluginDatabase/SearchGIG", True, type=bool)) + #self.ch_sf2.setChecked(settings.value("PluginDatabase/SearchSF2", True, type=bool)) + #self.ch_sfz.setChecked(settings.value("PluginDatabase/SearchSFZ", True, type=bool)) + #self.ch_native.setChecked(settings.value("PluginDatabase/SearchNative", True, type=bool)) + #self.ch_posix32.setChecked(settings.value("PluginDatabase/SearchPOSIX32", False, type=bool)) + #self.ch_posix64.setChecked(settings.value("PluginDatabase/SearchPOSIX64", False, type=bool)) + #self.ch_win32.setChecked(settings.value("PluginDatabase/SearchWin32", False, type=bool)) + #self.ch_win64.setChecked(settings.value("PluginDatabase/SearchWin64", False, type=bool)) + + def closeEvent(self, event): + #if self.pThread.isRunning(): + #self.pThread.terminate() + #self.pThread.wait() + #self.saveSettings() + QDialog.closeEvent(self, event) + + def done(self, r): + QDialog.done(self, r) + self.close() + +# ------------------------------------------------------------------------------------------------------------ +# Plugin Database Dialog + +class PluginDatabaseW(QDialog): + def __init__(self, parent): + QDialog.__init__(self, parent) + self.ui = ui_carla_database.Ui_PluginDatabaseW() + self.ui.setupUi(self) + + self.fLastTableIndex = 0 + self.fRetPlugin = None + self.fRealParent = parent + + self.ui.b_add.setEnabled(False) + + if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32): + self.ui.ch_bridged.setText(self.tr("Bridged (64bit)")) + else: + self.ui.ch_bridged.setText(self.tr("Bridged (32bit)")) + + if not (LINUX or MACOS): + self.ui.ch_bridged_wine.setChecked(False) + self.ui.ch_bridged_wine.setEnabled(False) + + self._loadSettings() + + self.connect(self.ui.b_add, SIGNAL("clicked()"), SLOT("slot_addPlugin()")) + self.connect(self.ui.b_refresh, SIGNAL("clicked()"), SLOT("slot_refreshPlugins()")) + self.connect(self.ui.tb_filters, SIGNAL("clicked()"), SLOT("slot_maybeShowFilters()")) + self.connect(self.ui.tableWidget, SIGNAL("currentCellChanged(int, int, int, int)"), SLOT("slot_checkPlugin(int)")) + self.connect(self.ui.tableWidget, SIGNAL("cellDoubleClicked(int, int)"), SLOT("slot_addPlugin()")) + + self.connect(self.ui.lineEdit, SIGNAL("textChanged(QString)"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_effects, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_instruments, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_midi, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_other, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_kits, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_internal, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_native, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_bridged, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_bridged_wine, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_gui, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + self.connect(self.ui.ch_stereo, SIGNAL("clicked()"), SLOT("slot_checkFilters()")) + + @pyqtSlot() + def slot_addPlugin(self): + if self.ui.tableWidget.currentRow() >= 0: + self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).pluginData + self.accept() + else: + self.reject() + + @pyqtSlot(int) + def slot_checkPlugin(self, row): + self.ui.b_add.setEnabled(row >= 0) + + @pyqtSlot() + def slot_checkFilters(self): + self._checkFilters() + + @pyqtSlot() + def slot_maybeShowFilters(self): + self._showFilters(not self.ui.frame.isVisible()) + + @pyqtSlot() + def slot_refreshPlugins(self): + #lastLoadedPlugin = settings_db.value("Plugins/LastLoadedBinary", "", type=str) + #if lastLoadedPlugin: + #lastLoadedPlugin = os.path.basename(lastLoadedPlugin) + #ask = QMessageBox.question(self, self.tr("Warning"), self.tr("There was an error while checking the plugin %s.\n" + #"Do you want to blacklist it?" % lastLoadedPlugin), + #QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) + + #if ask == QMessageBox.Yes: + #blacklist = toList(settingsDB.value("Plugins/Blacklisted", [])) + #blacklist.append(lastLoadedPlugin) + #settings_db.setValue("Plugins/Blacklisted", blacklist) + + #self.label.setText(self.tr("Looking for plugins...")) + if PluginRefreshW(self).exec_(): + self._reAddPlugins() + + if self.fRealParent: + self.fRealParent.loadRDFs() + + def _checkFilters(self): + text = self.ui.lineEdit.text().lower() + + hideEffects = not self.ui.ch_effects.isChecked() + hideInstruments = not self.ui.ch_instruments.isChecked() + hideMidi = not self.ui.ch_midi.isChecked() + hideOther = not self.ui.ch_other.isChecked() + + hideInternal = not self.ui.ch_internal.isChecked() + hideLadspa = not self.ui.ch_ladspa.isChecked() + hideDssi = not self.ui.ch_dssi.isChecked() + hideLV2 = not self.ui.ch_lv2.isChecked() + hideVST = not self.ui.ch_vst.isChecked() + hideKits = not self.ui.ch_kits.isChecked() + + hideNative = not self.ui.ch_native.isChecked() + hideBridged = not self.ui.ch_bridged.isChecked() + hideBridgedWine = not self.ui.ch_bridged_wine.isChecked() + + hideNonGui = self.ui.ch_gui.isChecked() + hideNonStereo = self.ui.ch_stereo.isChecked() + + if HAIKU or LINUX or MACOS: + nativeBins = [BINARY_POSIX32, BINARY_POSIX64] + wineBins = [BINARY_WIN32, BINARY_WIN64] + elif WINDOWS: + nativeBins = [BINARY_WIN32, BINARY_WIN64] + wineBins = [] + else: + nativeBins = [] + wineBins = [] + + rowCount = self.ui.tableWidget.rowCount() + + for i in range(rowCount): + self.ui.tableWidget.showRow(i) + + plugin = self.ui.tableWidget.item(i, 0).pluginData + aIns = plugin['audio.ins'] + aOuts = plugin['audio.outs'] + mIns = plugin['midi.ins'] + mOuts = plugin['midi.outs'] + ptype = self.ui.tableWidget.item(i, 12).text() + isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH) + isEffect = bool(aIns > 0 < aOuts and not isSynth) + isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts) + isKit = bool(ptype in ("GIG", "SF2", "SFZ")) + isOther = bool(not (isEffect or isSynth or isMidi or isKit)) + isNative = bool(plugin['build'] == BINARY_NATIVE) + isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2) + hasGui = bool(plugin['hints'] & PLUGIN_HAS_GUI) + + isBridged = bool(not isNative and plugin['build'] in nativeBins) + isBridgedWine = bool(not isNative and plugin['build'] in wineBins) + + if (hideEffects and isEffect): + self.ui.tableWidget.hideRow(i) + elif (hideInstruments and isSynth): + self.ui.tableWidget.hideRow(i) + elif (hideMidi and isMidi): + self.ui.tableWidget.hideRow(i) + elif (hideOther and isOther): + self.ui.tableWidget.hideRow(i) + elif (hideKits and isKit): + self.ui.tableWidget.hideRow(i) + elif (hideInternal and ptype == self.tr("Internal")): + self.ui.tableWidget.hideRow(i) + elif (hideLadspa and ptype == "LADSPA"): + self.ui.tableWidget.hideRow(i) + elif (hideDssi and ptype == "DSSI"): + self.ui.tableWidget.hideRow(i) + elif (hideLV2 and ptype == "LV2"): + self.ui.tableWidget.hideRow(i) + elif (hideVST and ptype == "VST"): + self.ui.tableWidget.hideRow(i) + elif (hideNative and isNative): + self.ui.tableWidget.hideRow(i) + elif (hideBridged and isBridged): + self.ui.tableWidget.hideRow(i) + elif (hideBridgedWine and isBridgedWine): + self.ui.tableWidget.hideRow(i) + elif (hideNonGui and not hasGui): + self.ui.tableWidget.hideRow(i) + elif (hideNonStereo and not isStereo): + self.ui.tableWidget.hideRow(i) + elif (text and not ( + text in self.ui.tableWidget.item(i, 0).text().lower() or + text in self.ui.tableWidget.item(i, 1).text().lower() or + text in self.ui.tableWidget.item(i, 2).text().lower() or + text in self.ui.tableWidget.item(i, 3).text().lower() or + text in self.ui.tableWidget.item(i, 13).text().lower())): + self.ui.tableWidget.hideRow(i) + + def _showFilters(self, yesNo): + self.ui.tb_filters.setArrowType(Qt.UpArrow if yesNo else Qt.DownArrow) + self.ui.frame.setVisible(yesNo) + + def _reAddPlugins(self): + #settingsDB = QSettings("falkTX", "CarlaPlugins") + settingsDB = QSettings("Cadence", "Carla-Database") + + rowCount = self.ui.tableWidget.rowCount() + for x in range(rowCount): + self.ui.tableWidget.removeRow(0) + + self.fLastTableIndex = 0 + self.ui.tableWidget.setSortingEnabled(False) + + internalCount = 0 + ladspaCount = 0 + dssiCount = 0 + lv2Count = 0 + vstCount = 0 + kitCount = 0 + + # --------------------------------------------------------------------------- + # Internal + + internalPlugins = toList(settingsDB.value("Plugins/Internal", [])) + + for plugins in internalPlugins: + for plugin in plugins: + internalCount += 1 + + if (not Carla.isControl) and internalCount != Carla.host.get_internal_plugin_count(): + internalCount = Carla.host.get_internal_plugin_count() + internalPlugins = [] + + for i in range(Carla.host.get_internal_plugin_count()): + descInfo = Carla.host.get_internal_plugin_info(i) + plugins = checkPluginInternal(descInfo) + + if plugins: + internalPlugins.append(plugins) + + settingsDB.setValue("Plugins/Internal", internalPlugins) + + for plugins in internalPlugins: + for plugin in plugins: + self._addPluginToTable(plugin, self.tr("Internal")) + + # --------------------------------------------------------------------------- + # LADSPA + + ladspaPlugins = [] + ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", [])) + ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", [])) + ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", [])) + ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", [])) + ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", [])) + + for plugins in ladspaPlugins: + for plugin in plugins: + self._addPluginToTable(plugin, "LADSPA") + ladspaCount += 1 + + # --------------------------------------------------------------------------- + # DSSI + + dssiPlugins = [] + dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", [])) + dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", [])) + dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", [])) + dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", [])) + dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", [])) + + for plugins in dssiPlugins: + for plugin in plugins: + self._addPluginToTable(plugin, "DSSI") + dssiCount += 1 + + # --------------------------------------------------------------------------- + # LV2 + + lv2Plugins = [] + lv2Plugins += toList(settingsDB.value("Plugins/LV2_native", [])) + lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix32", [])) + lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix64", [])) + lv2Plugins += toList(settingsDB.value("Plugins/LV2_win32", [])) + lv2Plugins += toList(settingsDB.value("Plugins/LV2_win64", [])) + + for plugins in lv2Plugins: + for plugin in plugins: + self._addPluginToTable(plugin, "LV2") + lv2Count += 1 + + # --------------------------------------------------------------------------- + # VST + + vstPlugins = [] + vstPlugins += toList(settingsDB.value("Plugins/VST_native", [])) + vstPlugins += toList(settingsDB.value("Plugins/VST_posix32", [])) + vstPlugins += toList(settingsDB.value("Plugins/VST_posix64", [])) + vstPlugins += toList(settingsDB.value("Plugins/VST_win32", [])) + vstPlugins += toList(settingsDB.value("Plugins/VST_win64", [])) + + for plugins in vstPlugins: + for plugin in plugins: + self._addPluginToTable(plugin, "VST") + vstCount += 1 + + # --------------------------------------------------------------------------- + # Kits + + gigs = toList(settingsDB.value("Plugins/GIG", [])) + sf2s = toList(settingsDB.value("Plugins/SF2", [])) + sfzs = toList(settingsDB.value("Plugins/SFZ", [])) + + for gig in gigs: + for gig_i in gig: + self._addPluginToTable(gig_i, "GIG") + kitCount += 1 + + for sf2 in sf2s: + for sf2_i in sf2: + self._addPluginToTable(sf2_i, "SF2") + kitCount += 1 + + for sfz in sfzs: + for sfz_i in sfz: + self._addPluginToTable(sfz_i, "SFZ") + kitCount += 1 + + # --------------------------------------------------------------------------- + + #self.slot_checkFilters() + self.ui.tableWidget.setSortingEnabled(True) + self.ui.tableWidget.sortByColumn(0, Qt.AscendingOrder) + + self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2, %i VST and %i Sound Kits" % (internalCount, ladspaCount, dssiCount, lv2Count, vstCount, kitCount))) + + def _addPluginToTable(self, plugin, ptype): + index = self.fLastTableIndex + + if plugin['build'] == BINARY_NATIVE: + bridgeText = self.tr("No") + else: + typeText = self.tr("Unknown") + if LINUX or MACOS: + if plugin['build'] == BINARY_POSIX32: + typeText = "32bit" + elif plugin['build'] == BINARY_POSIX64: + typeText = "64bit" + elif plugin['build'] == BINARY_WIN32: + typeText = "Windows 32bit" + elif plugin['build'] == BINARY_WIN64: + typeText = "Windows 64bit" + elif WINDOWS: + if plugin['build'] == BINARY_WIN32: + typeText = "32bit" + elif plugin['build'] == BINARY_WIN64: + typeText = "64bit" + bridgeText = self.tr("Yes (%s)" % typeText) + + self.ui.tableWidget.insertRow(index) + self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(plugin['name'])) + self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(plugin['label'])) + self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(plugin['maker'])) + #self.ui.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['uniqueId']))) + self.ui.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins']))) + self.ui.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs']))) + self.ui.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins']))) + self.ui.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs']))) + self.ui.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total']))) + self.ui.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_GUI) else self.tr("No"))) + self.ui.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No"))) + self.ui.tableWidget.setItem(index, 11, QTableWidgetItem(bridgeText)) + self.ui.tableWidget.setItem(index, 12, QTableWidgetItem(ptype)) + self.ui.tableWidget.setItem(index, 13, QTableWidgetItem(plugin['binary'])) + self.ui.tableWidget.item(self.fLastTableIndex, 0).pluginData = plugin + self.fLastTableIndex += 1 + + def _saveSettings(self): + settings = QSettings() #"falkTX", "CarlaPluginDatabase" + settings.setValue("PluginDatabase/Geometry", self.saveGeometry()) + settings.setValue("PluginDatabase/TableGeometry", self.ui.tableWidget.horizontalHeader().saveState()) + settings.setValue("PluginDatabase/ShowFilters", (self.ui.tb_filters.arrowType() == Qt.UpArrow)) + settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked()) + settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked()) + settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked()) + settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked()) + settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked()) + settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked()) + settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked()) + settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked()) + settings.setValue("PluginDatabase/ShowVST", self.ui.ch_vst.isChecked()) + settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked()) + settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked()) + settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked()) + settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked()) + settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked()) + settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked()) + + def _loadSettings(self): + settings = QSettings() #"falkTX", "CarlaPluginDatabase" + self.restoreGeometry(settings.value("PluginDatabase/Geometry", "")) + self.ui.tableWidget.horizontalHeader().restoreState(settings.value("PluginDatabase/TableGeometry", "")) + self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool)) + self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool)) + self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool)) + self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool)) + self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool)) + self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool)) + self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool)) + self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool)) + self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST", True, type=bool)) + self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool)) + self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool)) + self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool)) + self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool)) + self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool)) + self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool)) + + self._showFilters(settings.value("PluginDatabase/ShowFilters", False, type=bool)) + self._reAddPlugins() + + ## Blacklist plugins + #if not settings_db.contains("Plugins/Blacklisted"): + #blacklist = [] # FIXME + ## Broken or useless plugins + ##blacklist.append("dssi-vst.so") + #blacklist.append("liteon_biquad-vst.so") + #blacklist.append("liteon_biquad-vst_64bit.so") + #blacklist.append("fx_blur-vst.so") + #blacklist.append("fx_blur-vst_64bit.so") + #blacklist.append("fx_tempodelay-vst.so") + #blacklist.append("Scrubby_64bit.so") + #blacklist.append("Skidder_64bit.so") + #blacklist.append("libwormhole2_64bit.so") + #blacklist.append("vexvst.so") + ##blacklist.append("deckadance.dll") + #settings_db.setValue("Plugins/Blacklisted", blacklist) + + def closeEvent(self, event): + self._saveSettings() + QDialog.closeEvent(self, event) + + def done(self, r): + QDialog.done(self, r) + self.close() + # ------------------------------------------------------------------------------------------------------------ # TESTING -#from PyQt4.QtGui import QApplication +from PyQt4.QtGui import QApplication -#Carla.isControl = True +Carla.isControl = True #ptest = { #'index': 0, @@ -1505,13 +3079,15 @@ class PluginWidget(QFrame): #'unit': "un", #} -#app = QApplication(sys.argv) -#gui1 = CarlaAboutW(None) -#gui2 = PluginParameter(None, ptest, 0, 0) -#gui3 = PluginEdit(None, 0) -#gui4 = PluginWidget(None, 0) -#gui1.show() -#gui2.show() -#gui3.show() -#gui4.show() -#app.exec_() +app = QApplication(sys.argv) +app.setApplicationName("Carla") +app.setApplicationVersion(VERSION) +app.setOrganizationName("falkTX") +#gui = CarlaAboutW(None) +#gui = PluginParameter(None, ptest, 0, 0) +#gui = PluginEdit(None, 0) +#gui = PluginWidget(None, 0) +#gui = PluginDatabaseW(None) +gui = PluginRefreshW(None) +gui.show() +app.exec_()