Browse Source

Make base headers not depende on carla utils code

tags/1.9.4
falkTX 11 years ago
parent
commit
cb8f7807f1
21 changed files with 911 additions and 963 deletions
  1. +47
    -83
      source/backend/CarlaEngine.hpp
  2. +25
    -19
      source/backend/CarlaHost.h
  3. +10
    -80
      source/backend/CarlaPlugin.hpp
  4. +99
    -42
      source/backend/engine/CarlaEngine.cpp
  5. +11
    -1
      source/backend/engine/CarlaEngineInternal.hpp
  6. +48
    -46
      source/backend/engine/CarlaEngineJack.cpp
  7. +23
    -26
      source/backend/engine/CarlaEngineRtAudio.cpp
  8. +34
    -34
      source/backend/plugin/BridgePlugin.cpp
  9. +131
    -102
      source/backend/plugin/CarlaPlugin.cpp
  10. +20
    -3
      source/backend/plugin/CarlaPluginInternal.hpp
  11. +59
    -59
      source/backend/plugin/DssiPlugin.cpp
  12. +39
    -39
      source/backend/plugin/FluidSynthPlugin.cpp
  13. +34
    -34
      source/backend/plugin/LadspaPlugin.cpp
  14. +35
    -35
      source/backend/plugin/LinuxSamplerPlugin.cpp
  15. +60
    -60
      source/backend/plugin/Lv2Plugin.cpp
  16. +69
    -69
      source/backend/plugin/NativePlugin.cpp
  17. +73
    -73
      source/backend/plugin/VstPlugin.cpp
  18. +26
    -128
      source/backend/standalone/CarlaStandalone.cpp
  19. +58
    -20
      source/carla_backend.py
  20. +3
    -10
      source/includes/CarlaDefines.h
  21. +7
    -0
      source/utils/CarlaUtils.hpp

+ 47
- 83
source/backend/CarlaEngine.hpp View File

@@ -20,7 +20,6 @@


#include "CarlaBackend.h" #include "CarlaBackend.h"
#include "CarlaMIDI.h" #include "CarlaMIDI.h"
#include "CarlaString.hpp"


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
struct CarlaOscData; struct CarlaOscData;
@@ -239,10 +238,10 @@ struct EngineOptions {
unsigned int audioNumPeriods; unsigned int audioNumPeriods;
unsigned int audioBufferSize; unsigned int audioBufferSize;
unsigned int audioSampleRate; unsigned int audioSampleRate;
CarlaString audioDevice;
const char* audioDevice;


CarlaString binaryDir;
CarlaString resourceDir;
const char* binaryDir;
const char* resourceDir;


EngineOptions() EngineOptions()
#ifdef CARLA_OS_LINUX #ifdef CARLA_OS_LINUX
@@ -260,7 +259,31 @@ struct EngineOptions {
uiBridgesTimeout(4000), uiBridgesTimeout(4000),
audioNumPeriods(2), audioNumPeriods(2),
audioBufferSize(512), audioBufferSize(512),
audioSampleRate(44100) {}
audioSampleRate(44100),
audioDevice(nullptr),
binaryDir(nullptr),
resourceDir(nullptr) {}

~EngineOptions()
{
if (audioDevice != nullptr)
{
delete[] audioDevice;
audioDevice = nullptr;
}

if (binaryDir != nullptr)
{
delete[] binaryDir;
binaryDir = nullptr;
}

if (resourceDir != nullptr)
{
delete[] resourceDir;
resourceDir = nullptr;
}
}
}; };


/*! /*!
@@ -377,7 +400,7 @@ protected:
const CarlaEngine& fEngine; const CarlaEngine& fEngine;
const bool fIsInput; const bool fIsInput;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEnginePort)
CARLA_DECLARE_NON_COPY_CLASS(CarlaEnginePort)
#endif #endif
}; };


@@ -425,7 +448,7 @@ public:
protected: protected:
float* fBuffer; float* fBuffer;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineAudioPort)
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngineAudioPort)
#endif #endif
}; };


@@ -481,7 +504,7 @@ public:
protected: protected:
float* fBuffer; float* fBuffer;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineCVPort)
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngineCVPort)
#endif #endif
}; };


@@ -574,7 +597,7 @@ public:
protected: protected:
EngineEvent* fBuffer; EngineEvent* fBuffer;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineEventPort)
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngineEventPort)
#endif #endif
}; };


@@ -647,7 +670,7 @@ protected:
bool fActive; bool fActive;
uint32_t fLatency; uint32_t fLatency;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineClient)
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngineClient)
#endif #endif
}; };


@@ -846,22 +869,20 @@ public:
// Project management // Project management


/*! /*!
* Load \a filename of any type.\n
* Load a file of any type.\n
* This will try to load a generic file as a plugin, * This will try to load a generic file as a plugin,
* either by direct handling (GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI). * either by direct handling (GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
*/ */
bool loadFilename(const char* const filename);
bool loadFile(const char* const filename);


/*! /*!
* Load \a filename project file.\n
* (project files have *.carxp extension)
* \note Already loaded plugins are not removed; call removeAllPlugins() first if needed.
* Load a project file.
* @note Already loaded plugins are not removed; call removeAllPlugins() first if needed.
*/ */
bool loadProject(const char* const filename); bool loadProject(const char* const filename);


/*! /*!
* Save current project to \a filename.\n
* (project files have *.carxp extension)
* Save current project to a file.
*/ */
bool saveProject(const char* const filename); bool saveProject(const char* const filename);


@@ -871,58 +892,37 @@ public:
/*! /*!
* Get the current engine driver hints. * Get the current engine driver hints.
*/ */
unsigned int getHints() const noexcept
{
return fHints;
}
unsigned int getHints() const noexcept;


/*! /*!
* Get the current buffer size. * Get the current buffer size.
*/ */
uint32_t getBufferSize() const noexcept
{
return fBufferSize;
}
uint32_t getBufferSize() const noexcept;


/*! /*!
* Get the current sample rate. * Get the current sample rate.
*/ */
double getSampleRate() const noexcept
{
return fSampleRate;
}
double getSampleRate() const noexcept;


/*! /*!
* Get the current engine name. * Get the current engine name.
*/ */
const char* getName() const noexcept
{
return (const char*)fName;
}
const char* getName() const noexcept;


/*! /*!
* Get the current engine proccess mode. * Get the current engine proccess mode.
*/ */
EngineProcessMode getProccessMode() const noexcept
{
return fOptions.processMode;
}
EngineProcessMode getProccessMode() const noexcept;


/*! /*!
* Get the current engine options (read-only). * Get the current engine options (read-only).
*/ */
const EngineOptions& getOptions() const noexcept
{
return fOptions;
}
const EngineOptions& getOptions() const noexcept;


/*! /*!
* Get the current Time information (read-only). * Get the current Time information (read-only).
*/ */
const EngineTimeInfo& getTimeInfo() const noexcept
{
return fTimeInfo;
}
const EngineTimeInfo& getTimeInfo() const noexcept;


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Information (peaks) // Information (peaks)
@@ -968,7 +968,7 @@ public:
/*! /*!
* Force the engine to resend all patchbay clients, ports and connections again. * Force the engine to resend all patchbay clients, ports and connections again.
*/ */
virtual void patchbayRefresh();
virtual bool patchbayRefresh();


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Transport // Transport
@@ -1073,42 +1073,6 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------


protected: protected:
/*!
* Current engine driver hints.
* \see getHints()
*/
unsigned int fHints;

/*!
* Current buffer size.
* \see getBufferSize()
*/
uint32_t fBufferSize;

/*!
* Current sample rate.
* \see getSampleRate()
*/
double fSampleRate;

/*!
* Engine name.
* \see getName()
*/
CarlaString fName;

/*!
* Engine options.
* \see getOptions() and setOption()
*/
EngineOptions fOptions;

/*!
* Current time-pos information.
* \see getTimeInfo()
*/
EngineTimeInfo fTimeInfo;

/*! /*!
* Internal data, for CarlaEngine subclasses only. * Internal data, for CarlaEngine subclasses only.
*/ */
@@ -1251,7 +1215,7 @@ public:
void oscSend_control_exit(); void oscSend_control_exit();
#endif #endif


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngine)
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngine)
}; };


/**@}*/ /**@}*/


+ 25
- 19
source/backend/CarlaHost.h View File

@@ -470,7 +470,7 @@ typedef struct _CarlaTransportInfo {
CARLA_EXPORT const char* carla_get_complete_license_text(); CARLA_EXPORT const char* carla_get_complete_license_text();


/*! /*!
* Get all the supported file types in carla_load_filename().\n
* Get all the supported file extensions in carla_load_file().\n
* Returned string uses this syntax: * Returned string uses this syntax:
* @code * @code
* "*.ext1;*.ext2;*.ext3" * "*.ext1;*.ext2;*.ext3"
@@ -529,7 +529,7 @@ CARLA_EXPORT CarlaEngine* carla_get_host_engine();
*/ */
CARLA_EXPORT bool carla_engine_init(const char* driverName, const char* clientName); CARLA_EXPORT bool carla_engine_init(const char* driverName, const char* clientName);


#ifndef BUILD_BRIDGE
#ifdef BUILD_BRIDGE
/*! /*!
* Initialize the engine in bridged mode. * Initialize the engine in bridged mode.
* @param audioBaseName Shared memory key for audio pool * @param audioBaseName Shared memory key for audio pool
@@ -542,7 +542,7 @@ CARLA_EXPORT bool carla_engine_init_bridge(const char audioBaseName[6], const ch
/*! /*!
* Close the engine.\n * Close the engine.\n
* This function always closes the engine even if it returns false.\n * This function always closes the engine even if it returns false.\n
* In other words, something went wrong when closing the engine but it was still closed nonetheless.
* In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
*/ */
CARLA_EXPORT bool carla_engine_close(); CARLA_EXPORT bool carla_engine_close();


@@ -564,42 +564,48 @@ CARLA_EXPORT bool carla_is_engine_running();
CARLA_EXPORT void carla_set_engine_about_to_close(); CARLA_EXPORT void carla_set_engine_about_to_close();


/*! /*!
* Set the engine callback function to \a func.
* Use \a ptr to pass a custom pointer to the callback.
* Set the engine callback function.
* @param func Callback function
* @param ptr Callback pointer
*/ */
CARLA_EXPORT void carla_set_engine_callback(EngineCallbackFunc func, void* ptr); CARLA_EXPORT void carla_set_engine_callback(EngineCallbackFunc func, void* ptr);


#ifndef BUILD_BRIDGE
/*! /*!
* Set the engine option \a option.\n
* With the exception of OPTION_PROCESS_NAME, OPTION_TRANSPORT_MODE and OPTION_PATH_*,
* this function should not be called when the engine is running.
* Set an engine option.
* @param option Option
* @param value Value as number
* @param valueStr Value as string
*/ */
CARLA_EXPORT void carla_set_engine_option(EngineOption option, int value, const char* valueStr); CARLA_EXPORT void carla_set_engine_option(EngineOption option, int value, const char* valueStr);
#endif


/*! /*!
* Set the file callback function to \a func.
* Use \a ptr to pass a custom pointer to the callback.
* Set the file callback function.
* @param func Callback function
* @param ptr Callback pointer
*/ */
CARLA_EXPORT void carla_set_file_callback(FileCallbackFunc func, void* ptr); CARLA_EXPORT void carla_set_file_callback(FileCallbackFunc func, void* ptr);


/*! /*!
* Load \a filename of any type.\n
* Load a file of any type.\n
* This will try to load a generic file as a plugin, * This will try to load a generic file as a plugin,
* either by direct handling (GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
* @see carla_get_supported_file_types()
* either by direct handling (Csound, GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
* @param Filename Filename
* @see carla_get_supported_file_extensions()
*/ */
CARLA_EXPORT bool carla_load_filename(const char* filename);
CARLA_EXPORT bool carla_load_file(const char* filename);


/*! /*!
* Load \a filename project file.\n
* (project files have *.carxp extension)
* \note Already loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
* Load a Carla project file.
* @param Filename Filename
* @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
*/ */
CARLA_EXPORT bool carla_load_project(const char* filename); CARLA_EXPORT bool carla_load_project(const char* filename);


/*! /*!
* Save current project to \a filename.\n
* (project files have *.carxp extension)
* Save current project to a file.
* @param Filename Filename
*/ */
CARLA_EXPORT bool carla_save_project(const char* filename); CARLA_EXPORT bool carla_save_project(const char* filename);




+ 10
- 80
source/backend/CarlaPlugin.hpp View File

@@ -19,14 +19,13 @@
#define CARLA_PLUGIN_HPP_INCLUDED #define CARLA_PLUGIN_HPP_INCLUDED


#include "CarlaBackend.h" #include "CarlaBackend.h"
#include "CarlaString.hpp"


// Avoid including extra libs here // Avoid including extra libs here
typedef void* lo_address; typedef void* lo_address;
typedef struct _NativePluginDescriptor NativePluginDescriptor; typedef struct _NativePluginDescriptor NativePluginDescriptor;
#ifndef LADSPA_RDF_HPP_INCLUDED
//#ifndef LADSPA_RDF_HPP_INCLUDED
struct LADSPA_RDF_Descriptor; struct LADSPA_RDF_Descriptor;
#endif
//#endif


CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


@@ -109,30 +108,21 @@ public:
* *
* \see setId() * \see setId()
*/ */
unsigned int getId() const noexcept
{
return fId;
}
unsigned int getId() const noexcept;


/*! /*!
* Get the plugin's hints. * Get the plugin's hints.
* *
* \see PluginHints * \see PluginHints
*/ */
unsigned int getHints() const noexcept
{
return fHints;
}
unsigned int getHints() const noexcept;


/*! /*!
* Get the plugin's options (currently in use). * Get the plugin's options (currently in use).
* *
* \see PluginOptions, getAvailableOptions() and setOption() * \see PluginOptions, getAvailableOptions() and setOption()
*/ */
unsigned int getOptionsEnabled() const noexcept
{
return fOptions;
}
unsigned int getOptionsEnabled() const noexcept;


/*! /*!
* Check if the plugin is enabled.\n * Check if the plugin is enabled.\n
@@ -140,10 +130,7 @@ public:
* *
* \see setEnabled() * \see setEnabled()
*/ */
bool isEnabled() const noexcept
{
return fEnabled;
}
bool isEnabled() const noexcept;


/*! /*!
* Get the plugin's internal name.\n * Get the plugin's internal name.\n
@@ -151,27 +138,18 @@ public:
* *
* \see getRealName() and setName() * \see getRealName() and setName()
*/ */
const char* getName() const noexcept
{
return (const char*)fName;
}
const char* getName() const noexcept;


/*! /*!
* Get the currently loaded DLL filename for this plugin.\n * Get the currently loaded DLL filename for this plugin.\n
* (Sound kits return their exact filename). * (Sound kits return their exact filename).
*/ */
const char* getFilename() const noexcept
{
return (const char*)fFilename;
}
const char* getFilename() const noexcept;


/*! /*!
* Get the plugins's icon name. * Get the plugins's icon name.
*/ */
const char* getIconName() const noexcept
{
return (const char*)fIconName;
}
const char* getIconName() const noexcept;


/*! /*!
* Get the plugin's category (delay, filter, synth, etc). * Get the plugin's category (delay, filter, synth, etc).
@@ -870,54 +848,6 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------


protected: protected:
/*!
* Plugin Id, as passed in the constructor, returned in getId().
* \see getId and setId()
*/
unsigned int fId;

/*!
* Hints, as returned in getHints().
* \see PluginHints and getHints()
*/
unsigned int fHints;

/*!
* Defined and currently in-use options, returned in getOptions().
* \see PluginOptions, getOptionsAvailable(), getOptionsEnabled(), setOption()
*/
unsigned int fOptions;

/*!
* Patchbay client Id that matches this plugin, 0 if unused.
*/
int fPatchbayClientId;

/*!
* Wherever the plugin is ready for usage.\n
* When a plugin is disabled, it will never be processed or managed in any way.
* \see isEnabled() and setEnabled()
*/
bool fEnabled;

/*!
* Plugin name
* \see getName(), getRealName() and setName()
*/
CarlaString fName;

/*!
* Plugin filename, if applicable
* \see getFilename()
*/
CarlaString fFilename;

/*!
* Icon name
* \see getIconName()
*/
CarlaString fIconName;

/*! /*!
* Internal data, for CarlaPlugin subclasses only. * Internal data, for CarlaPlugin subclasses only.
*/ */
@@ -963,7 +893,7 @@ protected:
CARLA_DECLARE_NON_COPY_CLASS(ScopedSingleProcessLocker) CARLA_DECLARE_NON_COPY_CLASS(ScopedSingleProcessLocker)
}; };


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPlugin)
CARLA_DECLARE_NON_COPY_CLASS(CarlaPlugin)
}; };


/**@}*/ /**@}*/


+ 99
- 42
source/backend/engine/CarlaEngine.cpp View File

@@ -338,10 +338,7 @@ CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const
// Carla Engine // Carla Engine


CarlaEngine::CarlaEngine() CarlaEngine::CarlaEngine()
: fHints(0x0),
fBufferSize(0),
fSampleRate(0.0),
pData(new CarlaEngineProtectedData(this))
: pData(new CarlaEngineProtectedData(this))
{ {
carla_debug("CarlaEngine::CarlaEngine()"); carla_debug("CarlaEngine::CarlaEngine()");
} }
@@ -519,7 +516,7 @@ unsigned int CarlaEngine::getMaxPluginNumber() const noexcept


