Browse Source

DISTRHO plugin fixes and cleanup

tags/1.9.4
falkTX 11 years ago
parent
commit
dbaa48eeab
17 changed files with 89 additions and 53 deletions
  1. +1
    -1
      source/backend/CarlaBackend.hpp
  2. +1
    -1
      source/backend/CarlaEngine.hpp
  3. +2
    -2
      source/backend/CarlaNative.h
  4. +5
    -1
      source/backend/engine/CarlaEnginePlugin.cpp
  5. +5
    -3
      source/backend/engine/distrho/DistrhoPluginInfo.h
  6. +2
    -0
      source/backend/native/3bandeq/DistrhoPluginInfo.h
  7. +2
    -0
      source/backend/native/3bandsplitter/DistrhoPluginInfo.h
  8. +2
    -0
      source/backend/native/pingpongpan/DistrhoPluginInfo.h
  9. +24
    -5
      source/libs/distrho/DistrhoPlugin.hpp
  10. +2
    -3
      source/libs/distrho/DistrhoUI.hpp
  11. +1
    -11
      source/libs/distrho/DistrhoUtils.hpp
  12. +6
    -4
      source/libs/distrho/src/DistrhoDefines.h
  13. +1
    -1
      source/libs/distrho/src/DistrhoPlugin.cpp
  14. +5
    -5
      source/libs/distrho/src/DistrhoPluginInternal.hpp
  15. +7
    -0
      source/libs/distrho/src/DistrhoPluginVST.cpp
  16. +1
    -1
      source/libs/distrho/src/DistrhoUI.cpp
  17. +22
    -15
      source/libs/distrho/src/DistrhoUIInternal.hpp

+ 1
- 1
source/backend/CarlaBackend.hpp View File

