diff --git a/source/backend/CarlaBackend.hpp b/source/backend/CarlaBackend.hpp index 9615bbdba..e9acc58aa 100644 --- a/source/backend/CarlaBackend.hpp +++ b/source/backend/CarlaBackend.hpp @@ -722,7 +722,7 @@ struct ParameterRanges { if (newValue < 0.0f) newValue = 0.0f; - else if (newValue < 1.0f) + else if (newValue > 1.0f) newValue = 1.0f; return newValue; diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 7197b7512..749aa2ab8 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -338,7 +338,7 @@ struct EngineTimeInfo { static const uint32_t ValidBBT = 0x1; bool playing; - uint32_t frame; + uint64_t frame; uint64_t usecs; uint32_t valid; EngineTimeInfoBBT bbt; diff --git a/source/backend/CarlaNative.h b/source/backend/CarlaNative.h index ae6f774e4..68c0b29f8 100644 --- a/source/backend/CarlaNative.h +++ b/source/backend/CarlaNative.h @@ -142,8 +142,8 @@ typedef struct _TimeInfoBBT { typedef struct _TimeInfo { bool playing; - uint32_t frame; - uint32_t usecs; + uint64_t frame; + uint64_t usecs; TimeInfoBBT bbt; } TimeInfo; diff --git a/source/backend/engine/CarlaEnginePlugin.cpp b/source/backend/engine/CarlaEnginePlugin.cpp index e321cb680..cef62be4f 100644 --- a/source/backend/engine/CarlaEnginePlugin.cpp +++ b/source/backend/engine/CarlaEnginePlugin.cpp @@ -23,6 +23,9 @@ using DISTRHO::d_cconst; using DISTRHO::d_string; +#ifdef QTCREATOR_TEST +CARLA_BACKEND_START_NAMESPACE +#else // ----------------------------------------- // needed symbols @@ -33,11 +36,12 @@ CARLA_BACKEND_START_NAMESPACE CarlaEngine* CarlaEngine::newJack() { return nullptr; } -#ifdef WANT_RTAUDIO +# ifdef WANT_RTAUDIO CarlaEngine* CarlaEngine::newRtAudio(RtAudioApi) { return nullptr; } size_t CarlaEngine::getRtAudioApiCount() { return 0; } const char* CarlaEngine::getRtAudioApiName(const unsigned int) { return nullptr; } const char** CarlaEngine::getRtAudioApiDeviceNames(const unsigned int) { return nullptr; } +# endif #endif // ----------------------------------------- diff --git a/source/backend/engine/distrho/DistrhoPluginInfo.h b/source/backend/engine/distrho/DistrhoPluginInfo.h index bb2634eb3..2596a5725 100644 --- a/source/backend/engine/distrho/DistrhoPluginInfo.h +++ b/source/backend/engine/distrho/DistrhoPluginInfo.h @@ -1,5 +1,5 @@ /* - * Carla Plugin Engine + * Carla Plugin Engine (DISTRHO) * Copyright (C) 2012-2013 Filipe Coelho * * This program is free software; you can redistribute it and/or @@ -20,16 +20,18 @@ #define DISTRHO_PLUGIN_NAME "Carla" -#define DISTRHO_PLUGIN_HAS_UI 0 +#define DISTRHO_PLUGIN_HAS_UI 1 #define DISTRHO_PLUGIN_IS_SYNTH 1 #define DISTRHO_PLUGIN_NUM_INPUTS 2 #define DISTRHO_PLUGIN_NUM_OUTPUTS 2 -#define DISTRHO_PLUGIN_WANT_LATENCY 1 +#define DISTRHO_PLUGIN_WANT_LATENCY 0 #define DISTRHO_PLUGIN_WANT_PROGRAMS 1 #define DISTRHO_PLUGIN_WANT_STATE 1 #define DISTRHO_PLUGIN_URI "http://kxstudio.sf.net/carla" +#define DISTRHO_UI_EXTERNAL + #endif // __DISTRHO_PLUGIN_INFO_H__ diff --git a/source/backend/native/3bandeq/DistrhoPluginInfo.h b/source/backend/native/3bandeq/DistrhoPluginInfo.h index cb17c9351..f8b9afba1 100644 --- a/source/backend/native/3bandeq/DistrhoPluginInfo.h +++ b/source/backend/native/3bandeq/DistrhoPluginInfo.h @@ -31,4 +31,6 @@ #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/3BandEQ" +#define DISTRHO_UI_OPENGL + #endif // __DISTRHO_PLUGIN_INFO_H__ diff --git a/source/backend/native/3bandsplitter/DistrhoPluginInfo.h b/source/backend/native/3bandsplitter/DistrhoPluginInfo.h index 41840f799..22004ec17 100644 --- a/source/backend/native/3bandsplitter/DistrhoPluginInfo.h +++ b/source/backend/native/3bandsplitter/DistrhoPluginInfo.h @@ -31,4 +31,6 @@ #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/3BandSplitter" +#define DISTRHO_UI_OPENGL + #endif // __DISTRHO_PLUGIN_INFO_H__ diff --git a/source/backend/native/pingpongpan/DistrhoPluginInfo.h b/source/backend/native/pingpongpan/DistrhoPluginInfo.h index fd1332005..5306dfa4f 100644 --- a/source/backend/native/pingpongpan/DistrhoPluginInfo.h +++ b/source/backend/native/pingpongpan/DistrhoPluginInfo.h @@ -31,4 +31,6 @@ #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/PingPongPan" +#define DISTRHO_UI_OPENGL + #endif // __DISTRHO_PLUGIN_INFO_H__ diff --git a/source/libs/distrho/DistrhoPlugin.hpp b/source/libs/distrho/DistrhoPlugin.hpp index 1101eb4fe..a7eef7ea1 100644 --- a/source/libs/distrho/DistrhoPlugin.hpp +++ b/source/libs/distrho/DistrhoPlugin.hpp @@ -79,9 +79,25 @@ struct ParameterRanges { value = max; } + float fixValue(const float& value) const + { + if (value < min) + return min; + else if (value > max) + return max; + return value; + } + float normalizeValue(const float& value) const { - return (value - min) / (max - min); + float newValue = (value - min) / (max - min); + + if (newValue < 0.0f) + newValue = 0.0f; + else if (newValue > 1.0f) + newValue = 1.0f; + + return newValue; } float unnormalizeValue(const float& value) const @@ -132,17 +148,19 @@ struct MidiEvent { // TimePos struct TimePos { + bool playing; + uint64_t frame; double bpm; TimePos() - : bpm(120.0) {} + : playing(false), + frame(0), + bpm(120.0) {} }; // ------------------------------------------------- // Plugin -struct PluginPrivateData; - class Plugin { public: @@ -209,7 +227,8 @@ protected: // --------------------------------------------- private: - PluginPrivateData* const pData; + struct PrivateData; + PrivateData* const pData; friend class PluginInternal; }; diff --git a/source/libs/distrho/DistrhoUI.hpp b/source/libs/distrho/DistrhoUI.hpp index 55902df7c..1378eec8e 100644 --- a/source/libs/distrho/DistrhoUI.hpp +++ b/source/libs/distrho/DistrhoUI.hpp @@ -26,8 +26,6 @@ START_NAMESPACE_DISTRHO // ------------------------------------------------- // UI -struct UIPrivateData; - class UI { public: @@ -82,7 +80,8 @@ protected: // --------------------------------------------- private: - UIPrivateData* const pData; + struct PrivateData; + PrivateData* const pData; friend class UIInternal; }; diff --git a/source/libs/distrho/DistrhoUtils.hpp b/source/libs/distrho/DistrhoUtils.hpp index bb1460760..7f283f7ee 100644 --- a/source/libs/distrho/DistrhoUtils.hpp +++ b/source/libs/distrho/DistrhoUtils.hpp @@ -62,16 +62,6 @@ void d_msleep(unsigned int msecs) #endif } -static inline -void d_usleep(unsigned int usecs) -{ -#ifdef DISTRHO_OS_WINDOWS - Sleep(usecs / 1000); -#else - usleep(usecs); -#endif -} - // ------------------------------------------------- static inline @@ -504,4 +494,4 @@ d_string operator+(const char* const strBufBefore, const d_string& strAfter) END_NAMESPACE_DISTRHO -#endif // __UTILS_HPP__ +#endif // __DISTRHO_UTILS_HPP__ diff --git a/source/libs/distrho/src/DistrhoDefines.h b/source/libs/distrho/src/DistrhoDefines.h index f82f15452..96a485b9f 100644 --- a/source/libs/distrho/src/DistrhoDefines.h +++ b/source/libs/distrho/src/DistrhoDefines.h @@ -51,6 +51,12 @@ # error DISTRHO_PLUGIN_WANT_STATE undefined! #endif +#if DISTRHO_PLUGIN_HAS_UI +# if ! (defined(DISTRHO_UI_EXTERNAL) || defined(DISTRHO_UI_OPENGL) || defined(DISTRHO_UI_QT)) +# error DISTRHO_PLUGIN_HAS_UI is defined but not its type; please define one of DISTRHO_UI_EXTERNAL, DISTRHO_UI_OPENGL or DISTRHO_UI_QT +# endif +#endif + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) # define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport) # define DISTRHO_OS_WINDOWS 1 @@ -86,10 +92,6 @@ # define USE_NAMESPACE_DISTRHO #endif -#ifndef DISTRHO_UI_QT -# define DISTRHO_UI_OPENGL -#endif - #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI" #endif // __DISTRHO_DEFINES_H__ diff --git a/source/libs/distrho/src/DistrhoPlugin.cpp b/source/libs/distrho/src/DistrhoPlugin.cpp index 976493671..80ea640a3 100644 --- a/source/libs/distrho/src/DistrhoPlugin.cpp +++ b/source/libs/distrho/src/DistrhoPlugin.cpp @@ -34,7 +34,7 @@ const ParameterRanges PluginInternal::sFallbackRanges; // Plugin Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount) - : pData(new PluginPrivateData) + : pData(new PrivateData()) { if (parameterCount > 0) { diff --git a/source/libs/distrho/src/DistrhoPluginInternal.hpp b/source/libs/distrho/src/DistrhoPluginInternal.hpp index c5d69b820..690976ae1 100644 --- a/source/libs/distrho/src/DistrhoPluginInternal.hpp +++ b/source/libs/distrho/src/DistrhoPluginInternal.hpp @@ -28,7 +28,7 @@ START_NAMESPACE_DISTRHO extern uint32_t d_lastBufferSize; extern double d_lastSampleRate; -struct PluginPrivateData { +struct Plugin::PrivateData { uint32_t bufferSize; double sampleRate; @@ -49,9 +49,9 @@ struct PluginPrivateData { uint32_t latency; #endif - TimePos timePos; + TimePos timePos; - PluginPrivateData() + PrivateData() : bufferSize(d_lastBufferSize), sampleRate(d_lastSampleRate), parameterCount(0), @@ -73,7 +73,7 @@ struct PluginPrivateData { assert(sampleRate != 0.0); } - ~PluginPrivateData() + ~PrivateData() { if (parameterCount > 0 && parameters != nullptr) delete[] parameters; @@ -344,7 +344,7 @@ public: protected: Plugin* const kPlugin; - PluginPrivateData* const kData; + Plugin::PrivateData* const kData; private: static const d_string sFallbackString; diff --git a/source/libs/distrho/src/DistrhoPluginVST.cpp b/source/libs/distrho/src/DistrhoPluginVST.cpp index 599f8519a..7a8e33702 100644 --- a/source/libs/distrho/src/DistrhoPluginVST.cpp +++ b/source/libs/distrho/src/DistrhoPluginVST.cpp @@ -223,6 +223,13 @@ protected: #if DISTRHO_PLUGIN_IS_SYNTH // TODO #endif + return; + + // unused + (void)onOff; + (void)channel; + (void)note; + (void)velocity; } void uiResize(unsigned int width, unsigned int height) diff --git a/source/libs/distrho/src/DistrhoUI.cpp b/source/libs/distrho/src/DistrhoUI.cpp index 53409512f..2d4dea20e 100644 --- a/source/libs/distrho/src/DistrhoUI.cpp +++ b/source/libs/distrho/src/DistrhoUI.cpp @@ -27,7 +27,7 @@ double d_lastUiSampleRate = 0.0; // UI UI::UI() - : pData(new UIPrivateData) + : pData(new PrivateData()) { #if (defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2)) pData->parameterOffset = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS; diff --git a/source/libs/distrho/src/DistrhoUIInternal.hpp b/source/libs/distrho/src/DistrhoUIInternal.hpp index aa176ba71..da6bc7af7 100644 --- a/source/libs/distrho/src/DistrhoUIInternal.hpp +++ b/source/libs/distrho/src/DistrhoUIInternal.hpp @@ -19,7 +19,10 @@ #include "DistrhoDefines.h" -#ifdef DISTRHO_UI_OPENGL +#if defined(DISTRHO_UI_EXTERNAL) +# include "../DistrhoUI.hpp" +// TODO +#elif defined(DISTRHO_UI_OPENGL) # include "../DistrhoUIOpenGL.hpp" # include "../dgl/App.hpp" # include "../dgl/Window.hpp" @@ -43,7 +46,7 @@ extern double d_lastUiSampleRate; // ------------------------------------------------- -struct UIPrivateData { +struct UI::PrivateData { // DSP double sampleRate; uint32_t parameterOffset; @@ -56,7 +59,7 @@ struct UIPrivateData { uiResizeFunc uiResizeCallbackFunc; void* ptr; - UIPrivateData() + PrivateData() : sampleRate(d_lastUiSampleRate), parameterOffset(0), editParamCallbackFunc(nullptr), @@ -69,7 +72,7 @@ struct UIPrivateData { assert(sampleRate != 0.0); } - ~UIPrivateData() + ~PrivateData() { } @@ -214,17 +217,26 @@ public: void idle() { -#ifdef DISTRHO_UI_QT +#if defined(DISTRHO_UI_EXTERNAL) + // TODO - idle OSC +#elif defined(DISTRHO_UI_OPENGL) + glApp.idle(); +#else assert(kUi != nullptr); if (kUi != nullptr) kUi->d_uiIdle(); -#else - glApp.idle(); #endif } -#ifdef DISTRHO_UI_QT +#if defined(DISTRHO_UI_EXTERNAL) + // needed? +#elif defined(DISTRHO_UI_OPENGL) + intptr_t getWinId() + { + return glWindow.getWindowId(); + } +#else QtUI* getQtUI() const { return (QtUI*)kUi; @@ -234,24 +246,19 @@ public: { return ((QtUI*)kUi)->d_resizable(); } -#else - intptr_t getWinId() - { - return glWindow.getWindowId(); - } #endif // --------------------------------------------- -private: #ifdef DISTRHO_UI_OPENGL +private: App glApp; Window glWindow; #endif protected: UI* const kUi; - UIPrivateData* const kData; + UI::PrivateData* const kData; }; // -------------------------------------------------