bool CarlaEngine::init(const char* const clientName) bool CarlaEngine::init(const char* const clientName)
{ {
CARLA_SAFE_ASSERT_RETURN_ERR(fName.isEmpty(), "Invalid engine internal data (err #1)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->name.isEmpty(), "Invalid engine internal data (err #1)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->oscData == nullptr, "Invalid engine internal data (err #2)"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->oscData == nullptr, "Invalid engine internal data (err #2)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins == nullptr, "Invalid engine internal data (err #3)"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins == nullptr, "Invalid engine internal data (err #3)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->bufEvents.in == nullptr, "Invalid engine internal data (err #4)"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->bufEvents.in == nullptr, "Invalid engine internal data (err #4)");
@@ -532,7 +529,7 @@ bool CarlaEngine::init(const char* const clientName)
pData->maxPluginNumber = 0; pData->maxPluginNumber = 0;
pData->nextPluginId = 0; pData->nextPluginId = 0;


switch (fOptions.processMode)
switch (pData->options.processMode)
{ {
case ENGINE_PROCESS_MODE_SINGLE_CLIENT: case ENGINE_PROCESS_MODE_SINGLE_CLIENT:
case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS: case ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS:
@@ -560,10 +557,10 @@ bool CarlaEngine::init(const char* const clientName)


pData->nextPluginId = pData->maxPluginNumber; pData->nextPluginId = pData->maxPluginNumber;


fName = clientName;
fName.toBasic();
pData->name = clientName;
pData->name.toBasic();


fTimeInfo.clear();
pData->timeInfo.clear();


pData->plugins = new EnginePluginData[pData->maxPluginNumber]; pData->plugins = new EnginePluginData[pData->maxPluginNumber];


@@ -582,7 +579,7 @@ bool CarlaEngine::init(const char* const clientName)


bool CarlaEngine::close() bool CarlaEngine::close()
{ {
CARLA_SAFE_ASSERT_RETURN_ERR(fName.isNotEmpty(), "Invalid engine internal data (err #6)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->name.isNotEmpty(), "Invalid engine internal data (err #6)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #7)"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data (err #7)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextPluginId == pData->maxPluginNumber, "Invalid engine internal data (err #8)"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextPluginId == pData->maxPluginNumber, "Invalid engine internal data (err #8)");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #9)"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #9)");
@@ -620,7 +617,7 @@ bool CarlaEngine::close()
pData->bufEvents.out = nullptr; pData->bufEvents.out = nullptr;
} }


fName.clear();
pData->name.clear();


callback(ENGINE_CALLBACK_ENGINE_STOPPED, 0, 0, 0, 0.0f, nullptr); callback(ENGINE_CALLBACK_ENGINE_STOPPED, 0, 0, 0, 0.0f, nullptr);


@@ -701,16 +698,16 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons
switch (btype) switch (btype)
{ {
case BINARY_POSIX32: case BINARY_POSIX32:
bridgeBinary = fOptions.bridge_posix32.isNotEmpty() ? (const char*)fOptions.bridge_posix32 : nullptr;
bridgeBinary = pData->options.bridge_posix32.isNotEmpty() ? (const char*)pData->options.bridge_posix32 : nullptr;
break; break;
case BINARY_POSIX64: case BINARY_POSIX64:
bridgeBinary = fOptions.bridge_posix64.isNotEmpty() ? (const char*)fOptions.bridge_posix64 : nullptr;
bridgeBinary = pData->options.bridge_posix64.isNotEmpty() ? (const char*)pData->options.bridge_posix64 : nullptr;
break; break;
case BINARY_WIN32: case BINARY_WIN32:
bridgeBinary = fOptions.bridge_win32.isNotEmpty() ? (const char*)fOptions.bridge_win32 : nullptr;
bridgeBinary = pData->options.bridge_win32.isNotEmpty() ? (const char*)pData->options.bridge_win32 : nullptr;
break; break;
case BINARY_WIN64: case BINARY_WIN64:
bridgeBinary = fOptions.bridge_win64.isNotEmpty() ? (const char*)fOptions.bridge_win64 : nullptr;
bridgeBinary = pData->options.bridge_win64.isNotEmpty() ? (const char*)pData->options.bridge_win64 : nullptr;
break; break;
default: default:
bridgeBinary = nullptr; bridgeBinary = nullptr;
@@ -718,11 +715,11 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons
} }


# ifndef CARLA_OS_WIN # ifndef CARLA_OS_WIN
if (btype == BINARY_NATIVE && fOptions.bridge_native.isNotEmpty())
bridgeBinary = (const char*)fOptions.bridge_native;
if (btype == BINARY_NATIVE && pData->options.bridge_native.isNotEmpty())
bridgeBinary = (const char*)pData->options.bridge_native;
# endif # endif


if (btype != BINARY_NATIVE || (fOptions.preferPluginBridges && bridgeBinary != nullptr))
if (btype != BINARY_NATIVE || (pData->options.preferPluginBridges && bridgeBinary != nullptr))
{ {
if (bridgeBinary != nullptr) if (bridgeBinary != nullptr)
{ {
@@ -845,7 +842,7 @@ bool CarlaEngine::removePlugin(const unsigned int id)


pData->thread.stop(500); pData->thread.stop(500);


const bool lockWait(isRunning() && fOptions.processMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS);
const bool lockWait(isRunning() && pData->options.processMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS);
const CarlaEngineProtectedData::ScopedActionLock sal(pData, kEnginePostActionRemovePlugin, id, 0, lockWait); const CarlaEngineProtectedData::ScopedActionLock sal(pData, kEnginePostActionRemovePlugin, id, 0, lockWait);


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
@@ -991,7 +988,7 @@ bool CarlaEngine::switchPlugins(const unsigned int idA, const unsigned int idB)


pData->thread.stop(500); pData->thread.stop(500);


const bool lockWait(isRunning() && fOptions.processMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS);
const bool lockWait(isRunning() && pData->options.processMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS);
const CarlaEngineProtectedData::ScopedActionLock sal(pData, kEnginePostActionSwitchPlugins, idA, idB, lockWait); const CarlaEngineProtectedData::ScopedActionLock sal(pData, kEnginePostActionSwitchPlugins, idA, idB, lockWait);


#ifndef BUILD_BRIDGE // TODO #ifndef BUILD_BRIDGE // TODO
@@ -1108,10 +1105,10 @@ const char* CarlaEngine::getUniquePluginName(const char* const name) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Project management // Project management


bool CarlaEngine::loadFilename(const char* const filename)
bool CarlaEngine::loadFile(const char* const filename)
{ {
CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #1)"); CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #1)");
carla_debug("CarlaEngine::loadFilename(\"%s\")", filename);
carla_debug("CarlaEngine::loadFile(\"%s\")", filename);


#ifdef USE_JUCE #ifdef USE_JUCE
using namespace juce; using namespace juce;
@@ -1373,6 +1370,65 @@ bool CarlaEngine::saveProject(const char* const filename)
return false; return false;
} }


// -----------------------------------------------------------------------
// Information (base)

/*!
* Get the current engine driver hints.
*/
unsigned int CarlaEngine::getHints() const noexcept
{
return pData->hints;
}

/*!
* Get the current buffer size.
*/
uint32_t CarlaEngine::getBufferSize() const noexcept
{
return pData->bufferSize;
}

/*!
* Get the current sample rate.
*/
double CarlaEngine::getSampleRate() const noexcept
{
return pData->sampleRate;
}

/*!
* Get the current engine name.
*/
const char* CarlaEngine::getName() const noexcept
{
return (const char*)pData->name;
}

/*!
* Get the current engine proccess mode.
*/
EngineProcessMode CarlaEngine::getProccessMode() const noexcept
{
return pData->options.processMode;
}

/*!
* Get the current engine options (read-only).
*/
const EngineOptions& CarlaEngine::getOptions() const noexcept
{
return pData->options;
}

/*!
* Get the current Time information (read-only).
*/
const EngineTimeInfo& CarlaEngine::getTimeInfo() const noexcept
{
return pData->timeInfo;
}

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Information (peaks) // Information (peaks)


@@ -1428,9 +1484,10 @@ bool CarlaEngine::patchbayDisconnect(int)
return false; return false;
} }


void CarlaEngine::patchbayRefresh()
bool CarlaEngine::patchbayRefresh()
{ {
// nothing
setLastError("Unsupported operation");
return false;
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -1492,77 +1549,77 @@ void CarlaEngine::setOption(const EngineOption option, const int value, const ch
if (value < ENGINE_PROCESS_MODE_SINGLE_CLIENT || value > ENGINE_PROCESS_MODE_PATCHBAY) if (value < ENGINE_PROCESS_MODE_SINGLE_CLIENT || value > ENGINE_PROCESS_MODE_PATCHBAY)
return carla_stderr("CarlaEngine::setOption(ENGINE_OPTION_PROCESS_MODE, %i, \"%s\") - invalid value", value, valueStr); return carla_stderr("CarlaEngine::setOption(ENGINE_OPTION_PROCESS_MODE, %i, \"%s\") - invalid value", value, valueStr);


fOptions.processMode = static_cast<EngineProcessMode>(value);
pData->options.processMode = static_cast<EngineProcessMode>(value);
break; break;


case ENGINE_OPTION_TRANSPORT_MODE: case ENGINE_OPTION_TRANSPORT_MODE:
if (value < ENGINE_TRANSPORT_MODE_INTERNAL || value > ENGINE_TRANSPORT_MODE_JACK) if (value < ENGINE_TRANSPORT_MODE_INTERNAL || value > ENGINE_TRANSPORT_MODE_JACK)
return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, %i, \"%s\") - invalid value", value, valueStr); return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, %i, \"%s\") - invalid value", value, valueStr);


fOptions.transportMode = static_cast<EngineTransportMode>(value);
pData->options.transportMode = static_cast<EngineTransportMode>(value);
break; break;


case ENGINE_OPTION_FORCE_STEREO: case ENGINE_OPTION_FORCE_STEREO:
fOptions.forceStereo = (value != 0);
pData->options.forceStereo = (value != 0);
break; break;


case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES: case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES:
fOptions.preferPluginBridges = (value != 0);
pData->options.preferPluginBridges = (value != 0);
break; break;


case ENGINE_OPTION_PREFER_UI_BRIDGES: case ENGINE_OPTION_PREFER_UI_BRIDGES:
fOptions.preferUiBridges = (value != 0);
pData->options.preferUiBridges = (value != 0);
break; break;


case ENGINE_OPTION_UIS_ALWAYS_ON_TOP: case ENGINE_OPTION_UIS_ALWAYS_ON_TOP:
fOptions.uisAlwaysOnTop = (value != 0);
pData->options.uisAlwaysOnTop = (value != 0);
break; break;


case ENGINE_OPTION_MAX_PARAMETERS: case ENGINE_OPTION_MAX_PARAMETERS:
if (value < 1) if (value < 1)
return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr); return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr);


fOptions.maxParameters = static_cast<uint>(value);
pData->options.maxParameters = static_cast<uint>(value);
break; break;


case ENGINE_OPTION_UI_BRIDGES_TIMEOUT: case ENGINE_OPTION_UI_BRIDGES_TIMEOUT:
if (value < 1) if (value < 1)
return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, %i, \"%s\") - invalid value", value, valueStr); return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, %i, \"%s\") - invalid value", value, valueStr);


fOptions.uiBridgesTimeout = static_cast<uint>(value);
pData->options.uiBridgesTimeout = static_cast<uint>(value);
break; break;


case ENGINE_OPTION_AUDIO_NUM_PERIODS: case ENGINE_OPTION_AUDIO_NUM_PERIODS:
if (value < 2 || value > 3) if (value < 2 || value > 3)
return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_AUDIO_NUM_PERIODS, %i, \"%s\") - invalid value", value, valueStr); return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_AUDIO_NUM_PERIODS, %i, \"%s\") - invalid value", value, valueStr);


fOptions.audioNumPeriods = static_cast<uint>(value);
pData->options.audioNumPeriods = static_cast<uint>(value);
break; break;


case ENGINE_OPTION_AUDIO_BUFFER_SIZE: case ENGINE_OPTION_AUDIO_BUFFER_SIZE:
if (value < 8) if (value < 8)
return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_AUDIO_BUFFER_SIZE, %i, \"%s\") - invalid value", value, valueStr); return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_AUDIO_BUFFER_SIZE, %i, \"%s\") - invalid value", value, valueStr);


fOptions.audioBufferSize = static_cast<uint>(value);
pData->options.audioBufferSize = static_cast<uint>(value);
break; break;


case ENGINE_OPTION_AUDIO_SAMPLE_RATE: case ENGINE_OPTION_AUDIO_SAMPLE_RATE:
if (value < 22050) if (value < 22050)
return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_AUDIO_SAMPLE_RATE, %i, \"%s\") - invalid value", value, valueStr); return carla_stderr2("carla_set_engine_option(ENGINE_OPTION_AUDIO_SAMPLE_RATE, %i, \"%s\") - invalid value", value, valueStr);


fOptions.audioSampleRate = static_cast<uint>(value);
pData->options.audioSampleRate = static_cast<uint>(value);
break; break;


case ENGINE_OPTION_AUDIO_DEVICE: case ENGINE_OPTION_AUDIO_DEVICE:
fOptions.audioDevice = valueStr;
pData->options.audioDevice = valueStr;
break; break;


case ENGINE_OPTION_PATH_BINARIES: case ENGINE_OPTION_PATH_BINARIES:
fOptions.binaryDir = valueStr;
pData->options.binaryDir = valueStr;
break; break;


case ENGINE_OPTION_PATH_RESOURCES: case ENGINE_OPTION_PATH_RESOURCES:
fOptions.resourceDir = valueStr;
pData->options.resourceDir = valueStr;
break; break;
} }
} }
@@ -1671,12 +1728,12 @@ void CarlaEngine::runPendingRtEvents()
pData->doNextPluginAction(true); pData->doNextPluginAction(true);


if (pData->time.playing) if (pData->time.playing)
pData->time.frame += fBufferSize;
pData->time.frame += pData->bufferSize;


if (fOptions.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
if (pData->options.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
{ {
fTimeInfo.playing = pData->time.playing;
fTimeInfo.frame = pData->time.frame;
pData->timeInfo.playing = pData->time.playing;
pData->timeInfo.frame = pData->time.frame;
} }
} }




+ 11
- 1
source/backend/engine/CarlaEngineInternal.hpp View File

