Browse Source

More cleanup

tags/1.9.4
falkTX 12 years ago
parent
commit
8c44e90246
24 changed files with 737 additions and 760 deletions
  1. +54
    -54
      source/modules/distrho/DistrhoPlugin.hpp
  2. +10
    -10
      source/modules/distrho/DistrhoPluginMain.cpp
  3. +30
    -29
      source/modules/distrho/DistrhoUI.hpp
  4. +27
    -21
      source/modules/distrho/DistrhoUIExternal.hpp
  5. +10
    -10
      source/modules/distrho/DistrhoUIMain.cpp
  6. +15
    -41
      source/modules/distrho/DistrhoUIOpenGL.hpp
  7. +25
    -41
      source/modules/distrho/DistrhoUIQt.hpp
  8. +158
    -144
      source/modules/distrho/DistrhoUtils.hpp
  9. +12
    -12
      source/modules/distrho/src/DistrhoDefines.h
  10. +20
    -20
      source/modules/distrho/src/DistrhoPlugin.cpp
  11. +127
    -127
      source/modules/distrho/src/DistrhoPluginInternal.hpp
  12. +54
    -54
      source/modules/distrho/src/DistrhoPluginLADSPA+DSSI.cpp
  13. +16
    -16
      source/modules/distrho/src/DistrhoPluginLV2.cpp
  14. +10
    -10
      source/modules/distrho/src/DistrhoPluginLV2export.cpp
  15. +19
    -21
      source/modules/distrho/src/DistrhoPluginVST.cpp
  16. +15
    -15
      source/modules/distrho/src/DistrhoUI.cpp
  17. +18
    -16
      source/modules/distrho/src/DistrhoUIDSSI.cpp
  18. +11
    -11
      source/modules/distrho/src/DistrhoUIExternal.cpp
  19. +69
    -73
      source/modules/distrho/src/DistrhoUIInternal.hpp
  20. +11
    -11
      source/modules/distrho/src/DistrhoUIOpenGL.cpp
  21. +13
    -13
      source/modules/distrho/src/DistrhoUIQt.cpp
  22. +9
    -9
      source/modules/distrho/src/_todo/DistrhoPluginJACK.cpp
  23. +2
    -2
      source/modules/utils/CarlaString.hpp
  24. +2
    -0
      source/modules/utils/CarlaUtils.hpp

+ 54
- 54
source/modules/distrho/DistrhoPlugin.hpp View File

@@ -2,26 +2,26 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_PLUGIN_HPP__
#define __DISTRHO_PLUGIN_HPP__
#ifndef DISTRHO_PLUGIN_HPP_INCLUDED
#define DISTRHO_PLUGIN_HPP_INCLUDED


#include "DistrhoUtils.hpp" #include "DistrhoUtils.hpp"


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// Parameter Hints // Parameter Hints


const uint32_t PARAMETER_IS_AUTOMABLE = 1 << 0; const uint32_t PARAMETER_IS_AUTOMABLE = 1 << 0;
@@ -30,7 +30,7 @@ const uint32_t PARAMETER_IS_INTEGER = 1 << 2;
const uint32_t PARAMETER_IS_LOGARITHMIC = 1 << 3; const uint32_t PARAMETER_IS_LOGARITHMIC = 1 << 3;
const uint32_t PARAMETER_IS_OUTPUT = 1 << 4; const uint32_t PARAMETER_IS_OUTPUT = 1 << 4;


// -------------------------------------------------
// -----------------------------------------------------------------------
// Parameter Ranges // Parameter Ranges


