diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 77794fa9..612b492a 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -49,15 +49,15 @@ public: // ------------------------------------------------------------------- // Host UI State - void d_uiResize(unsigned int width, unsigned int height); + void d_uiResize(uint width, uint height); protected: // ------------------------------------------------------------------- // Basic Information - virtual const char* d_getName() const noexcept { return DISTRHO_PLUGIN_NAME; } - virtual unsigned int d_getWidth() const noexcept = 0; - virtual unsigned int d_getHeight() const noexcept = 0; + virtual const char* d_getName() const noexcept { return DISTRHO_PLUGIN_NAME; } + virtual uint d_getWidth() const noexcept = 0; + virtual uint d_getHeight() const noexcept = 0; // ------------------------------------------------------------------- // DSP Callbacks diff --git a/distrho/src/DistrhoPluginCarla.cpp b/distrho/src/DistrhoPluginCarla.cpp index a6542ef6..982dbecb 100644 --- a/distrho/src/DistrhoPluginCarla.cpp +++ b/distrho/src/DistrhoPluginCarla.cpp @@ -110,7 +110,7 @@ protected: // TODO } - void handleUiResize(const unsigned int width, const unsigned int height) + void handleUiResize(const uint width, const uint height) { fUI.setSize(width, height); } @@ -154,7 +154,7 @@ private: } #endif - static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height) + static void uiResizeCallback(void* ptr, uint width, uint height) { handlePtr->handleUiResize(width, height); } diff --git a/distrho/src/DistrhoPluginLADSPA+DSSI.cpp b/distrho/src/DistrhoPluginLADSPA+DSSI.cpp index 2a2b1826..e79ffeb7 100644 --- a/distrho/src/DistrhoPluginLADSPA+DSSI.cpp +++ b/distrho/src/DistrhoPluginLADSPA+DSSI.cpp @@ -57,9 +57,8 @@ public: fPortAudioOuts = nullptr; #endif + if (const uint32_t count = fPlugin.getParameterCount()) { - const uint32_t count(fPlugin.getParameterCount()); - fPortControls = new LADSPA_Data*[count]; fLastControlValues = new LADSPA_Data[count]; @@ -69,13 +68,18 @@ public: fLastControlValues[i] = fPlugin.getParameterValue(i); } } + else + { + fPortControls = nullptr; + fLastControlValues = nullptr; + } #if DISTRHO_PLUGIN_WANT_LATENCY fPortLatency = nullptr; #endif } - ~PluginLadspaDssi() + ~PluginLadspaDssi() noexcept { if (fPortControls != nullptr) { @@ -83,7 +87,7 @@ public: fPortControls = nullptr; } - if (fLastControlValues) + if (fLastControlValues != nullptr) { delete[] fLastControlValues; fLastControlValues = nullptr; @@ -104,12 +108,12 @@ public: // ------------------------------------------------------------------- - void ladspa_connect_port(const unsigned long port, LADSPA_Data* const dataLocation) + void ladspa_connect_port(const ulong port, LADSPA_Data* const dataLocation) noexcept { - unsigned long index = 0; + ulong index = 0; #if DISTRHO_PLUGIN_NUM_INPUTS > 0 - for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i) + for (ulong i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i) { if (port == index++) { @@ -120,7 +124,7 @@ public: #endif #if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 - for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) + for (ulong i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) { if (port == index++) { @@ -138,7 +142,7 @@ public: } #endif - for (unsigned long i=0, count=fPlugin.getParameterCount(); i < count; ++i) + for (ulong i=0, count=fPlugin.getParameterCount(); i < count; ++i) { if (port == index++) { @@ -151,14 +155,14 @@ public: // ------------------------------------------------------------------- #ifdef DISTRHO_PLUGIN_TARGET_DSSI - void ladspa_run(const unsigned long sampleCount) + void ladspa_run(const ulong sampleCount) { dssi_run_synth(sampleCount, nullptr, 0); } - void dssi_run_synth(const unsigned long sampleCount, snd_seq_event_t* const events, const unsigned long eventCount) + void dssi_run_synth(const ulong sampleCount, snd_seq_event_t* const events, const ulong eventCount) #else - void ladspa_run(const unsigned long sampleCount) + void ladspa_run(const ulong sampleCount) #endif { // pre-roll @@ -191,6 +195,7 @@ public: { const snd_seq_event_t& seqEvent(events[i]); + // FIXME if (seqEvent.data.note.channel > 0xF || seqEvent.data.control.channel > 0xF) continue; @@ -264,8 +269,7 @@ public: #if defined(DISTRHO_PLUGIN_TARGET_DSSI) && ! DISTRHO_PLUGIN_IS_SYNTH return; // unused - (void)events; - (void)eventCount; + (void)events; (void)eventCount; #endif } @@ -286,7 +290,7 @@ public: # endif # if DISTRHO_PLUGIN_WANT_PROGRAMS - const DSSI_Program_Descriptor* dssi_get_program(const unsigned long index) + const DSSI_Program_Descriptor* dssi_get_program(const ulong index) { if (index >= fPlugin.getProgramCount()) return nullptr; @@ -300,12 +304,11 @@ public: return &desc; } - void dssi_select_program(const unsigned long bank, const unsigned long program) + void dssi_select_program(const ulong bank, const ulong program) { - const unsigned long realProgram(bank * 128 + program); + const ulong realProgram(bank * 128 + program); - if (realProgram >= fPlugin.getProgramCount()) - return; + DISTRHO_SAFE_ASSERT_RETURN(realProgram < fPlugin.getProgramCount(),); fPlugin.setProgram(realProgram); @@ -372,7 +375,7 @@ private: // ----------------------------------------------------------------------- -static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, unsigned long sampleRate) +static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, ulong sampleRate) { if (d_lastBufferSize == 0) d_lastBufferSize = 2048; @@ -383,7 +386,7 @@ static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, unsigned long #define instancePtr ((PluginLadspaDssi*)instance) -static void ladspa_connect_port(LADSPA_Handle instance, unsigned long port, LADSPA_Data* dataLocation) +static void ladspa_connect_port(LADSPA_Handle instance, ulong port, LADSPA_Data* dataLocation) { instancePtr->ladspa_connect_port(port, dataLocation); } @@ -393,7 +396,7 @@ static void ladspa_activate(LADSPA_Handle instance) instancePtr->ladspa_activate(); } -static void ladspa_run(LADSPA_Handle instance, unsigned long sampleCount) +static void ladspa_run(LADSPA_Handle instance, ulong sampleCount) { instancePtr->ladspa_run(sampleCount); } @@ -417,19 +420,19 @@ static char* dssi_configure(LADSPA_Handle instance, const char* key, const char* # endif # if DISTRHO_PLUGIN_WANT_PROGRAMS -static const DSSI_Program_Descriptor* dssi_get_program(LADSPA_Handle instance, unsigned long index) +static const DSSI_Program_Descriptor* dssi_get_program(LADSPA_Handle instance, ulong index) { return instancePtr->dssi_get_program(index); } -static void dssi_select_program(LADSPA_Handle instance, unsigned long bank, unsigned long program) +static void dssi_select_program(LADSPA_Handle instance, ulong bank, ulong program) { instancePtr->dssi_select_program(bank, program); } # endif # if DISTRHO_PLUGIN_IS_SYNTH -static void dssi_run_synth(LADSPA_Handle instance, unsigned long sampleCount, snd_seq_event_t* events, unsigned long eventCount) +static void dssi_run_synth(LADSPA_Handle instance, ulong sampleCount, snd_seq_event_t* events, ulong eventCount) { instancePtr->dssi_run_synth(sampleCount, events, eventCount); } @@ -443,7 +446,7 @@ static void dssi_run_synth(LADSPA_Handle instance, unsigned long sampleCount, sn static LADSPA_Descriptor sLadspaDescriptor = { /* UniqueID */ 0, /* Label */ nullptr, - /* Properties */ LADSPA_PROPERTY_REALTIME | LADSPA_PROPERTY_HARD_RT_CAPABLE, + /* Properties */ LADSPA_PROPERTY_HARD_RT_CAPABLE, /* Name */ nullptr, /* Maker */ nullptr, /* Copyright */ nullptr, @@ -506,8 +509,8 @@ public: d_lastSampleRate = 0.0; // Get port count, init - unsigned long port = 0; - unsigned long portCount = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS + plugin.getParameterCount(); + ulong port = 0; + ulong portCount = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS + plugin.getParameterCount(); #if DISTRHO_PLUGIN_WANT_LATENCY portCount += 1; #endif @@ -517,7 +520,7 @@ public: // Set ports #if DISTRHO_PLUGIN_NUM_INPUTS > 0 - for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i, ++port) + for (ulong i=0; i < DISTRHO_PLUGIN_NUM_INPUTS; ++i, ++port) { char portName[24] = { '\0' }; std::sprintf(portName, "Audio Input %lu", i+1); @@ -532,7 +535,7 @@ public: #endif #if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 - for (unsigned long i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i, ++port) + for (ulong i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i, ++port) { char portName[24] = { '\0' }; std::sprintf(portName, "Audio Output %lu", i+1); @@ -556,7 +559,7 @@ public: ++port; #endif - for (unsigned long i=0, count=plugin.getParameterCount(); i < count; ++i, ++port) + for (ulong i=0, count=plugin.getParameterCount(); i < count; ++i, ++port) { portNames[port] = strdup((const char*)plugin.getParameterName(i)); portDescriptors[port] = LADSPA_PORT_CONTROL; @@ -665,7 +668,7 @@ public: if (sLadspaDescriptor.PortNames != nullptr) { - for (unsigned long i=0; i < sLadspaDescriptor.PortCount; ++i) + for (ulong i=0; i < sLadspaDescriptor.PortCount; ++i) { if (sLadspaDescriptor.PortNames[i] != nullptr) std::free((void*)sLadspaDescriptor.PortNames[i]); @@ -684,7 +687,7 @@ static DescriptorInitializer sDescInit; END_NAMESPACE_DISTRHO DISTRHO_PLUGIN_EXPORT -const LADSPA_Descriptor* ladspa_descriptor(unsigned long index) +const LADSPA_Descriptor* ladspa_descriptor(ulong index) { USE_NAMESPACE_DISTRHO return (index == 0) ? &sLadspaDescriptor : nullptr; @@ -692,7 +695,7 @@ const LADSPA_Descriptor* ladspa_descriptor(unsigned long index) #ifdef DISTRHO_PLUGIN_TARGET_DSSI DISTRHO_PLUGIN_EXPORT -const DSSI_Descriptor* dssi_descriptor(unsigned long index) +const DSSI_Descriptor* dssi_descriptor(ulong index) { USE_NAMESPACE_DISTRHO return (index == 0) ? &sDssiDescriptor : nullptr; diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp index 37ee4829..ec5d4219 100644 --- a/distrho/src/DistrhoPluginVST.cpp +++ b/distrho/src/DistrhoPluginVST.cpp @@ -215,7 +215,7 @@ protected: #endif } - void uiResize(const unsigned int width, const unsigned int height) + void uiResize(const uint width, const uint height) { fUI.setSize(width, height); hostCallback(audioMasterSizeWindow, width, height, nullptr, 0.0f); @@ -256,7 +256,7 @@ private: handlePtr->sendNote(channel, note, velocity); } - static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height) + static void uiResizeCallback(void* ptr, uint width, uint height) { handlePtr->uiResize(width, height); } diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index 915ed0dc..a015675a 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -79,7 +79,7 @@ void UI::d_sendNote(uint8_t channel, uint8_t note, uint8_t velocity) // ----------------------------------------------------------------------- // Host UI State -void UI::d_uiResize(unsigned int width, unsigned int height) +void UI::d_uiResize(uint width, uint height) { pData->uiResizeCallback(width, height); } diff --git a/distrho/src/DistrhoUIDSSI.cpp b/distrho/src/DistrhoUIDSSI.cpp index 067b96df..12c48d2a 100644 --- a/distrho/src/DistrhoUIDSSI.cpp +++ b/distrho/src/DistrhoUIDSSI.cpp @@ -60,7 +60,7 @@ struct OscData { lo_send(addr, targetPath, "if", index, value); } - void send_midi(unsigned char data[4]) const + void send_midi(uchar data[4]) const { char targetPath[std::strlen(path)+6]; std::strcpy(targetPath, path); @@ -126,13 +126,13 @@ public: } #endif - void dssiui_control(unsigned long index, float value) + void dssiui_control(ulong index, float value) { fUI.parameterChanged(index, value); } #if DISTRHO_PLUGIN_WANT_PROGRAMS - void dssiui_program(unsigned long bank, unsigned long program) + void dssiui_program(ulong bank, ulong program) { fUI.programChanged(bank * 128 + program); } @@ -186,7 +186,7 @@ protected: fOscData.send_midi(mdata); } - void uiResize(const unsigned int width, const unsigned int height) + void uiResize(const uint width, const uint height) { fUI.setSize(width, height); } @@ -217,7 +217,7 @@ private: uiPtr->sendNote(channel, note, velocity); } - static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height) + static void uiResizeCallback(void* ptr, uint width, uint height) { uiPtr->uiResize(width, height); } diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp index caa24cb3..2672a850 100644 --- a/distrho/src/DistrhoUIInternal.hpp +++ b/distrho/src/DistrhoUIInternal.hpp @@ -36,7 +36,7 @@ typedef void (*editParamFunc) (void* ptr, uint32_t rindex, bool started); typedef void (*setParamFunc) (void* ptr, uint32_t rindex, float value); typedef void (*setStateFunc) (void* ptr, const char* key, const char* value); typedef void (*sendNoteFunc) (void* ptr, uint8_t channel, uint8_t note, uint8_t velo); -typedef void (*uiResizeFunc) (void* ptr, unsigned int width, unsigned int height); +typedef void (*uiResizeFunc) (void* ptr, uint width, uint height); // ----------------------------------------------------------------------- // UI private data @@ -113,7 +113,7 @@ struct UI::PrivateData { sendNoteCallbackFunc(ptr, channel, note, velocity); } - void uiResizeCallback(const unsigned int width, const unsigned int height) + void uiResizeCallback(const uint width, const uint height) { if (uiResizeCallbackFunc != nullptr) uiResizeCallbackFunc(ptr, width, height); @@ -169,14 +169,14 @@ public: return fUi->d_getName(); } - unsigned int getWidth() const noexcept + uint getWidth() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, 0); return fUi->d_getWidth(); } - unsigned int getHeight() const noexcept + uint getHeight() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, 0); @@ -239,7 +239,7 @@ public: glApp.quit(); } - void setSize(const unsigned int width, const unsigned int height) + void setSize(const uint width, const uint height) { glWindow.setSize(width, height); } diff --git a/distrho/src/DistrhoUILV2.cpp b/distrho/src/DistrhoUILV2.cpp index 51fcf5ef..ad7271fc 100644 --- a/distrho/src/DistrhoUILV2.cpp +++ b/distrho/src/DistrhoUILV2.cpp @@ -152,7 +152,7 @@ protected: { } - void uiResize(const unsigned int width, const unsigned int height) + void uiResize(const uint width, const uint height) { fUI.setSize(width, height); fUiResize->ui_resize(fUiResize->handle, width, height); @@ -199,7 +199,7 @@ private: uiPtr->sendNote(channel, note, velocity); } - static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height) + static void uiResizeCallback(void* ptr, uint width, uint height) { uiPtr->uiResize(width, height); }