@@ -151,13 +151,20 @@ struct CarlaEngineProtectedData {
EngineCallbackFunc callback; EngineCallbackFunc callback;
void* callbackPtr; void* callbackPtr;


CarlaString lastError;
unsigned int hints;
uint32_t bufferSize;
double sampleRate;


bool aboutToClose; // don't re-activate thread if true bool aboutToClose; // don't re-activate thread if true
unsigned int curPluginCount; // number of plugins loaded (0...max) unsigned int curPluginCount; // number of plugins loaded (0...max)
unsigned int maxPluginNumber; // number of plugins allowed (0, 16, 99 or 255) unsigned int maxPluginNumber; // number of plugins allowed (0, 16, 99 or 255)
unsigned int nextPluginId; // invalid if == maxPluginNumber unsigned int nextPluginId; // invalid if == maxPluginNumber


CarlaString lastError;
CarlaString name;
EngineOptions options;
EngineTimeInfo timeInfo;

EnginePluginData* plugins; EnginePluginData* plugins;


struct InternalEvents { struct InternalEvents {
@@ -213,6 +220,9 @@ struct CarlaEngineProtectedData {
oscData(nullptr), oscData(nullptr),
callback(nullptr), callback(nullptr),
callbackPtr(nullptr), callbackPtr(nullptr),
hints(0x0),
bufferSize(0),
sampleRate(0.0),
aboutToClose(false), aboutToClose(false),
curPluginCount(0), curPluginCount(0),
maxPluginNumber(0), maxPluginNumber(0),


+ 48
- 46
source/backend/engine/CarlaEngineJack.cpp View File

@@ -579,13 +579,13 @@ public:
carla_debug("CarlaEngineJack::CarlaEngineJack()"); carla_debug("CarlaEngineJack::CarlaEngineJack()");


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
fOptions.processMode = ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS;
pData->options.processMode = ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS;
#else #else
carla_fill<jack_port_t*>(fRackPorts, kRackPortCount, nullptr); carla_fill<jack_port_t*>(fRackPorts, kRackPortCount, nullptr);
#endif #endif


// FIXME: Always enable JACK transport for now // FIXME: Always enable JACK transport for now
fOptions.transportMode = ENGINE_TRANSPORT_MODE_JACK;
pData->options.transportMode = ENGINE_TRANSPORT_MODE_JACK;


carla_zeroStruct<jack_position_t>(fTransportPos); carla_zeroStruct<jack_position_t>(fTransportPos);
} }
@@ -608,7 +608,7 @@ public:


unsigned int getMaxClientNameSize() const noexcept override unsigned int getMaxClientNameSize() const noexcept override
{ {
if (fOptions.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
if (pData->options.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT || pData->options.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
{ {
unsigned int ret = 0; unsigned int ret = 0;


@@ -625,7 +625,7 @@ public:


unsigned int getMaxPortNameSize() const noexcept override unsigned int getMaxPortNameSize() const noexcept override
{ {
if (fOptions.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
if (pData->options.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT || pData->options.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
{ {
unsigned int ret = 0; unsigned int ret = 0;


@@ -666,8 +666,8 @@ public:


if (fClient != nullptr) if (fClient != nullptr)
{ {
fBufferSize = jackbridge_get_buffer_size(fClient);
fSampleRate = jackbridge_get_sample_rate(fClient);
pData->bufferSize = jackbridge_get_buffer_size(fClient);
pData->sampleRate = jackbridge_get_sample_rate(fClient);


jackbridge_custom_publish_data(fClient, URI_CANVAS_ICON, "carla", 6); jackbridge_custom_publish_data(fClient, URI_CANVAS_ICON, "carla", 6);
jackbridge_custom_set_data_appearance_callback(fClient, carla_jack_custom_appearance_callback, this); jackbridge_custom_set_data_appearance_callback(fClient, carla_jack_custom_appearance_callback, this);
@@ -688,7 +688,7 @@ public:
jackbridge_set_port_connect_callback(fClient, carla_jack_port_connect_callback, this); jackbridge_set_port_connect_callback(fClient, carla_jack_port_connect_callback, this);
jackbridge_set_port_rename_callback(fClient, carla_jack_port_rename_callback, this); jackbridge_set_port_rename_callback(fClient, carla_jack_port_rename_callback, this);


if (fOptions.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
fRackPorts[kRackPortAudioIn1] = jackbridge_port_register(fClient, "audio-in1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); fRackPorts[kRackPortAudioIn1] = jackbridge_port_register(fClient, "audio-in1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
fRackPorts[kRackPortAudioIn2] = jackbridge_port_register(fClient, "audio-in2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); fRackPorts[kRackPortAudioIn2] = jackbridge_port_register(fClient, "audio-in2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
@@ -715,13 +715,13 @@ public:


return false; return false;
#else #else
if (fBufferSize == 0 || fSampleRate == 0.0)
if (pData->bufferSize == 0 || pData->sampleRate == 0.0)
{ {
// open temp client to get initial buffer-size and sample-rate values // open temp client to get initial buffer-size and sample-rate values
if (jack_client_t* tmpClient = jackbridge_client_open(clientName, JackNullOption, nullptr)) if (jack_client_t* tmpClient = jackbridge_client_open(clientName, JackNullOption, nullptr))
{ {
fBufferSize = jackbridge_get_buffer_size(tmpClient);
fSampleRate = jackbridge_get_sample_rate(tmpClient);
pData->bufferSize = jackbridge_get_buffer_size(tmpClient);
pData->sampleRate = jackbridge_get_sample_rate(tmpClient);


jackbridge_client_close(tmpClient); jackbridge_client_close(tmpClient);
} }
@@ -743,7 +743,7 @@ public:
#else #else
if (jackbridge_deactivate(fClient)) if (jackbridge_deactivate(fClient))
{ {
if (fOptions.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
jackbridge_port_unregister(fClient, fRackPorts[kRackPortAudioIn1]); jackbridge_port_unregister(fClient, fRackPorts[kRackPortAudioIn1]);
jackbridge_port_unregister(fClient, fRackPorts[kRackPortAudioIn2]); jackbridge_port_unregister(fClient, fRackPorts[kRackPortAudioIn2]);
@@ -856,8 +856,8 @@ public:


CARLA_SAFE_ASSERT_RETURN(client != nullptr, nullptr); CARLA_SAFE_ASSERT_RETURN(client != nullptr, nullptr);


fBufferSize = jackbridge_get_buffer_size(client);
fSampleRate = jackbridge_get_sample_rate(client);
pData->bufferSize = jackbridge_get_buffer_size(client);
pData->sampleRate = jackbridge_get_sample_rate(client);


jackbridge_custom_publish_data(client, URI_CANVAS_ICON, iconName, std::strlen(iconName)+1); jackbridge_custom_publish_data(client, URI_CANVAS_ICON, iconName, std::strlen(iconName)+1);


@@ -868,11 +868,11 @@ public:
jackbridge_set_process_callback(client, carla_jack_process_callback, this); jackbridge_set_process_callback(client, carla_jack_process_callback, this);
jackbridge_on_shutdown(client, carla_jack_shutdown_callback, this); jackbridge_on_shutdown(client, carla_jack_shutdown_callback, this);
#else #else
if (fOptions.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
if (pData->options.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
client = fClient; client = fClient;
} }
else if (fOptions.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
else if (pData->options.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
{ {
client = jackbridge_client_open(plugin->getName(), JackNullOption, nullptr); client = jackbridge_client_open(plugin->getName(), JackNullOption, nullptr);


@@ -912,13 +912,13 @@ public:


CARLA_ASSERT(plugin->getId() == id); CARLA_ASSERT(plugin->getId() == id);


bool needsReinit = (fOptions.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT);
bool needsReinit = (pData->options.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT);
const char* name = getUniquePluginName(newName); const char* name = getUniquePluginName(newName);


// TODO - use rename port if single-client // TODO - use rename port if single-client


// JACK client rename // JACK client rename
if (fOptions.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
if (pData->options.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
{ {
CarlaEngineJackClient* const client((CarlaEngineJackClient*)plugin->getEngineClient()); CarlaEngineJackClient* const client((CarlaEngineJackClient*)plugin->getEngineClient());


@@ -1039,9 +1039,9 @@ public:
return false; return false;
} }


void patchbayRefresh() override
bool patchbayRefresh() override
{ {
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, false);


fLastGroupId = 0; fLastGroupId = 0;
fLastPortId = 0; fLastPortId = 0;
@@ -1053,6 +1053,8 @@ public:
fGroupIconsChanged.clear(); fGroupIconsChanged.clear();


initJackPatchbay(jackbridge_get_client_name(fClient)); initJackPatchbay(jackbridge_get_client_name(fClient));

return true;
} }
#endif #endif


@@ -1061,7 +1063,7 @@ public:


void transportPlay() override void transportPlay() override
{ {
if (fOptions.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
if (pData->options.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
CarlaEngine::transportPlay(); CarlaEngine::transportPlay();
else if (fClient != nullptr) else if (fClient != nullptr)
jackbridge_transport_start(fClient); jackbridge_transport_start(fClient);
@@ -1069,7 +1071,7 @@ public:


void transportPause() override void transportPause() override
{ {
if (fOptions.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
if (pData->options.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
CarlaEngine::transportPause(); CarlaEngine::transportPause();
else if (fClient != nullptr) else if (fClient != nullptr)
jackbridge_transport_stop(fClient); jackbridge_transport_stop(fClient);
@@ -1077,7 +1079,7 @@ public:


void transportRelocate(const uint32_t frame) override void transportRelocate(const uint32_t frame) override
{ {
if (fOptions.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
if (pData->options.transportMode == ENGINE_TRANSPORT_MODE_INTERNAL)
CarlaEngine::transportRelocate(frame); CarlaEngine::transportRelocate(frame);
else if (fClient != nullptr) else if (fClient != nullptr)
jackbridge_transport_locate(fClient, frame); jackbridge_transport_locate(fClient, frame);
@@ -1088,19 +1090,19 @@ public:
protected: protected:
void handleJackBufferSizeCallback(const uint32_t newBufferSize) void handleJackBufferSizeCallback(const uint32_t newBufferSize)
{ {
if (fBufferSize == newBufferSize)
if (pData->bufferSize == newBufferSize)
return; return;


fBufferSize = newBufferSize;
pData->bufferSize = newBufferSize;
bufferSizeChanged(newBufferSize); bufferSizeChanged(newBufferSize);
} }


void handleJackSampleRateCallback(const double newSampleRate) void handleJackSampleRateCallback(const double newSampleRate)
{ {
if (fSampleRate == newSampleRate)
if (pData->sampleRate == newSampleRate)
return; return;


fSampleRate = newSampleRate;
pData->sampleRate = newSampleRate;
sampleRateChanged(newSampleRate); sampleRateChanged(newSampleRate);
} }


@@ -1115,39 +1117,39 @@ protected:


void saveTransportInfo() void saveTransportInfo()
{ {
if (fOptions.transportMode != ENGINE_TRANSPORT_MODE_JACK)
if (pData->options.transportMode != ENGINE_TRANSPORT_MODE_JACK)
return; return;


fTransportPos.unique_1 = fTransportPos.unique_2 + 1; // invalidate fTransportPos.unique_1 = fTransportPos.unique_2 + 1; // invalidate


fTransportState = jackbridge_transport_query(fClient, &fTransportPos); fTransportState = jackbridge_transport_query(fClient, &fTransportPos);


fTimeInfo.playing = (fTransportState == JackTransportRolling);
pData->timeInfo.playing = (fTransportState == JackTransportRolling);


if (fTransportPos.unique_1 == fTransportPos.unique_2) if (fTransportPos.unique_1 == fTransportPos.unique_2)
{ {
fTimeInfo.frame = fTransportPos.frame;
fTimeInfo.usecs = fTransportPos.usecs;
pData->timeInfo.frame = fTransportPos.frame;
pData->timeInfo.usecs = fTransportPos.usecs;


if (fTransportPos.valid & JackPositionBBT) if (fTransportPos.valid & JackPositionBBT)
{ {
fTimeInfo.valid = EngineTimeInfo::ValidBBT;
fTimeInfo.bbt.bar = fTransportPos.bar;
fTimeInfo.bbt.beat = fTransportPos.beat;
fTimeInfo.bbt.tick = fTransportPos.tick;
fTimeInfo.bbt.barStartTick = fTransportPos.bar_start_tick;
fTimeInfo.bbt.beatsPerBar = fTransportPos.beats_per_bar;
fTimeInfo.bbt.beatType = fTransportPos.beat_type;
fTimeInfo.bbt.ticksPerBeat = fTransportPos.ticks_per_beat;
fTimeInfo.bbt.beatsPerMinute = fTransportPos.beats_per_minute;
pData->timeInfo.valid = EngineTimeInfo::ValidBBT;
pData->timeInfo.bbt.bar = fTransportPos.bar;
pData->timeInfo.bbt.beat = fTransportPos.beat;
pData->timeInfo.bbt.tick = fTransportPos.tick;
pData->timeInfo.bbt.barStartTick = fTransportPos.bar_start_tick;
pData->timeInfo.bbt.beatsPerBar = fTransportPos.beats_per_bar;
pData->timeInfo.bbt.beatType = fTransportPos.beat_type;
pData->timeInfo.bbt.ticksPerBeat = fTransportPos.ticks_per_beat;
pData->timeInfo.bbt.beatsPerMinute = fTransportPos.beats_per_minute;
} }
else else
fTimeInfo.valid = 0x0;
pData->timeInfo.valid = 0x0;
} }
else else
{ {
fTimeInfo.frame = 0;
fTimeInfo.valid = 0x0;
pData->timeInfo.frame = 0;
pData->timeInfo.valid = 0x0;
} }
} }


@@ -1159,7 +1161,7 @@ protected:
{ {
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
// pass-through // pass-through
if (fOptions.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
float* const audioIn1 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioIn1], nframes); float* const audioIn1 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioIn1], nframes);
float* const audioIn2 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioIn2], nframes); float* const audioIn2 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioIn2], nframes);
@@ -1193,7 +1195,7 @@ protected:


return runPendingRtEvents(); return runPendingRtEvents();
#else #else
if (fOptions.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
if (pData->options.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
for (unsigned int i=0; i < pData->curPluginCount; ++i) for (unsigned int i=0; i < pData->curPluginCount; ++i)
{ {
@@ -1210,7 +1212,7 @@ protected:
return runPendingRtEvents(); return runPendingRtEvents();
} }


if (fOptions.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
// get buffers from jack // get buffers from jack
float* const audioIn1 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioIn1], nframes); float* const audioIn1 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioIn1], nframes);
@@ -1411,7 +1413,7 @@ protected:


void handleJackLatencyCallback(const jack_latency_callback_mode_t mode) void handleJackLatencyCallback(const jack_latency_callback_mode_t mode)
{ {
if (fOptions.processMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT)
if (pData->options.processMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT)
return; return;


for (unsigned int i=0; i < pData->curPluginCount; ++i) for (unsigned int i=0; i < pData->curPluginCount; ++i)


+ 23
- 26
source/backend/engine/CarlaEngineRtAudio.cpp View File

@@ -114,9 +114,9 @@ public:
#endif #endif


// just to make sure // just to make sure
fOptions.forceStereo = true;
fOptions.processMode = ENGINE_PROCESS_MODE_CONTINUOUS_RACK;
fOptions.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL;
pData->options.forceStereo = true;
pData->options.processMode = ENGINE_PROCESS_MODE_CONTINUOUS_RACK;
pData->options.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL;
} }


~CarlaEngineRtAudio() override ~CarlaEngineRtAudio() override
@@ -162,13 +162,13 @@ public:
return false; return false;
} }


if (fOptions.audioDevice.isNotEmpty())
if (pData->options.audioDevice != nullptr)
{ {
for (unsigned int i=0; i < devCount; ++i) for (unsigned int i=0; i < devCount; ++i)
{ {
RtAudio::DeviceInfo devInfo(fAudio.getDeviceInfo(i)); RtAudio::DeviceInfo devInfo(fAudio.getDeviceInfo(i));


if (devInfo.probed && devInfo.outputChannels > 0 && devInfo.name == (const char*)fOptions.audioDevice)
if (devInfo.probed && devInfo.outputChannels > 0 && devInfo.name == (const char*)pData->options.audioDevice)
{ {
deviceSet = true; deviceSet = true;
fConnectName = devInfo.name.c_str(); fConnectName = devInfo.name.c_str();
@@ -205,10 +205,10 @@ public:
else else
fAudioIsInterleaved = true; fAudioIsInterleaved = true;


fBufferSize = fOptions.audioBufferSize;
pData->bufferSize = pData->options.audioBufferSize;


try { try {
fAudio.openStream(&oParams, &iParams, RTAUDIO_FLOAT32, fOptions.audioSampleRate, &fBufferSize, carla_rtaudio_process_callback, this, &rtOptions);
fAudio.openStream(&oParams, &iParams, RTAUDIO_FLOAT32, pData->options.audioSampleRate, &pData->bufferSize, carla_rtaudio_process_callback, this, &rtOptions);
} }
catch (RtError& e) catch (RtError& e)
{ {
@@ -228,7 +228,7 @@ public:


fAudioCountIn = iParams.nChannels; fAudioCountIn = iParams.nChannels;
fAudioCountOut = oParams.nChannels; fAudioCountOut = oParams.nChannels;
fSampleRate = fAudio.getStreamSampleRate();
pData->sampleRate = fAudio.getStreamSampleRate();


CARLA_ASSERT(fAudioCountOut > 0); CARLA_ASSERT(fAudioCountOut > 0);


@@ -237,7 +237,7 @@ public:
fAudioBufIn = new float*[fAudioCountIn]; fAudioBufIn = new float*[fAudioCountIn];


for (uint i=0; i < fAudioCountIn; ++i) for (uint i=0; i < fAudioCountIn; ++i)
fAudioBufIn[i] = new float[fBufferSize];
fAudioBufIn[i] = new float[pData->bufferSize];
} }


if (fAudioCountOut > 0) if (fAudioCountOut > 0)
@@ -245,13 +245,13 @@ public:
fAudioBufOut = new float*[fAudioCountOut]; fAudioBufOut = new float*[fAudioCountOut];


for (uint i=0; i < fAudioCountOut; ++i) for (uint i=0; i < fAudioCountOut; ++i)
fAudioBufOut[i] = new float[fBufferSize];
fAudioBufOut[i] = new float[pData->bufferSize];
} }


fAudioBufRackIn[0] = new float[fBufferSize];
fAudioBufRackIn[1] = new float[fBufferSize];
fAudioBufRackOut[0] = new float[fBufferSize];
fAudioBufRackOut[1] = new float[fBufferSize];
fAudioBufRackIn[0] = new float[pData->bufferSize];
fAudioBufRackIn[1] = new float[pData->bufferSize];
fAudioBufRackOut[0] = new float[pData->bufferSize];
fAudioBufRackOut[1] = new float[pData->bufferSize];


fAudioIsReady = true; fAudioIsReady = true;


@@ -639,12 +639,9 @@ public:
return true; return true;
} }


void patchbayRefresh() override
bool patchbayRefresh() override
{ {
CARLA_ASSERT(fAudioIsReady);

if (! fAudioIsReady)
return;
CARLA_SAFE_ASSERT_RETURN(fAudioIsReady, false);


char strBuf[STR_MAX+1]; char strBuf[STR_MAX+1];


@@ -840,7 +837,7 @@ protected:


// assert buffers // assert buffers
CARLA_ASSERT(nframes != 0); CARLA_ASSERT(nframes != 0);
CARLA_ASSERT_INT2(nframes == fBufferSize, nframes, fBufferSize);
CARLA_ASSERT_INT2(nframes == pData->bufferSize, nframes, pData->bufferSize);
CARLA_ASSERT(outsPtr != nullptr); CARLA_ASSERT(outsPtr != nullptr);


if (pData->curPluginCount == 0 || fAudioCountOut == 0 || ! fAudioIsReady) if (pData->curPluginCount == 0 || fAudioCountOut == 0 || ! fAudioIsReady)
@@ -905,17 +902,17 @@ protected:


engineEvent.channel = midiChannel; engineEvent.channel = midiChannel;


if (midiEvent.time < fTimeInfo.frame)
if (midiEvent.time < pData->timeInfo.frame)
{ {
engineEvent.time = 0; engineEvent.time = 0;
} }
else if (midiEvent.time >= fTimeInfo.frame + nframes)
else if (midiEvent.time >= pData->timeInfo.frame + nframes)
{ {
engineEvent.time = fTimeInfo.frame + nframes-1;
carla_stderr("MIDI Event in the future!, %i vs %i", engineEvent.time, fTimeInfo.frame);
engineEvent.time = pData->timeInfo.frame + nframes-1;
carla_stderr("MIDI Event in the future!, %i vs %i", engineEvent.time, pData->timeInfo.frame);
} }
else else
engineEvent.time = midiEvent.time - fTimeInfo.frame;
engineEvent.time = midiEvent.time - pData->timeInfo.frame;


if (MIDI_IS_STATUS_CONTROL_CHANGE(midiStatus)) if (MIDI_IS_STATUS_CONTROL_CHANGE(midiStatus))
{ {
@@ -1143,7 +1140,7 @@ protected:
timeStamp = 0.0; timeStamp = 0.0;


RtMidiEvent midiEvent; RtMidiEvent midiEvent;
midiEvent.time = fTimeInfo.frame + (timeStamp*(double)fBufferSize);
midiEvent.time = pData->timeInfo.frame + (timeStamp*(double)pData->bufferSize);


if (midiEvent.time < lastTime) if (midiEvent.time < lastTime)
midiEvent.time = lastTime; midiEvent.time = lastTime;


+ 34
- 34
source/backend/plugin/BridgePlugin.cpp View File

@@ -258,7 +258,7 @@ public:


pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_BRIDGE); pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_BRIDGE);


fHints |= PLUGIN_IS_BRIDGE;
pData->hints |= PLUGIN_IS_BRIDGE;
} }


~BridgePlugin() override ~BridgePlugin() override
@@ -348,7 +348,7 @@ public:


int32_t getChunkData(void** const dataPtr) const override int32_t getChunkData(void** const dataPtr) const override
{ {
CARLA_ASSERT(fOptions & PLUGIN_OPTION_USE_CHUNKS);
CARLA_ASSERT(pData->options & PLUGIN_OPTION_USE_CHUNKS);
CARLA_ASSERT(dataPtr != nullptr); CARLA_ASSERT(dataPtr != nullptr);


#if 0 #if 0
@@ -637,7 +637,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -661,7 +661,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -684,7 +684,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -700,7 +700,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -842,21 +842,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) > 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) > 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) > 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -914,7 +914,7 @@ public:
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
} }


if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{ {
fShmControl.writeOpcode(kPluginBridgeOpcodeMidiEvent); fShmControl.writeOpcode(kPluginBridgeOpcodeMidiEvent);
fShmControl.writeLong(event.time); fShmControl.writeLong(event.time);
@@ -928,12 +928,12 @@ public:
} }


case kEngineControlEventTypeMidiBank: case kEngineControlEventTypeMidiBank:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankId = ctrlEvent.param; nextBankId = ctrlEvent.param;
break; break;


case kEngineControlEventTypeMidiProgram: case kEngineControlEventTypeMidiProgram:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{ {
const uint32_t nextProgramId(ctrlEvent.param); const uint32_t nextProgramId(ctrlEvent.param);


@@ -956,14 +956,14 @@ public:
break; break;


case kEngineControlEventTypeAllSoundOff: case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
// TODO // TODO
} }
break; break;


case kEngineControlEventTypeAllNotesOff: case kEngineControlEventTypeAllNotesOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
{ {
@@ -986,13 +986,13 @@ public:
uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data);
uint8_t channel = event.channel; uint8_t channel = event.channel;


if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (fOptions & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
continue; continue;
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
continue; continue;
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (fOptions & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
continue; continue;
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (fOptions & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
continue; continue;


// Fix bad note-off // Fix bad note-off
@@ -1106,9 +1106,9 @@ public:
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


{ {
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) != 0 && pData->postProc.volume != 1.0f;
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doVolume = (pData->hints & PLUGIN_CAN_VOLUME) != 0 && pData->postProc.volume != 1.0f;
const bool doDryWet = (pData->hints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


bool isPair; bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1]; float bufValue, oldBufLeft[doBalance ? frames : 1];
@@ -1350,7 +1350,7 @@ public:
CARLA_ASSERT(maker != nullptr); CARLA_ASSERT(maker != nullptr);
CARLA_ASSERT(copyright != nullptr); CARLA_ASSERT(copyright != nullptr);


fHints = hints | PLUGIN_IS_BRIDGE;
pData->hints = hints | PLUGIN_IS_BRIDGE;


fInfo.category = static_cast<PluginCategory>(category); fInfo.category = static_cast<PluginCategory>(category);
fInfo.uniqueId = uniqueId; fInfo.uniqueId = uniqueId;
@@ -1360,8 +1360,8 @@ public:
fInfo.maker = maker; fInfo.maker = maker;
fInfo.copyright = copyright; fInfo.copyright = copyright;


if (fName.isEmpty())
fName = name;
if (pData->name.isEmpty())
pData->name = name;


break; break;
} }
@@ -1507,7 +1507,7 @@ public:
break; break;


if (std::strcmp(key, CARLA_BRIDGE_MSG_HIDE_GUI) == 0) if (std::strcmp(key, CARLA_BRIDGE_MSG_HIDE_GUI) == 0)
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
else if (std::strcmp(key, CARLA_BRIDGE_MSG_SAVED) == 0) else if (std::strcmp(key, CARLA_BRIDGE_MSG_SAVED) == 0)
fSaved = true; fSaved = true;


@@ -1698,9 +1698,9 @@ public:
// set info // set info


if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);


fFilename = filename;
pData->filename = filename;
fBridgeBinary = bridgeBinary; fBridgeBinary = bridgeBinary;


// --------------------------------------------------------------- // ---------------------------------------------------------------
@@ -1786,8 +1786,8 @@ public:
fShmControl.commitWrite(); fShmControl.commitWrite();


// register plugin now so we can receive OSC (and wait for it) // register plugin now so we can receive OSC (and wait for it)
fHints |= PLUGIN_IS_BRIDGE;
pData->engine->registerEnginePlugin(fId, this);
pData->hints |= PLUGIN_IS_BRIDGE;
pData->engine->registerEnginePlugin(pData->id, this);


// init OSC // init OSC
{ {
@@ -1809,7 +1809,7 @@ public:
if (fInitError || ! fInitiated) if (fInitError || ! fInitiated)
{ {
// unregister so it gets handled properly // unregister so it gets handled properly
pData->engine->registerEnginePlugin(fId, nullptr);
pData->engine->registerEnginePlugin(pData->id, nullptr);


pData->osc.thread.stop(6000); pData->osc.thread.stop(6000);


@@ -1822,14 +1822,14 @@ public:
// --------------------------------------------------------------- // ---------------------------------------------------------------
// register client // register client


if (fName.isEmpty())
if (pData->name.isEmpty())
{ {
if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
else if (label != nullptr) else if (label != nullptr)
fName = pData->engine->getUniquePluginName(label);
pData->name = pData->engine->getUniquePluginName(label);
else else
fName = pData->engine->getUniquePluginName("unknown");
pData->name = pData->engine->getUniquePluginName("unknown");
} }


pData->client = pData->engine->addClient(this); pData->client = pData->engine->addClient(this);


+ 131
- 102
source/backend/plugin/CarlaPlugin.cpp View File

@@ -222,13 +222,7 @@ unsigned int CarlaPluginProtectedData::loadSettings(const unsigned int options,
// Constructor and destructor // Constructor and destructor


CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id) CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id)
: fId(id),
fHints(0x0),
fOptions(0x0),
fPatchbayClientId(0),
fEnabled(false),
fIconName("plugin"),
pData(new CarlaPluginProtectedData(engine, this))
: pData(new CarlaPluginProtectedData(engine, this))
{ {
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,); CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);
CARLA_ASSERT(id < engine->getMaxPluginNumber()); CARLA_ASSERT(id < engine->getMaxPluginNumber());
@@ -267,6 +261,41 @@ CarlaPlugin::~CarlaPlugin()
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Information (base) // Information (base)


unsigned int CarlaPlugin::getId() const noexcept
{
return pData->id;
}

unsigned int CarlaPlugin::getHints() const noexcept
{
return pData->hints;
}

unsigned int CarlaPlugin::getOptionsEnabled() const noexcept
{
return pData->options;
}

bool CarlaPlugin::isEnabled() const noexcept
{
return pData->enabled;
}

const char* CarlaPlugin::getName() const noexcept
{
return (const char*)pData->name;
}

const char* CarlaPlugin::getFilename() const noexcept
{
return (const char*)pData->filename;
}

const char* CarlaPlugin::getIconName() const noexcept
{
return (const char*)pData->iconName;
}

uint32_t CarlaPlugin::getLatencyInFrames() const noexcept uint32_t CarlaPlugin::getLatencyInFrames() const noexcept
{ {
return pData->latency; return pData->latency;
@@ -497,9 +526,9 @@ const SaveState& CarlaPlugin::getSaveState()
getLabel(strBuf); getLabel(strBuf);


pData->saveState.type = carla_strdup(getPluginTypeAsString(getType())); pData->saveState.type = carla_strdup(getPluginTypeAsString(getType()));
pData->saveState.name = carla_strdup(fName);
pData->saveState.name = carla_strdup(pData->name);
pData->saveState.label = carla_strdup(strBuf); pData->saveState.label = carla_strdup(strBuf);
pData->saveState.binary = carla_strdup(fFilename);
pData->saveState.binary = carla_strdup(pData->filename);
pData->saveState.uniqueID = getUniqueId(); pData->saveState.uniqueID = getUniqueId();


// --------------------------------------------------------------- // ---------------------------------------------------------------
@@ -520,7 +549,7 @@ const SaveState& CarlaPlugin::getSaveState()
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Chunk // Chunk


if (fOptions & PLUGIN_OPTION_USE_CHUNKS)
if (pData->options & PLUGIN_OPTION_USE_CHUNKS)
{ {
void* data = nullptr; void* data = nullptr;
const int32_t dataSize(getChunkData(&data)); const int32_t dataSize(getChunkData(&data));
@@ -798,7 +827,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState)
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Part 6 - set chunk // Part 6 - set chunk


if (saveState.chunk != nullptr && (fOptions & PLUGIN_OPTION_USE_CHUNKS) != 0)
if (saveState.chunk != nullptr && (pData->options & PLUGIN_OPTION_USE_CHUNKS) != 0)
setChunkData(saveState.chunk); setChunkData(saveState.chunk);


// --------------------------------------------------------------- // ---------------------------------------------------------------
@@ -884,14 +913,14 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename)


void CarlaPlugin::setId(const unsigned int newId) noexcept void CarlaPlugin::setId(const unsigned int newId) noexcept
{ {
fId = newId;
pData->id = newId;
} }


void CarlaPlugin::setName(const char* const newName) void CarlaPlugin::setName(const char* const newName)
{ {
CARLA_ASSERT(newName != nullptr && newName[0] != '\0'); CARLA_ASSERT(newName != nullptr && newName[0] != '\0');


fName = newName;
pData->name = newName;
} }


void CarlaPlugin::setOption(const unsigned int option, const bool yesNo) void CarlaPlugin::setOption(const unsigned int option, const bool yesNo)
@@ -899,19 +928,19 @@ void CarlaPlugin::setOption(const unsigned int option, const bool yesNo)
CARLA_ASSERT(getOptionsAvailable() & option); CARLA_ASSERT(getOptionsAvailable() & option);


if (yesNo) if (yesNo)
fOptions |= option;
pData->options |= option;
else else
fOptions &= ~option;
pData->options &= ~option;


pData->saveSetting(option, yesNo); pData->saveSetting(option, yesNo);
} }


void CarlaPlugin::setEnabled(const bool yesNo) void CarlaPlugin::setEnabled(const bool yesNo)
{ {
if (fEnabled == yesNo)
if (pData->enabled == yesNo)
return; return;


fEnabled = yesNo;
pData->enabled = yesNo;


pData->masterMutex.lock(); pData->masterMutex.lock();
pData->masterMutex.unlock(); pData->masterMutex.unlock();
@@ -944,10 +973,10 @@ void CarlaPlugin::setActive(const bool active, const bool sendOsc, const bool se
const float value(active ? 1.0f : 0.0f); const float value(active ? 1.0f : 0.0f);


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_ACTIVE, value);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_ACTIVE, value);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_ACTIVE, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, PARAMETER_ACTIVE, 0, value, nullptr);
#else #else
return; return;


@@ -970,10 +999,10 @@ void CarlaPlugin::setDryWet(const float value, const bool sendOsc, const bool se
pData->postProc.dryWet = fixedValue; pData->postProc.dryWet = fixedValue;


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_DRYWET, fixedValue);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_DRYWET, fixedValue);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_DRYWET, 0, fixedValue, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, PARAMETER_DRYWET, 0, fixedValue, nullptr);
} }


void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool sendCallback) void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool sendCallback)
@@ -988,10 +1017,10 @@ void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool se
pData->postProc.volume = fixedValue; pData->postProc.volume = fixedValue;


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_VOLUME, fixedValue);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_VOLUME, fixedValue);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_VOLUME, 0, fixedValue, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, PARAMETER_VOLUME, 0, fixedValue, nullptr);
} }


void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bool sendCallback) void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bool sendCallback)
@@ -1006,10 +1035,10 @@ void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bo
pData->postProc.balanceLeft = fixedValue; pData->postProc.balanceLeft = fixedValue;


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, fixedValue);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_BALANCE_LEFT, fixedValue);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_LEFT, 0, fixedValue, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, PARAMETER_BALANCE_LEFT, 0, fixedValue, nullptr);
} }


void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const bool sendCallback) void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const bool sendCallback)
@@ -1024,10 +1053,10 @@ void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const b
pData->postProc.balanceRight = fixedValue; pData->postProc.balanceRight = fixedValue;


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, fixedValue);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_BALANCE_RIGHT, fixedValue);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_RIGHT, 0, fixedValue, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, PARAMETER_BALANCE_RIGHT, 0, fixedValue, nullptr);
} }


void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool sendCallback) void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool sendCallback)
@@ -1042,10 +1071,10 @@ void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool s
pData->postProc.panning = fixedValue; pData->postProc.panning = fixedValue;


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_PANNING, fixedValue);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_PANNING, fixedValue);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_PANNING, 0, fixedValue, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, PARAMETER_PANNING, 0, fixedValue, nullptr);
} }
#endif #endif


@@ -1065,12 +1094,12 @@ void CarlaPlugin::setCtrlChannel(const int8_t channel, const bool sendOsc, const
const float ctrlf(channel); const float ctrlf(channel);


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, ctrlf);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_CTRL_CHANNEL, ctrlf);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_CTRL_CHANNEL, 0, ctrlf, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, PARAMETER_CTRL_CHANNEL, 0, ctrlf, nullptr);


if (fHints & PLUGIN_IS_BRIDGE)
if (pData->hints & PLUGIN_IS_BRIDGE)
osc_send_control(pData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf); osc_send_control(pData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf);
#else #else
return; return;
@@ -1099,11 +1128,11 @@ void CarlaPlugin::setParameterValue(const uint32_t parameterId, const float valu
uiParameterChange(parameterId, value); uiParameterChange(parameterId, value);


if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_value(fId, parameterId, value);
pData->engine->oscSend_control_set_parameter_value(pData->id, parameterId, value);
#endif #endif


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, parameterId, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, parameterId, 0, value, nullptr);


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
return; return;
@@ -1164,12 +1193,12 @@ void CarlaPlugin::setParameterMidiChannel(const uint32_t parameterId, uint8_t ch


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_midi_channel(fId, parameterId, channel);
pData->engine->oscSend_control_set_parameter_midi_channel(pData->id, parameterId, channel);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED, fId, parameterId, channel, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED, pData->id, parameterId, channel, 0.0f, nullptr);


if (fHints & PLUGIN_IS_BRIDGE)
if (pData->hints & PLUGIN_IS_BRIDGE)
{} // TODO {} // TODO
#else #else
return; return;
@@ -1193,12 +1222,12 @@ void CarlaPlugin::setParameterMidiCC(const uint32_t parameterId, int16_t cc, con


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_parameter_midi_cc(fId, parameterId, cc);
pData->engine->oscSend_control_set_parameter_midi_cc(pData->id, parameterId, cc);


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED, fId, parameterId, cc, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED, pData->id, parameterId, cc, 0.0f, nullptr);


if (fHints & PLUGIN_IS_BRIDGE)
if (pData->hints & PLUGIN_IS_BRIDGE)
{} // TODO {} // TODO
#else #else
return; return;
@@ -1305,11 +1334,11 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_program(fId, fixedIndex);
pData->engine->oscSend_control_set_program(pData->id, fixedIndex);
#endif #endif


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PROGRAM_CHANGED, pData->id, fixedIndex, 0, 0.0f, nullptr);


// Change default parameter values // Change default parameter values
if (fixedIndex >= 0) if (fixedIndex >= 0)
@@ -1331,12 +1360,12 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO
if (sendOsc || sendCallback) if (sendOsc || sendCallback)
{ {
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
pData->engine->oscSend_control_set_default_value(fId, i, value);
pData->engine->oscSend_control_set_parameter_value(fId, i, value);
pData->engine->oscSend_control_set_default_value(pData->id, i, value);
pData->engine->oscSend_control_set_parameter_value(pData->id, i, value);
#endif #endif


pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, i, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, pData->id, i, 0, value, nullptr);
} }
} }
} }
@@ -1368,11 +1397,11 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
if (sendOsc) if (sendOsc)
pData->engine->oscSend_control_set_midi_program(fId, fixedIndex);
pData->engine->oscSend_control_set_midi_program(pData->id, fixedIndex);
#endif #endif


if (sendCallback) if (sendCallback)
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, fixedIndex, 0, 0.0f, nullptr);


if (fixedIndex >= 0) if (fixedIndex >= 0)
{ {
@@ -1393,12 +1422,12 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s
if (sendOsc || sendCallback) if (sendOsc || sendCallback)
{ {
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
pData->engine->oscSend_control_set_default_value(fId, i, value);
pData->engine->oscSend_control_set_parameter_value(fId, i, value);
pData->engine->oscSend_control_set_default_value(pData->id, i, value);
pData->engine->oscSend_control_set_parameter_value(pData->id, i, value);
#endif #endif


pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, i, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, pData->id, i, 0, value, nullptr);
} }
} }
} }
@@ -1434,10 +1463,10 @@ void CarlaPlugin::showCustomUI(const bool yesNo)