struct ParameterRanges { struct ParameterRanges {
@@ -41,7 +41,7 @@ struct ParameterRanges {
float stepSmall; float stepSmall;
float stepLarge; float stepLarge;


ParameterRanges()
ParameterRanges() noexcept
: def(0.0f), : def(0.0f),
min(0.0f), min(0.0f),
max(1.0f), max(1.0f),
@@ -49,7 +49,7 @@ struct ParameterRanges {
stepSmall(0.00001f), stepSmall(0.00001f),
stepLarge(0.01f) {} stepLarge(0.01f) {}


ParameterRanges(float def, float min, float max)
ParameterRanges(float def, float min, float max) noexcept
: step(0.001f), : step(0.001f),
stepSmall(0.00001f), stepSmall(0.00001f),
stepLarge(0.01f) stepLarge(0.01f)
@@ -59,7 +59,7 @@ struct ParameterRanges {
this->max = max; this->max = max;
} }


ParameterRanges(float def, float min, float max, float step, float stepSmall, float stepLarge)
ParameterRanges(float def, float min, float max, float step, float stepSmall, float stepLarge) noexcept
{ {
this->def = def; this->def = def;
this->min = min; this->min = min;
@@ -69,7 +69,7 @@ struct ParameterRanges {
this->stepLarge = stepLarge; this->stepLarge = stepLarge;
} }


void clear()
void clear() noexcept
{ {
def = 0.0f; def = 0.0f;
min = 0.0f; min = 0.0f;
@@ -79,7 +79,7 @@ struct ParameterRanges {
stepLarge = 0.01f; stepLarge = 0.01f;
} }


void fixValue(float& value) const
void fixValue(float& value) const noexcept
{ {
if (value < min) if (value < min)
value = min; value = min;
@@ -87,7 +87,7 @@ struct ParameterRanges {
value = max; value = max;
} }


float fixedValue(const float& value) const
float getFixedValue(const float& value) const noexcept
{ {
if (value < min) if (value < min)
return min; return min;
@@ -96,25 +96,24 @@ struct ParameterRanges {
return value; return value;
} }


float normalizedValue(const float& value) const
float getNormalizedValue(const float& value) const noexcept
{ {
const float newValue((value - min) / (max - min)); const float newValue((value - min) / (max - min));


if (newValue < 0.0f)
if (newValue <= 0.0f)
return 0.0f; return 0.0f;
else if (newValue > 1.0f)
if (newValue >= 1.0f)
return 1.0f; return 1.0f;

return newValue; return newValue;
} }


float unnormalizedValue(const float& value) const
float getUnnormalizedValue(const float& value) const noexcept
{ {
return value * (max - min) + min; return value * (max - min) + min;
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------
// Parameter // Parameter


struct Parameter { struct Parameter {
@@ -127,7 +126,7 @@ struct Parameter {
Parameter() Parameter()
: hints(0x0) {} : hints(0x0) {}


void clear()
void clear() noexcept
{ {
hints = 0x0; hints = 0x0;
name = ""; name = "";
@@ -137,7 +136,7 @@ struct Parameter {
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------
// MidiEvent // MidiEvent


struct MidiEvent { struct MidiEvent {
@@ -145,12 +144,12 @@ struct MidiEvent {
uint8_t buf[4]; uint8_t buf[4];
uint8_t size; uint8_t size;


MidiEvent()
MidiEvent() noexcept
{ {
clear(); clear();
} }


void clear()
void clear() noexcept
{ {
frame = 0; frame = 0;
buf[0] = 0; buf[0] = 0;
@@ -161,7 +160,7 @@ struct MidiEvent {
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------
// TimePos // TimePos


struct TimePos { struct TimePos {
@@ -169,13 +168,13 @@ struct TimePos {
uint64_t frame; uint64_t frame;
double bpm; double bpm;


TimePos()
TimePos() noexcept
: playing(false), : playing(false),
frame(0), frame(0),
bpm(120.0) {} bpm(120.0) {}
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------
// Plugin // Plugin


class Plugin class Plugin
@@ -184,30 +183,30 @@ public:
Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount); Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount);
virtual ~Plugin(); virtual ~Plugin();


// ---------------------------------------------
// -------------------------------------------------------------------
// Host state // Host state


uint32_t d_bufferSize() const;
double d_sampleRate() const;
uint32_t d_getBufferSize() const noexcept;
double d_getSampleRate() const noexcept;
#if DISTRHO_PLUGIN_WANT_TIMEPOS #if DISTRHO_PLUGIN_WANT_TIMEPOS
const TimePos& d_timePos() const;
const TimePos& d_getTimePos() const noexcept;
#endif #endif
#if DISTRHO_PLUGIN_WANT_LATENCY #if DISTRHO_PLUGIN_WANT_LATENCY
void d_setLatency(uint32_t frames);
void d_setLatency(uint32_t frames) noexcept;
#endif #endif


protected: protected:
// ---------------------------------------------
// -------------------------------------------------------------------
// Information // Information


virtual const char* d_name() const { return DISTRHO_PLUGIN_NAME; }
virtual const char* d_label() const = 0;
virtual const char* d_maker() const = 0;
virtual const char* d_license() const = 0;
virtual uint32_t d_version() const = 0;
virtual long d_uniqueId() const = 0;
virtual const char* d_getName() const noexcept { return DISTRHO_PLUGIN_NAME; }
virtual const char* d_getLabel() const noexcept = 0;
virtual const char* d_getMaker() const noexcept = 0;
virtual const char* d_getLicense() const noexcept = 0;
virtual uint32_t d_getVersion() const noexcept = 0;
virtual long d_getUniqueId() const noexcept = 0;


// ---------------------------------------------
// -------------------------------------------------------------------
// Init // Init


virtual void d_initParameter(uint32_t index, Parameter& parameter) = 0; virtual void d_initParameter(uint32_t index, Parameter& parameter) = 0;
@@ -218,10 +217,10 @@ protected:
virtual void d_initStateKey(uint32_t index, d_string& stateKey) = 0; virtual void d_initStateKey(uint32_t index, d_string& stateKey) = 0;
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------
// Internal data // Internal data


virtual float d_parameterValue(uint32_t index) = 0;
virtual float d_getParameterValue(uint32_t index) const = 0;
virtual void d_setParameterValue(uint32_t index, float value) = 0; virtual void d_setParameterValue(uint32_t index, float value) = 0;
#if DISTRHO_PLUGIN_WANT_PROGRAMS #if DISTRHO_PLUGIN_WANT_PROGRAMS
virtual void d_setProgram(uint32_t index) = 0; virtual void d_setProgram(uint32_t index) = 0;
@@ -230,20 +229,20 @@ protected:
virtual void d_setState(const char* key, const char* value) = 0; virtual void d_setState(const char* key, const char* value) = 0;
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------
// Process // Process


virtual void d_activate() {} virtual void d_activate() {}
virtual void d_deactivate() {} virtual void d_deactivate() {}
virtual void d_run(float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents) = 0; virtual void d_run(float** inputs, float** outputs, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents) = 0;


// ---------------------------------------------
// -------------------------------------------------------------------
// Callbacks (optional) // Callbacks (optional)


virtual void d_bufferSizeChanged(uint32_t newBufferSize); virtual void d_bufferSizeChanged(uint32_t newBufferSize);
virtual void d_sampleRateChanged(double newSampleRate); virtual void d_sampleRateChanged(double newSampleRate);


// ---------------------------------------------
// -------------------------------------------------------------------


private: private:
struct PrivateData; struct PrivateData;
@@ -251,12 +250,13 @@ private:
friend class PluginInternal; friend class PluginInternal;
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------
// Create plugin, entry point


Plugin* createPlugin();
extern Plugin* createPlugin();


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


#endif // __DISTRHO_PLUGIN_HPP__
#endif // DISTRHO_PLUGIN_HPP_INCLUDED

+ 10
- 10
source/modules/distrho/DistrhoPluginMain.cpp View File

@@ -2,23 +2,23 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "src/DistrhoPlugin.cpp" #include "src/DistrhoPlugin.cpp"


#if defined(DISTRHO_PLUGIN_TARGET_JACK) #if defined(DISTRHO_PLUGIN_TARGET_JACK)
# include "src/DistrhoPluginJACK.cpp" # include "src/DistrhoPluginJACK.cpp"
#elif defined(DISTRHO_PLUGIN_TARGET_LADSPA) || defined(DISTRHO_PLUGIN_TARGET_DSSI)
#elif (defined(DISTRHO_PLUGIN_TARGET_LADSPA) || defined(DISTRHO_PLUGIN_TARGET_DSSI))
# include "src/DistrhoPluginLADSPA+DSSI.cpp" # include "src/DistrhoPluginLADSPA+DSSI.cpp"
#elif defined(DISTRHO_PLUGIN_TARGET_LV2) #elif defined(DISTRHO_PLUGIN_TARGET_LV2)
# include "src/DistrhoPluginLV2.cpp" # include "src/DistrhoPluginLV2.cpp"


+ 30
- 29
source/modules/distrho/DistrhoUI.hpp View File

@@ -2,26 +2,26 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_UI_HPP__
#define __DISTRHO_UI_HPP__
#ifndef DISTRHO_UI_HPP_INCLUDED
#define DISTRHO_UI_HPP_INCLUDED


#include "DistrhoUtils.hpp" #include "DistrhoUtils.hpp"


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// UI // UI


class UI class UI
@@ -30,10 +30,10 @@ public:
UI(); UI();
virtual ~UI(); virtual ~UI();


// ---------------------------------------------
// -------------------------------------------------------------------
// Host DSP State // Host DSP State


double d_sampleRate() const;
double d_getSampleRate() const noexcept;
void d_editParameter(uint32_t index, bool started); void d_editParameter(uint32_t index, bool started);
void d_setParameterValue(uint32_t index, float value); void d_setParameterValue(uint32_t index, float value);
#if DISTRHO_PLUGIN_WANT_STATE #if DISTRHO_PLUGIN_WANT_STATE
@@ -43,20 +43,20 @@ public:
void d_sendNote(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity); void d_sendNote(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity);
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------
// Host UI State // Host UI State


void d_uiResize(unsigned int width, unsigned int height); void d_uiResize(unsigned int width, unsigned int height);


protected: protected:
// ---------------------------------------------
// Information
// -------------------------------------------------------------------
// Basic Information


virtual const char* d_name() const { return DISTRHO_PLUGIN_NAME; }
virtual unsigned int d_width() const = 0;
virtual unsigned int d_height() const = 0;
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;


// ---------------------------------------------
// -------------------------------------------------------------------
// DSP Callbacks // DSP Callbacks


virtual void d_parameterChanged(uint32_t index, float value) = 0; virtual void d_parameterChanged(uint32_t index, float value) = 0;
@@ -70,12 +70,12 @@ protected:
virtual void d_noteReceived(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) = 0; virtual void d_noteReceived(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) = 0;
#endif #endif


// ---------------------------------------------
// UI Callbacks
// -------------------------------------------------------------------
// UI Callbacks (optional)


virtual void d_uiIdle() = 0;
virtual void d_uiIdle() {}


// ---------------------------------------------
// -------------------------------------------------------------------


private: private:
struct PrivateData; struct PrivateData;
@@ -83,12 +83,13 @@ private:
friend class UIInternal; friend class UIInternal;
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------
// Create UI, entry point


UI* createUI();
extern UI* createUI();


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


#endif // __DISTRHO_UI_HPP__
#endif // DISTRHO_UI_HPP_INCLUDED

+ 27
- 21
source/modules/distrho/DistrhoUIExternal.hpp View File

@@ -2,28 +2,28 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_UI_EXTERNAL_HPP__
#define __DISTRHO_UI_EXTERNAL_HPP__
#ifndef DISTRHO_UI_EXTERNAL_HPP_INCLUDED
#define DISTRHO_UI_EXTERNAL_HPP_INCLUDED


#include "DistrhoUI.hpp" #include "DistrhoUI.hpp"


#include <lo/lo.h>
//#include <lo/lo.h>


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// External UI // External UI


class ExternalUI : public UI class ExternalUI : public UI
@@ -33,16 +33,18 @@ public:
virtual ~ExternalUI() override; virtual ~ExternalUI() override;


protected: protected:
virtual const char* d_externalFilename() const = 0;
// -------------------------------------------------------------------
// Information (External)

virtual const char* d_getExternalFilename() const = 0;


private: private:
friend class UIInternal;
// -------------------------------------------------------------------
// Implement stuff not needed for external UIs


// ---------------------------------------------
// not needed for external UIs
unsigned int d_getWidth() const noexcept override { return 0; }
unsigned int d_getHeight() const noexcept override { return 0; }


unsigned int d_width() const override { return 0; }
unsigned int d_height() const override { return 0; }
void d_parameterChanged(uint32_t, float) override {} void d_parameterChanged(uint32_t, float) override {}
#if DISTRHO_PLUGIN_WANT_PROGRAMS #if DISTRHO_PLUGIN_WANT_PROGRAMS
void d_programChanged(uint32_t) override {} void d_programChanged(uint32_t) override {}
@@ -53,11 +55,15 @@ private:
#if DISTRHO_PLUGIN_IS_SYNTH #if DISTRHO_PLUGIN_IS_SYNTH
void d_noteReceived(bool, uint8_t, uint8_t, uint8_t) override {} void d_noteReceived(bool, uint8_t, uint8_t, uint8_t) override {}
#endif #endif

void d_uiIdle() override {} void d_uiIdle() override {}

friend class UIInternal;
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------



END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


#endif // __DISTRHO_UI_EXTERNAL_HPP__
#endif // DISTRHO_UI_EXTERNAL_HPP_INCLUDED

+ 10
- 10
source/modules/distrho/DistrhoUIMain.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "src/DistrhoUI.cpp" #include "src/DistrhoUI.cpp"
@@ -30,6 +30,6 @@
# include "src/DistrhoUIExternal.cpp" # include "src/DistrhoUIExternal.cpp"
#elif defined(DISTRHO_UI_OPENGL) #elif defined(DISTRHO_UI_OPENGL)
# include "src/DistrhoUIOpenGL.cpp" # include "src/DistrhoUIOpenGL.cpp"
#else
#elif defined(DISTRHO_UI_QT)
# include "src/DistrhoUIQt.cpp" # include "src/DistrhoUIQt.cpp"
#endif #endif

+ 15
- 41
source/modules/distrho/DistrhoUIOpenGL.hpp View File

@@ -2,30 +2,30 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_UI_OPENGL_HPP__
#define __DISTRHO_UI_OPENGL_HPP__
#ifndef DISTRHO_UI_OPENGL_HPP_INCLUDED
#define DISTRHO_UI_OPENGL_HPP_INCLUDED


#include "DistrhoUI.hpp" #include "DistrhoUI.hpp"


#include "dgl/Widget.hpp" #include "dgl/Widget.hpp"


USE_NAMESPACE_DGL
using DGL::Widget;


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// OpenGL UI // OpenGL UI


class OpenGLUI : public UI, class OpenGLUI : public UI,
@@ -35,38 +35,12 @@ public:
OpenGLUI(); OpenGLUI();
virtual ~OpenGLUI() override; virtual ~OpenGLUI() override;


protected:
// ---------------------------------------------
// Information

virtual unsigned int d_width() const override = 0;
virtual unsigned int d_height() const override = 0;

// ---------------------------------------------
// DSP Callbacks

virtual void d_parameterChanged(uint32_t index, float value) override = 0;
#if DISTRHO_PLUGIN_WANT_PROGRAMS
virtual void d_programChanged(uint32_t index) override = 0;
#endif
#if DISTRHO_PLUGIN_WANT_STATE
virtual void d_stateChanged(const char* key, const char* value) override = 0;
#endif
#if DISTRHO_PLUGIN_IS_SYNTH
virtual void d_noteReceived(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) override = 0;
#endif

// ---------------------------------------------
// UI Callbacks

virtual void d_uiIdle() override {}

private: private:
friend class UIInternal; friend class UIInternal;
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


#endif // __DISTRHO_UI_OPENGL_HPP__
#endif // DISTRHO_UI_OPENGL_HPP_INCLUDED

+ 25
- 41
source/modules/distrho/DistrhoUIQt.hpp View File

@@ -2,20 +2,20 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_UI_QT_HPP__
#define __DISTRHO_UI_QT_HPP__
#ifndef DISTRHO_UI_QT_HPP_INCLUDED
#define DISTRHO_UI_QT_HPP_INCLUDED


#include "DistrhoUI.hpp" #include "DistrhoUI.hpp"


@@ -29,7 +29,7 @@


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// Qt UI // Qt UI


class QtUI : public UI, class QtUI : public UI,
@@ -39,47 +39,31 @@ public:
QtUI(); QtUI();
virtual ~QtUI() override; virtual ~QtUI() override;


// ---------------------------------------------
// -------------------------------------------------------------------
// UI Helpers // UI Helpers


void setSize(unsigned int width, unsigned int height); void setSize(unsigned int width, unsigned int height);


protected: protected:
// ---------------------------------------------
// Information

virtual bool d_resizable() const { return false; }
virtual uint d_minimumWidth() const { return 100; }
virtual uint d_minimumHeight() const { return 100; }
// -------------------------------------------------------------------
// Information (Qt)


// ---------------------------------------------
// DSP Callbacks
virtual bool d_isResizable() const noexcept { return false; }
virtual uint d_getMinimumWidth() const noexcept { return 100; }
virtual uint d_getMinimumHeight() const noexcept { return 100; }


virtual void d_parameterChanged(uint32_t index, float value) override = 0;
#if DISTRHO_PLUGIN_WANT_PROGRAMS
virtual void d_programChanged(uint32_t index) override = 0;
#endif
#if DISTRHO_PLUGIN_WANT_STATE
virtual void d_stateChanged(const char* key, const char* value) override = 0;
#endif
#if DISTRHO_PLUGIN_IS_SYNTH
virtual void d_noteReceived(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) override = 0;
#endif

// ---------------------------------------------
// UI Callbacks
private:
// -------------------------------------------------------------------
// Implemented internally


virtual void d_uiIdle() override {}
unsigned int d_getWidth() const noexcept override { return width(); }
unsigned int d_getHeight() const noexcept override { return height(); }


private:
friend class UIInternal; friend class UIInternal;

unsigned int d_width() const override { return width(); }
unsigned int d_height() const override { return height(); }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


#endif // __DISTRHO_UI_QT_HPP__
#endif // DISTRHO_UI_QT_HPP_INCLUDED

+ 158
- 144
source/modules/distrho/DistrhoUtils.hpp View File

@@ -2,20 +2,20 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_UTILS_HPP__
#define __DISTRHO_UTILS_HPP__
#ifndef DISTRHO_UTILS_HPP_INCLUDED
#define DISTRHO_UTILS_HPP_INCLUDED


#include "src/DistrhoDefines.h" #include "src/DistrhoDefines.h"


@@ -51,17 +51,17 @@ inline float
} }
#endif #endif


START_NAMESPACE_DISTRHO

// -------------------------------------------------
// -----------------------------------------------------------------------
// misc functions


static inline static inline
long d_cconst(int a, int b, int c, int d)
long d_cconst(int a, int b, int c, int d) noexcept
{ {
return (a << 24) | (b << 16) | (c << 8) | (d << 0); return (a << 24) | (b << 16) | (c << 8) | (d << 0);
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// string print functions


#ifndef DEBUG #ifndef DEBUG
# define d_debug(...) # define d_debug(...)
@@ -71,15 +71,9 @@ void d_debug(const char* const fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
# ifndef DISTRHO_OS_WINDOWS
std::fprintf(stdout, "\x1b[30;1m"); std::fprintf(stdout, "\x1b[30;1m");
# endif
std::vfprintf(stdout, fmt, args); std::vfprintf(stdout, fmt, args);
# ifndef DISTRHO_OS_WINDOWS
std::fprintf(stdout, "\x1b[0m\n"); std::fprintf(stdout, "\x1b[0m\n");
# else
std::fprintf(stdout, "\n");
# endif
va_end(args); va_end(args);
} }
#endif #endif
@@ -109,19 +103,14 @@ void d_stderr2(const char* const fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
#ifndef DISTRHO_OS_WINDOWS
std::fprintf(stderr, "\x1b[31m"); std::fprintf(stderr, "\x1b[31m");
#endif
std::vfprintf(stderr, fmt, args); std::vfprintf(stderr, fmt, args);
#ifndef DISTRHO_OS_WINDOWS
std::fprintf(stderr, "\x1b[0m\n"); std::fprintf(stderr, "\x1b[0m\n");
#else
std::fprintf(stderr, "\n");
#endif
va_end(args); va_end(args);
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// d_*sleep


static inline static inline
void d_sleep(unsigned int secs) void d_sleep(unsigned int secs)
@@ -143,12 +132,13 @@ void d_msleep(unsigned int msecs)
#endif #endif
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// d_string class


class d_string class d_string
{ {
public: public:
// ---------------------------------------------
// -------------------------------------------------------------------
// constructors (no explicit conversions allowed) // constructors (no explicit conversions allowed)


explicit d_string() explicit d_string()
@@ -171,7 +161,8 @@ public:


explicit d_string(const int value) explicit d_string(const int value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%d", value); std::snprintf(strBuf, 0xff, "%d", value);


_init(); _init();
@@ -180,7 +171,8 @@ public:


explicit d_string(const unsigned int value, const bool hexadecimal = false) explicit d_string(const unsigned int value, const bool hexadecimal = false)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value); std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value);


_init(); _init();
@@ -189,7 +181,8 @@ public:


explicit d_string(const long int value) explicit d_string(const long int value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%ld", value); std::snprintf(strBuf, 0xff, "%ld", value);


_init(); _init();
@@ -198,7 +191,8 @@ public:


explicit d_string(const unsigned long int value, const bool hexadecimal = false) explicit d_string(const unsigned long int value, const bool hexadecimal = false)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value); std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value);


_init(); _init();
@@ -207,7 +201,8 @@ public:


explicit d_string(const float value) explicit d_string(const float value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%f", value); std::snprintf(strBuf, 0xff, "%f", value);


_init(); _init();
@@ -216,49 +211,50 @@ public:


explicit d_string(const double value) explicit d_string(const double value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
std::memset(strBuf, 0, (0xff+1)*sizeof(char));
std::snprintf(strBuf, 0xff, "%g", value); std::snprintf(strBuf, 0xff, "%g", value);


_init(); _init();
_dup(strBuf); _dup(strBuf);
} }


// ---------------------------------------------
// -------------------------------------------------------------------
// non-explicit constructor // non-explicit constructor


d_string(const d_string& str) d_string(const d_string& str)
{ {
_init(); _init();
_dup(str.buffer);
_dup(str.fBuffer);
} }


// ---------------------------------------------
// deconstructor
// -------------------------------------------------------------------
// destructor


~d_string() ~d_string()
{ {
assert(buffer != nullptr);
assert(fBuffer != nullptr);


delete[] buffer;
buffer = nullptr;
delete[] fBuffer;
fBuffer = nullptr;
} }


// ---------------------------------------------
// -------------------------------------------------------------------
// public methods // public methods


size_t length() const
size_t length() const noexcept
{ {
return bufferLen;
return fBufferLen;
} }


bool isEmpty() const
bool isEmpty() const noexcept
{ {
return (bufferLen == 0);
return (fBufferLen == 0);
} }


bool isNotEmpty() const
bool isNotEmpty() const noexcept
{ {
return (bufferLen != 0);
return (fBufferLen != 0);
} }


#ifdef __USE_GNU #ifdef __USE_GNU
@@ -268,14 +264,14 @@ public:
return false; return false;


if (ignoreCase) if (ignoreCase)
return (strcasestr(buffer, strBuf) != nullptr);
return (strcasestr(fBuffer, strBuf) != nullptr);
else else
return (std::strstr(buffer, strBuf) != nullptr);
return (std::strstr(fBuffer, strBuf) != nullptr);
} }


bool contains(const d_string& str, const bool ignoreCase = false) const bool contains(const d_string& str, const bool ignoreCase = false) const
{ {
return contains(str.buffer, ignoreCase);
return contains(str.fBuffer, ignoreCase);
} }
#else #else
bool contains(const char* const strBuf) const bool contains(const char* const strBuf) const
@@ -283,21 +279,21 @@ public:
if (strBuf == nullptr) if (strBuf == nullptr)
return false; return false;


return (std::strstr(buffer, strBuf) != nullptr);
return (std::strstr(fBuffer, strBuf) != nullptr);
} }


bool contains(const d_string& str) const bool contains(const d_string& str) const
{ {
return contains(str.buffer);
return contains(str.fBuffer);
} }
#endif #endif


bool isDigit(const size_t pos) const
bool isDigit(const size_t pos) const noexcept
{ {
if (pos >= bufferLen)
if (pos >= fBufferLen)
return false; return false;


return (buffer[pos] >= '0' && buffer[pos] <= '9');
return (fBuffer[pos] >= '0' && fBuffer[pos] <= '9');
} }


bool startsWith(const char* const prefix) const bool startsWith(const char* const prefix) const
@@ -307,10 +303,10 @@ public:


const size_t prefixLen(std::strlen(prefix)); const size_t prefixLen(std::strlen(prefix));


if (bufferLen < prefixLen)
if (fBufferLen < prefixLen)
return false; return false;


return (std::strncmp(buffer + (bufferLen-prefixLen), prefix, prefixLen) == 0);
return (std::strncmp(fBuffer + (fBufferLen-prefixLen), prefix, prefixLen) == 0);
} }


bool endsWith(const char* const suffix) const bool endsWith(const char* const suffix) const
@@ -320,124 +316,144 @@ public:


const size_t suffixLen(std::strlen(suffix)); const size_t suffixLen(std::strlen(suffix));


if (bufferLen < suffixLen)
if (fBufferLen < suffixLen)
return false; return false;


return (std::strncmp(buffer + (bufferLen-suffixLen), suffix, suffixLen) == 0);
return (std::strncmp(fBuffer + (fBufferLen-suffixLen), suffix, suffixLen) == 0);
} }


void clear()
void clear() noexcept
{ {
truncate(0); truncate(0);
} }


size_t find(const char c) const
size_t find(const char c) const noexcept
{ {
for (size_t i=0; i < bufferLen; ++i)
for (size_t i=0; i < fBufferLen; ++i)
{ {
if (buffer[i] == c)
if (fBuffer[i] == c)
return i; return i;
} }


return 0; return 0;
} }


size_t rfind(const char c) const
size_t rfind(const char c) const noexcept
{ {
for (size_t i=bufferLen; i > 0; --i)
for (size_t i=fBufferLen; i > 0; --i)
{ {
if (buffer[i-1] == c)
if (fBuffer[i-1] == c)
return i-1; return i-1;
} }


return 0; return 0;
} }


void replace(const char before, const char after)
size_t rfind(const char* const strBuf) const
{
if (strBuf == nullptr || strBuf[0] == '\0')
return fBufferLen;

size_t ret = fBufferLen+1;
const char* tmpBuf = fBuffer;

for (size_t i=0; i < fBufferLen; ++i)
{
if (std::strstr(tmpBuf, strBuf) == nullptr)
break;

--ret;
++tmpBuf;
}

return (ret > fBufferLen) ? fBufferLen : fBufferLen-ret;
}

void replace(const char before, const char after) noexcept
{ {
if (after == '\0') if (after == '\0')
return; return;


for (size_t i=0; i < bufferLen; ++i)
for (size_t i=0; i < fBufferLen; ++i)
{ {
if (buffer[i] == before)
buffer[i] = after;
else if (buffer[i] == '\0')
if (fBuffer[i] == before)
fBuffer[i] = after;
else if (fBuffer[i] == '\0')
break; break;
} }
} }


void truncate(const size_t n)
void truncate(const size_t n) noexcept
{ {
if (n >= bufferLen)
if (n >= fBufferLen)
return; return;


for (size_t i=n; i < bufferLen; ++i)
buffer[i] = '\0';
for (size_t i=n; i < fBufferLen; ++i)
fBuffer[i] = '\0';


bufferLen = n;
fBufferLen = n;
} }


void toBasic()
void toBasic() noexcept
{ {
for (size_t i=0; i < bufferLen; ++i)
for (size_t i=0; i < fBufferLen; ++i)
{ {
if (buffer[i] >= '0' && buffer[i] <= '9')
if (fBuffer[i] >= '0' && fBuffer[i] <= '9')
continue; continue;
if (buffer[i] >= 'A' && buffer[i] <= 'Z')
if (fBuffer[i] >= 'A' && fBuffer[i] <= 'Z')
continue; continue;
if (buffer[i] >= 'a' && buffer[i] <= 'z')
if (fBuffer[i] >= 'a' && fBuffer[i] <= 'z')
continue; continue;
if (buffer[i] == '_')
if (fBuffer[i] == '_')
continue; continue;


buffer[i] = '_';
fBuffer[i] = '_';
} }
} }


void toLower()
void toLower() noexcept
{ {
static const char kCharDiff = 'a' - 'A';
static const char kCharDiff('a' - 'A');


for (size_t i=0; i < bufferLen; ++i)
for (size_t i=0; i < fBufferLen; ++i)
{ {
if (buffer[i] >= 'A' && buffer[i] <= 'Z')
buffer[i] += kCharDiff;
if (fBuffer[i] >= 'A' && fBuffer[i] <= 'Z')
fBuffer[i] += kCharDiff;
} }
} }


void toUpper()
void toUpper() noexcept
{ {
static const char kCharDiff = 'a' - 'A';
static const char kCharDiff('a' - 'A');


for (size_t i=0; i < bufferLen; ++i)
for (size_t i=0; i < fBufferLen; ++i)
{ {
if (buffer[i] >= 'a' && buffer[i] <= 'z')
buffer[i] -= kCharDiff;
if (fBuffer[i] >= 'a' && fBuffer[i] <= 'z')
fBuffer[i] -= kCharDiff;
} }
} }


// ---------------------------------------------
// -------------------------------------------------------------------
// public operators // public operators


operator const char*() const
operator const char*() const noexcept
{ {
return buffer;
return fBuffer;
} }


char& operator[](const size_t pos)
char& operator[](const size_t pos) const noexcept
{ {
return buffer[pos];
return fBuffer[pos];
} }


bool operator==(const char* const strBuf) const bool operator==(const char* const strBuf) const
{ {
return (strBuf != nullptr && std::strcmp(buffer, strBuf) == 0);
return (strBuf != nullptr && std::strcmp(fBuffer, strBuf) == 0);
} }


bool operator==(const d_string& str) const bool operator==(const d_string& str) const
{ {
return operator==(str.buffer);
return operator==(str.fBuffer);
} }


bool operator!=(const char* const strBuf) const bool operator!=(const char* const strBuf) const
@@ -447,7 +463,7 @@ public:


bool operator!=(const d_string& str) const bool operator!=(const d_string& str) const
{ {
return !operator==(str.buffer);
return !operator==(str.fBuffer);
} }


d_string& operator=(const char* const strBuf) d_string& operator=(const char* const strBuf)
@@ -459,15 +475,15 @@ public:


d_string& operator=(const d_string& str) d_string& operator=(const d_string& str)
{ {
return operator=(str.buffer);
return operator=(str.fBuffer);
} }


d_string& operator+=(const char* const strBuf) d_string& operator+=(const char* const strBuf)
{ {
const size_t newBufSize = bufferLen + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
const size_t newBufSize = fBufferLen + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, buffer);
std::strcpy(newBuf, fBuffer);
std::strcat(newBuf, strBuf); std::strcat(newBuf, strBuf);


_dup(newBuf, newBufSize-1); _dup(newBuf, newBufSize-1);
@@ -477,15 +493,15 @@ public:


d_string& operator+=(const d_string& str) d_string& operator+=(const d_string& str)
{ {
return operator+=(str.buffer);
return operator+=(str.fBuffer);
} }


d_string operator+(const char* const strBuf) d_string operator+(const char* const strBuf)
{ {
const size_t newBufSize = bufferLen + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
const size_t newBufSize = fBufferLen + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, buffer);
std::strcpy(newBuf, fBuffer);
std::strcat(newBuf, strBuf); std::strcat(newBuf, strBuf);


return d_string(newBuf); return d_string(newBuf);
@@ -493,21 +509,21 @@ public:


d_string operator+(const d_string& str) d_string operator+(const d_string& str)
{ {
return operator+(str.buffer);
return operator+(str.fBuffer);
} }


// ---------------------------------------------
// -------------------------------------------------------------------


private: private:
char* buffer;
size_t bufferLen;
bool firstInit;
char* fBuffer;
size_t fBufferLen;
bool fFirstInit;


void _init()
void _init() noexcept
{ {
buffer = nullptr;
bufferLen = 0;
firstInit = true;
fBuffer = nullptr;
fBufferLen = 0;
fFirstInit = true;
} }


// allocate string strBuf if not null // allocate string strBuf if not null
@@ -517,22 +533,22 @@ private:
if (strBuf != nullptr) if (strBuf != nullptr)
{ {
// don't recreate string if contents match // don't recreate string if contents match
if (firstInit || std::strcmp(buffer, strBuf) != 0)
if (fFirstInit || std::strcmp(fBuffer, strBuf) != 0)
{ {
if (! firstInit)
if (! fFirstInit)
{ {
assert(buffer != nullptr);
delete[] buffer;
assert(fBuffer != nullptr);
delete[] fBuffer;
} }


bufferLen = (size > 0) ? size : std::strlen(strBuf);
buffer = new char[bufferLen+1];
fBufferLen = (size > 0) ? size : std::strlen(strBuf);
fBuffer = new char[fBufferLen+1];


std::strcpy(buffer, strBuf);
std::strcpy(fBuffer, strBuf);


buffer[bufferLen] = '\0';
fBuffer[fBufferLen] = '\0';


firstInit = false;
fFirstInit = false;
} }
} }
else else
@@ -540,31 +556,31 @@ private:
assert(size == 0); assert(size == 0);


// don't recreate null string // don't recreate null string
if (firstInit || bufferLen != 0)
if (fFirstInit || fBufferLen != 0)
{ {
if (! firstInit)
if (! fFirstInit)
{ {
assert(buffer != nullptr);
delete[] buffer;
assert(fBuffer != nullptr);
delete[] fBuffer;
} }


bufferLen = 0;
buffer = new char[1];
buffer[0] = '\0';
fBufferLen = 0;
fBuffer = new char[1];
fBuffer[0] = '\0';


firstInit = false;
fFirstInit = false;
} }
} }
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


static inline static inline
d_string operator+(const d_string& strBefore, const char* const strBufAfter) d_string operator+(const d_string& strBefore, const char* const strBufAfter)
{ {
const char* const strBufBefore = (const char*)strBefore; const char* const strBufBefore = (const char*)strBefore;
const size_t newBufSize = strBefore.length() + ((strBufAfter != nullptr) ? std::strlen(strBufAfter) : 0) + 1;
const size_t newBufSize = strBefore.length() + ((strBufAfter != nullptr) ? std::strlen(strBufAfter) : 0) + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, strBufBefore); std::strcpy(newBuf, strBufBefore);
@@ -577,7 +593,7 @@ static inline
d_string operator+(const char* const strBufBefore, const d_string& strAfter) d_string operator+(const char* const strBufBefore, const d_string& strAfter)
{ {
const char* const strBufAfter = (const char*)strAfter; const char* const strBufAfter = (const char*)strAfter;
const size_t newBufSize = ((strBufBefore != nullptr) ? std::strlen(strBufBefore) : 0) + strAfter.length() + 1;
const size_t newBufSize = ((strBufBefore != nullptr) ? std::strlen(strBufBefore) : 0) + strAfter.length() + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, strBufBefore); std::strcpy(newBuf, strBufBefore);
@@ -586,8 +602,6 @@ d_string operator+(const char* const strBufBefore, const d_string& strAfter)
return d_string(newBuf); return d_string(newBuf);
} }


// -------------------------------------------------

END_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------


#endif // __DISTRHO_UTILS_HPP__
#endif // DISTRHO_UTILS_HPP_INCLUDED

+ 12
- 12
source/modules/distrho/src/DistrhoDefines.h View File

@@ -2,20 +2,20 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_DEFINES_H__
#define __DISTRHO_DEFINES_H__
#ifndef DISTRHO_DEFINES_H_INCLUDED
#define DISTRHO_DEFINES_H_INCLUDED


#include "DistrhoPluginInfo.h" #include "DistrhoPluginInfo.h"


@@ -115,4 +115,4 @@


#define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI" #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI"


#endif // __DISTRHO_DEFINES_H__
#endif // DISTRHO_DEFINES_H_INCLUDED

+ 20
- 20
source/modules/distrho/src/DistrhoPlugin.cpp View File

@@ -2,35 +2,35 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoPluginInternal.hpp" #include "DistrhoPluginInternal.hpp"


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// Static data // Static data


uint32_t d_lastBufferSize = 0; uint32_t d_lastBufferSize = 0;
double d_lastSampleRate = 0.0; double d_lastSampleRate = 0.0;


// -------------------------------------------------
// -----------------------------------------------------------------------
// Static, fallback data // Static, fallback data


const d_string PluginInternal::sFallbackString; const d_string PluginInternal::sFallbackString;
const ParameterRanges PluginInternal::sFallbackRanges; const ParameterRanges PluginInternal::sFallbackRanges;


// -------------------------------------------------
// -----------------------------------------------------------------------
// Plugin // Plugin


Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount) Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount)
@@ -39,7 +39,7 @@ Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCou
if (parameterCount > 0) if (parameterCount > 0)
{ {
pData->parameterCount = parameterCount; pData->parameterCount = parameterCount;
pData->parameters = new Parameter[parameterCount];
pData->parameters = new Parameter[parameterCount];
} }


if (programCount > 0) if (programCount > 0)
@@ -64,34 +64,34 @@ Plugin::~Plugin()
delete pData; delete pData;
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// Host state // Host state


uint32_t Plugin::d_bufferSize() const
uint32_t Plugin::d_getBufferSize() const noexcept
{ {
return pData->bufferSize; return pData->bufferSize;
} }


double Plugin::d_sampleRate() const
double Plugin::d_getSampleRate() const noexcept
{ {
return pData->sampleRate; return pData->sampleRate;
} }


#if DISTRHO_PLUGIN_WANT_TIMEPOS #if DISTRHO_PLUGIN_WANT_TIMEPOS
const TimePos& Plugin::d_timePos() const
const TimePos& Plugin::d_getTimePos() const noexcept
{ {
return pData->timePos; return pData->timePos;
} }
#endif #endif


#if DISTRHO_PLUGIN_WANT_LATENCY #if DISTRHO_PLUGIN_WANT_LATENCY
void Plugin::d_setLatency(uint32_t frames)
void Plugin::d_setLatency(uint32_t frames) noexcept
{ {
pData->latency = frames; pData->latency = frames;
} }
#endif #endif


// -------------------------------------------------
// -----------------------------------------------------------------------
// Callbacks // Callbacks


void Plugin::d_bufferSizeChanged(uint32_t) void Plugin::d_bufferSizeChanged(uint32_t)
@@ -102,6 +102,6 @@ void Plugin::d_sampleRateChanged(double)
{ {
} }


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO

+ 127
- 127
source/modules/distrho/src/DistrhoPluginInternal.hpp View File

@@ -2,26 +2,26 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_PLUGIN_INTERNAL_HPP__
#define __DISTRHO_PLUGIN_INTERNAL_HPP__
#ifndef DISTRHO_PLUGIN_INTERNAL_HPP_INCLUDED
#define DISTRHO_PLUGIN_INTERNAL_HPP_INCLUDED


#include "../DistrhoPlugin.hpp" #include "../DistrhoPlugin.hpp"


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------


#define MAX_MIDI_EVENTS 512 #define MAX_MIDI_EVENTS 512


@@ -79,14 +79,14 @@ struct Plugin::PrivateData {


~PrivateData() ~PrivateData()
{ {
if (parameterCount > 0 && parameters != nullptr)
if (parameters != nullptr)
{ {
delete[] parameters; delete[] parameters;
parameters = nullptr; parameters = nullptr;
} }


#if DISTRHO_PLUGIN_WANT_PROGRAMS #if DISTRHO_PLUGIN_WANT_PROGRAMS
if (programCount > 0 && programNames != nullptr)
if (programNames != nullptr)
{ {
delete[] programNames; delete[] programNames;
programNames = nullptr; programNames = nullptr;
@@ -94,7 +94,7 @@ struct Plugin::PrivateData {
#endif #endif


#if DISTRHO_PLUGIN_WANT_STATE #if DISTRHO_PLUGIN_WANT_STATE
if (stateCount > 0 && stateKeys != nullptr)
if (stateKeys != nullptr)
{ {
delete[] stateKeys; delete[] stateKeys;
stateKeys = nullptr; stateKeys = nullptr;
@@ -103,268 +103,268 @@ struct Plugin::PrivateData {
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


class PluginInternal class PluginInternal
{ {
public: public:
PluginInternal() PluginInternal()
: kPlugin(createPlugin()),
kData((kPlugin != nullptr) ? kPlugin->pData : nullptr)
: fPlugin(createPlugin()),
fData((fPlugin != nullptr) ? fPlugin->pData : nullptr)
{ {
assert(kPlugin != nullptr);
assert(fPlugin != nullptr);


if (kPlugin == nullptr)
if (fPlugin == nullptr)
return; return;


for (uint32_t i=0, count=kData->parameterCount; i < count; ++i)
kPlugin->d_initParameter(i, kData->parameters[i]);
for (uint32_t i=0, count=fData->parameterCount; i < count; ++i)
fPlugin->d_initParameter(i, fData->parameters[i]);


#if DISTRHO_PLUGIN_WANT_PROGRAMS #if DISTRHO_PLUGIN_WANT_PROGRAMS
for (uint32_t i=0, count=kData->programCount; i < count; ++i)
kPlugin->d_initProgramName(i, kData->programNames[i]);
for (uint32_t i=0, count=fData->programCount; i < count; ++i)
fPlugin->d_initProgramName(i, fData->programNames[i]);
#endif #endif


#if DISTRHO_PLUGIN_WANT_STATE #if DISTRHO_PLUGIN_WANT_STATE
for (uint32_t i=0, count=kData->stateCount; i < count; ++i)
kPlugin->d_initStateKey(i, kData->stateKeys[i]);
for (uint32_t i=0, count=fData->stateCount; i < count; ++i)
fPlugin->d_initStateKey(i, fData->stateKeys[i]);
#endif #endif
} }


~PluginInternal() ~PluginInternal()
{ {
if (kPlugin != nullptr)
delete kPlugin;
if (fPlugin != nullptr)
delete fPlugin;
} }


// ---------------------------------------------
// -------------------------------------------------------------------


const char* name() const
const char* getName() const
{ {
assert(kPlugin != nullptr);
return (kPlugin != nullptr) ? kPlugin->d_name() : "";
assert(fPlugin != nullptr);
return (fPlugin != nullptr) ? fPlugin->d_getName() : "";
} }


const char* label() const
const char* getLabel() const
{ {
assert(kPlugin != nullptr);
return (kPlugin != nullptr) ? kPlugin->d_label() : "";
assert(fPlugin != nullptr);
return (fPlugin != nullptr) ? fPlugin->d_getLabel() : "";
} }


const char* maker() const
const char* getMaker() const
{ {
assert(kPlugin != nullptr);
return (kPlugin != nullptr) ? kPlugin->d_maker() : "";
assert(fPlugin != nullptr);
return (fPlugin != nullptr) ? fPlugin->d_getMaker() : "";
} }


const char* license() const
const char* getLicense() const
{ {
assert(kPlugin != nullptr);
return (kPlugin != nullptr) ? kPlugin->d_license() : "";
assert(fPlugin != nullptr);
return (fPlugin != nullptr) ? fPlugin->d_getLicense() : "";
} }


uint32_t version() const
uint32_t getVersion() const
{ {
assert(kPlugin != nullptr);
return (kPlugin != nullptr) ? kPlugin->d_version() : 1000;
assert(fPlugin != nullptr);
return (fPlugin != nullptr) ? fPlugin->d_getVersion() : 1000;
} }


long uniqueId() const
long getUniqueId() const
{ {
assert(kPlugin != nullptr);
return (kPlugin != nullptr) ? kPlugin->d_uniqueId() : 0;
assert(fPlugin != nullptr);
return (fPlugin != nullptr) ? fPlugin->d_getUniqueId() : 0;
} }


// ---------------------------------------------
// -------------------------------------------------------------------


#if DISTRHO_PLUGIN_WANT_LATENCY #if DISTRHO_PLUGIN_WANT_LATENCY
uint32_t latency() const
uint32_t getLatency() const
{ {
assert(kData != nullptr);
return (kData != nullptr) ? kData->latency : 0;
assert(fData != nullptr);
return (fData != nullptr) ? fData->getLatency : 0;
} }
#endif #endif


uint32_t parameterCount() const
uint32_t getParameterCount() const
{ {
assert(kData != nullptr);
return (kData != nullptr) ? kData->parameterCount : 0;
assert(fData != nullptr);
return (fData != nullptr) ? fData->parameterCount : 0;
} }


uint32_t parameterHints(const uint32_t index) const
uint32_t getParameterHints(const uint32_t index) const
{ {
assert(kData != nullptr && index < kData->parameterCount);
return (kData != nullptr && index < kData->parameterCount) ? kData->parameters[index].hints : 0x0;
assert(fData != nullptr && index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].hints : 0x0;
} }


bool parameterIsOutput(const uint32_t index) const
bool isParameterIsOutput(const uint32_t index) const
{ {
return (parameterHints(index) & PARAMETER_IS_OUTPUT);
return (getParameterHints(index) & PARAMETER_IS_OUTPUT);
} }


const d_string& parameterName(const uint32_t index) const
const d_string& getParameterName(const uint32_t index) const
{ {
assert(kData != nullptr && index < kData->parameterCount);
return (kData != nullptr && index < kData->parameterCount) ? kData->parameters[index].name : sFallbackString;
assert(fData != nullptr && index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].name : sFallbackString;
} }


const d_string& parameterSymbol(const uint32_t index) const
const d_string& getParameterSymbol(const uint32_t index) const
{ {
assert(kData != nullptr && index < kData->parameterCount);
return (kData != nullptr && index < kData->parameterCount) ? kData->parameters[index].symbol : sFallbackString;
assert(fData != nullptr && index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].symbol : sFallbackString;
} }


const d_string& parameterUnit(const uint32_t index) const
const d_string& getParameterUnit(const uint32_t index) const
{ {
assert(kData != nullptr && index < kData->parameterCount);
return (kData != nullptr && index < kData->parameterCount) ? kData->parameters[index].unit : sFallbackString;
assert(fData != nullptr && index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].unit : sFallbackString;
} }


const ParameterRanges& parameterRanges(const uint32_t index) const
const ParameterRanges& getParameterRanges(const uint32_t index) const
{ {
assert(kData != nullptr && index < kData->parameterCount);
return (kData != nullptr && index < kData->parameterCount) ? kData->parameters[index].ranges : sFallbackRanges;
assert(fData != nullptr && index < fData->parameterCount);
return (fData != nullptr && index < fData->parameterCount) ? fData->parameters[index].ranges : sFallbackRanges;
} }


float parameterValue(const uint32_t index)
float getParameterValue(const uint32_t index) const
{ {
assert(kPlugin != nullptr && index < kData->parameterCount);
return (kPlugin != nullptr && index < kData->parameterCount) ? kPlugin->d_parameterValue(index) : 0.0f;
assert(fPlugin != nullptr && index < fData->parameterCount);
return (fPlugin != nullptr && index < fData->parameterCount) ? fPlugin->d_getParameterValue(index) : 0.0f;
} }


void setParameterValue(const uint32_t index, const float value) void setParameterValue(const uint32_t index, const float value)
{ {
assert(kPlugin != nullptr && index < kData->parameterCount);
assert(fPlugin != nullptr && index < fData->parameterCount);


if (kPlugin != nullptr && index < kData->parameterCount)
kPlugin->d_setParameterValue(index, value);
if (fPlugin != nullptr && index < fData->parameterCount)
fPlugin->d_setParameterValue(index, value);
} }


#if DISTRHO_PLUGIN_WANT_PROGRAMS #if DISTRHO_PLUGIN_WANT_PROGRAMS
uint32_t programCount() const
uint32_t getProgramCount() const
{ {
assert(kData != nullptr);
return (kData != nullptr) ? kData->programCount : 0;
assert(fData != nullptr);
return (fData != nullptr) ? fData->programCount : 0;
} }


const d_string& programName(const uint32_t index) const
const d_string& getProgramName(const uint32_t index) const
{ {
assert(kData != nullptr && index < kData->programCount);
return (kData != nullptr && index < kData->programCount) ? kData->programNames[index] : sFallbackString;
assert(fData != nullptr && index < fData->programCount);
return (fData != nullptr && index < fData->programCount) ? fData->programNames[index] : sFallbackString;
} }


void setProgram(const uint32_t index) void setProgram(const uint32_t index)
{ {
assert(kPlugin != nullptr && index < kData->programCount);
assert(fPlugin != nullptr && index < fData->programCount);


if (kPlugin != nullptr && index < kData->programCount)
kPlugin->d_setProgram(index);
if (fPlugin != nullptr && index < fData->programCount)
fPlugin->d_setProgram(index);
} }
#endif #endif


#if DISTRHO_PLUGIN_WANT_STATE #if DISTRHO_PLUGIN_WANT_STATE
uint32_t stateCount() const
uint32_t getStateCount() const
{ {
assert(kData != nullptr);
return kData != nullptr ? kData->stateCount : 0;
assert(fData != nullptr);
return fData != nullptr ? fData->stateCount : 0;
} }


const d_string& stateKey(const uint32_t index) const
const d_string& getStateKey(const uint32_t index) const
{ {
assert(kData != nullptr && index < kData->stateCount);
return (kData != nullptr && index < kData->stateCount) ? kData->stateKeys[index] : sFallbackString;
assert(fData != nullptr && index < fData->stateCount);
return (fData != nullptr && index < fData->stateCount) ? fData->stateKeys[index] : sFallbackString;
} }


void setState(const char* const key, const char* const value) void setState(const char* const key, const char* const value)
{ {
assert(kPlugin != nullptr && key != nullptr && value != nullptr);
assert(fPlugin != nullptr && key != nullptr && value != nullptr);


if (kPlugin != nullptr && key != nullptr && value != nullptr)
kPlugin->d_setState(key, value);
if (fPlugin != nullptr && key != nullptr && value != nullptr)
fPlugin->d_setState(key, value);
} }
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------


void activate() void activate()
{ {
assert(kPlugin != nullptr);
assert(fPlugin != nullptr);


if (kPlugin != nullptr)
kPlugin->d_activate();
if (fPlugin != nullptr)
fPlugin->d_activate();
} }


void deactivate() void deactivate()
{ {
assert(kPlugin != nullptr);
assert(fPlugin != nullptr);


if (kPlugin != nullptr)
kPlugin->d_deactivate();
if (fPlugin != nullptr)
fPlugin->d_deactivate();
} }


void run(float** const inputs, float** const outputs, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents) void run(float** const inputs, float** const outputs, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents)
{ {
assert(kPlugin != nullptr);
assert(fPlugin != nullptr);


if (kPlugin != nullptr)
kPlugin->d_run(inputs, outputs, frames, midiEventCount, midiEvents);
if (fPlugin != nullptr)
fPlugin->d_run(inputs, outputs, frames, midiEventCount, midiEvents);
} }


// ---------------------------------------------
// -------------------------------------------------------------------


void setBufferSize(const uint32_t bufferSize, bool doCallback = false) void setBufferSize(const uint32_t bufferSize, bool doCallback = false)
{ {
assert(kData != nullptr && kPlugin != nullptr && bufferSize >= 2);
assert(fData != nullptr && fPlugin != nullptr && bufferSize >= 2);


if (kData != nullptr)
if (fData != nullptr)
{ {
if (doCallback && kData->bufferSize == bufferSize)
if (doCallback && fData->bufferSize == bufferSize)
doCallback = false; doCallback = false;


kData->bufferSize = bufferSize;
fData->bufferSize = bufferSize;
} }


if (kPlugin != nullptr && doCallback)
if (fPlugin != nullptr && doCallback)
{ {
kPlugin->d_deactivate();
kPlugin->d_bufferSizeChanged(bufferSize);
kPlugin->d_activate();
fPlugin->d_deactivate();
fPlugin->d_bufferSizeChanged(bufferSize);
fPlugin->d_activate();
} }
} }


void setSampleRate(const double sampleRate, bool doCallback = false) void setSampleRate(const double sampleRate, bool doCallback = false)
{ {
assert(kData != nullptr && kPlugin != nullptr && sampleRate > 0.0);
assert(fData != nullptr && fPlugin != nullptr && sampleRate > 0.0);


if (kData != nullptr)
if (fData != nullptr)
{ {
if (doCallback && kData->sampleRate == sampleRate)
if (doCallback && fData->sampleRate == sampleRate)
doCallback = false; doCallback = false;


kData->sampleRate = sampleRate;
fData->sampleRate = sampleRate;
} }


if (kPlugin != nullptr && doCallback)
if (fPlugin != nullptr && doCallback)
{ {
kPlugin->d_deactivate();
kPlugin->d_sampleRateChanged(sampleRate);
kPlugin->d_activate();
fPlugin->d_deactivate();
fPlugin->d_sampleRateChanged(sampleRate);
fPlugin->d_activate();
} }
} }


// ---------------------------------------------
// -------------------------------------------------------------------


protected: protected:
Plugin* const kPlugin;
Plugin::PrivateData* const kData;
Plugin* const fPlugin;
Plugin::PrivateData* const fData;


private: private:
static const d_string sFallbackString; static const d_string sFallbackString;
static const ParameterRanges sFallbackRanges; static const ParameterRanges sFallbackRanges;
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


#endif // __DISTRHO_PLUGIN_INTERNAL_HPP__
#endif // DISTRHO_PLUGIN_INTERNAL_HPP_INCLUDED

+ 54
- 54
source/modules/distrho/src/DistrhoPluginLADSPA+DSSI.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoPluginInternal.hpp" #include "DistrhoPluginInternal.hpp"
@@ -32,11 +32,11 @@
# warning LADSPA/DSSI does not support TimePos # warning LADSPA/DSSI does not support TimePos
#endif #endif


// -------------------------------------------------
typedef LADSPA_Data* LADSPA_DataPtr;


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


typedef LADSPA_Data* LADSPA_DataPtr;
// -----------------------------------------------------------------------


class PluginLadspaDssi class PluginLadspaDssi
{ {
@@ -52,7 +52,7 @@ public:
fPortAudioOuts[i] = nullptr; fPortAudioOuts[i] = nullptr;


{ {
const uint32_t count(fPlugin.parameterCount());
const uint32_t count(fPlugin.getParameterCount());


fPortControls = new LADSPA_DataPtr[count];; fPortControls = new LADSPA_DataPtr[count];;
fLastControlValues = new LADSPA_Data[count];; fLastControlValues = new LADSPA_Data[count];;
@@ -60,7 +60,7 @@ public:
for (uint32_t i=0; i < count; ++i) for (uint32_t i=0; i < count; ++i)
{ {
fPortControls[i] = nullptr; fPortControls[i] = nullptr;
fLastControlValues[i] = fPlugin.parameterValue(i);
fLastControlValues[i] = fPlugin.getParameterValue(i);
} }
} }


@@ -84,7 +84,7 @@ public:
} }
} }


// ---------------------------------------------
// -------------------------------------------------------------------


void ladspa_connect_port(const unsigned long port, const LADSPA_DataPtr dataLocation) void ladspa_connect_port(const unsigned long port, const LADSPA_DataPtr dataLocation)
{ {
@@ -116,7 +116,7 @@ public:
} }
#endif #endif


for (unsigned long i=0, count=fPlugin.parameterCount(); i < count; ++i)
for (unsigned long i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{ {
if (port == index++) if (port == index++)
{ {
@@ -126,7 +126,7 @@ public:
} }
} }


// ---------------------------------------------
// -------------------------------------------------------------------


#ifdef DISTRHO_PLUGIN_TARGET_DSSI #ifdef DISTRHO_PLUGIN_TARGET_DSSI
# if DISTRHO_PLUGIN_WANT_STATE # if DISTRHO_PLUGIN_WANT_STATE
@@ -145,14 +145,14 @@ public:
# if DISTRHO_PLUGIN_WANT_PROGRAMS # if DISTRHO_PLUGIN_WANT_PROGRAMS
const DSSI_Program_Descriptor* dssi_get_program(const unsigned long index) const DSSI_Program_Descriptor* dssi_get_program(const unsigned long index)
{ {
if (index >= fPlugin.programCount())
if (index >= fPlugin.getProgramCount())
return nullptr; return nullptr;


static DSSI_Program_Descriptor desc; static DSSI_Program_Descriptor desc;


desc.Bank = index / 128; desc.Bank = index / 128;
desc.Program = index % 128; desc.Program = index % 128;
desc.Name = fPlugin.programName(index);
desc.Name = fPlugin.getProgramName(index);


return &desc; return &desc;
} }
@@ -161,7 +161,7 @@ public:
{ {
const unsigned long realProgram(bank * 128 + program); const unsigned long realProgram(bank * 128 + program);


if (realProgram >= fPlugin.programCount())
if (realProgram >= fPlugin.getProgramCount())
return; return;


fPlugin.setProgram(realProgram); fPlugin.setProgram(realProgram);
@@ -169,19 +169,19 @@ public:
// Update parameters // Update parameters
for (uint32_t i=0, count=fPlugin.parameterCount(); i < count; ++i) for (uint32_t i=0, count=fPlugin.parameterCount(); i < count; ++i)
{ {
if (! fPlugin.parameterIsOutput(i))
{
fLastControlValues[i] = fPlugin.parameterValue(i);
if (fPlugin.isParameterIsOutput(i))
continue;


if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
}
fLastControlValues[i] = fPlugin.getParameterValue(i);

if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
} }
} }
# endif # endif
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------


void ladspa_activate() void ladspa_activate()
{ {
@@ -207,13 +207,13 @@ public:
// Check for updated parameters // Check for updated parameters
float curValue; float curValue;


for (uint32_t i=0, count=fPlugin.parameterCount(); i < count; ++i)
for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{ {
assert(fPortControls[i] != nullptr); assert(fPortControls[i] != nullptr);


curValue = *fPortControls[i]; curValue = *fPortControls[i];


if (fLastControlValues[i] != curValue && ! fPlugin.parameterIsOutput(i))
if (fLastControlValues[i] != curValue && ! fPlugin.isParameterIsOutput(i))
{ {
fLastControlValues[i] = curValue; fLastControlValues[i] = curValue;
fPlugin.setParameterValue(i, curValue); fPlugin.setParameterValue(i, curValue);
@@ -301,7 +301,7 @@ public:
updateParameterOutputs(); updateParameterOutputs();
} }


// ---------------------------------------------
// -------------------------------------------------------------------


private: private:
PluginInternal fPlugin; PluginInternal fPlugin;
@@ -315,19 +315,19 @@ private:


LADSPA_Data* fLastControlValues; LADSPA_Data* fLastControlValues;


// ---------------------------------------------
// -------------------------------------------------------------------


void updateParameterOutputs() void updateParameterOutputs()
{ {
for (uint32_t i=0, count=fPlugin.parameterCount(); i < count; ++i)
for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{ {
if (fPlugin.parameterIsOutput(i))
{
fLastControlValues[i] = fPlugin.parameterValue(i);
if (! fPlugin.isParameterIsOutput(i))
continue;


if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
}
fLastControlValues[i] = fPlugin.getParameterValue(i);

if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
} }


#if DISTRHO_PLUGIN_WANT_LATENCY #if DISTRHO_PLUGIN_WANT_LATENCY
@@ -337,7 +337,7 @@ private:
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, unsigned long sampleRate) static LADSPA_Handle ladspa_instantiate(const LADSPA_Descriptor*, unsigned long sampleRate)
{ {
@@ -405,7 +405,7 @@ static void dssi_run_synth(LADSPA_Handle instance, unsigned long sampleCount, sn


#undef instancePtr #undef instancePtr


// -------------------------------------------------
// -----------------------------------------------------------------------


static LADSPA_Descriptor sLadspaDescriptor = { static LADSPA_Descriptor sLadspaDescriptor = {
/* UniqueID */ 0, /* UniqueID */ 0,
@@ -458,7 +458,7 @@ static DSSI_Descriptor sDssiDescriptor = {
}; };
#endif #endif


// -------------------------------------------------
// -----------------------------------------------------------------------


class DescriptorInitializer class DescriptorInitializer
{ {
@@ -474,11 +474,11 @@ public:


// Get port count, init // Get port count, init
unsigned long port = 0; unsigned long port = 0;
unsigned long portCount = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS + plugin.parameterCount();
unsigned long portCount = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS + plugin.getParameterCount();
#if DISTRHO_PLUGIN_WANT_LATENCY #if DISTRHO_PLUGIN_WANT_LATENCY
portCount += 1; portCount += 1;
#endif #endif
const char** const portNames = new const char*[portCount];
const char** const portNames = new const char*[portCount];
LADSPA_PortDescriptor* portDescriptors = new LADSPA_PortDescriptor[portCount]; LADSPA_PortDescriptor* portDescriptors = new LADSPA_PortDescriptor[portCount];
LADSPA_PortRangeHint* portRangeHints = new LADSPA_PortRangeHint [portCount]; LADSPA_PortRangeHint* portRangeHints = new LADSPA_PortRangeHint [portCount];


@@ -519,18 +519,18 @@ public:
++port; ++port;
#endif #endif


for (unsigned long i=0, count=plugin.parameterCount(); i < count; ++i, ++port)
for (unsigned long i=0, count=plugin.getParameterCount(); i < count; ++i, ++port)
{ {
portNames[port] = strdup((const char*)plugin.parameterName(i));
portNames[port] = strdup((const char*)plugin.getParameterName(i));
portDescriptors[port] = LADSPA_PORT_CONTROL; portDescriptors[port] = LADSPA_PORT_CONTROL;


if (plugin.parameterIsOutput(i))
if (plugin.isParameterIsOutput(i))
portDescriptors[port] |= LADSPA_PORT_OUTPUT; portDescriptors[port] |= LADSPA_PORT_OUTPUT;
else else
portDescriptors[port] |= LADSPA_PORT_INPUT; portDescriptors[port] |= LADSPA_PORT_INPUT;


{ {
const ParameterRanges& ranges(plugin.parameterRanges(i));
const ParameterRanges& ranges(plugin.getParameterRanges(i));
const float defValue(ranges.def); const float defValue(ranges.def);


portRangeHints[port].HintDescriptor = LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; portRangeHints[port].HintDescriptor = LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE;
@@ -565,7 +565,7 @@ public:
} }


{ {
const uint32_t hints(plugin.parameterHints(i));
const uint32_t hints(plugin.getParameterHints(i));


if (hints & PARAMETER_IS_BOOLEAN) if (hints & PARAMETER_IS_BOOLEAN)
portRangeHints[port].HintDescriptor |= LADSPA_HINT_TOGGLED; portRangeHints[port].HintDescriptor |= LADSPA_HINT_TOGGLED;
@@ -577,11 +577,11 @@ public:
} }


// Set data // Set data
sLadspaDescriptor.UniqueID = plugin.uniqueId();
sLadspaDescriptor.Label = strdup(plugin.label());
sLadspaDescriptor.Name = strdup(plugin.name());
sLadspaDescriptor.Maker = strdup(plugin.maker());
sLadspaDescriptor.Copyright = strdup(plugin.license());
sLadspaDescriptor.UniqueID = plugin.getUniqueId();
sLadspaDescriptor.Label = strdup(plugin.getLabel());
sLadspaDescriptor.Name = strdup(plugin.getName());
sLadspaDescriptor.Maker = strdup(plugin.getMaker());
sLadspaDescriptor.Copyright = strdup(plugin.getLicense());
sLadspaDescriptor.PortCount = portCount; sLadspaDescriptor.PortCount = portCount;
sLadspaDescriptor.PortNames = portNames; sLadspaDescriptor.PortNames = portNames;
sLadspaDescriptor.PortDescriptors = portDescriptors; sLadspaDescriptor.PortDescriptors = portDescriptors;
@@ -645,9 +645,9 @@ public:


static DescriptorInitializer sDescInit; static DescriptorInitializer sDescInit;


END_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------


// -------------------------------------------------
END_NAMESPACE_DISTRHO


DISTRHO_PLUGIN_EXPORT DISTRHO_PLUGIN_EXPORT
const LADSPA_Descriptor* ladspa_descriptor(unsigned long index) const LADSPA_Descriptor* ladspa_descriptor(unsigned long index)


+ 16
- 16
source/modules/distrho/src/DistrhoPluginLV2.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoPluginInternal.hpp" #include "DistrhoPluginInternal.hpp"
@@ -47,12 +47,12 @@
#define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_STATE || DISTRHO_PLUGIN_WANT_TIMEPOS) #define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_STATE || DISTRHO_PLUGIN_WANT_TIMEPOS)
#define DISTRHO_LV2_USE_EVENTS_OUT (DISTRHO_PLUGIN_WANT_STATE) #define DISTRHO_LV2_USE_EVENTS_OUT (DISTRHO_PLUGIN_WANT_STATE)


// -------------------------------------------------
typedef float* floatptr;
typedef std::map<d_string,d_string> StringMap;


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


typedef float* floatptr;
typedef std::map<d_string,d_string> stringMap;
// -----------------------------------------------------------------------


class PluginLv2 class PluginLv2
{ {
@@ -493,7 +493,7 @@ private:
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


static LV2_Handle lv2_instantiate(const LV2_Descriptor*, double sampleRate, const char*, const LV2_Feature* const* features) static LV2_Handle lv2_instantiate(const LV2_Descriptor*, double sampleRate, const char*, const LV2_Feature* const* features)
{ {
@@ -638,7 +638,7 @@ static const void* lv2_extension_data(const char* uri)


#undef instancePtr #undef instancePtr


// -------------------------------------------------
// -----------------------------------------------------------------------


static LV2_Descriptor sLv2Descriptor = { static LV2_Descriptor sLv2Descriptor = {
DISTRHO_PLUGIN_URI, DISTRHO_PLUGIN_URI,
@@ -651,9 +651,9 @@ static LV2_Descriptor sLv2Descriptor = {
lv2_extension_data lv2_extension_data
}; };


END_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------


// -------------------------------------------------
END_NAMESPACE_DISTRHO


DISTRHO_PLUGIN_EXPORT DISTRHO_PLUGIN_EXPORT
const LV2_Descriptor* lv2_descriptor(uint32_t index) const LV2_Descriptor* lv2_descriptor(uint32_t index)


+ 10
- 10
source/modules/distrho/src/DistrhoPluginLV2export.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoPluginInternal.hpp" #include "DistrhoPluginInternal.hpp"
@@ -51,7 +51,7 @@
#define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_STATE || DISTRHO_PLUGIN_WANT_TIMEPOS) #define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_STATE || DISTRHO_PLUGIN_WANT_TIMEPOS)
#define DISTRHO_LV2_USE_EVENTS_OUT (DISTRHO_PLUGIN_WANT_STATE) #define DISTRHO_LV2_USE_EVENTS_OUT (DISTRHO_PLUGIN_WANT_STATE)


// -------------------------------------------------
// -----------------------------------------------------------------------


DISTRHO_PLUGIN_EXPORT DISTRHO_PLUGIN_EXPORT
void lv2_generate_ttl(const char* const basename) void lv2_generate_ttl(const char* const basename)


+ 19
- 21
source/modules/distrho/src/DistrhoPluginVST.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoPluginInternal.hpp" #include "DistrhoPluginInternal.hpp"
@@ -38,7 +38,7 @@


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------


#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI


@@ -133,7 +133,7 @@ public:
} }
} }


// ---------------------------------------------
// -------------------------------------------------------------------


void idle() void idle()
{ {
@@ -172,7 +172,7 @@ public:
return fUi.height(); return fUi.height();
} }


// ---------------------------------------------
// -------------------------------------------------------------------
// functions called from the plugin side, RT no block // functions called from the plugin side, RT no block


void setParameterValueFromPlugin(uint32_t index, float perValue) void setParameterValueFromPlugin(uint32_t index, float perValue)
@@ -192,7 +192,7 @@ public:
} }
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------


protected: protected:
intptr_t hostCallback(int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt) intptr_t hostCallback(int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt)
@@ -264,7 +264,7 @@ private:
MidiEvent fMidiEvents[MAX_MIDI_EVENTS]; MidiEvent fMidiEvents[MAX_MIDI_EVENTS];
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------
// Callbacks // Callbacks


#define handlePtr ((UIVst*)ptr) #define handlePtr ((UIVst*)ptr)
@@ -298,7 +298,7 @@ private:
}; };
#endif #endif


// -------------------------------------------------
// -----------------------------------------------------------------------


class PluginVst class PluginVst
{ {
@@ -498,7 +498,7 @@ public:
#endif #endif
} }


// ---------------------------------------------
// -------------------------------------------------------------------


private: private:
// VST stuff // VST stuff
@@ -556,7 +556,7 @@ private:
#endif #endif
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


#define handlePtr ((PluginVst*)effect->object) #define handlePtr ((PluginVst*)effect->object)


@@ -707,9 +707,9 @@ static void vst_processReplacingCallback(AEffect* effect, float** inputs, float*


#undef handlePtr #undef handlePtr


END_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------


// -------------------------------------------------
END_NAMESPACE_DISTRHO


DISTRHO_PLUGIN_EXPORT DISTRHO_PLUGIN_EXPORT
const AEffect* VSTPluginMain(audioMasterCallback audioMaster) const AEffect* VSTPluginMain(audioMasterCallback audioMaster)
@@ -762,5 +762,3 @@ const AEffect* VSTPluginMain(audioMasterCallback audioMaster)


return effect; return effect;
} }

// -------------------------------------------------

+ 15
- 15
source/modules/distrho/src/DistrhoUI.cpp View File

@@ -2,28 +2,28 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoUIInternal.hpp" #include "DistrhoUIInternal.hpp"


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// Static data // Static data


double d_lastUiSampleRate = 0.0; double d_lastUiSampleRate = 0.0;


// -------------------------------------------------
// -----------------------------------------------------------------------
// UI // UI


UI::UI() UI::UI()
@@ -36,10 +36,10 @@ UI::~UI()
delete pData; delete pData;
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// Host DSP State // Host DSP State


double UI::d_sampleRate() const
double UI::d_getSampleRate() const noexcept
{ {
return pData->sampleRate; return pData->sampleRate;
} }
@@ -68,7 +68,7 @@ void UI::d_sendNote(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity)
} }
#endif #endif


// -------------------------------------------------
// -----------------------------------------------------------------------
// Host UI State // Host UI State


void UI::d_uiResize(unsigned int width, unsigned int height) void UI::d_uiResize(unsigned int width, unsigned int height)
@@ -76,6 +76,6 @@ void UI::d_uiResize(unsigned int width, unsigned int height)
pData->uiResizeCallback(width, height); pData->uiResizeCallback(width, height);
} }


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO

+ 18
- 16
source/modules/distrho/src/DistrhoUIDSSI.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoUIInternal.hpp" #include "DistrhoUIInternal.hpp"
@@ -32,7 +32,7 @@


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------


struct OscData { struct OscData {
lo_address addr; lo_address addr;
@@ -93,7 +93,7 @@ struct OscData {
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


#ifdef DISTRHO_UI_QT #ifdef DISTRHO_UI_QT
class UIDssi : public QMainWindow class UIDssi : public QMainWindow
@@ -170,7 +170,7 @@ public:
#endif #endif
} }


// ---------------------------------------------
// -------------------------------------------------------------------


#if DISTRHO_PLUGIN_WANT_STATE #if DISTRHO_PLUGIN_WANT_STATE
void dssiui_configure(const char* key, const char* value) void dssiui_configure(const char* key, const char* value)
@@ -251,7 +251,7 @@ public:
#endif #endif
} }


// ---------------------------------------------
// -------------------------------------------------------------------


protected: protected:
void setParameterValue(uint32_t rindex, float value) void setParameterValue(uint32_t rindex, float value)
@@ -321,7 +321,7 @@ private:


const OscData& fOscData; const OscData& fOscData;


// ---------------------------------------------
// -------------------------------------------------------------------
// Callbacks // Callbacks


#define uiPtr ((UIDssi*)ptr) #define uiPtr ((UIDssi*)ptr)
@@ -349,7 +349,7 @@ private:
#undef uiPtr #undef uiPtr
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


static OscData gOscData; static OscData gOscData;
static const char* gUiTitle = nullptr; static const char* gUiTitle = nullptr;
@@ -366,7 +366,7 @@ static void initUiIfNeeded()
globalUI = new UIDssi(gOscData, gUiTitle); globalUI = new UIDssi(gOscData, gUiTitle);
} }


// -------------------------------------------------
// -----------------------------------------------------------------------


int osc_debug_handler(const char* path, const char*, lo_arg**, int, lo_message, void*) int osc_debug_handler(const char* path, const char*, lo_arg**, int, lo_message, void*)
{ {
@@ -492,6 +492,8 @@ int osc_quit_handler(const char*, const char*, lo_arg**, int, lo_message, void*)


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


// -----------------------------------------------------------------------

int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
USE_NAMESPACE_DISTRHO USE_NAMESPACE_DISTRHO


+ 11
- 11
source/modules/distrho/src/DistrhoUIExternal.cpp View File

@@ -2,23 +2,23 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoUIInternal.hpp" #include "DistrhoUIInternal.hpp"


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// External UI // External UI


ExternalUI::ExternalUI() ExternalUI::ExternalUI()
@@ -30,6 +30,6 @@ ExternalUI::~ExternalUI()
{ {
} }


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO

+ 69
- 73
source/modules/distrho/src/DistrhoUIInternal.hpp View File

@@ -2,22 +2,22 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifndef __DISTRHO_UI_INTERNAL_HPP__
#define __DISTRHO_UI_INTERNAL_HPP__
#ifndef DISTRHO_UI_INTERNAL_HPP_INCLUDED
#define DISTRHO_UI_INTERNAL_HPP_INCLUDED


#include "DistrhoDefines.h"
# include "../DistrhoUI.hpp"


#if defined(DISTRHO_UI_EXTERNAL) #if defined(DISTRHO_UI_EXTERNAL)
# include "../DistrhoUIExternal.hpp" # include "../DistrhoUIExternal.hpp"
@@ -33,7 +33,7 @@


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------


typedef void (*editParamFunc) (void* ptr, uint32_t index, bool started); typedef void (*editParamFunc) (void* ptr, uint32_t index, bool started);
typedef void (*setParamFunc) (void* ptr, uint32_t index, float value); typedef void (*setParamFunc) (void* ptr, uint32_t index, float value);
@@ -43,7 +43,7 @@ typedef void (*uiResizeFunc) (void* ptr, unsigned int width, unsigned int heigh


extern double d_lastUiSampleRate; extern double d_lastUiSampleRate;


// -------------------------------------------------
// -----------------------------------------------------------------------


struct UI::PrivateData { struct UI::PrivateData {
// DSP // DSP
@@ -73,15 +73,11 @@ struct UI::PrivateData {
#if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2) #if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2)
parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS; parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;
# if DISTRHO_PLUGIN_WANT_LATENCY # if DISTRHO_PLUGIN_WANT_LATENCY
parameterOffset += 1; // latency
parameterOffset += 1;
# endif # endif
#endif #endif
} }


~PrivateData()
{
}

void editParamCallback(uint32_t index, bool started) void editParamCallback(uint32_t index, bool started)
{ {
if (editParamCallbackFunc != nullptr) if (editParamCallbackFunc != nullptr)
@@ -113,7 +109,7 @@ struct UI::PrivateData {
} }
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


class UIInternal class UIInternal
{ {
@@ -122,15 +118,15 @@ public:
#ifdef DISTRHO_UI_OPENGL #ifdef DISTRHO_UI_OPENGL
: glApp(), : glApp(),
glWindow(&glApp, winId), glWindow(&glApp, winId),
kUi(createUI()),
fUi(createUI()),
#else #else
: kUi(createUI()),
: fUi(createUI()),
#endif #endif
kData((kUi != nullptr) ? kUi->pData : nullptr)
fData((fUi != nullptr) ? fUi->pData : nullptr)
{ {
assert(kUi != nullptr);
assert(fUi != nullptr);


if (kUi == nullptr)
if (fUi == nullptr)
return; return;


#ifdef DISTRHO_UI_QT #ifdef DISTRHO_UI_QT
@@ -140,88 +136,88 @@ public:
return; return;
#endif #endif


kData->ptr = ptr;
kData->editParamCallbackFunc = editParamCall;
kData->setParamCallbackFunc = setParamCall;
kData->setStateCallbackFunc = setStateCall;
kData->sendNoteCallbackFunc = sendNoteCall;
kData->uiResizeCallbackFunc = uiResizeCall;
fData->ptr = ptr;
fData->editParamCallbackFunc = editParamCall;
fData->setParamCallbackFunc = setParamCall;
fData->setStateCallbackFunc = setStateCall;
fData->sendNoteCallbackFunc = sendNoteCall;
fData->uiResizeCallbackFunc = uiResizeCall;
} }


~UIInternal() ~UIInternal()
{ {
if (kUi != nullptr)
delete kUi;
if (fUi != nullptr)
delete fUi;
} }


// ---------------------------------------------
// -------------------------------------------------------------------


const char* name() const
const char* getName() const
{ {
assert(kUi != nullptr);
return (kUi != nullptr) ? kUi->d_name() : "";
assert(fUi != nullptr);
return (fUi != nullptr) ? fUi->d_getName() : "";
} }


unsigned int width() const
unsigned int getWidth() const
{ {
assert(kUi != nullptr);
return (kUi != nullptr) ? kUi->d_width() : 0;
assert(fUi != nullptr);
return (fUi != nullptr) ? fUi->d_getWidth() : 0;
} }


unsigned int height() const
unsigned int getHeight() const
{ {
assert(kUi != nullptr);
return (kUi != nullptr) ? kUi->d_height() : 0;
assert(fUi != nullptr);
return (fUi != nullptr) ? fUi->d_getHeight() : 0;
} }


// ---------------------------------------------
// -------------------------------------------------------------------


void parameterChanged(uint32_t index, float value) void parameterChanged(uint32_t index, float value)
{ {
assert(kUi != nullptr);
assert(fUi != nullptr);


if (kUi != nullptr)
kUi->d_parameterChanged(index, value);
if (fUi != nullptr)
fUi->d_parameterChanged(index, value);
} }


#if DISTRHO_PLUGIN_WANT_PROGRAMS #if DISTRHO_PLUGIN_WANT_PROGRAMS
void programChanged(uint32_t index) void programChanged(uint32_t index)
{ {
assert(kUi != nullptr);
assert(fUi != nullptr);


if (kUi != nullptr)
kUi->d_programChanged(index);
if (fUi != nullptr)
fUi->d_programChanged(index);
} }
#endif #endif


#if DISTRHO_PLUGIN_WANT_STATE #if DISTRHO_PLUGIN_WANT_STATE
void stateChanged(const char* key, const char* value) void stateChanged(const char* key, const char* value)
{ {
assert(kUi != nullptr);
assert(fUi != nullptr);


if (kUi != nullptr)
kUi->d_stateChanged(key, value);
if (fUi != nullptr)
fUi->d_stateChanged(key, value);
} }
#endif #endif


#if DISTRHO_PLUGIN_IS_SYNTH #if DISTRHO_PLUGIN_IS_SYNTH
void noteReceived(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) void noteReceived(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity)
{ {
assert(kUi != nullptr);
assert(fUi != nullptr);


if (kUi != nullptr)
kUi->d_noteReceived(onOff, channel, note, velocity);
if (fUi != nullptr)
fUi->d_noteReceived(onOff, channel, note, velocity);
} }
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------


void idle() void idle()
{ {
assert(kUi != nullptr);
assert(fUi != nullptr);


if (kUi != nullptr)
kUi->d_uiIdle();
if (fUi != nullptr)
fUi->d_uiIdle();


#ifdef DISTRHO_UI_OPENGL #ifdef DISTRHO_UI_OPENGL
glApp.idle(); glApp.idle();
@@ -229,7 +225,7 @@ public:
} }


#if defined(DISTRHO_UI_EXTERNAL) #if defined(DISTRHO_UI_EXTERNAL)
// needed?
// not needed
#elif defined(DISTRHO_UI_OPENGL) #elif defined(DISTRHO_UI_OPENGL)
App& getApp() App& getApp()
{ {
@@ -246,24 +242,24 @@ public:
return glWindow.getWindowId(); return glWindow.getWindowId();
} }


void fixSize()
void fixWindowSize()
{ {
assert(kUi != nullptr);
glWindow.setSize(kUi->d_width(), kUi->d_height());
assert(fUi != nullptr);
glWindow.setSize(fUi->d_getWidth(), fUi->d_getHeight());
} }
#else
#elif defined(DISTRHO_UI_QT)
QtUI* getQtUI() const QtUI* getQtUI() const
{ {
return (QtUI*)kUi;
return (QtUI*)fUi;
} }


bool resizable() const
bool isResizable() const
{ {
return ((QtUI*)kUi)->d_resizable();
return ((QtUI*)fUi)->d_isResizable();
} }
#endif #endif


// ---------------------------------------------
// -------------------------------------------------------------------


#ifdef DISTRHO_UI_OPENGL #ifdef DISTRHO_UI_OPENGL
private: private:
@@ -272,12 +268,12 @@ private:
#endif #endif


protected: protected:
UI* const kUi;
UI::PrivateData* const kData;
UI* const fUi;
UI::PrivateData* const fData;
}; };


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO


#endif // __DISTRHO_UI_INTERNAL_HPP__
#endif // DISTRHO_UI_INTERNAL_HPP_INCLUDED

+ 11
- 11
source/modules/distrho/src/DistrhoUIOpenGL.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoUIInternal.hpp" #include "DistrhoUIInternal.hpp"
@@ -22,7 +22,7 @@ END_NAMESPACE_DGL


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// OpenGL UI // OpenGL UI


OpenGLUI::OpenGLUI() OpenGLUI::OpenGLUI()
@@ -38,6 +38,6 @@ OpenGLUI::~OpenGLUI()
{ {
} }


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO

+ 13
- 13
source/modules/distrho/src/DistrhoUIQt.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "DistrhoUIInternal.hpp" #include "DistrhoUIInternal.hpp"
@@ -20,7 +20,7 @@


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------
// -----------------------------------------------------------------------
// Qt UI // Qt UI


QtUI::QtUI() QtUI::QtUI()
@@ -33,11 +33,11 @@ QtUI::~QtUI()
{ {
} }


// -------------------------------------------------
// -----------------------------------------------------------------------


void QtUI::setSize(unsigned int width, unsigned int height) void QtUI::setSize(unsigned int width, unsigned int height)
{ {
if (d_resizable())
if (d_isResizable())
resize(width, height); resize(width, height);
else else
setFixedSize(width, height); setFixedSize(width, height);
@@ -45,6 +45,6 @@ void QtUI::setSize(unsigned int width, unsigned int height)
d_uiResize(width, height); d_uiResize(width, height);
} }


// -------------------------------------------------
// -----------------------------------------------------------------------


END_NAMESPACE_DISTRHO END_NAMESPACE_DISTRHO

+ 9
- 9
source/modules/distrho/src/_todo/DistrhoPluginJACK.cpp View File

@@ -2,16 +2,16 @@
* DISTRHO Plugin Toolkit (DPT) * DISTRHO Plugin Toolkit (DPT)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#ifdef DISTRHO_PLUGIN_TARGET_JACK #ifdef DISTRHO_PLUGIN_TARGET_JACK


+ 2
- 2
source/modules/utils/CarlaString.hpp View File

@@ -477,7 +477,7 @@ static inline
CarlaString operator+(const CarlaString& strBefore, const char* const strBufAfter) CarlaString operator+(const CarlaString& strBefore, const char* const strBufAfter)
{ {
const char* const strBufBefore = (const char*)strBefore; const char* const strBufBefore = (const char*)strBefore;
const size_t newBufSize = strBefore.length() + ((strBufAfter != nullptr) ? std::strlen(strBufAfter) : 0) + 1;
const size_t newBufSize = strBefore.length() + ((strBufAfter != nullptr) ? std::strlen(strBufAfter) : 0) + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, strBufBefore); std::strcpy(newBuf, strBufBefore);
@@ -490,7 +490,7 @@ static inline
CarlaString operator+(const char* const strBufBefore, const CarlaString& strAfter) CarlaString operator+(const char* const strBufBefore, const CarlaString& strAfter)
{ {
const char* const strBufAfter = (const char*)strAfter; const char* const strBufAfter = (const char*)strAfter;
const size_t newBufSize = ((strBufBefore != nullptr) ? std::strlen(strBufBefore) : 0) + strAfter.length() + 1;
const size_t newBufSize = ((strBufBefore != nullptr) ? std::strlen(strBufBefore) : 0) + strAfter.length() + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, strBufBefore); std::strcpy(newBuf, strBufBefore);


+ 2
- 0
source/modules/utils/CarlaUtils.hpp View File

@@ -411,4 +411,6 @@ void carla_zeroStruct(T* const structure, const size_t count)
std::memset(structure, 0, count*sizeof(T)); std::memset(structure, 0, count*sizeof(T));
} }


// -----------------------------------------------------------------------

#endif // CARLA_UTILS_HPP_INCLUDED #endif // CARLA_UTILS_HPP_INCLUDED

Loading…
Cancel
Save