@@ -722,7 +722,7 @@ struct ParameterRanges {

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

return newValue;


+ 1
- 1
source/backend/CarlaEngine.hpp View File

@@ -338,7 +338,7 @@ struct EngineTimeInfo {
static const uint32_t ValidBBT = 0x1;

bool playing;
uint32_t frame;
uint64_t frame;
uint64_t usecs;
uint32_t valid;
EngineTimeInfoBBT bbt;


+ 2
- 2
source/backend/CarlaNative.h View File

@@ -142,8 +142,8 @@ typedef struct _TimeInfoBBT {

typedef struct _TimeInfo {
bool playing;
uint32_t frame;
uint32_t usecs;
uint64_t frame;
uint64_t usecs;
TimeInfoBBT bbt;
} TimeInfo;



+ 5
- 1
source/backend/engine/CarlaEnginePlugin.cpp View File

@@ -23,6 +23,9 @@
using DISTRHO::d_cconst;
using DISTRHO::d_string;

#ifdef QTCREATOR_TEST
CARLA_BACKEND_START_NAMESPACE
#else
// -----------------------------------------
// needed symbols

@@ -33,11 +36,12 @@ CARLA_BACKEND_START_NAMESPACE

CarlaEngine* CarlaEngine::newJack() { return nullptr; }

#ifdef WANT_RTAUDIO
# ifdef WANT_RTAUDIO
CarlaEngine* CarlaEngine::newRtAudio(RtAudioApi) { return nullptr; }
size_t CarlaEngine::getRtAudioApiCount() { return 0; }
const char* CarlaEngine::getRtAudioApiName(const unsigned int) { return nullptr; }
const char** CarlaEngine::getRtAudioApiDeviceNames(const unsigned int) { return nullptr; }
# endif
#endif

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


+ 5
- 3
source/backend/engine/distrho/DistrhoPluginInfo.h View File

@@ -1,5 +1,5 @@
/*
* Carla Plugin Engine
* Carla Plugin Engine (DISTRHO)
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
@@ -20,16 +20,18 @@

#define DISTRHO_PLUGIN_NAME "Carla"

#define DISTRHO_PLUGIN_HAS_UI 0
#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_SYNTH 1

#define DISTRHO_PLUGIN_NUM_INPUTS 2
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2

#define DISTRHO_PLUGIN_WANT_LATENCY 1
#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 1

#define DISTRHO_PLUGIN_URI "http://kxstudio.sf.net/carla"

#define DISTRHO_UI_EXTERNAL

#endif // __DISTRHO_PLUGIN_INFO_H__

+ 2
- 0
source/backend/native/3bandeq/DistrhoPluginInfo.h View File

@@ -31,4 +31,6 @@

#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/3BandEQ"

#define DISTRHO_UI_OPENGL

#endif // __DISTRHO_PLUGIN_INFO_H__

+ 2
- 0
source/backend/native/3bandsplitter/DistrhoPluginInfo.h View File

@@ -31,4 +31,6 @@

#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/3BandSplitter"

#define DISTRHO_UI_OPENGL

#endif // __DISTRHO_PLUGIN_INFO_H__

+ 2
- 0
source/backend/native/pingpongpan/DistrhoPluginInfo.h View File

@@ -31,4 +31,6 @@

#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/PingPongPan"

#define DISTRHO_UI_OPENGL

#endif // __DISTRHO_PLUGIN_INFO_H__

+ 24
- 5
source/libs/distrho/DistrhoPlugin.hpp View File

@@ -79,9 +79,25 @@ struct ParameterRanges {
value = max;
}

float fixValue(const float& value) const
{
if (value < min)
return min;
else if (value > max)
return max;
return value;
}

float normalizeValue(const float& value) const
{
return (value - min) / (max - min);
float newValue = (value - min) / (max - min);

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

return newValue;
}

float unnormalizeValue(const float& value) const
@@ -132,17 +148,19 @@ struct MidiEvent {
// TimePos

struct TimePos {
bool playing;
uint64_t frame;
double bpm;

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

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

struct PluginPrivateData;

class Plugin
{
public:
@@ -209,7 +227,8 @@ protected:
// ---------------------------------------------

private:
PluginPrivateData* const pData;
struct PrivateData;
PrivateData* const pData;
friend class PluginInternal;
};



+ 2
- 3
source/libs/distrho/DistrhoUI.hpp View File

@@ -26,8 +26,6 @@ START_NAMESPACE_DISTRHO
// -------------------------------------------------
// UI

struct UIPrivateData;

class UI
{
public:
@@ -82,7 +80,8 @@ protected:
// ---------------------------------------------

private:
UIPrivateData* const pData;
struct PrivateData;
PrivateData* const pData;
friend class UIInternal;
};



+ 1
- 11
source/libs/distrho/DistrhoUtils.hpp View File

@@ -62,16 +62,6 @@ void d_msleep(unsigned int msecs)
#endif
}

static inline
void d_usleep(unsigned int usecs)
{
#ifdef DISTRHO_OS_WINDOWS
Sleep(usecs / 1000);
#else
usleep(usecs);
#endif
}

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

static inline
@@ -504,4 +494,4 @@ d_string operator+(const char* const strBufBefore, const d_string& strAfter)

END_NAMESPACE_DISTRHO

#endif // __UTILS_HPP__
#endif // __DISTRHO_UTILS_HPP__

+ 6
- 4
source/libs/distrho/src/DistrhoDefines.h View File

@@ -51,6 +51,12 @@
# error DISTRHO_PLUGIN_WANT_STATE undefined!
#endif

#if DISTRHO_PLUGIN_HAS_UI
# if ! (defined(DISTRHO_UI_EXTERNAL) || defined(DISTRHO_UI_OPENGL) || defined(DISTRHO_UI_QT))
# error DISTRHO_PLUGIN_HAS_UI is defined but not its type; please define one of DISTRHO_UI_EXTERNAL, DISTRHO_UI_OPENGL or DISTRHO_UI_QT
# endif
#endif

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport)
# define DISTRHO_OS_WINDOWS 1
@@ -86,10 +92,6 @@
# define USE_NAMESPACE_DISTRHO
#endif

#ifndef DISTRHO_UI_QT
# define DISTRHO_UI_OPENGL
#endif

#define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI"

#endif // __DISTRHO_DEFINES_H__

+ 1
- 1
source/libs/distrho/src/DistrhoPlugin.cpp View File

@@ -34,7 +34,7 @@ const ParameterRanges PluginInternal::sFallbackRanges;
// Plugin

Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount)
: pData(new PluginPrivateData)
: pData(new PrivateData())
{
if (parameterCount > 0)
{


+ 5
- 5
source/libs/distrho/src/DistrhoPluginInternal.hpp View File

@@ -28,7 +28,7 @@ START_NAMESPACE_DISTRHO
extern uint32_t d_lastBufferSize;
extern double d_lastSampleRate;

struct PluginPrivateData {
struct Plugin::PrivateData {
uint32_t bufferSize;
double sampleRate;

@@ -49,9 +49,9 @@ struct PluginPrivateData {
uint32_t latency;
#endif

TimePos timePos;
TimePos timePos;

PluginPrivateData()
PrivateData()
: bufferSize(d_lastBufferSize),
sampleRate(d_lastSampleRate),
parameterCount(0),
@@ -73,7 +73,7 @@ struct PluginPrivateData {
assert(sampleRate != 0.0);
}

~PluginPrivateData()
~PrivateData()
{
if (parameterCount > 0 && parameters != nullptr)
delete[] parameters;
@@ -344,7 +344,7 @@ public:

protected:
Plugin* const kPlugin;
PluginPrivateData* const kData;
Plugin::PrivateData* const kData;

private:
static const d_string sFallbackString;


+ 7
- 0
source/libs/distrho/src/DistrhoPluginVST.cpp View File

@@ -223,6 +223,13 @@ protected:
#if DISTRHO_PLUGIN_IS_SYNTH
// TODO
#endif
return;

// unused
(void)onOff;
(void)channel;
(void)note;
(void)velocity;
}

void uiResize(unsigned int width, unsigned int height)


+ 1
- 1
source/libs/distrho/src/DistrhoUI.cpp View File

@@ -27,7 +27,7 @@ double d_lastUiSampleRate = 0.0;
// UI

UI::UI()
: pData(new UIPrivateData)
: pData(new PrivateData())
{
#if (defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2))
pData->parameterOffset = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;


+ 22
- 15
source/libs/distrho/src/DistrhoUIInternal.hpp View File

@@ -19,7 +19,10 @@

#include "DistrhoDefines.h"

#ifdef DISTRHO_UI_OPENGL
#if defined(DISTRHO_UI_EXTERNAL)
# include "../DistrhoUI.hpp"
// TODO
#elif defined(DISTRHO_UI_OPENGL)
# include "../DistrhoUIOpenGL.hpp"
# include "../dgl/App.hpp"
# include "../dgl/Window.hpp"
@@ -43,7 +46,7 @@ extern double d_lastUiSampleRate;

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

struct UIPrivateData {
struct UI::PrivateData {
// DSP
double sampleRate;
uint32_t parameterOffset;
@@ -56,7 +59,7 @@ struct UIPrivateData {
uiResizeFunc uiResizeCallbackFunc;
void* ptr;

UIPrivateData()
PrivateData()
: sampleRate(d_lastUiSampleRate),
parameterOffset(0),
editParamCallbackFunc(nullptr),
@@ -69,7 +72,7 @@ struct UIPrivateData {
assert(sampleRate != 0.0);
}

~UIPrivateData()
~PrivateData()
{
}

@@ -214,17 +217,26 @@ public:

void idle()
{
#ifdef DISTRHO_UI_QT
#if defined(DISTRHO_UI_EXTERNAL)
// TODO - idle OSC
#elif defined(DISTRHO_UI_OPENGL)
glApp.idle();
#else
assert(kUi != nullptr);

if (kUi != nullptr)
kUi->d_uiIdle();
#else
glApp.idle();
#endif
}

#ifdef DISTRHO_UI_QT
#if defined(DISTRHO_UI_EXTERNAL)
// needed?
#elif defined(DISTRHO_UI_OPENGL)
intptr_t getWinId()
{
return glWindow.getWindowId();
}
#else
QtUI* getQtUI() const
{
return (QtUI*)kUi;
@@ -234,24 +246,19 @@ public:
{
return ((QtUI*)kUi)->d_resizable();
}
#else
intptr_t getWinId()
{
return glWindow.getWindowId();
}
#endif

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

private:
#ifdef DISTRHO_UI_OPENGL
private:
App glApp;
Window glWindow;
#endif

protected:
UI* const kUi;
UIPrivateData* const kData;
UI::PrivateData* const kData;
};

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


Loading…
Cancel
Save