void CarlaPlugin::idle() void CarlaPlugin::idle()
{ {
if (! fEnabled)
if (! pData->enabled)
return; return;


if (fHints & PLUGIN_NEEDS_SINGLE_THREAD)
if (pData->hints & PLUGIN_NEEDS_SINGLE_THREAD)
{ {
// Process postponed events // Process postponed events
postRtEventsRun(); postRtEventsRun();
@@ -1522,7 +1551,7 @@ void CarlaPlugin::registerToOscClient()
#endif #endif


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
pData->engine->oscSend_control_add_plugin_start(fId, fName);
pData->engine->oscSend_control_add_plugin_start(pData->id, pData->name);
#endif #endif


// Base data // Base data
@@ -1537,9 +1566,9 @@ void CarlaPlugin::registerToOscClient()
getCopyright(bufCopyright); getCopyright(bufCopyright);


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
pData->engine->oscSend_bridge_plugin_info(getCategory(), fHints, bufName, bufLabel, bufMaker, bufCopyright, getUniqueId());
pData->engine->oscSend_bridge_plugin_info(getCategory(), pData->hints, bufName, bufLabel, bufMaker, bufCopyright, getUniqueId());
#else #else
pData->engine->oscSend_control_set_plugin_data(fId, getType(), getCategory(), fHints, bufName, bufLabel, bufMaker, bufCopyright, getUniqueId());
pData->engine->oscSend_control_set_plugin_data(pData->id, getType(), getCategory(), pData->hints, bufName, bufLabel, bufMaker, bufCopyright, getUniqueId());
#endif #endif
} }


@@ -1553,7 +1582,7 @@ void CarlaPlugin::registerToOscClient()
pData->engine->oscSend_bridge_midi_count(getMidiInCount(), getMidiOutCount(), getMidiInCount() + getMidiOutCount()); pData->engine->oscSend_bridge_midi_count(getMidiInCount(), getMidiOutCount(), getMidiInCount() + getMidiOutCount());
pData->engine->oscSend_bridge_parameter_count(cIns, cOuts, cTotals); pData->engine->oscSend_bridge_parameter_count(cIns, cOuts, cTotals);
#else #else
pData->engine->oscSend_control_set_plugin_ports(fId, getAudioInCount(), getAudioOutCount(), getMidiInCount(), getMidiOutCount(), cIns, cOuts);
pData->engine->oscSend_control_set_plugin_ports(pData->id, getAudioInCount(), getAudioOutCount(), getMidiInCount(), getMidiOutCount(), cIns, cOuts);
#endif #endif
} }


@@ -1579,10 +1608,10 @@ void CarlaPlugin::registerToOscClient()
pData->engine->oscSend_bridge_parameter_ranges(i, paramRanges.def, paramRanges.min, paramRanges.max, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); pData->engine->oscSend_bridge_parameter_ranges(i, paramRanges.def, paramRanges.min, paramRanges.max, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge);
pData->engine->oscSend_bridge_set_parameter_value(i, getParameterValue(i)); pData->engine->oscSend_bridge_set_parameter_value(i, getParameterValue(i));
#else #else
pData->engine->oscSend_control_set_parameter_data(fId, i,paramData.hints, bufName, bufUnit, getParameterValue(i));
pData->engine->oscSend_control_set_parameter_ranges(fId, i, paramRanges.min, paramRanges.max, paramRanges.def, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge);
pData->engine->oscSend_control_set_parameter_midi_cc(fId, i, paramData.midiCC);
pData->engine->oscSend_control_set_parameter_midi_channel(fId, i, paramData.midiChannel);
pData->engine->oscSend_control_set_parameter_data(pData->id, i,paramData.hints, bufName, bufUnit, getParameterValue(i));
pData->engine->oscSend_control_set_parameter_ranges(pData->id, i, paramRanges.min, paramRanges.max, paramRanges.def, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge);
pData->engine->oscSend_control_set_parameter_midi_cc(pData->id, i, paramData.midiCC);
pData->engine->oscSend_control_set_parameter_midi_channel(pData->id, i, paramData.midiChannel);
#endif #endif
} }
} }
@@ -1598,12 +1627,12 @@ void CarlaPlugin::registerToOscClient()


pData->engine->oscSend_bridge_set_program(pData->prog.current); pData->engine->oscSend_bridge_set_program(pData->prog.current);
#else #else
pData->engine->oscSend_control_set_program_count(fId, pData->prog.count);
pData->engine->oscSend_control_set_program_count(pData->id, pData->prog.count);


for (uint32_t i=0; i < pData->prog.count; ++i) for (uint32_t i=0; i < pData->prog.count; ++i)
pData->engine->oscSend_control_set_program_name(fId, i, pData->prog.names[i]);
pData->engine->oscSend_control_set_program_name(pData->id, i, pData->prog.names[i]);


pData->engine->oscSend_control_set_program(fId, pData->prog.current);
pData->engine->oscSend_control_set_program(pData->id, pData->prog.current);
#endif #endif
} }


@@ -1622,31 +1651,31 @@ void CarlaPlugin::registerToOscClient()


pData->engine->oscSend_bridge_set_midi_program(pData->midiprog.current); pData->engine->oscSend_bridge_set_midi_program(pData->midiprog.current);
#else #else
pData->engine->oscSend_control_set_midi_program_count(fId, pData->midiprog.count);
pData->engine->oscSend_control_set_midi_program_count(pData->id, pData->midiprog.count);


for (uint32_t i=0; i < pData->midiprog.count; ++i) for (uint32_t i=0; i < pData->midiprog.count; ++i)
{ {
const MidiProgramData& mpData(pData->midiprog.data[i]); const MidiProgramData& mpData(pData->midiprog.data[i]);


pData->engine->oscSend_control_set_midi_program_data(fId, i, mpData.bank, mpData.program, mpData.name);
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, mpData.bank, mpData.program, mpData.name);
} }


pData->engine->oscSend_control_set_midi_program(fId, pData->midiprog.current);
pData->engine->oscSend_control_set_midi_program(pData->id, pData->midiprog.current);
#endif #endif
} }


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
pData->engine->oscSend_control_add_plugin_end(fId);
pData->engine->oscSend_control_add_plugin_end(pData->id);


// Internal Parameters // Internal Parameters
{ {
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_DRYWET, pData->postProc.dryWet);
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_VOLUME, pData->postProc.volume);
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, pData->postProc.balanceLeft);
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, pData->postProc.balanceRight);
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_PANNING, pData->postProc.panning);
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, pData->ctrlChannel);
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_ACTIVE, pData->active ? 1.0f : 0.0f);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_DRYWET, pData->postProc.dryWet);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_VOLUME, pData->postProc.volume);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_BALANCE_LEFT, pData->postProc.balanceLeft);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_BALANCE_RIGHT, pData->postProc.balanceRight);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_PANNING, pData->postProc.panning);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_CTRL_CHANNEL, pData->ctrlChannel);
pData->engine->oscSend_control_set_parameter_value(pData->id, PARAMETER_ACTIVE, pData->active ? 1.0f : 0.0f);
} }
#endif #endif
} }
@@ -1680,7 +1709,7 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url)
} }


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
if (fHints & PLUGIN_IS_BRIDGE)
if (pData->hints & PLUGIN_IS_BRIDGE)
return; return;
#endif #endif


@@ -1775,13 +1804,13 @@ void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note,
if (sendOsc) if (sendOsc)
{ {
if (velo > 0) if (velo > 0)
pData->engine->oscSend_control_note_on(fId, channel, note, velo);
pData->engine->oscSend_control_note_on(pData->id, channel, note, velo);
else else
pData->engine->oscSend_control_note_off(fId, channel, note);
pData->engine->oscSend_control_note_off(pData->id, channel, note);
} }


if (sendCallback) if (sendCallback)
pData->engine->callback((velo > 0) ? ENGINE_CALLBACK_NOTE_ON : ENGINE_CALLBACK_NOTE_OFF, fId, channel, note, velo, nullptr);
pData->engine->callback((velo > 0) ? ENGINE_CALLBACK_NOTE_ON : ENGINE_CALLBACK_NOTE_OFF, pData->id, channel, note, velo, nullptr);
} }
#endif #endif


@@ -1821,7 +1850,7 @@ void CarlaPlugin::postRtEventsRun()


case kPluginPostRtEventDebug: case kPluginPostRtEventDebug:
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
pData->engine->callback(ENGINE_CALLBACK_DEBUG, fId, event.value1, event.value2, event.value3, nullptr);
pData->engine->callback(ENGINE_CALLBACK_DEBUG, pData->id, event.value1, event.value2, event.value3, nullptr);
#endif #endif
break; break;


@@ -1835,10 +1864,10 @@ void CarlaPlugin::postRtEventsRun()
{ {
// Update OSC control client // Update OSC control client
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
pData->engine->oscSend_control_set_parameter_value(fId, event.value1, event.value3);
pData->engine->oscSend_control_set_parameter_value(pData->id, event.value1, event.value3);


// Update Host // Update Host
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, event.value1, 0, event.value3, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, event.value1, 0, event.value3, nullptr);
} }
#endif #endif
break; break;
@@ -1851,10 +1880,10 @@ void CarlaPlugin::postRtEventsRun()
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
// Update OSC control client // Update OSC control client
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
pData->engine->oscSend_control_set_program(fId, event.value1);
pData->engine->oscSend_control_set_program(pData->id, event.value1);


// Update Host // Update Host
pData->engine->callback(ENGINE_CALLBACK_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PROGRAM_CHANGED, pData->id, event.value1, 0, 0.0f, nullptr);


// Update param values // Update param values
{ {
@@ -1866,12 +1895,12 @@ void CarlaPlugin::postRtEventsRun()


if (sendOsc) if (sendOsc)
{ {
pData->engine->oscSend_control_set_parameter_value(fId, j, value);
pData->engine->oscSend_control_set_default_value(fId, j, pData->param.ranges[j].def);
pData->engine->oscSend_control_set_parameter_value(pData->id, j, value);
pData->engine->oscSend_control_set_default_value(pData->id, j, pData->param.ranges[j].def);
} }


pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, pData->param.ranges[j].def, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, j, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, pData->id, j, 0, pData->param.ranges[j].def, nullptr);
} }
} }
#endif #endif
@@ -1885,10 +1914,10 @@ void CarlaPlugin::postRtEventsRun()
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
// Update OSC control client // Update OSC control client
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
pData->engine->oscSend_control_set_midi_program(fId, event.value1);
pData->engine->oscSend_control_set_midi_program(pData->id, event.value1);


// Update Host // Update Host
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, event.value1, 0, 0.0f, nullptr);


// Update param values // Update param values
{ {
@@ -1900,12 +1929,12 @@ void CarlaPlugin::postRtEventsRun()


if (sendOsc) if (sendOsc)
{ {
pData->engine->oscSend_control_set_parameter_value(fId, j, value);
pData->engine->oscSend_control_set_default_value(fId, j, pData->param.ranges[j].def);
pData->engine->oscSend_control_set_parameter_value(pData->id, j, value);
pData->engine->oscSend_control_set_default_value(pData->id, j, pData->param.ranges[j].def);
} }


pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, pData->param.ranges[j].def, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED, pData->id, j, 0, value, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED, pData->id, j, 0, pData->param.ranges[j].def, nullptr);
} }
} }
#endif #endif
@@ -1918,10 +1947,10 @@ void CarlaPlugin::postRtEventsRun()
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
// Update OSC control client // Update OSC control client
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
pData->engine->oscSend_control_note_on(fId, event.value1, event.value2, int(event.value3));
pData->engine->oscSend_control_note_on(pData->id, event.value1, event.value2, int(event.value3));


// Update Host // Update Host
pData->engine->callback(ENGINE_CALLBACK_NOTE_ON, fId, event.value1, event.value2, int(event.value3), nullptr);
pData->engine->callback(ENGINE_CALLBACK_NOTE_ON, pData->id, event.value1, event.value2, int(event.value3), nullptr);
#endif #endif
break; break;


@@ -1932,10 +1961,10 @@ void CarlaPlugin::postRtEventsRun()
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
// Update OSC control client // Update OSC control client
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
pData->engine->oscSend_control_note_off(fId, event.value1, event.value2);
pData->engine->oscSend_control_note_off(pData->id, event.value1, event.value2);


// Update Host // Update Host
pData->engine->callback(ENGINE_CALLBACK_NOTE_OFF, fId, event.value1, event.value2, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_NOTE_OFF, pData->id, event.value1, event.value2, 0.0f, nullptr);
#endif #endif
break; break;
} }
@@ -2043,8 +2072,8 @@ CarlaPlugin::ScopedDisabler::ScopedDisabler(CarlaPlugin* const plugin)


plugin->pData->masterMutex.lock(); plugin->pData->masterMutex.lock();


if (plugin->fEnabled)
plugin->fEnabled = false;
if (plugin->pData->enabled)
plugin->pData->enabled = false;


if (plugin->pData->client->isActive()) if (plugin->pData->client->isActive())
plugin->pData->client->deactivate(); plugin->pData->client->deactivate();
@@ -2064,7 +2093,7 @@ CarlaPlugin::ScopedDisabler::~ScopedDisabler()
if (fPlugin->pData->client == nullptr) if (fPlugin->pData->client == nullptr)
return; return;


fPlugin->fEnabled = true;
fPlugin->pData->enabled = true;
fPlugin->pData->client->activate(); fPlugin->pData->client->activate();
fPlugin->pData->masterMutex.unlock(); fPlugin->pData->masterMutex.unlock();
} }


+ 20
- 3
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -31,7 +31,7 @@


#include <cmath> #include <cmath>


#define CARLA_PROCESS_CONTINUE_CHECK if (! fEnabled) { pData->engine->callback(ENGINE_CALLBACK_DEBUG, fId, 0, 0, 0.0f, "Processing while plugin is disabled!!"); return; }
#define CARLA_PROCESS_CONTINUE_CHECK if (! pData->enabled) { pData->engine->callback(ENGINE_CALLBACK_DEBUG, pData->id, 0, 0, 0.0f, "Processing while plugin is disabled!!"); return; }


#ifdef USE_JUCE #ifdef USE_JUCE
#include "juce_audio_basics.h" #include "juce_audio_basics.h"
@@ -491,21 +491,33 @@ struct CarlaPluginProtectedData {
CarlaEngine* const engine; CarlaEngine* const engine;
CarlaEngineClient* client; CarlaEngineClient* client;


unsigned int id;
unsigned int hints;
unsigned int options;

bool active; bool active;
bool enabled;
bool needsReset; bool needsReset;

void* lib; void* lib;
void* uiLib; void* uiLib;


// misc // misc
int8_t ctrlChannel; int8_t ctrlChannel;
unsigned int extraHints; unsigned int extraHints;
CarlaString idStr;
int patchbayClientId;


// latency // latency
uint32_t latency; uint32_t latency;
float** latencyBuffers; float** latencyBuffers;


// data
// data 1
CarlaString name;
CarlaString filename;
CarlaString iconName;
CarlaString idStr;

// data 2
PluginAudioData audioIn; PluginAudioData audioIn;
PluginAudioData audioOut; PluginAudioData audioOut;
PluginEventData event; PluginEventData event;
@@ -624,12 +636,17 @@ struct CarlaPluginProtectedData {
CarlaPluginProtectedData(CarlaEngine* const eng, CarlaPlugin* const plug) CarlaPluginProtectedData(CarlaEngine* const eng, CarlaPlugin* const plug)
: engine(eng), : engine(eng),
client(nullptr), client(nullptr),
id(0),
hints(0x0),
options(0x0),
active(false), active(false),
enabled(false),
needsReset(false), needsReset(false),
lib(nullptr), lib(nullptr),
uiLib(nullptr), uiLib(nullptr),
ctrlChannel(0), ctrlChannel(0),
extraHints(0x0), extraHints(0x0),
patchbayClientId(0),
latency(0), latency(0),
latencyBuffers(nullptr), latencyBuffers(nullptr),
osc(eng, plug) {} osc(eng, plug) {}


+ 59
- 59
source/backend/plugin/DssiPlugin.cpp View File

@@ -53,7 +53,7 @@ public:
carla_debug("DssiPlugin::~DssiPlugin()"); carla_debug("DssiPlugin::~DssiPlugin()");


// close UI // close UI
if (fHints & PLUGIN_HAS_CUSTOM_UI)
if (pData->hints & PLUGIN_HAS_CUSTOM_UI)
{ {
showCustomUI(false); showCustomUI(false);


@@ -74,7 +74,7 @@ public:


if (fDescriptor != nullptr) if (fDescriptor != nullptr)
{ {
if (fName.isNotEmpty() && fDssiDescriptor != nullptr && fDssiDescriptor->run_synth == nullptr && fDssiDescriptor->run_multiple_synths != nullptr)
if (pData->name.isNotEmpty() && fDssiDescriptor != nullptr && fDssiDescriptor->run_synth == nullptr && fDssiDescriptor->run_multiple_synths != nullptr)
removeUniqueMultiSynth(fDescriptor->Label); removeUniqueMultiSynth(fDescriptor->Label);


if (fDescriptor->cleanup != nullptr) if (fDescriptor->cleanup != nullptr)
@@ -115,7 +115,7 @@ public:
if (pData->audioIn.count == 0 && pData->audioOut.count > 0 && (fDssiDescriptor->run_synth != nullptr || fDssiDescriptor->run_multiple_synths != nullptr)) if (pData->audioIn.count == 0 && pData->audioOut.count > 0 && (fDssiDescriptor->run_synth != nullptr || fDssiDescriptor->run_multiple_synths != nullptr))
return PLUGIN_CATEGORY_SYNTH; return PLUGIN_CATEGORY_SYNTH;


return getPluginCategoryFromName(fName);
return getPluginCategoryFromName(pData->name);
} }


long getUniqueId() const override long getUniqueId() const override
@@ -136,7 +136,7 @@ public:
int32_t getChunkData(void** const dataPtr) const override int32_t getChunkData(void** const dataPtr) const override
{ {
CARLA_SAFE_ASSERT_RETURN(fUsesCustomData, 0); CARLA_SAFE_ASSERT_RETURN(fUsesCustomData, 0);
CARLA_SAFE_ASSERT_RETURN(fOptions & PLUGIN_OPTION_USE_CHUNKS, 0);
CARLA_SAFE_ASSERT_RETURN(pData->options & PLUGIN_OPTION_USE_CHUNKS, 0);
CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor != nullptr, 0); CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor != nullptr, 0);
CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor->get_custom_data != nullptr, 0); CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor->get_custom_data != nullptr, 0);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr, 0); CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr, 0);
@@ -156,8 +156,8 @@ public:


unsigned int getOptionsAvailable() const override unsigned int getOptionsAvailable() const override
{ {
const bool isAmSynth = fFilename.contains("amsynth", true);
const bool isDssiVst = fFilename.contains("dssi-vst", true);
const bool isAmSynth = pData->filename.contains("amsynth", true);
const bool isDssiVst = pData->filename.contains("dssi-vst", true);


unsigned int options = 0x0; unsigned int options = 0x0;


@@ -169,7 +169,7 @@ public:


if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK) if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
if (fOptions & PLUGIN_OPTION_FORCE_STEREO)
if (pData->options & PLUGIN_OPTION_FORCE_STEREO)
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0)) else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0))
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
@@ -311,7 +311,7 @@ public:
void setChunkData(const char* const stringData) override void setChunkData(const char* const stringData) override
{ {
CARLA_SAFE_ASSERT_RETURN(fUsesCustomData,); CARLA_SAFE_ASSERT_RETURN(fUsesCustomData,);
CARLA_SAFE_ASSERT_RETURN(fOptions & PLUGIN_OPTION_USE_CHUNKS,);
CARLA_SAFE_ASSERT_RETURN(pData->options & PLUGIN_OPTION_USE_CHUNKS,);
CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor != nullptr,); CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor->set_custom_data != nullptr,); CARLA_SAFE_ASSERT_RETURN(fDssiDescriptor->set_custom_data != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,); CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
@@ -432,7 +432,7 @@ public:
} }
} }


if ((fOptions & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1))
if ((pData->options & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1))
{ {
if (fHandle2 == nullptr) if (fHandle2 == nullptr)
fHandle2 = fDescriptor->instantiate(fDescriptor, (unsigned long)sampleRate); fHandle2 = fDescriptor->instantiate(fDescriptor, (unsigned long)sampleRate);
@@ -505,7 +505,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -705,7 +705,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -721,7 +721,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -732,27 +732,27 @@ public:
} }


if (forcedStereoIn || forcedStereoOut) if (forcedStereoIn || forcedStereoOut)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;
else else
fOptions &= ~PLUGIN_OPTION_FORCE_STEREO;
pData->options &= ~PLUGIN_OPTION_FORCE_STEREO;


// plugin hints // plugin hints
fHints = 0x0;
pData->hints = 0x0;


if (LADSPA_IS_HARD_RT_CAPABLE(fDescriptor->Properties)) if (LADSPA_IS_HARD_RT_CAPABLE(fDescriptor->Properties))
fHints |= PLUGIN_IS_RTSAFE;
pData->hints |= PLUGIN_IS_RTSAFE;


if (fGuiFilename != nullptr) if (fGuiFilename != nullptr)
fHints |= PLUGIN_HAS_CUSTOM_UI;
pData->hints |= PLUGIN_HAS_CUSTOM_UI;


if (aOuts > 0 && (aIns == aOuts || aIns == 1)) if (aOuts > 0 && (aIns == aOuts || aIns == 1))
fHints |= PLUGIN_CAN_DRYWET;
pData->hints |= PLUGIN_CAN_DRYWET;


if (aOuts > 0) if (aOuts > 0)
fHints |= PLUGIN_CAN_VOLUME;
pData->hints |= PLUGIN_CAN_VOLUME;


if (aOuts >= 2 && aOuts % 2 == 0) if (aOuts >= 2 && aOuts % 2 == 0)
fHints |= PLUGIN_CAN_BALANCE;
pData->hints |= PLUGIN_CAN_BALANCE;


// extra plugin hints // extra plugin hints
pData->extraHints = 0x0; pData->extraHints = 0x0;
@@ -764,7 +764,7 @@ public:
pData->extraHints |= PLUGIN_EXTRA_HINT_CAN_RUN_RACK; pData->extraHints |= PLUGIN_EXTRA_HINT_CAN_RUN_RACK;


// check latency // check latency
if (fHints & PLUGIN_CAN_DRYWET)
if (pData->hints & PLUGIN_CAN_DRYWET)
{ {
for (uint32_t i=0; i < pData->param.count; ++i) for (uint32_t i=0; i < pData->param.count; ++i)
{ {
@@ -860,10 +860,10 @@ public:
// Update OSC Names // Update OSC Names
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
{ {
pData->engine->oscSend_control_set_midi_program_count(fId, count);
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);


for (i=0; i < count; ++i) for (i=0; i < count; ++i)
pData->engine->oscSend_control_set_midi_program_data(fId, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
} }
#endif #endif


@@ -910,7 +910,7 @@ public:
if (programChanged) if (programChanged)
setMidiProgram(pData->midiprog.current, true, true, true); setMidiProgram(pData->midiprog.current, true, true, true);


pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0f, nullptr);
} }
} }


@@ -971,7 +971,7 @@ public:


if (pData->needsReset) if (pData->needsReset)
{ {
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
midiEventCount = MAX_MIDI_CHANNELS*2; midiEventCount = MAX_MIDI_CHANNELS*2;
carla_zeroStruct<snd_seq_event_t>(fMidiEvents, midiEventCount); carla_zeroStruct<snd_seq_event_t>(fMidiEvents, midiEventCount);
@@ -1049,7 +1049,7 @@ public:
// Event Input (System) // Event Input (System)


bool allNotesOffSent = false; bool allNotesOffSent = false;
bool isSampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFERS) == 0;
bool isSampleAccurate = (pData->options & PLUGIN_OPTION_FIXED_BUFFERS) == 0;


uint32_t time, numEvents = pData->event.portIn->getEventCount(); uint32_t time, numEvents = pData->event.portIn->getEventCount();
uint32_t startTime = 0; uint32_t startTime = 0;
@@ -1111,21 +1111,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) != 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) != 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) != 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) != 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) != 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) != 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -1184,7 +1184,7 @@ public:
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
} }


if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{ {
if (midiEventCount >= kPluginMaxMidiEvents) if (midiEventCount >= kPluginMaxMidiEvents)
continue; continue;
@@ -1204,12 +1204,12 @@ public:
} }


case kEngineControlEventTypeMidiBank: case kEngineControlEventTypeMidiBank:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankId = ctrlEvent.param; nextBankId = ctrlEvent.param;
break; break;


case kEngineControlEventTypeMidiProgram: case kEngineControlEventTypeMidiProgram:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{ {
const uint32_t nextProgramId = ctrlEvent.param; const uint32_t nextProgramId = ctrlEvent.param;


@@ -1226,7 +1226,7 @@ public:
break; break;


case kEngineControlEventTypeAllSoundOff: case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (midiEventCount >= kPluginMaxMidiEvents) if (midiEventCount >= kPluginMaxMidiEvents)
continue; continue;
@@ -1243,7 +1243,7 @@ public:
break; break;


case kEngineControlEventTypeAllNotesOff: case kEngineControlEventTypeAllNotesOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
{ {
@@ -1318,7 +1318,7 @@ public:
} }
case MIDI_STATUS_POLYPHONIC_AFTERTOUCH: case MIDI_STATUS_POLYPHONIC_AFTERTOUCH:
{ {
if (fOptions & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
if (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
{ {
const uint8_t note = engineEvent.data[1]; const uint8_t note = engineEvent.data[1];
const uint8_t pressure = engineEvent.data[2]; const uint8_t pressure = engineEvent.data[2];
@@ -1332,7 +1332,7 @@ public:
} }
case MIDI_STATUS_CONTROL_CHANGE: case MIDI_STATUS_CONTROL_CHANGE:
{ {
if (fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
if (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
{ {
const uint8_t control = engineEvent.data[1]; const uint8_t control = engineEvent.data[1];
const uint8_t value = engineEvent.data[2]; const uint8_t value = engineEvent.data[2];
@@ -1346,7 +1346,7 @@ public:
} }
case MIDI_STATUS_CHANNEL_PRESSURE: case MIDI_STATUS_CHANNEL_PRESSURE:
{ {
if (fOptions & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
if (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
{ {
const uint8_t pressure = engineEvent.data[1]; const uint8_t pressure = engineEvent.data[1];


@@ -1358,7 +1358,7 @@ public:
} }
case MIDI_STATUS_PITCH_WHEEL_CONTROL: case MIDI_STATUS_PITCH_WHEEL_CONTROL:
{ {
if (fOptions & PLUGIN_OPTION_SEND_PITCHBEND)
if (pData->options & PLUGIN_OPTION_SEND_PITCHBEND)
{ {
const uint8_t lsb = engineEvent.data[1]; const uint8_t lsb = engineEvent.data[1];
const uint8_t msb = engineEvent.data[2]; const uint8_t msb = engineEvent.data[2];
@@ -1505,8 +1505,8 @@ public:
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


{ {
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doDryWet = (pData->hints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


bool isPair; bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1]; float bufValue, oldBufLeft[doBalance ? frames : 1];
@@ -1859,16 +1859,16 @@ public:
// get info // get info


if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
else if (fDescriptor->Name != nullptr) else if (fDescriptor->Name != nullptr)
fName = pData->engine->getUniquePluginName(fDescriptor->Name);
pData->name = pData->engine->getUniquePluginName(fDescriptor->Name);
else else
fName = pData->engine->getUniquePluginName(fDescriptor->Label);
pData->name = pData->engine->getUniquePluginName(fDescriptor->Label);


fFilename = filename;
pData->filename = filename;


CARLA_ASSERT(fName.isNotEmpty());
CARLA_ASSERT(fFilename.isNotEmpty());
CARLA_ASSERT(pData->name.isNotEmpty());
CARLA_ASSERT(pData->filename.isNotEmpty());


// --------------------------------------------------------------- // ---------------------------------------------------------------
// register client // register client
@@ -1919,29 +1919,29 @@ public:
// load plugin settings // load plugin settings


{ {
const bool isAmSynth = fFilename.contains("amsynth", true);
const bool isDssiVst = fFilename.contains("dssi-vst", true);
const bool isAmSynth = pData->filename.contains("amsynth", true);
const bool isDssiVst = pData->filename.contains("dssi-vst", true);


// set default options // set default options
fOptions = 0x0;
pData->options = 0x0;


fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;


if (isAmSynth || isDssiVst) if (isAmSynth || isDssiVst)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;


if (pData->engine->getOptions().forceStereo) if (pData->engine->getOptions().forceStereo)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;


if (fUsesCustomData) if (fUsesCustomData)
fOptions |= PLUGIN_OPTION_USE_CHUNKS;
pData->options |= PLUGIN_OPTION_USE_CHUNKS;


if (fDssiDescriptor->run_synth != nullptr || fDssiDescriptor->run_multiple_synths != nullptr) if (fDssiDescriptor->run_synth != nullptr || fDssiDescriptor->run_multiple_synths != nullptr)
{ {
fOptions |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
fOptions |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
fOptions |= PLUGIN_OPTION_SEND_PITCHBEND;
fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
pData->options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
pData->options |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;


if (fDssiDescriptor->run_synth == nullptr) if (fDssiDescriptor->run_synth == nullptr)
carla_stderr2("WARNING: Plugin can ONLY use run_multiple_synths!"); carla_stderr2("WARNING: Plugin can ONLY use run_multiple_synths!");
@@ -1952,11 +1952,11 @@ public:
pData->idStr += std::strrchr(filename, OS_SEP)+1; pData->idStr += std::strrchr(filename, OS_SEP)+1;
pData->idStr += "/"; pData->idStr += "/";
pData->idStr += label; pData->idStr += label;
fOptions = pData->loadSettings(fOptions, getOptionsAvailable());
pData->options = pData->loadSettings(pData->options, getOptionsAvailable());


// ignore settings, we need this anyway // ignore settings, we need this anyway
if (isAmSynth || isDssiVst) if (isAmSynth || isDssiVst)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;
} }


return true; return true;


+ 39
- 39
source/backend/plugin/FluidSynthPlugin.cpp View File

@@ -462,7 +462,7 @@ public:
// if (pData->ctrlChannel == static_cast<int32_t>(i)) // if (pData->ctrlChannel == static_cast<int32_t>(i))
// { // {
// pData->midiprog.current = index; // pData->midiprog.current = index;
// pData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, index, 0, 0.0f, nullptr);
// pData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, index, 0, 0.0f, nullptr);
// } // }
// } // }
// //
@@ -544,7 +544,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -578,7 +578,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -593,7 +593,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -612,7 +612,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -630,7 +630,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -853,10 +853,10 @@ public:
// --------------------------------------- // ---------------------------------------


// plugin hints // plugin hints
fHints = 0x0;
fHints |= PLUGIN_IS_SYNTH;
fHints |= PLUGIN_CAN_VOLUME;
fHints |= PLUGIN_CAN_BALANCE;
pData->hints = 0x0;
pData->hints |= PLUGIN_IS_SYNTH;
pData->hints |= PLUGIN_CAN_VOLUME;
pData->hints |= PLUGIN_CAN_BALANCE;


// extra plugin hints // extra plugin hints
pData->extraHints = 0x0; pData->extraHints = 0x0;
@@ -929,10 +929,10 @@ public:
// Update OSC Names // Update OSC Names
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
{ {
pData->engine->oscSend_control_set_midi_program_count(fId, count);
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);


for (i=0; i < count; ++i) for (i=0; i < count; ++i)
pData->engine->oscSend_control_set_midi_program_data(fId, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
} }
#endif #endif


@@ -974,7 +974,7 @@ public:
} }
else else
{ {
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0f, nullptr);
} }
} }


@@ -1007,7 +1007,7 @@ public:


if (pData->needsReset) if (pData->needsReset)
{ {
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
for (int c=0; c < MAX_MIDI_CHANNELS; ++c) for (int c=0; c < MAX_MIDI_CHANNELS; ++c)
{ {
@@ -1112,21 +1112,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) > 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) > 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) > 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -1185,7 +1185,7 @@ public:
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
} }


if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{ {
fluid_synth_cc(fSynth, event.channel, ctrlEvent.param, ctrlEvent.value*127.0f); fluid_synth_cc(fSynth, event.channel, ctrlEvent.param, ctrlEvent.value*127.0f);
} }
@@ -1194,12 +1194,12 @@ public:
} }


case kEngineControlEventTypeMidiBank: case kEngineControlEventTypeMidiBank:
if (event.channel < MAX_MIDI_CHANNELS && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankIds[event.channel] = ctrlEvent.param; nextBankIds[event.channel] = ctrlEvent.param;
break; break;


case kEngineControlEventTypeMidiProgram: case kEngineControlEventTypeMidiProgram:
if (event.channel < MAX_MIDI_CHANNELS && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{ {
const uint32_t bankId(nextBankIds[event.channel]); const uint32_t bankId(nextBankIds[event.channel]);
const uint32_t progId(ctrlEvent.param); const uint32_t progId(ctrlEvent.param);
@@ -1221,7 +1221,7 @@ public:
break; break;


case kEngineControlEventTypeAllSoundOff: case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
#ifdef FLUIDSYNTH_VERSION_NEW_API #ifdef FLUIDSYNTH_VERSION_NEW_API
fluid_synth_all_sounds_off(fSynth, event.channel); fluid_synth_all_sounds_off(fSynth, event.channel);
@@ -1232,7 +1232,7 @@ public:
break; break;


case kEngineControlEventTypeAllNotesOff: case kEngineControlEventTypeAllNotesOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
{ {
@@ -1280,27 +1280,27 @@ public:


pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, note, velo); pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, note, velo);
} }
else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (fOptions & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) != 0)
else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) != 0)
{ {
//const uint8_t note = midiEvent.data[1]; //const uint8_t note = midiEvent.data[1];
//const uint8_t pressure = midiEvent.data[2]; //const uint8_t pressure = midiEvent.data[2];


// TODO, not in fluidsynth API // TODO, not in fluidsynth API
} }
else if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0)
else if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0)
{ {
const uint8_t control = midiEvent.data[1]; const uint8_t control = midiEvent.data[1];
const uint8_t value = midiEvent.data[2]; const uint8_t value = midiEvent.data[2];


fluid_synth_cc(fSynth, channel, control, value); fluid_synth_cc(fSynth, channel, control, value);
} }
else if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (fOptions & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) != 0)
else if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) != 0)
{ {
const uint8_t pressure = midiEvent.data[1]; const uint8_t pressure = midiEvent.data[1];


fluid_synth_channel_pressure(fSynth, channel, pressure);; fluid_synth_channel_pressure(fSynth, channel, pressure);;
} }
else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (fOptions & PLUGIN_OPTION_SEND_PITCHBEND) != 0)
else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) != 0)
{ {
const uint8_t lsb = midiEvent.data[1]; const uint8_t lsb = midiEvent.data[1];
const uint8_t msb = midiEvent.data[2]; const uint8_t msb = midiEvent.data[2];
@@ -1388,8 +1388,8 @@ public:


{ {
// note - balance not possible with kUses16Outs, so we can safely skip fAudioOutBuffers // note - balance not possible with kUses16Outs, so we can safely skip fAudioOutBuffers
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) > 0 && pData->postProc.volume != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) > 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doVolume = (pData->hints & PLUGIN_CAN_VOLUME) > 0 && pData->postProc.volume != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) > 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


float oldBufLeft[doBalance ? frames : 1]; float oldBufLeft[doBalance ? frames : 1];


@@ -1556,16 +1556,16 @@ public:
// --------------------------------------------------------------- // ---------------------------------------------------------------
// get info // get info


fFilename = filename;
fLabel = label;
pData->filename = filename;
fLabel = label;


if (kUses16Outs && ! fLabel.endsWith(" (16 outs)")) if (kUses16Outs && ! fLabel.endsWith(" (16 outs)"))
fLabel += " (16 outs)"; fLabel += " (16 outs)";


if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
else else
fName = pData->engine->getUniquePluginName(label);
pData->name = pData->engine->getUniquePluginName(label);


// --------------------------------------------------------------- // ---------------------------------------------------------------
// register client // register client
@@ -1583,18 +1583,18 @@ public:


{ {
// set default options // set default options
fOptions = 0x0;
pData->options = 0x0;


fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
fOptions |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
fOptions |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
fOptions |= PLUGIN_OPTION_SEND_PITCHBEND;
fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
pData->options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
pData->options |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;


// load settings // load settings
pData->idStr = "SF2/"; pData->idStr = "SF2/";
pData->idStr += label; pData->idStr += label;
fOptions = pData->loadSettings(fOptions, getOptionsAvailable());
pData->options = pData->loadSettings(pData->options, getOptionsAvailable());
} }


return true; return true;


+ 34
- 34
source/backend/plugin/LadspaPlugin.cpp View File

@@ -127,7 +127,7 @@ public:
return PLUGIN_CATEGORY_SYNTH; return PLUGIN_CATEGORY_SYNTH;
} }


return getPluginCategoryFromName(fName);
return getPluginCategoryFromName(pData->name);
} }


long getUniqueId() const override long getUniqueId() const override
@@ -165,7 +165,7 @@ public:


unsigned int getOptionsAvailable() const override unsigned int getOptionsAvailable() const override
{ {
const bool isDssiVst = fFilename.contains("dssi-vst", true);
const bool isDssiVst = pData->filename.contains("dssi-vst", true);


unsigned int options = 0x0; unsigned int options = 0x0;


@@ -175,7 +175,7 @@ public:


if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK) if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
if (fOptions & PLUGIN_OPTION_FORCE_STEREO)
if (pData->options & PLUGIN_OPTION_FORCE_STEREO)
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0)) else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0))
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
@@ -441,7 +441,7 @@ public:
} }
} }


if ((fOptions & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1))
if ((pData->options & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1))
{ {
if (fHandle2 == nullptr) if (fHandle2 == nullptr)
fHandle2 = fDescriptor->instantiate(fDescriptor, (unsigned long)sampleRate); fHandle2 = fDescriptor->instantiate(fDescriptor, (unsigned long)sampleRate);
@@ -509,7 +509,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -704,7 +704,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -720,7 +720,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -731,24 +731,24 @@ public:
} }


if (forcedStereoIn || forcedStereoOut) if (forcedStereoIn || forcedStereoOut)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;
else else
fOptions &= ~PLUGIN_OPTION_FORCE_STEREO;
pData->options &= ~PLUGIN_OPTION_FORCE_STEREO;


// plugin hints // plugin hints
fHints = 0x0;
pData->hints = 0x0;


if (LADSPA_IS_HARD_RT_CAPABLE(fDescriptor->Properties)) if (LADSPA_IS_HARD_RT_CAPABLE(fDescriptor->Properties))
fHints |= PLUGIN_IS_RTSAFE;
pData->hints |= PLUGIN_IS_RTSAFE;


if (aOuts > 0 && (aIns == aOuts || aIns == 1)) if (aOuts > 0 && (aIns == aOuts || aIns == 1))
fHints |= PLUGIN_CAN_DRYWET;
pData->hints |= PLUGIN_CAN_DRYWET;


if (aOuts > 0) if (aOuts > 0)
fHints |= PLUGIN_CAN_VOLUME;
pData->hints |= PLUGIN_CAN_VOLUME;


if (aOuts >= 2 && aOuts % 2 == 0) if (aOuts >= 2 && aOuts % 2 == 0)
fHints |= PLUGIN_CAN_BALANCE;
pData->hints |= PLUGIN_CAN_BALANCE;


// extra plugin hints // extra plugin hints
pData->extraHints = 0x0; pData->extraHints = 0x0;
@@ -757,7 +757,7 @@ public:
pData->extraHints |= PLUGIN_EXTRA_HINT_CAN_RUN_RACK; pData->extraHints |= PLUGIN_EXTRA_HINT_CAN_RUN_RACK;


// check latency // check latency
if (fHints & PLUGIN_CAN_DRYWET)
if (pData->hints & PLUGIN_CAN_DRYWET)
{ {
for (uint32_t i=0; i < pData->param.count; ++i) for (uint32_t i=0; i < pData->param.count; ++i)
{ {
@@ -891,7 +891,7 @@ public:
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
// Event Input (System) // Event Input (System)


bool isSampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFERS) == 0;
bool isSampleAccurate = (pData->options & PLUGIN_OPTION_FIXED_BUFFERS) == 0;


uint32_t time, numEvents = pData->event.portIn->getEventCount(); uint32_t time, numEvents = pData->event.portIn->getEventCount();
uint32_t timeOffset = 0; uint32_t timeOffset = 0;
@@ -936,21 +936,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) > 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) > 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) > 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -1137,8 +1137,8 @@ public:
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


{ {
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doDryWet = (pData->hints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


bool isPair; bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1]; float bufValue, oldBufLeft[doBalance ? frames : 1];
@@ -1422,18 +1422,18 @@ public:
fRdfDescriptor = ladspa_rdf_dup(rdfDescriptor); fRdfDescriptor = ladspa_rdf_dup(rdfDescriptor);


if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
else if (fRdfDescriptor != nullptr && fRdfDescriptor->Title != nullptr) else if (fRdfDescriptor != nullptr && fRdfDescriptor->Title != nullptr)
fName = pData->engine->getUniquePluginName(fRdfDescriptor->Title);
pData->name = pData->engine->getUniquePluginName(fRdfDescriptor->Title);
else if (fDescriptor->Name != nullptr) else if (fDescriptor->Name != nullptr)
fName = pData->engine->getUniquePluginName(fDescriptor->Name);
pData->name = pData->engine->getUniquePluginName(fDescriptor->Name);
else else
fName = pData->engine->getUniquePluginName(fDescriptor->Label);
pData->name = pData->engine->getUniquePluginName(fDescriptor->Label);


fFilename = filename;
pData->filename = filename;


CARLA_ASSERT(fName.isNotEmpty());
CARLA_ASSERT(fFilename.isNotEmpty());
CARLA_ASSERT(pData->name.isNotEmpty());
CARLA_ASSERT(pData->filename.isNotEmpty());


// --------------------------------------------------------------- // ---------------------------------------------------------------
// register client // register client
@@ -1461,16 +1461,16 @@ public:
// load plugin settings // load plugin settings


{ {
const bool isDssiVst = fFilename.contains("dssi-vst", true);
const bool isDssiVst = pData->filename.contains("dssi-vst", true);


// set default options // set default options
fOptions = 0x0;
pData->options = 0x0;


if (isDssiVst) if (isDssiVst)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;


if (pData->engine->getOptions().forceStereo) if (pData->engine->getOptions().forceStereo)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;


// load settings // load settings
pData->idStr = "LADSPA/"; pData->idStr = "LADSPA/";
@@ -1479,11 +1479,11 @@ public:
pData->idStr += CarlaString(getUniqueId()); pData->idStr += CarlaString(getUniqueId());
pData->idStr += "/"; pData->idStr += "/";
pData->idStr += label; pData->idStr += label;
fOptions = pData->loadSettings(fOptions, getOptionsAvailable());
pData->options = pData->loadSettings(pData->options, getOptionsAvailable());


// ignore settings, we need this anyway // ignore settings, we need this anyway
if (isDssiVst) if (isDssiVst)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;
} }


return true; return true;


+ 35
- 35
source/backend/plugin/LinuxSamplerPlugin.cpp View File

@@ -312,7 +312,7 @@ public:


if (pData->engine->isOffline()) if (pData->engine->isOffline())
{ {
fEngineChannel->PrepareLoadInstrument((const char*)fFilename, rIndex);
fEngineChannel->PrepareLoadInstrument((const char*)pData->filename, rIndex);
fEngineChannel->LoadInstrument(); fEngineChannel->LoadInstrument();
} }
else else
@@ -360,7 +360,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -375,7 +375,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -394,7 +394,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -407,10 +407,10 @@ public:
// --------------------------------------- // ---------------------------------------


// plugin hints // plugin hints
fHints = 0x0;
//fHints |= PLUGIN_IS_SYNTH;
fHints |= PLUGIN_CAN_VOLUME;
fHints |= PLUGIN_CAN_BALANCE;
pData->hints = 0x0;
//pData->hints |= PLUGIN_IS_SYNTH;
pData->hints |= PLUGIN_CAN_VOLUME;
pData->hints |= PLUGIN_CAN_BALANCE;


// extra plugin hints // extra plugin hints
pData->extraHints = 0x0; pData->extraHints = 0x0;
@@ -466,10 +466,10 @@ public:
// Update OSC Names // Update OSC Names
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
{ {
pData->engine->oscSend_control_set_midi_program_count(fId, count);
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);


for (i=0; i < count; ++i) for (i=0; i < count; ++i)
pData->engine->oscSend_control_set_midi_program_data(fId, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
} }
#endif #endif


@@ -479,7 +479,7 @@ public:
} }
else else
{ {
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0f, nullptr);
} }
} }


@@ -526,7 +526,7 @@ public:


if (pData->needsReset) if (pData->needsReset)
{ {
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k) for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
{ {
@@ -572,7 +572,7 @@ public:
// Event Input (System) // Event Input (System)


bool allNotesOffSent = false; bool allNotesOffSent = false;
bool sampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFERS) == 0;
bool sampleAccurate = (pData->options & PLUGIN_OPTION_FIXED_BUFFERS) == 0;


uint32_t time, nEvents = pData->event.portIn->getEventCount(); uint32_t time, nEvents = pData->event.portIn->getEventCount();
uint32_t startTime = 0; uint32_t startTime = 0;
@@ -632,21 +632,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) > 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) > 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) > 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -705,7 +705,7 @@ public:
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
} }


if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{ {
fMidiInputPort->DispatchControlChange(ctrlEvent.param, ctrlEvent.value*127.0f, event.channel, sampleAccurate ? startTime : time); fMidiInputPort->DispatchControlChange(ctrlEvent.param, ctrlEvent.value*127.0f, event.channel, sampleAccurate ? startTime : time);
} }
@@ -714,12 +714,12 @@ public:
} }


case kEngineControlEventTypeMidiBank: case kEngineControlEventTypeMidiBank:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankId = ctrlEvent.param; nextBankId = ctrlEvent.param;
break; break;


case kEngineControlEventTypeMidiProgram: case kEngineControlEventTypeMidiProgram:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{ {
const uint32_t nextProgramId = ctrlEvent.param; const uint32_t nextProgramId = ctrlEvent.param;


@@ -736,14 +736,14 @@ public:
break; break;


case kEngineControlEventTypeAllSoundOff: case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, event.channel, sampleAccurate ? startTime : time); fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, event.channel, sampleAccurate ? startTime : time);
} }
break; break;


case kEngineControlEventTypeAllNotesOff: case kEngineControlEventTypeAllNotesOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
{ {
@@ -789,27 +789,27 @@ public:


pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, note, velo); pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, note, velo);
} }
else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (fOptions & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) != 0)
else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) != 0)
{ {
//const uint8_t note = midiEvent.data[1]; //const uint8_t note = midiEvent.data[1];
//const uint8_t pressure = midiEvent.data[2]; //const uint8_t pressure = midiEvent.data[2];


// unsupported // unsupported
} }
else if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0)
else if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0)
{ {
const uint8_t control = midiEvent.data[1]; const uint8_t control = midiEvent.data[1];
const uint8_t value = midiEvent.data[2]; const uint8_t value = midiEvent.data[2];


fMidiInputPort->DispatchControlChange(control, value, channel, fragmentPos); fMidiInputPort->DispatchControlChange(control, value, channel, fragmentPos);
} }
else if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (fOptions & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) != 0)
else if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) != 0)
{ {
//const uint8_t pressure = midiEvent.data[1]; //const uint8_t pressure = midiEvent.data[1];


// unsupported // unsupported
} }
else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (fOptions & PLUGIN_OPTION_SEND_PITCHBEND) != 0)
else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) != 0)
{ {
const uint8_t lsb = midiEvent.data[1]; const uint8_t lsb = midiEvent.data[1];
const uint8_t msb = midiEvent.data[2]; const uint8_t msb = midiEvent.data[2];
@@ -873,8 +873,8 @@ public:
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


{ {
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) > 0 && pData->postProc.volume != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) > 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doVolume = (pData->hints & PLUGIN_CAN_VOLUME) > 0 && pData->postProc.volume != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) > 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


float oldBufLeft[doBalance ? frames : 1]; float oldBufLeft[doBalance ? frames : 1];


@@ -1053,15 +1053,15 @@ public:
fRealName = info.InstrumentName.c_str(); fRealName = info.InstrumentName.c_str();
fLabel = info.Product.c_str(); fLabel = info.Product.c_str();
fMaker = info.Artists.c_str(); fMaker = info.Artists.c_str();
fFilename = filename;
pData->filename = filename;


if (kUses16Outs && ! fLabel.endsWith(" (16 outs)")) if (kUses16Outs && ! fLabel.endsWith(" (16 outs)"))
fLabel += " (16 outs)"; fLabel += " (16 outs)";


if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
else else
fName = pData->engine->getUniquePluginName((const char*)fRealName);
pData->name = pData->engine->getUniquePluginName((const char*)fRealName);


// --------------------------------------------------------------- // ---------------------------------------------------------------
// Register client // Register client
@@ -1094,17 +1094,17 @@ public:


{ {
// set default options // set default options
fOptions = 0x0;
pData->options = 0x0;


fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
fOptions |= PLUGIN_OPTION_SEND_PITCHBEND;
fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;


// load settings // load settings
pData->idStr = kIsGIG ? "GIG" : "SFZ"; pData->idStr = kIsGIG ? "GIG" : "SFZ";
pData->idStr += "/"; pData->idStr += "/";
pData->idStr += label; pData->idStr += label;
fOptions = pData->loadSettings(fOptions, getOptionsAvailable());
pData->options = pData->loadSettings(pData->options, getOptionsAvailable());
} }


return true; return true;


+ 60
- 60
source/backend/plugin/Lv2Plugin.cpp View File

@@ -559,7 +559,7 @@ public:
if (LV2_IS_UTILITY(cat1, cat2)) if (LV2_IS_UTILITY(cat1, cat2))
return PLUGIN_CATEGORY_UTILITY; return PLUGIN_CATEGORY_UTILITY;


return getPluginCategoryFromName(fName);
return getPluginCategoryFromName(pData->name);
} }


long getUniqueId() const override long getUniqueId() const override
@@ -643,7 +643,7 @@ public:


if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK) if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
if (fOptions & PLUGIN_OPTION_FORCE_STEREO)
if (pData->options & PLUGIN_OPTION_FORCE_STEREO)
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0)) else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0))
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
@@ -910,7 +910,7 @@ public:
{ {
CarlaPlugin::setName(newName); CarlaPlugin::setName(newName);


//QString guiTitle(QString("%1 (GUI)").arg((const char*)fName));
//QString guiTitle(QString("%1 (GUI)").arg((const char*)pData->name));


//if (pData->gui != nullptr) //if (pData->gui != nullptr)
//pData->gui->setWindowTitle(guiTitle); //pData->gui->setWindowTitle(guiTitle);
@@ -1136,8 +1136,8 @@ public:
{ {
fUi.handle = nullptr; fUi.handle = nullptr;
fUi.widget = nullptr; fUi.widget = nullptr;
pData->engine->callback(ENGINE_CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI");
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_ERROR, pData->id, 0, 0, 0.0f, "Plugin refused to open its own UI");
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
return; return;
} }


@@ -1198,8 +1198,8 @@ public:
delete pData->gui; delete pData->gui;
pData->gui = nullptr; pData->gui = nullptr;


pData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI");
pData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr);
pData->engine->callback(CALLBACK_ERROR, pData->id, 0, 0, 0.0f, "Plugin refused to open its own UI");
pData->engine->callback(CALLBACK_SHOW_GUI, pData->id, -1, 0, 0.0f, nullptr);
return; return;
} }


@@ -1208,7 +1208,7 @@ public:


updateUi(); updateUi();


pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName));
pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)pData->name));
pData->gui->show(); pData->gui->show();
} }
else else
@@ -1271,7 +1271,7 @@ public:
if (fExt.uiidle != nullptr && fExt.uiidle->idle(fUi.handle) != 0) if (fExt.uiidle != nullptr && fExt.uiidle->idle(fUi.handle) != 0)
{ {
showCustomUI(false); showCustomUI(false);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
} }
} }


@@ -1376,7 +1376,7 @@ public:
fExt.worker = (const LV2_Worker_Interface*)fDescriptor->extension_data(LV2_WORKER__interface); fExt.worker = (const LV2_Worker_Interface*)fDescriptor->extension_data(LV2_WORKER__interface);
} }


if ((fOptions & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1) && fExt.state == nullptr && fExt.worker == nullptr)
if ((pData->options & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1) && fExt.state == nullptr && fExt.worker == nullptr)
{ {
if (fHandle2 == nullptr) if (fHandle2 == nullptr)
fHandle2 = fDescriptor->instantiate(fDescriptor, sampleRate, fRdfDescriptor->Bundle, fFeatures); fHandle2 = fDescriptor->instantiate(fDescriptor, sampleRate, fRdfDescriptor->Bundle, fFeatures);
@@ -1516,7 +1516,7 @@ public:
{ {
if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -2072,7 +2072,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -2088,7 +2088,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -2105,35 +2105,35 @@ public:
fEventsOut.ctrl->port = pData->event.portOut; fEventsOut.ctrl->port = pData->event.portOut;


if (forcedStereoIn || forcedStereoOut) if (forcedStereoIn || forcedStereoOut)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;
else else
fOptions &= ~PLUGIN_OPTION_FORCE_STEREO;
pData->options &= ~PLUGIN_OPTION_FORCE_STEREO;


// plugin hints // plugin hints
fHints = 0x0;
pData->hints = 0x0;


if (isRealtimeSafe()) if (isRealtimeSafe())
fHints |= PLUGIN_IS_RTSAFE;
pData->hints |= PLUGIN_IS_RTSAFE;


if (fUi.type != PLUGIN_UI_NULL) if (fUi.type != PLUGIN_UI_NULL)
{ {
fHints |= PLUGIN_HAS_CUSTOM_UI;
pData->hints |= PLUGIN_HAS_CUSTOM_UI;


if (fUi.type == PLUGIN_UI_QT || fUi.type == PLUGIN_UI_PARENT) if (fUi.type == PLUGIN_UI_QT || fUi.type == PLUGIN_UI_PARENT)
fHints |= PLUGIN_NEEDS_SINGLE_THREAD;
pData->hints |= PLUGIN_NEEDS_SINGLE_THREAD;
} }


//if (LV2_IS_GENERATOR(fRdfDescriptor->Type[0], fRdfDescriptor->Type[1])) //if (LV2_IS_GENERATOR(fRdfDescriptor->Type[0], fRdfDescriptor->Type[1]))
// fHints |= PLUGIN_IS_SYNTH;
// pData->hints |= PLUGIN_IS_SYNTH;


if (aOuts > 0 && (aIns == aOuts || aIns == 1)) if (aOuts > 0 && (aIns == aOuts || aIns == 1))
fHints |= PLUGIN_CAN_DRYWET;
pData->hints |= PLUGIN_CAN_DRYWET;


if (aOuts > 0) if (aOuts > 0)
fHints |= PLUGIN_CAN_VOLUME;
pData->hints |= PLUGIN_CAN_VOLUME;


if (aOuts >= 2 && aOuts % 2 == 0) if (aOuts >= 2 && aOuts % 2 == 0)
fHints |= PLUGIN_CAN_BALANCE;
pData->hints |= PLUGIN_CAN_BALANCE;


// extra plugin hints // extra plugin hints
pData->extraHints &= ~PLUGIN_EXTRA_HINT_CAN_RUN_RACK; pData->extraHints &= ~PLUGIN_EXTRA_HINT_CAN_RUN_RACK;
@@ -2215,10 +2215,10 @@ public:
// Update OSC Names // Update OSC Names
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
{ {
pData->engine->oscSend_control_set_midi_program_count(fId, count);
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);


for (i=0; i < count; ++i) for (i=0; i < count; ++i)
pData->engine->oscSend_control_set_midi_program_data(fId, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
} }
#endif #endif


@@ -2280,7 +2280,7 @@ public:
if (programChanged) if (programChanged)
setMidiProgram(pData->midiprog.current, true, true, true); setMidiProgram(pData->midiprog.current, true, true, true);


pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0f, nullptr);
} }
} }


@@ -2396,7 +2396,7 @@ public:
{ {
k = fEventsIn.ctrlIndex; k = fEventsIn.ctrlIndex;


if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
for (i=0; i < MAX_MIDI_CHANNELS; ++i) for (i=0; i < MAX_MIDI_CHANNELS; ++i)
{ {
@@ -2670,7 +2670,7 @@ public:
// Event Input (System) // Event Input (System)


bool allNotesOffSent = false; bool allNotesOffSent = false;
bool sampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFERS) == 0;
bool sampleAccurate = (pData->options & PLUGIN_OPTION_FIXED_BUFFERS) == 0;


uint32_t time, nEvents = (fEventsIn.ctrl->port != nullptr) ? fEventsIn.ctrl->port->getEventCount() : 0; uint32_t time, nEvents = (fEventsIn.ctrl->port != nullptr) ? fEventsIn.ctrl->port->getEventCount() : 0;
uint32_t startTime = 0; uint32_t startTime = 0;
@@ -2750,21 +2750,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) > 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) > 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) > 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -2823,7 +2823,7 @@ public:
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
} }


if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{ {
uint8_t midiData[3]; uint8_t midiData[3];
midiData[0] = MIDI_STATUS_CONTROL_CHANGE + i; midiData[0] = MIDI_STATUS_CONTROL_CHANGE + i;
@@ -2844,12 +2844,12 @@ public:
} }


case kEngineControlEventTypeMidiBank: case kEngineControlEventTypeMidiBank:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankId = ctrlEvent.param; nextBankId = ctrlEvent.param;
break; break;


case kEngineControlEventTypeMidiProgram: case kEngineControlEventTypeMidiProgram:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{ {
const uint32_t nextProgramId = ctrlEvent.param; const uint32_t nextProgramId = ctrlEvent.param;


@@ -2866,7 +2866,7 @@ public:
break; break;


case kEngineControlEventTypeAllSoundOff: case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
const uint32_t mtime(sampleAccurate ? startTime : time); const uint32_t mtime(sampleAccurate ? startTime : time);


@@ -2887,7 +2887,7 @@ public:
break; break;


case kEngineControlEventTypeAllNotesOff: case kEngineControlEventTypeAllNotesOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
{ {
@@ -2925,13 +2925,13 @@ public:
uint8_t channel = event.channel; uint8_t channel = event.channel;
uint32_t mtime = sampleAccurate ? startTime : time; uint32_t mtime = sampleAccurate ? startTime : time;


if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (fOptions & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
continue; continue;
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
continue; continue;
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (fOptions & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
continue; continue;
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (fOptions & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
continue; continue;


// Fix bad note-off // Fix bad note-off
@@ -3204,8 +3204,8 @@ public:
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


{ {
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doDryWet = (pData->hints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


bool isPair; bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1]; float bufValue, oldBufLeft[doBalance ? frames : 1];
@@ -3632,7 +3632,7 @@ protected:
// void guiClosedCallback() override // void guiClosedCallback() override
// { // {
// showGui(false); // showGui(false);
// pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr);
// pData->engine->callback(CALLBACK_SHOW_GUI, pData->id, 0, 0, 0.0f, nullptr);
// } // }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -3701,9 +3701,9 @@ protected:
pData->midiprog.data[index].name = carla_strdup(progDesc->name ? progDesc->name : ""); pData->midiprog.data[index].name = carla_strdup(progDesc->name ? progDesc->name : "");


if (index == pData->midiprog.current) if (index == pData->midiprog.current)
pData->engine->callback(ENGINE_CALLBACK_UPDATE, fId, 0, 0, 0.0, nullptr);
pData->engine->callback(ENGINE_CALLBACK_UPDATE, pData->id, 0, 0, 0.0, nullptr);
else else
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0, nullptr);
} }
} }
} }
@@ -3899,7 +3899,7 @@ protected:


fUi.handle = nullptr; fUi.handle = nullptr;
fUi.widget = nullptr; fUi.widget = nullptr;
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
} }


uint32_t handleUiPortMap(const char* const symbol) uint32_t handleUiPortMap(const char* const symbol)
@@ -4413,9 +4413,9 @@ public:
// get info // get info


if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
else else
fName = pData->engine->getUniquePluginName(fRdfDescriptor->Name);
pData->name = pData->engine->getUniquePluginName(fRdfDescriptor->Name);


// --------------------------------------------------------------- // ---------------------------------------------------------------
// register client // register client
@@ -4444,32 +4444,32 @@ public:


{ {
// set default options // set default options
fOptions = 0x0;
pData->options = 0x0;


fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;


if (getMidiInCount() > 0 || needsFixedBuffer()) if (getMidiInCount() > 0 || needsFixedBuffer())
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;


if (pData->engine->getOptions().forceStereo) if (pData->engine->getOptions().forceStereo)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;


if (getMidiInCount() > 0) if (getMidiInCount() > 0)
{ {
fOptions |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
fOptions |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
fOptions |= PLUGIN_OPTION_SEND_PITCHBEND;
fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
pData->options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
pData->options |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
} }


// load settings // load settings
pData->idStr = "LV2/"; pData->idStr = "LV2/";
pData->idStr += uri; pData->idStr += uri;
fOptions = pData->loadSettings(fOptions, getOptionsAvailable());
pData->options = pData->loadSettings(pData->options, getOptionsAvailable());


// ignore settings, we need this anyway // ignore settings, we need this anyway
if (getMidiInCount() > 0 || needsFixedBuffer()) if (getMidiInCount() > 0 || needsFixedBuffer())
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;
} }


// --------------------------------------------------------------- // ---------------------------------------------------------------
@@ -4488,7 +4488,7 @@ public:
//#ifdef BUILD_BRIDGE //#ifdef BUILD_BRIDGE
// const bool preferUiBridges(pData->engine->getOptions().preferUiBridges); // const bool preferUiBridges(pData->engine->getOptions().preferUiBridges);
//#else //#else
// const bool preferUiBridges(pData->engine->getOptions().preferUiBridges && (fHints & PLUGIN_IS_BRIDGE) == 0);
// const bool preferUiBridges(pData->engine->getOptions().preferUiBridges && (pData->hints & PLUGIN_IS_BRIDGE) == 0);
//#endif //#endif


for (uint32_t i=0; i < fRdfDescriptor->UICount; ++i) for (uint32_t i=0; i < fRdfDescriptor->UICount; ++i)
@@ -4752,7 +4752,7 @@ public:
// ------------------------------------------------------- // -------------------------------------------------------
// initialize ui features (part 1) // initialize ui features (part 1)


//QString guiTitle(QString("%1 (GUI)").arg((const char*)fName));
//QString guiTitle(QString("%1 (GUI)").arg((const char*)pData->name));


LV2_Extension_Data_Feature* const uiDataFt = new LV2_Extension_Data_Feature; LV2_Extension_Data_Feature* const uiDataFt = new LV2_Extension_Data_Feature;
uiDataFt->data_access = fDescriptor->extension_data; uiDataFt->data_access = fDescriptor->extension_data;


+ 69
- 69
source/backend/plugin/NativePlugin.cpp View File

@@ -145,7 +145,7 @@ public:
carla_debug("NativePlugin::~NativePlugin()"); carla_debug("NativePlugin::~NativePlugin()");


// close UI // close UI
if (fHints & PLUGIN_HAS_UI)
if (pData->hints & PLUGIN_HAS_UI)
{ {
if (fIsUiVisible && fDescriptor != nullptr && fDescriptor->ui_show != nullptr && fHandle != nullptr) if (fIsUiVisible && fDescriptor != nullptr && fDescriptor->ui_show != nullptr && fHandle != nullptr)
fDescriptor->ui_show(fHandle, false); fDescriptor->ui_show(fHandle, false);
@@ -261,7 +261,7 @@ public:


if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK) if (pData->engine->getProccessMode() != ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
{ {
if (fOptions & PLUGIN_OPTION_FORCE_STEREO)
if (pData->options & PLUGIN_OPTION_FORCE_STEREO)
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0)) else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0))
options |= PLUGIN_OPTION_FORCE_STEREO; options |= PLUGIN_OPTION_FORCE_STEREO;
@@ -571,7 +571,7 @@ public:
if (pData->ctrlChannel == static_cast<int32_t>(i)) if (pData->ctrlChannel == static_cast<int32_t>(i))
{ {
pData->midiprog.current = index; pData->midiprog.current = index;
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, fId, index, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, index, 0, 0.0f, nullptr);
} }
} }


@@ -603,7 +603,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,); CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_SAFE_ASSERT_RETURN(index >= -1 && index < static_cast<int32_t>(pData->midiprog.count),); CARLA_SAFE_ASSERT_RETURN(index >= -1 && index < static_cast<int32_t>(pData->midiprog.count),);


if ((fHints & PLUGIN_IS_SYNTH) != 0 && (pData->ctrlChannel < 0 || pData->ctrlChannel >= MAX_MIDI_CHANNELS))
if ((pData->hints & PLUGIN_IS_SYNTH) != 0 && (pData->ctrlChannel < 0 || pData->ctrlChannel >= MAX_MIDI_CHANNELS))
return; return;


if (index >= 0) if (index >= 0)
@@ -717,7 +717,7 @@ public:
mOuts = fDescriptor->midiOuts; mOuts = fDescriptor->midiOuts;
params = (fDescriptor->get_parameter_count != nullptr && fDescriptor->get_parameter_info != nullptr) ? fDescriptor->get_parameter_count(fHandle) : 0; params = (fDescriptor->get_parameter_count != nullptr && fDescriptor->get_parameter_info != nullptr) ? fDescriptor->get_parameter_count(fHandle) : 0;


if ((fOptions & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1) && mIns <= 1 && mOuts <= 1)
if ((pData->options & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1) && mIns <= 1 && mOuts <= 1)
{ {
if (fHandle2 == nullptr) if (fHandle2 == nullptr)
fHandle2 = fDescriptor->instantiate(&fHost); fHandle2 = fDescriptor->instantiate(&fHost);
@@ -784,7 +784,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -817,7 +817,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -852,7 +852,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -874,7 +874,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -996,7 +996,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -1012,7 +1012,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -1023,33 +1023,33 @@ public:
} }


if (forcedStereoIn || forcedStereoOut) if (forcedStereoIn || forcedStereoOut)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;
else else
fOptions &= ~PLUGIN_OPTION_FORCE_STEREO;
pData->options &= ~PLUGIN_OPTION_FORCE_STEREO;


// plugin hints // plugin hints
fHints = 0x0;
pData->hints = 0x0;


if (aOuts > 0 && (aIns == aOuts || aIns == 1)) if (aOuts > 0 && (aIns == aOuts || aIns == 1))
fHints |= PLUGIN_CAN_DRYWET;
pData->hints |= PLUGIN_CAN_DRYWET;


if (aOuts > 0) if (aOuts > 0)
fHints |= PLUGIN_CAN_VOLUME;
pData->hints |= PLUGIN_CAN_VOLUME;


if (aOuts >= 2 && aOuts % 2 == 0) if (aOuts >= 2 && aOuts % 2 == 0)
fHints |= PLUGIN_CAN_BALANCE;
pData->hints |= PLUGIN_CAN_BALANCE;


// native plugin hints // native plugin hints
if (fDescriptor->hints & ::PLUGIN_IS_RTSAFE) if (fDescriptor->hints & ::PLUGIN_IS_RTSAFE)
fHints |= PLUGIN_IS_RTSAFE;
pData->hints |= PLUGIN_IS_RTSAFE;
if (fDescriptor->hints & ::PLUGIN_IS_SYNTH) if (fDescriptor->hints & ::PLUGIN_IS_SYNTH)
fHints |= PLUGIN_IS_SYNTH;
pData->hints |= PLUGIN_IS_SYNTH;
if (fDescriptor->hints & ::PLUGIN_HAS_UI) if (fDescriptor->hints & ::PLUGIN_HAS_UI)
fHints |= PLUGIN_HAS_CUSTOM_UI;
pData->hints |= PLUGIN_HAS_CUSTOM_UI;
if (fDescriptor->hints & ::PLUGIN_NEEDS_SINGLE_THREAD) if (fDescriptor->hints & ::PLUGIN_NEEDS_SINGLE_THREAD)
fHints |= PLUGIN_NEEDS_SINGLE_THREAD;
pData->hints |= PLUGIN_NEEDS_SINGLE_THREAD;
if (fDescriptor->hints & ::PLUGIN_NEEDS_FIXED_BUFFERS) if (fDescriptor->hints & ::PLUGIN_NEEDS_FIXED_BUFFERS)
fHints |= PLUGIN_NEEDS_FIXED_BUFFERS;
pData->hints |= PLUGIN_NEEDS_FIXED_BUFFERS;


// extra plugin hints // extra plugin hints
pData->extraHints = 0x0; pData->extraHints = 0x0;
@@ -1101,10 +1101,10 @@ public:
// Update OSC Names // Update OSC Names
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
{ {
pData->engine->oscSend_control_set_midi_program_count(fId, count);
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);


for (i=0; i < count; ++i) for (i=0; i < count; ++i)
pData->engine->oscSend_control_set_midi_program_data(fId, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
} }
#endif #endif


@@ -1151,7 +1151,7 @@ public:
if (programChanged) if (programChanged)
setMidiProgram(pData->midiprog.current, true, true, true); setMidiProgram(pData->midiprog.current, true, true, true);


pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0f, nullptr);
} }
} }


@@ -1215,7 +1215,7 @@ public:


if (pData->needsReset) if (pData->needsReset)
{ {
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k) for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
{ {
@@ -1312,7 +1312,7 @@ public:
// Event Input (System) // Event Input (System)


bool allNotesOffSent = false; bool allNotesOffSent = false;
bool sampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFERS) == 0;
bool sampleAccurate = (pData->options & PLUGIN_OPTION_FIXED_BUFFERS) == 0;


uint32_t time, nEvents = pData->event.portIn->getEventCount(); uint32_t time, nEvents = pData->event.portIn->getEventCount();
uint32_t startTime = 0; uint32_t startTime = 0;
@@ -1378,21 +1378,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) > 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) > 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) > 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -1451,7 +1451,7 @@ public:
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
} }


if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{ {
if (fMidiEventCount >= kPluginMaxMidiEvents*2) if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue; continue;
@@ -1470,12 +1470,12 @@ public:
} }


case kEngineControlEventTypeMidiBank: case kEngineControlEventTypeMidiBank:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankId = ctrlEvent.param; nextBankId = ctrlEvent.param;
break; break;


case kEngineControlEventTypeMidiProgram: case kEngineControlEventTypeMidiProgram:
if (event.channel < MAX_MIDI_CHANNELS && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{ {
const uint32_t nextProgramId(ctrlEvent.param); const uint32_t nextProgramId(ctrlEvent.param);


@@ -1500,7 +1500,7 @@ public:
break; break;


case kEngineControlEventTypeAllSoundOff: case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (fMidiEventCount >= kPluginMaxMidiEvents*2) if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue; continue;
@@ -1517,7 +1517,7 @@ public:
break; break;


case kEngineControlEventTypeAllNotesOff: case kEngineControlEventTypeAllNotesOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
{ {
@@ -1553,13 +1553,13 @@ public:
uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data);
uint8_t channel = event.channel; uint8_t channel = event.channel;


if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (fOptions & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
continue; continue;
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
continue; continue;
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (fOptions & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
continue; continue;
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (fOptions & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
continue; continue;


// Fix bad note-off // Fix bad note-off
@@ -1734,8 +1734,8 @@ public:
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


{ {
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doDryWet = (pData->hints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


bool isPair; bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1]; float bufValue, oldBufLeft[doBalance ? frames : 1];
@@ -2019,13 +2019,13 @@ protected:


bool handleWriteMidiEvent(const NativeMidiEvent* const event) bool handleWriteMidiEvent(const NativeMidiEvent* const event)
{ {
CARLA_ASSERT(fEnabled);
CARLA_ASSERT(pData->enabled);
CARLA_ASSERT(fIsProcessing); CARLA_ASSERT(fIsProcessing);
CARLA_ASSERT(fMidiOut.count > 0 || pData->event.portOut != nullptr); CARLA_ASSERT(fMidiOut.count > 0 || pData->event.portOut != nullptr);
CARLA_ASSERT(event != nullptr); CARLA_ASSERT(event != nullptr);
CARLA_ASSERT(event->data[0] != 0); CARLA_ASSERT(event->data[0] != 0);


if (! fEnabled)
if (! pData->enabled)
return false; return false;
if (fMidiOut.count == 0) if (fMidiOut.count == 0)
return false; return false;
@@ -2064,7 +2064,7 @@ protected:


void handleUiClosed() void handleUiClosed()
{ {
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, 0, 0, 0.0f, nullptr);
fIsUiVisible = false; fIsUiVisible = false;
} }


@@ -2142,7 +2142,7 @@ protected:
case ::HOST_OPCODE_RELOAD_ALL: case ::HOST_OPCODE_RELOAD_ALL:
break; break;
case HOST_OPCODE_UI_UNAVAILABLE: case HOST_OPCODE_UI_UNAVAILABLE:
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, fId, -1, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, nullptr);
break; break;
} }


@@ -2226,40 +2226,40 @@ public:
// set icon // set icon


if (std::strcmp(fDescriptor->label, "audiofile") == 0) if (std::strcmp(fDescriptor->label, "audiofile") == 0)
fIconName = "file";
pData->iconName = "file";
else if (std::strcmp(fDescriptor->label, "midifile") == 0) else if (std::strcmp(fDescriptor->label, "midifile") == 0)
fIconName = "file";
pData->iconName = "file";
else if (std::strcmp(fDescriptor->label, "sunvoxfile") == 0) else if (std::strcmp(fDescriptor->label, "sunvoxfile") == 0)
fIconName = "file";
pData->iconName = "file";


else if (std::strcmp(fDescriptor->label, "3BandEQ") == 0) else if (std::strcmp(fDescriptor->label, "3BandEQ") == 0)
fIconName = "distrho";
pData->iconName = "distrho";
else if (std::strcmp(fDescriptor->label, "3BandSplitter") == 0) else if (std::strcmp(fDescriptor->label, "3BandSplitter") == 0)
fIconName = "distrho";
pData->iconName = "distrho";
else if (std::strcmp(fDescriptor->label, "Nekobi") == 0) else if (std::strcmp(fDescriptor->label, "Nekobi") == 0)
fIconName = "distrho";
pData->iconName = "distrho";
else if (std::strcmp(fDescriptor->label, "Notes") == 0) else if (std::strcmp(fDescriptor->label, "Notes") == 0)
fIconName = "distrho";
pData->iconName = "distrho";
else if (std::strcmp(fDescriptor->label, "PingPongPan") == 0) else if (std::strcmp(fDescriptor->label, "PingPongPan") == 0)
fIconName = "distrho";
pData->iconName = "distrho";
else if (std::strcmp(fDescriptor->label, "StereoEnhancer") == 0) else if (std::strcmp(fDescriptor->label, "StereoEnhancer") == 0)
fIconName = "distrho";
pData->iconName = "distrho";


// --------------------------------------------------------------- // ---------------------------------------------------------------
// get info // get info


if (name != nullptr) if (name != nullptr)
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
else if (fDescriptor->name != nullptr) else if (fDescriptor->name != nullptr)
fName = pData->engine->getUniquePluginName(fDescriptor->name);
pData->name = pData->engine->getUniquePluginName(fDescriptor->name);
else else
fName = pData->engine->getUniquePluginName(label);
pData->name = pData->engine->getUniquePluginName(label);


{ {
CARLA_ASSERT(fHost.uiName == nullptr); CARLA_ASSERT(fHost.uiName == nullptr);


char uiName[fName.length()+6+1];
std::strcpy(uiName, (const char*)fName);
char uiName[pData->name.length()+6+1];
std::strcpy(uiName, (const char*)pData->name);
std::strcat(uiName, " (GUI)"); std::strcat(uiName, " (GUI)");


fHost.uiName = carla_strdup(uiName); fHost.uiName = carla_strdup(uiName);
@@ -2294,34 +2294,34 @@ public:
const bool hasMidiProgs(fDescriptor->get_midi_program_count != nullptr && fDescriptor->get_midi_program_count(fHandle) > 0); const bool hasMidiProgs(fDescriptor->get_midi_program_count != nullptr && fDescriptor->get_midi_program_count(fHandle) > 0);


// set default options // set default options
fOptions = 0x0;
pData->options = 0x0;


if (hasMidiProgs && (fDescriptor->supports & ::PLUGIN_SUPPORTS_PROGRAM_CHANGES) == 0) if (hasMidiProgs && (fDescriptor->supports & ::PLUGIN_SUPPORTS_PROGRAM_CHANGES) == 0)
fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;


if (getMidiInCount() > 0 || (fDescriptor->hints & ::PLUGIN_NEEDS_FIXED_BUFFERS) != 0) if (getMidiInCount() > 0 || (fDescriptor->hints & ::PLUGIN_NEEDS_FIXED_BUFFERS) != 0)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;


if (pData->engine->getOptions().forceStereo) if (pData->engine->getOptions().forceStereo)
fOptions |= PLUGIN_OPTION_FORCE_STEREO;
pData->options |= PLUGIN_OPTION_FORCE_STEREO;


if (fDescriptor->supports & ::PLUGIN_SUPPORTS_CHANNEL_PRESSURE) if (fDescriptor->supports & ::PLUGIN_SUPPORTS_CHANNEL_PRESSURE)
fOptions |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
pData->options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
if (fDescriptor->supports & ::PLUGIN_SUPPORTS_NOTE_AFTERTOUCH) if (fDescriptor->supports & ::PLUGIN_SUPPORTS_NOTE_AFTERTOUCH)
fOptions |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
pData->options |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
if (fDescriptor->supports & ::PLUGIN_SUPPORTS_PITCHBEND) if (fDescriptor->supports & ::PLUGIN_SUPPORTS_PITCHBEND)
fOptions |= PLUGIN_OPTION_SEND_PITCHBEND;
pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
if (fDescriptor->supports & ::PLUGIN_SUPPORTS_ALL_SOUND_OFF) if (fDescriptor->supports & ::PLUGIN_SUPPORTS_ALL_SOUND_OFF)
fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;


// load settings // load settings
pData->idStr = "Native/"; pData->idStr = "Native/";
pData->idStr += label; pData->idStr += label;
fOptions = pData->loadSettings(fOptions, getOptionsAvailable());
pData->options = pData->loadSettings(pData->options, getOptionsAvailable());


// ignore settings, we need this anyway // ignore settings, we need this anyway
if (getMidiInCount() > 0 || (fDescriptor->hints & ::PLUGIN_NEEDS_FIXED_BUFFERS) != 0) if (getMidiInCount() > 0 || (fDescriptor->hints & ::PLUGIN_NEEDS_FIXED_BUFFERS) != 0)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;
} }


return true; return true;


+ 73
- 73
source/backend/plugin/VstPlugin.cpp View File

@@ -72,7 +72,7 @@ public:
carla_debug("VstPlugin::~VstPlugin()"); carla_debug("VstPlugin::~VstPlugin()");


// close UI // close UI
if (fHints & PLUGIN_HAS_CUSTOM_UI)
if (pData->hints & PLUGIN_HAS_CUSTOM_UI)
{ {
showCustomUI(false); showCustomUI(false);


@@ -147,7 +147,7 @@ public:
if (fEffect->flags & effFlagsIsSynth) if (fEffect->flags & effFlagsIsSynth)
return PLUGIN_CATEGORY_SYNTH; return PLUGIN_CATEGORY_SYNTH;


return getPluginCategoryFromName(fName);
return getPluginCategoryFromName(pData->name);
} }


long getUniqueId() const override long getUniqueId() const override
@@ -167,7 +167,7 @@ public:


int32_t getChunkData(void** const dataPtr) const override int32_t getChunkData(void** const dataPtr) const override
{ {
CARLA_ASSERT(fOptions & PLUGIN_OPTION_USE_CHUNKS);
CARLA_ASSERT(pData->options & PLUGIN_OPTION_USE_CHUNKS);
CARLA_ASSERT(fEffect != nullptr); CARLA_ASSERT(fEffect != nullptr);
CARLA_ASSERT(dataPtr != nullptr); CARLA_ASSERT(dataPtr != nullptr);


@@ -194,7 +194,7 @@ public:
if (fEffect->flags & effFlagsProgramChunks) if (fEffect->flags & effFlagsProgramChunks)
options |= PLUGIN_OPTION_USE_CHUNKS; options |= PLUGIN_OPTION_USE_CHUNKS;


if (vstPluginCanDo(fEffect, "receiveVstEvents") || vstPluginCanDo(fEffect, "receiveVstMidiEvent") || (fEffect->flags & effFlagsIsSynth) > 0 || (fHints & PLUGIN_WANTS_MIDI_INPUT))
if (vstPluginCanDo(fEffect, "receiveVstEvents") || vstPluginCanDo(fEffect, "receiveVstMidiEvent") || (fEffect->flags & effFlagsIsSynth) > 0 || (pData->hints & PLUGIN_WANTS_MIDI_INPUT))
{ {
options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES; options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES;
options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE; options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
@@ -289,7 +289,7 @@ public:
CarlaPlugin::setName(newName); CarlaPlugin::setName(newName);


//if (pData->gui != nullptr) //if (pData->gui != nullptr)
// pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName));
// pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)pData->name));
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -309,7 +309,7 @@ public:


void setChunkData(const char* const stringData) override void setChunkData(const char* const stringData) override
{ {
CARLA_ASSERT(fOptions & PLUGIN_OPTION_USE_CHUNKS);
CARLA_ASSERT(pData->options & PLUGIN_OPTION_USE_CHUNKS);
CARLA_ASSERT(fEffect != nullptr); CARLA_ASSERT(fEffect != nullptr);
CARLA_ASSERT(stringData != nullptr); CARLA_ASSERT(stringData != nullptr);


@@ -427,7 +427,7 @@ public:
pData->gui->setSize(fGui.lastWidth, fGui.lastHeight); pData->gui->setSize(fGui.lastWidth, fGui.lastHeight);
} }


pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName));
pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)pData->name));
pData->gui->show(); pData->gui->show();
} }
else else
@@ -440,8 +440,8 @@ public:
pData->gui = nullptr; pData->gui = nullptr;
} }


pData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI");
pData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr);
pData->engine->callback(CALLBACK_ERROR, pData->id, 0, 0, 0.0f, "Plugin refused to open its own UI");
pData->engine->callback(CALLBACK_SHOW_GUI, pData->id, -1, 0, 0.0f, nullptr);
return; return;
} }
} }
@@ -517,7 +517,7 @@ public:
aOuts = fEffect->numOutputs; aOuts = fEffect->numOutputs;
params = fEffect->numParams; params = fEffect->numParams;


if (vstPluginCanDo(fEffect, "receiveVstEvents") || vstPluginCanDo(fEffect, "receiveVstMidiEvent") || (fEffect->flags & effFlagsIsSynth) > 0 || (fHints & PLUGIN_WANTS_MIDI_INPUT))
if (vstPluginCanDo(fEffect, "receiveVstEvents") || vstPluginCanDo(fEffect, "receiveVstMidiEvent") || (fEffect->flags & effFlagsIsSynth) > 0 || (pData->hints & PLUGIN_WANTS_MIDI_INPUT))
{ {
mIns = 1; mIns = 1;
needsCtrlIn = true; needsCtrlIn = true;
@@ -560,7 +560,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -585,7 +585,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -616,7 +616,7 @@ public:
VstParameterProperties prop; VstParameterProperties prop;
carla_zeroStruct<VstParameterProperties>(prop); carla_zeroStruct<VstParameterProperties>(prop);


if (fHints & PLUGIN_HAS_COCKOS_EXTENSIONS)
if (pData->hints & PLUGIN_HAS_COCKOS_EXTENSIONS)
{ {
double range[2] = { 0.0, 1.0 }; double range[2] = { 0.0, 1.0 };


@@ -725,7 +725,7 @@ public:
pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT;
#endif #endif


if ((fHints & PLUGIN_USES_OLD_VSTSDK) != 0 || dispatcher(effCanBeAutomated, j, 0, nullptr, 0.0f) == 1)
if ((pData->hints & PLUGIN_USES_OLD_VSTSDK) != 0 || dispatcher(effCanBeAutomated, j, 0, nullptr, 0.0f) == 1)
pData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; pData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE;


// no such thing as VST default parameters // no such thing as VST default parameters
@@ -750,7 +750,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -766,7 +766,7 @@ public:


if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT) if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{ {
portName = fName;
portName = pData->name;
portName += ":"; portName += ":";
} }


@@ -779,36 +779,36 @@ public:
// plugin hints // plugin hints
const intptr_t vstCategory = dispatcher(effGetPlugCategory, 0, 0, nullptr, 0.0f); const intptr_t vstCategory = dispatcher(effGetPlugCategory, 0, 0, nullptr, 0.0f);


fHints = 0x0;
pData->hints = 0x0;


//if (vstCategory == kPlugCategSynth || vstCategory == kPlugCategGenerator) //if (vstCategory == kPlugCategSynth || vstCategory == kPlugCategGenerator)
// fHints |= PLUGIN_IS_SYNTH;
// pData->hints |= PLUGIN_IS_SYNTH;


if (fEffect->flags & effFlagsHasEditor) if (fEffect->flags & effFlagsHasEditor)
{ {
fHints |= PLUGIN_HAS_CUSTOM_UI;
pData->hints |= PLUGIN_HAS_CUSTOM_UI;


if (! fGui.isOsc) if (! fGui.isOsc)
fHints |= PLUGIN_NEEDS_SINGLE_THREAD;
pData->hints |= PLUGIN_NEEDS_SINGLE_THREAD;
} }


if (dispatcher(effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion) if (dispatcher(effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion)
fHints |= PLUGIN_USES_OLD_VSTSDK;
pData->hints |= PLUGIN_USES_OLD_VSTSDK;


if ((fEffect->flags & effFlagsCanReplacing) != 0 && fEffect->processReplacing != fEffect->process) if ((fEffect->flags & effFlagsCanReplacing) != 0 && fEffect->processReplacing != fEffect->process)
fHints |= PLUGIN_CAN_PROCESS_REPLACING;
pData->hints |= PLUGIN_CAN_PROCESS_REPLACING;


if (static_cast<uintptr_t>(dispatcher(effCanDo, 0, 0, (void*)"hasCockosExtensions", 0.0f)) == 0xbeef0000) if (static_cast<uintptr_t>(dispatcher(effCanDo, 0, 0, (void*)"hasCockosExtensions", 0.0f)) == 0xbeef0000)
fHints |= PLUGIN_HAS_COCKOS_EXTENSIONS;
pData->hints |= PLUGIN_HAS_COCKOS_EXTENSIONS;


if (aOuts > 0 && (aIns == aOuts || aIns == 1)) if (aOuts > 0 && (aIns == aOuts || aIns == 1))
fHints |= PLUGIN_CAN_DRYWET;
pData->hints |= PLUGIN_CAN_DRYWET;


if (aOuts > 0) if (aOuts > 0)
fHints |= PLUGIN_CAN_VOLUME;
pData->hints |= PLUGIN_CAN_VOLUME;


if (aOuts >= 2 && aOuts % 2 == 0) if (aOuts >= 2 && aOuts % 2 == 0)
fHints |= PLUGIN_CAN_BALANCE;
pData->hints |= PLUGIN_CAN_BALANCE;


// extra plugin hints // extra plugin hints
pData->extraHints = 0x0; pData->extraHints = 0x0;
@@ -829,7 +829,7 @@ public:
} }


// check latency // check latency
if (fHints & PLUGIN_CAN_DRYWET)
if (pData->hints & PLUGIN_CAN_DRYWET)
{ {
#ifdef VESTIGE_HEADER #ifdef VESTIGE_HEADER
char* const empty3Ptr = &fEffect->empty3[0]; char* const empty3Ptr = &fEffect->empty3[0];
@@ -899,10 +899,10 @@ public:
// Update OSC Names // Update OSC Names
if (pData->engine->isOscControlRegistered()) if (pData->engine->isOscControlRegistered())
{ {
pData->engine->oscSend_control_set_program_count(fId, count);
pData->engine->oscSend_control_set_program_count(pData->id, count);


for (i=0; i < count; ++i) for (i=0; i < count; ++i)
pData->engine->oscSend_control_set_program_name(fId, i, pData->prog.names[i]);
pData->engine->oscSend_control_set_program_name(pData->id, i, pData->prog.names[i]);
} }
#endif #endif


@@ -957,7 +957,7 @@ public:
dispatcher(effSetProgram, 0, pData->prog.current, nullptr, 0.0f); dispatcher(effSetProgram, 0, pData->prog.current, nullptr, 0.0f);
} }


pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0f, nullptr);
} }
} }


@@ -1005,7 +1005,7 @@ public:


if (pData->needsReset) if (pData->needsReset)
{ {
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k) for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
{ {
@@ -1145,7 +1145,7 @@ public:
// Event Input (System) // Event Input (System)


bool allNotesOffSent = false; bool allNotesOffSent = false;
bool sampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFERS) == 0;
bool sampleAccurate = (pData->options & PLUGIN_OPTION_FIXED_BUFFERS) == 0;


uint32_t time, nEvents = pData->event.portIn->getEventCount(); uint32_t time, nEvents = pData->event.portIn->getEventCount();
uint32_t startTime = 0; uint32_t startTime = 0;
@@ -1202,21 +1202,21 @@ public:
{ {
float value; float value;


if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) > 0)
{ {
value = ctrlEvent.value; value = ctrlEvent.value;
setDryWet(value, false, false); setDryWet(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
} }


if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) > 0)
{ {
value = ctrlEvent.value*127.0f/100.0f; value = ctrlEvent.value*127.0f/100.0f;
setVolume(value, false, false); setVolume(value, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
} }


if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) > 0)
{ {
float left, right; float left, right;
value = ctrlEvent.value/0.5f - 1.0f; value = ctrlEvent.value/0.5f - 1.0f;
@@ -1275,7 +1275,7 @@ public:
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value); pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
} }


if ((fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
{ {
if (fMidiEventCount >= kPluginMaxMidiEvents*2) if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue; continue;
@@ -1299,7 +1299,7 @@ public:
break; break;


case kEngineControlEventTypeMidiProgram: case kEngineControlEventTypeMidiProgram:
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{ {
if (ctrlEvent.param < pData->prog.count) if (ctrlEvent.param < pData->prog.count)
{ {
@@ -1311,7 +1311,7 @@ public:
break; break;


case kEngineControlEventTypeAllSoundOff: case kEngineControlEventTypeAllSoundOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (fMidiEventCount >= kPluginMaxMidiEvents*2) if (fMidiEventCount >= kPluginMaxMidiEvents*2)
continue; continue;
@@ -1329,7 +1329,7 @@ public:
break; break;


case kEngineControlEventTypeAllNotesOff: case kEngineControlEventTypeAllNotesOff:
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{ {
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
{ {
@@ -1366,13 +1366,13 @@ public:
uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data);
uint8_t channel = event.channel; uint8_t channel = event.channel;


if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (fOptions & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
continue; continue;
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (fOptions & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
continue; continue;
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (fOptions & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
continue; continue;
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (fOptions & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
continue; continue;


// Fix bad note-off // Fix bad note-off
@@ -1508,7 +1508,7 @@ public:


fIsProcessing = true; fIsProcessing = true;


if (fHints & PLUGIN_CAN_PROCESS_REPLACING)
if (pData->hints & PLUGIN_CAN_PROCESS_REPLACING)
{ {
fEffect->processReplacing(fEffect, fEffect->processReplacing(fEffect,
(pData->audioIn.count > 0) ? vstInBuffer : nullptr, (pData->audioIn.count > 0) ? vstInBuffer : nullptr,
@@ -1541,9 +1541,9 @@ public:
// Post-processing (dry/wet, volume and balance) // Post-processing (dry/wet, volume and balance)


{ {
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) != 0 && pData->postProc.volume != 1.0f;
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
const bool doVolume = (pData->hints & PLUGIN_CAN_VOLUME) != 0 && pData->postProc.volume != 1.0f;
const bool doDryWet = (pData->hints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f;
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);


bool isPair; bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1]; float bufValue, oldBufLeft[doBalance ? frames : 1];
@@ -1733,7 +1733,7 @@ protected:
// void guiClosedCallback() override // void guiClosedCallback() override
// { // {
// showGui(false); // showGui(false);
// pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr);
// pData->engine->callback(CALLBACK_SHOW_GUI, pData->id, 0, 0, 0.0f, nullptr);
// } // }


intptr_t dispatcher(int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt) const intptr_t dispatcher(int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt) const
@@ -1787,7 +1787,7 @@ protected:
switch (opcode) switch (opcode)
{ {
case audioMasterAutomate: case audioMasterAutomate:
if (! fEnabled)
if (! pData->enabled)
break; break;


// plugins should never do this: // plugins should never do this:
@@ -1840,7 +1840,7 @@ protected:


case audioMasterWantMidi: case audioMasterWantMidi:
// Deprecated in VST SDK 2.4 // Deprecated in VST SDK 2.4
fHints |= PLUGIN_WANTS_MIDI_INPUT;
pData->hints |= PLUGIN_WANTS_MIDI_INPUT;
break; break;
#endif #endif


@@ -1853,12 +1853,12 @@ protected:
break; break;


case audioMasterProcessEvents: case audioMasterProcessEvents:
CARLA_ASSERT(fEnabled);
CARLA_ASSERT(pData->enabled);
CARLA_ASSERT(fIsProcessing); CARLA_ASSERT(fIsProcessing);
CARLA_ASSERT(pData->event.portOut != nullptr); CARLA_ASSERT(pData->event.portOut != nullptr);
CARLA_ASSERT(ptr != nullptr); CARLA_ASSERT(ptr != nullptr);


if (! fEnabled)
if (! pData->enabled)
return 0; return 0;
if (! fIsProcessing) if (! fIsProcessing)
return 0; return 0;
@@ -1928,11 +1928,11 @@ protected:


#if 0 #if 0
case audioMasterIOChanged: case audioMasterIOChanged:
CARLA_ASSERT(fEnabled);
CARLA_ASSERT(pData->enabled);


// TESTING // TESTING


if (! fEnabled)
if (! pData->enabled)
{ {
ret = 1; ret = 1;
break; break;
@@ -2094,12 +2094,12 @@ protected:
if (pData->prog.current != current) if (pData->prog.current != current)
{ {
pData->prog.current = current; pData->prog.current = current;
pData->engine->callback(ENGINE_CALLBACK_PROGRAM_CHANGED, fId, current, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_PROGRAM_CHANGED, pData->id, current, 0, 0.0f, nullptr);
} }
} }
} }


pData->engine->callback(ENGINE_CALLBACK_UPDATE, fId, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_UPDATE, pData->id, 0, 0, 0.0f, nullptr);
ret = 1; ret = 1;
break; break;


@@ -2224,7 +2224,7 @@ public:


if (name != nullptr) if (name != nullptr)
{ {
fName = pData->engine->getUniquePluginName(name);
pData->name = pData->engine->getUniquePluginName(name);
} }
else else
{ {
@@ -2233,16 +2233,16 @@ public:


if (strBuf[0] != '\0') if (strBuf[0] != '\0')
{ {
fName = pData->engine->getUniquePluginName(strBuf);
pData->name = pData->engine->getUniquePluginName(strBuf);
} }
else else
{ {
const char* const label = std::strrchr(filename, OS_SEP)+1; const char* const label = std::strrchr(filename, OS_SEP)+1;
fName = pData->engine->getUniquePluginName(label);
pData->name = pData->engine->getUniquePluginName(label);
} }
} }


fFilename = filename;
pData->filename = filename;


// --------------------------------------------------------------- // ---------------------------------------------------------------
// register client // register client
@@ -2266,10 +2266,10 @@ public:
dispatcher(effSetProcessPrecision, 0, kVstProcessPrecision32, nullptr, 0.0f); dispatcher(effSetProcessPrecision, 0, kVstProcessPrecision32, nullptr, 0.0f);


if (dispatcher(effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion) if (dispatcher(effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion)
fHints |= PLUGIN_USES_OLD_VSTSDK;
pData->hints |= PLUGIN_USES_OLD_VSTSDK;


if (static_cast<uintptr_t>(dispatcher(effCanDo, 0, 0, (void*)"hasCockosExtensions", 0.0f)) == 0xbeef0000) if (static_cast<uintptr_t>(dispatcher(effCanDo, 0, 0, (void*)"hasCockosExtensions", 0.0f)) == 0xbeef0000)
fHints |= PLUGIN_HAS_COCKOS_EXTENSIONS;
pData->hints |= PLUGIN_HAS_COCKOS_EXTENSIONS;


// --------------------------------------------------------------- // ---------------------------------------------------------------
// gui stuff // gui stuff
@@ -2300,22 +2300,22 @@ public:


{ {
// set default options // set default options
fOptions = 0x0;
pData->options = 0x0;


fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;


if (getMidiInCount() > 0) if (getMidiInCount() > 0)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;


if (fEffect->flags & effFlagsProgramChunks) if (fEffect->flags & effFlagsProgramChunks)
fOptions |= PLUGIN_OPTION_USE_CHUNKS;
pData->options |= PLUGIN_OPTION_USE_CHUNKS;


if (vstPluginCanDo(fEffect, "receiveVstEvents") || vstPluginCanDo(fEffect, "receiveVstMidiEvent") || (fEffect->flags & effFlagsIsSynth) > 0 || (fHints & PLUGIN_WANTS_MIDI_INPUT))
if (vstPluginCanDo(fEffect, "receiveVstEvents") || vstPluginCanDo(fEffect, "receiveVstMidiEvent") || (fEffect->flags & effFlagsIsSynth) > 0 || (pData->hints & PLUGIN_WANTS_MIDI_INPUT))
{ {
fOptions |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
fOptions |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
fOptions |= PLUGIN_OPTION_SEND_PITCHBEND;
fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
pData->options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
pData->options |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
} }


// load settings // load settings
@@ -2323,11 +2323,11 @@ public:
//pData->idStr += std::strrchr(filename, OS_SEP)+1; // FIXME! //pData->idStr += std::strrchr(filename, OS_SEP)+1; // FIXME!
//pData->idStr += "/"; //pData->idStr += "/";
pData->idStr += CarlaString(getUniqueId()); pData->idStr += CarlaString(getUniqueId());
fOptions = pData->loadSettings(fOptions, getOptionsAvailable());
pData->options = pData->loadSettings(pData->options, getOptionsAvailable());


// ignore settings, we need this anyway // ignore settings, we need this anyway
if (getMidiInCount() > 0) if (getMidiInCount() > 0)
fOptions |= PLUGIN_OPTION_FIXED_BUFFERS;
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;
} }


return true; return true;


+ 26
- 128
source/backend/standalone/CarlaStandalone.cpp View File

@@ -397,7 +397,7 @@ bool carla_engine_init(const char* driverName, const char* clientName)
#endif #endif


// TODO: make this an option, put somewhere else // TODO: make this an option, put somewhere else
if (getenv("WINE_RT") == nullptr)
if (std::getenv("WINE_RT") == nullptr)
{ {
carla_setenv("WINE_RT", "15"); carla_setenv("WINE_RT", "15");
carla_setenv("WINE_SVR_RT", "10"); carla_setenv("WINE_SVR_RT", "10");
@@ -570,28 +570,22 @@ void carla_set_engine_callback(EngineCallbackFunc func, void* ptr)
//#endif //#endif
} }


#if 0
#if 0
void carla_set_engine_option(CarlaEngineOption option, int value, const char* valueStr)
void carla_set_engine_option(EngineOption option, int value, const char* valueStr)
{ {
carla_debug("carla_set_engine_option(%i:%s, %i, \"%s\")", option, CB::EngineOption2Str(option), value, valueStr); carla_debug("carla_set_engine_option(%i:%s, %i, \"%s\")", option, CB::EngineOption2Str(option), value, valueStr);


switch (option) switch (option)
{ {
case CB::ENGINE_OPTION_PROCESS_NAME:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
#ifdef USE_JUCE
juce::Thread::setCurrentThreadName(valueStr);
#endif
case CB::ENGINE_OPTION_DEBUG:
break; break;


case CB::ENGINE_OPTION_PROCESS_MODE: case CB::ENGINE_OPTION_PROCESS_MODE:
CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_PROCESS_MODE_SINGLE_CLIENT && value <= CB::ENGINE_PROCESS_MODE_BRIDGE,);
CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_PROCESS_MODE_SINGLE_CLIENT && value < CB::ENGINE_PROCESS_MODE_BRIDGE,);
gStandalone.engineOptions.processMode = static_cast<CB::EngineProcessMode>(value); gStandalone.engineOptions.processMode = static_cast<CB::EngineProcessMode>(value);
break; break;


case CB::ENGINE_OPTION_TRANSPORT_MODE: case CB::ENGINE_OPTION_TRANSPORT_MODE:
CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_TRANSPORT_MODE_INTERNAL && value <= CB::ENGINE_TRANSPORT_MODE_BRIDGE,);
CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_TRANSPORT_MODE_INTERNAL && value < CB::ENGINE_TRANSPORT_MODE_BRIDGE,);
gStandalone.engineOptions.transportMode = static_cast<CB::EngineTransportMode>(value); gStandalone.engineOptions.transportMode = static_cast<CB::EngineTransportMode>(value);
break; break;


@@ -626,7 +620,7 @@ void carla_set_engine_option(CarlaEngineOption option, int value, const char* va
break; break;


case CB::ENGINE_OPTION_AUDIO_NUM_PERIODS: case CB::ENGINE_OPTION_AUDIO_NUM_PERIODS:
CARLA_SAFE_ASSERT_RETURN(value == 2 || value == 3,);
CARLA_SAFE_ASSERT_RETURN(value >= 2 && value <= 3,);
gStandalone.engineOptions.audioNumPeriods = static_cast<unsigned int>(value); gStandalone.engineOptions.audioNumPeriods = static_cast<unsigned int>(value);
break; break;


@@ -645,101 +639,15 @@ void carla_set_engine_option(CarlaEngineOption option, int value, const char* va
gStandalone.engineOptions.audioDevice = valueStr; gStandalone.engineOptions.audioDevice = valueStr;
break; break;


case CB::ENGINE_OPTION_PATH_RESOURCES:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.resourceDir = valueStr;
break;

#ifndef BUILD_BRIDGE
case CB::ENGINE_OPTION_PATH_BRIDGE_NATIVE:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_native = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_POSIX32:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_posix32 = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_POSIX64:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_posix64 = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_WIN32:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_win32 = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_WIN64:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_win64 = valueStr;
break;
#endif

#ifdef WANT_LV2
case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_EXTERNAL:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Extrn = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_GTK2:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Gtk2 = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_GTK3:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Gtk3 = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_NTK:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Ntk = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_QT4:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Qt4 = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_QT5:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Qt5 = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_COCOA:
case CB::ENGINE_OPTION_PATH_BINARIES:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',); CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Cocoa = valueStr;
gStandalone.engineOptions.binaryDir = valueStr;
break; break;


case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_WINDOWS:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2Win = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_LV2_X11:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_lv2X11 = valueStr;
break;
#endif

#ifdef WANT_VST
case CB::ENGINE_OPTION_PATH_BRIDGE_VST_MAC:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_vstMac = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_VST_HWND:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_vstHWND = valueStr;
break;

case CB::ENGINE_OPTION_PATH_BRIDGE_VST_X11:
case CB::ENGINE_OPTION_PATH_RESOURCES:
CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',); CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',);
gStandalone.engineOptions.bridge_vstX11 = valueStr;
gStandalone.engineOptions.resourceDir = valueStr;
break; break;
#endif
} }


if (gStandalone.engine != nullptr) if (gStandalone.engine != nullptr)
@@ -748,45 +656,43 @@ void carla_set_engine_option(CarlaEngineOption option, int value, const char* va


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


void carla_set_file_callback(CarlaFileCallbackFunc func, void* ptr)
void carla_set_file_callback(FileCallbackFunc func, void* ptr)
{ {
carla_debug("carla_set_file_callback(%p, %p)", func, ptr); carla_debug("carla_set_file_callback(%p, %p)", func, ptr);


gFileHandler.callback = func;
gFileHandler.callbackPtr = ptr;
gStandalone.fileCallback = func;
gStandalone.fileCallbackPtr = ptr;
} }


const char* carla_file_callback(CarlaFileCallbackOpcode action, bool isDir, const char* title, const char* filter)
const char* carla_file_callback(FileCallbackOpcode action, bool isDir, const char* title, const char* filter)
{ {
if (gFileHandler.callback == nullptr)
if (gStandalone.fileCallback == nullptr)
return nullptr; return nullptr;


return gFileHandler.callback(gFileHandler.callbackPtr, action, isDir, title, filter);
return gStandalone.fileCallback(gStandalone.fileCallbackPtr, action, isDir, title, filter);
} }


// ------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------
#endif


bool carla_load_filename(const char* filename)
bool carla_load_file(const char* filename)
{ {
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
carla_debug("carla_load_filename(\"%s\")", filename);
carla_debug("carla_load_file(\"%s\")", filename);


if (gStandalone.engine != nullptr && gStandalone.engine->isRunning())
return gStandalone.engine->loadFilename(filename);
if (gStandalone.engine != nullptr)
return gStandalone.engine->loadFile(filename);


carla_stderr2("Engine is not running"); carla_stderr2("Engine is not running");
gStandalone.lastError = "Engine is not running"; gStandalone.lastError = "Engine is not running";
return false; return false;
} }


#if 0
bool carla_load_project(const char* filename) bool carla_load_project(const char* filename)
{ {
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
carla_debug("carla_load_project(\"%s\")", filename); carla_debug("carla_load_project(\"%s\")", filename);


if (gStandalone.engine != nullptr && gStandalone.engine->isRunning())
if (gStandalone.engine != nullptr)
return gStandalone.engine->loadProject(filename); return gStandalone.engine->loadProject(filename);


carla_stderr2("Engine is not running"); carla_stderr2("Engine is not running");
@@ -799,7 +705,6 @@ bool carla_save_project(const char* filename)
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
carla_debug("carla_save_project(\"%s\")", filename); carla_debug("carla_save_project(\"%s\")", filename);


// allow to save even if engine isn't running
if (gStandalone.engine != nullptr) if (gStandalone.engine != nullptr)
return gStandalone.engine->saveProject(filename); return gStandalone.engine->saveProject(filename);


@@ -815,7 +720,7 @@ bool carla_patchbay_connect(int portA, int portB)
CARLA_SAFE_ASSERT_RETURN(portA != portB, false); CARLA_SAFE_ASSERT_RETURN(portA != portB, false);
carla_debug("carla_patchbay_connect(%i, %i)", portA, portB); carla_debug("carla_patchbay_connect(%i, %i)", portA, portB);


if (gStandalone.engine != nullptr && gStandalone.engine->isRunning())
if (gStandalone.engine != nullptr)
return gStandalone.engine->patchbayConnect(portA, portB); return gStandalone.engine->patchbayConnect(portA, portB);


carla_stderr2("Engine is not running"); carla_stderr2("Engine is not running");
@@ -827,7 +732,7 @@ bool carla_patchbay_disconnect(int connectionId)
{ {
carla_debug("carla_patchbay_disconnect(%i)", connectionId); carla_debug("carla_patchbay_disconnect(%i)", connectionId);


if (gStandalone.engine != nullptr && gStandalone.engine->isRunning())
if (gStandalone.engine != nullptr)
return gStandalone.engine->patchbayDisconnect(connectionId); return gStandalone.engine->patchbayDisconnect(connectionId);


carla_stderr2("Engine is not running"); carla_stderr2("Engine is not running");
@@ -839,11 +744,8 @@ bool carla_patchbay_refresh()
{ {
carla_debug("carla_patchbay_refresh()"); carla_debug("carla_patchbay_refresh()");


if (gStandalone.engine != nullptr && gStandalone.engine->isRunning())
{
gStandalone.engine->patchbayRefresh();
return true;
}
if (gStandalone.engine != nullptr)
return gStandalone.engine->patchbayRefresh();


carla_stderr2("Engine is not running"); carla_stderr2("Engine is not running");
gStandalone.lastError = "Engine is not running"; gStandalone.lastError = "Engine is not running";
@@ -851,7 +753,6 @@ bool carla_patchbay_refresh()
} }


// ------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------
#endif


void carla_transport_play() void carla_transport_play()
{ {
@@ -885,7 +786,6 @@ uint64_t carla_get_current_transport_frame()
return timeInfo.frame; return timeInfo.frame;
} }


#if 0
const CarlaTransportInfo* carla_get_transport_info() const CarlaTransportInfo* carla_get_transport_info()
{ {
static CarlaTransportInfo info; static CarlaTransportInfo info;
@@ -900,7 +800,7 @@ const CarlaTransportInfo* carla_get_transport_info()


CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &info); CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &info);


const EngineTimeInfo& timeInfo(gStandalone.engine->getTimeInfo());
const CB::EngineTimeInfo& timeInfo(gStandalone.engine->getTimeInfo());


info.playing = timeInfo.playing; info.playing = timeInfo.playing;
info.frame = timeInfo.frame; info.frame = timeInfo.frame;
@@ -915,8 +815,6 @@ const CarlaTransportInfo* carla_get_transport_info()


return &info; return &info;
} }
#endif
#endif


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




+ 58
- 20
source/carla_backend.py View File

@@ -1103,24 +1103,24 @@ class Host(object):
# Get the complete license text of used third-party code and features. # Get the complete license text of used third-party code and features.
# Returned string is in basic html format. # Returned string is in basic html format.
def get_complete_license_text(self): def get_complete_license_text(self):
return self.lib.carla_get_complete_license_text()
return charPtrToString(self.lib.carla_get_complete_license_text())


# Get all the supported file types in carla_load_filename().
# Get all the supported file extensions in carla_load_file().
# Returned string uses this syntax: # Returned string uses this syntax:
# @code # @code
# "*.ext1;*.ext2;*.ext3" # "*.ext1;*.ext2;*.ext3"
# @endcode # @endcode
def get_supported_file_extensions(self): def get_supported_file_extensions(self):
return self.lib.carla_get_supported_file_extensions()
return charPtrToString(self.lib.carla_get_supported_file_extensions())


# Get how many engine drivers are available. # Get how many engine drivers are available.
def get_engine_driver_count(self): def get_engine_driver_count(self):
return self.lib.carla_get_engine_driver_count()
return int(self.lib.carla_get_engine_driver_count())


# Get an engine driver name. # Get an engine driver name.
# @param index Driver index # @param index Driver index
def get_engine_driver_name(self, index): def get_engine_driver_name(self, index):
return self.lib.carla_get_engine_driver_name(index)
return charPtrToString(self.lib.carla_get_engine_driver_name(index))


# Get the device names of an engine driver. # Get the device names of an engine driver.
# @param index Driver index # @param index Driver index
@@ -1133,40 +1133,78 @@ class Host(object):
def get_engine_driver_device_info(self, index, name): def get_engine_driver_device_info(self, index, name):
return structToDict(self.lib.carla_get_engine_driver_device_info(index, name)) return structToDict(self.lib.carla_get_engine_driver_device_info(index, name))


# Get how many internal plugins are available.
def get_internal_plugin_count(self): def get_internal_plugin_count(self):
return self.lib.carla_get_internal_plugin_count()
return int(self.lib.carla_get_internal_plugin_count())


def get_internal_plugin_info(self, internalPluginId):
return structToDict(self.lib.carla_get_internal_plugin_info(internalPluginId).contents)
# Get information about an internal plugin.
# @param index Internal plugin Id
def get_internal_plugin_info(self, index):
return structToDict(self.lib.carla_get_internal_plugin_info(index).contents)


# Initialize the engine.
# Make sure to call carla_engine_idle() at regular intervals afterwards.
# @param driverName Driver to use
# @param clientName Engine master client name
def engine_init(self, driverName, clientName): def engine_init(self, driverName, clientName):
return self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8"))
return bool(self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8")))


# Close the engine.
# This function always closes the engine even if it returns false.
# In other words, even when something goes wrong when closing the engine it still be closed nonetheless.
def engine_close(self): def engine_close(self):
return self.lib.carla_engine_close()
return bool(self.lib.carla_engine_close())


# Idle the engine.
# Do not call this if the engine is not running.
def engine_idle(self): def engine_idle(self):
self.lib.carla_engine_idle() self.lib.carla_engine_idle()


# Check if the engine is running.
def is_engine_running(self): def is_engine_running(self):
return self.lib.carla_is_engine_running()
return bool(self.lib.carla_is_engine_running())


# Tell the engine it's about to close.
# This is used to prevent the engine thread(s) from reactivating.
def set_engine_about_to_close(self): def set_engine_about_to_close(self):
self.lib.carla_set_engine_about_to_close() self.lib.carla_set_engine_about_to_close()


# Set the engine callback function.
# @param func Callback function
def set_engine_callback(self, func): def set_engine_callback(self, func):
self._callback = EngineCallbackFunc(func)
self.lib.carla_set_engine_callback(self._callback, c_nullptr)
self._engineCallback = EngineCallbackFunc(func)
self.lib.carla_set_engine_callback(self._engineCallback, None)


# Set an engine option.
# @param option Option
# @param value Value as number
# @param valueStr Value as string
def set_engine_option(self, option, value, valueStr): def set_engine_option(self, option, value, valueStr):
self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8")) self.lib.carla_set_engine_option(option, value, valueStr.encode("utf-8"))


def load_filename(self, filename):
return self.lib.carla_load_filename(filename.encode("utf-8"))

# Set the file callback function.
# @param func Callback function
# @param ptr Callback pointer
def set_file_callback(self, func):
self._fileCallback = FileCallbackFunc(func)
self.lib.carla_set_file_callback(self._fileCallback, None)

# Load a file of any type.\n
# This will try to load a generic file as a plugin,
# either by direct handling (Csound, GIG, SF2 and SFZ) or by using an internal plugin (like Audio and MIDI).
# @param Filename Filename
# @see carla_get_supported_file_extensions()
def load_file(self, filename):
return self.lib.carla_load_file(filename.encode("utf-8"))

# Load a Carla project file.
# @param Filename Filename
# @note Currently loaded plugins are not removed; call carla_remove_all_plugins() first if needed.
def load_project(self, filename): def load_project(self, filename):
return self.lib.carla_load_project(filename.encode("utf-8")) return self.lib.carla_load_project(filename.encode("utf-8"))


# Save current project to a file.
# @param Filename Filename
def save_project(self, filename): def save_project(self, filename):
return self.lib.carla_save_project(filename.encode("utf-8")) return self.lib.carla_save_project(filename.encode("utf-8"))


@@ -1401,8 +1439,6 @@ class Host(object):
self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p] self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo) self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)


return

self.lib.carla_get_internal_plugin_count.argtypes = None self.lib.carla_get_internal_plugin_count.argtypes = None
self.lib.carla_get_internal_plugin_count.restype = c_uint self.lib.carla_get_internal_plugin_count.restype = c_uint


@@ -1424,14 +1460,16 @@ class Host(object):
self.lib.carla_set_engine_about_to_close.argtypes = None self.lib.carla_set_engine_about_to_close.argtypes = None
self.lib.carla_set_engine_about_to_close.restype = None self.lib.carla_set_engine_about_to_close.restype = None


return

self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p] self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
self.lib.carla_set_engine_callback.restype = None self.lib.carla_set_engine_callback.restype = None


self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p] self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
self.lib.carla_set_engine_option.restype = None self.lib.carla_set_engine_option.restype = None


self.lib.carla_load_filename.argtypes = [c_char_p]
self.lib.carla_load_filename.restype = c_bool
self.lib.carla_load_file.argtypes = [c_char_p]
self.lib.carla_load_file.restype = c_bool


self.lib.carla_load_project.argtypes = [c_char_p] self.lib.carla_load_project.argtypes = [c_char_p]
self.lib.carla_load_project.restype = c_bool self.lib.carla_load_project.restype = c_bool


+ 3
- 10
source/includes/CarlaDefines.h View File

@@ -69,18 +69,11 @@
#endif #endif


/* Common includes */ /* Common includes */
#ifdef CARLA_OS_WIN
# include <winsock2.h>
# include <windows.h>
#ifdef __cplusplus
# include <cstddef>
#else #else
# include <unistd.h>
# ifndef __cdecl
# define __cdecl
# endif
#endif

#ifndef __cplusplus
# include <stdbool.h> # include <stdbool.h>
# include <stddef.h>
#endif #endif


/* Define various string format types */ /* Define various string format types */


+ 7
- 0
source/utils/CarlaUtils.hpp View File

@@ -32,6 +32,13 @@
# include <stdint.h> # include <stdint.h>
#endif #endif


#ifdef CARLA_OS_WIN
# include <winsock2.h>
# include <windows.h>
#else
# include <unistd.h>
#endif

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




Loading…
Cancel
Save