Browse Source

Small API changes and fixup

tags/1.9.4
falkTX 11 years ago
parent
commit
137cff992f
9 changed files with 205 additions and 117 deletions
  1. +104
    -49
      source/backend/CarlaBackend.h
  2. +18
    -10
      source/backend/CarlaEngine.hpp
  3. +6
    -6
      source/backend/CarlaHost.h
  4. +0
    -10
      source/backend/CarlaPlugin.hpp
  5. +7
    -17
      source/backend/engine/CarlaEngineInternal.hpp
  6. +2
    -2
      source/backend/engine/CarlaEngineOsc.hpp
  7. +37
    -12
      source/carla_backend.py
  8. +12
    -11
      source/includes/CarlaMIDI.h
  9. +19
    -0
      source/utils/CarlaBackendUtils.hpp

+ 104
- 49
source/backend/CarlaBackend.h View File

@@ -114,43 +114,53 @@ const unsigned int ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x4;
* Plugin is a bridge.\n
* This hint is required because "bridge" itself is not a plugin type.
*/
const unsigned int PLUGIN_IS_BRIDGE = 0x01;
const unsigned int PLUGIN_IS_BRIDGE = 0x001;

/*!
* Plugin is hard real-time safe.
*/
const unsigned int PLUGIN_IS_RTSAFE = 0x02;
const unsigned int PLUGIN_IS_RTSAFE = 0x002;

/*!
* Plugin is a synth (produces sound).
*/
const unsigned int PLUGIN_IS_SYNTH = 0x04;
const unsigned int PLUGIN_IS_SYNTH = 0x004;

/*!
* Plugin has its own custom UI.
* @see CarlaPlugin::showCustomUI() and carla_show_custom_ui()
*/
const unsigned int PLUGIN_HAS_CUSTOM_UI = 0x08;
const unsigned int PLUGIN_HAS_CUSTOM_UI = 0x008;

/*!
* Plugin can use internal Dry/Wet control.
*/
const unsigned int PLUGIN_CAN_DRYWET = 0x10;
const unsigned int PLUGIN_CAN_DRYWET = 0x010;

/*!
* Plugin can use internal Volume control.
*/
const unsigned int PLUGIN_CAN_VOLUME = 0x20;
const unsigned int PLUGIN_CAN_VOLUME = 0x020;

/*!
* Plugin can use internal (Stereo) Balance controls.
*/
const unsigned int PLUGIN_CAN_BALANCE = 0x40;
const unsigned int PLUGIN_CAN_BALANCE = 0x040;

/*!
* Plugin can use internal (Mono) Panning control.
*/
const unsigned int PLUGIN_CAN_PANNING = 0x80;
const unsigned int PLUGIN_CAN_PANNING = 0x080;

/*!
* Plugin needs a constant, fixed-size audio buffer.
*/
const unsigned int PLUGIN_NEEDS_FIXED_BUFFERS = 0x100;

/*!
* Plugin needs all UI events in a single/main thread.
*/
const unsigned int PLUGIN_NEEDS_SINGLE_THREAD = 0x200;

/** @} */

@@ -540,6 +550,35 @@ typedef enum {

} PluginCategory;

// ------------------------------------------------------------------------------------------------------------
// Parameter Type

/*!
* Plugin parameter type.
*/
typedef enum {
/*!
* Null parameter type.
*/
PARAMETER_UNKNOWN = 0,

/*!
* Input parameter.
*/
PARAMETER_INPUT = 1,

/*!
* Ouput parameter.
*/
PARAMETER_OUTPUT = 2,

/*!
* Special (hidden) parameter.
*/
PARAMETER_SPECIAL = 3

} ParameterType;

// ------------------------------------------------------------------------------------------------------------
// Internal Parameter Index

@@ -1062,7 +1101,18 @@ typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, uint
/*!
* Parameter data.
*/
typedef struct _ParameterData {
typedef struct {
/*!
* This parameter type.
*/
ParameterType type;

/*!
* This parameter hints.
* @see ParameterHints
*/
unsigned int hints;

/*!
* Index as seen by Carla.
*/
@@ -1073,12 +1123,6 @@ typedef struct _ParameterData {
*/
int32_t rindex;

/*!
* This parameter hints.
* @see ParameterHints
*/
unsigned int hints;

/*!
* Currently mapped MIDI CC.\n
* A value lower than 0 means invalid or unused.\n
@@ -1094,21 +1138,24 @@ typedef struct _ParameterData {

#ifdef __cplusplus
/*!
* C++ constructor.
* Clear data.
*/
_ParameterData() noexcept
: index(PARAMETER_NULL),
rindex(-1),
hints(0x0),
midiCC(-1),
midiChannel(0) {}
void clear() noexcept
{
type = PARAMETER_UNKNOWN;
hints = 0x0;
index = PARAMETER_NULL;
rindex = -1;
midiCC =-1;
midiChannel = 0;
}
#endif
} ParameterData;

/*!
* Parameter ranges.
*/
typedef struct _ParameterRanges {
typedef struct {
/*!
* Default value.
*/
@@ -1141,15 +1188,17 @@ typedef struct _ParameterRanges {

#ifdef __cplusplus
/*!
* C++ constructor.
* Clear data.
*/
_ParameterRanges() noexcept
: def(0.0f),
min(0.0f),
max(1.0f),
step(0.01f),
stepSmall(0.0001f),
stepLarge(0.1f) {}
void clear() noexcept
{
def = 0.0f;
min = 0.0f;
max = 1.0f;
step = 0.01f;
stepSmall = 0.0001f;
stepLarge = 0.1f;
}

/*!
* Fix default value within range.
@@ -1229,7 +1278,7 @@ typedef struct _ParameterRanges {
/*!
* MIDI Program data.
*/
typedef struct _MidiProgramData {
typedef struct {
/*!
* MIDI bank.
*/
@@ -1247,19 +1296,21 @@ typedef struct _MidiProgramData {

#ifdef __cplusplus
/*!
* C++ constructor.
* Clear data.
*/
_MidiProgramData() noexcept
: bank(0),
program(0),
name(nullptr) {}
void clear() noexcept
{
bank = 0;
program = 0;
name = nullptr;
}
#endif
} MidiProgramData;

/*!
* Custom data, used for saving key:value 'dictionaries'.
*/
typedef struct _CustomData {
typedef struct {
/*!
* Value type, in URI form.
* @see CustomDataTypes
@@ -1279,19 +1330,21 @@ typedef struct _CustomData {

#ifdef __cplusplus
/*!
* C++ constructor.
* Clear data.
*/
_CustomData() noexcept
: type(nullptr),
key(nullptr),
value(nullptr) {}
void clear() noexcept
{
type = nullptr;
key = nullptr;
value = nullptr;
}
#endif
} CustomData;

/*!
* Engine driver device information.
*/
typedef struct _EngineDriverDeviceInfo {
typedef struct {
/*!
* This driver device hints.
* @see EngineDriverHints
@@ -1312,12 +1365,14 @@ typedef struct _EngineDriverDeviceInfo {

#ifdef __cplusplus
/*!
* C++ constructor.
* Clear data.
*/
_EngineDriverDeviceInfo()
: hints(0x0),
bufferSizes(nullptr),
sampleRates(nullptr) {}
void clear() noexcept
{
hints = 0x0;
bufferSizes = nullptr;
sampleRates = nullptr;
}
#endif
} EngineDriverDeviceInfo;



+ 18
- 10
source/backend/CarlaEngine.hpp View File

@@ -168,6 +168,9 @@ struct EngineControlEvent {
uint16_t param; //!< Parameter Id, midi bank or midi program.
float value; //!< Parameter value, normalized to 0.0f<->1.0f.

/*!
* Clear data.
*/
void clear() noexcept
{
type = kEngineControlEventTypeNull;
@@ -181,17 +184,20 @@ struct EngineControlEvent {
*/
struct EngineMidiEvent {
uint8_t port; //!< Port offset (usually 0)
uint8_t data[4]; //!< MIDI data, without channel bit
uint8_t size; //!< Number of bytes used
uint8_t data[4]; //!< MIDI data, without channel bit

/*!
* Clear data.
*/
void clear() noexcept
{
port = 0;
size = 0;
data[0] = 0;
data[1] = 0;
data[2] = 0;
data[3] = 0;
size = 0;
}
};

@@ -203,16 +209,17 @@ struct EngineEvent {
uint32_t time; //!< Time offset in frames
uint8_t channel; //!< Channel, used for MIDI-related events

/*!
* Event specific data.
*/
union {
EngineControlEvent ctrl;
EngineMidiEvent midi;
};

EngineEvent() noexcept
{
clear();
}

/*!
* Clear data.
*/
void clear() noexcept
{
type = kEngineEventTypeNull;
@@ -325,9 +332,10 @@ struct EngineTimeInfo {
EngineTimeInfoBBT bbt;

EngineTimeInfo() noexcept
{
clear();
}
: playing(false),
frame(0),
usecs(0),
valid(0x0) {}

void clear() noexcept
{


+ 6
- 6
source/backend/CarlaHost.h View File

@@ -171,7 +171,7 @@ typedef struct _CarlaPluginInfo {
/*!
* C++ constructor.
*/
_CarlaPluginInfo()
_CarlaPluginInfo() noexcept
: type(CarlaBackend::PLUGIN_NONE),
category(CarlaBackend::PLUGIN_CATEGORY_NONE),
hints(0x0),
@@ -280,7 +280,7 @@ typedef struct _CarlaNativePluginInfo {
/*!
* C++ constructor.
*/
_CarlaNativePluginInfo()
_CarlaNativePluginInfo() noexcept
: category(CarlaBackend::PLUGIN_CATEGORY_NONE),
hints(0x0),
audioIns(0),
@@ -317,7 +317,7 @@ typedef struct _CarlaPortCountInfo {
/*!
* C++ constructor.
*/
_CarlaPortCountInfo()
_CarlaPortCountInfo() noexcept
: ins(0),
outs(0) {}
#endif
@@ -353,7 +353,7 @@ typedef struct _CarlaParameterInfo {
/*!
* C++ constructor.
*/
_CarlaParameterInfo()
_CarlaParameterInfo() noexcept
: name(nullptr),
symbol(nullptr),
unit(nullptr),
@@ -402,7 +402,7 @@ typedef struct _CarlaScalePointInfo {
/*!
* C++ constructor.
*/
_CarlaScalePointInfo()
_CarlaScalePointInfo() noexcept
: value(0.0f),
label(nullptr) {}

@@ -459,7 +459,7 @@ typedef struct _CarlaTransportInfo {
/*!
* C++ constructor.
*/
_CarlaTransportInfo()
_CarlaTransportInfo() noexcept
: playing(false),
frame(0),
bar(0),


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

@@ -33,16 +33,6 @@ CARLA_BACKEND_START_NAMESPACE
} /* Fix editor indentation */
#endif

/*!
* @defgroup PluginHints
* @{
*/

const unsigned int PLUGIN_NEEDS_FIXED_BUFFERS = 0x100;
const unsigned int PLUGIN_NEEDS_SINGLE_THREAD = 0x200;

/** @} */

/*!
* @defgroup CarlaPluginAPI Carla Plugin API
*


+ 7
- 17
source/backend/engine/CarlaEngineInternal.hpp View File

@@ -131,13 +131,6 @@ struct EnginePluginData {
CarlaPlugin* plugin;
float insPeak[2];
float outsPeak[2];

EnginePluginData()
: plugin(nullptr)
{
insPeak[0] = insPeak[1] = 0.0f;
outsPeak[0] = outsPeak[1] = 0.0f;
}
};

// -----------------------------------------------------------------------
@@ -171,7 +164,7 @@ struct CarlaEngineProtectedData {
EngineEvent* in;
EngineEvent* out;

InternalEvents()
InternalEvents() noexcept
: in(nullptr),
out(nullptr) {}

@@ -186,7 +179,7 @@ struct CarlaEngineProtectedData {
bool playing;
uint64_t frame;

InternalTime()
InternalTime() noexcept
: playing(false),
frame(0) {}
} time;
@@ -197,7 +190,7 @@ struct CarlaEngineProtectedData {
unsigned int value;
CarlaMutex mutex;

NextAction()
NextAction() noexcept
: opcode(kEnginePostActionNull),
pluginId(0),
value(0) {}
@@ -207,7 +200,7 @@ struct CarlaEngineProtectedData {
CARLA_ASSERT(opcode == kEnginePostActionNull);
}

void ready()
void ready() noexcept
{
mutex.lock();
mutex.unlock();
@@ -253,10 +246,7 @@ struct CarlaEngineProtectedData {
{
CarlaPlugin* const plugin(plugins[i+1].plugin);

CARLA_ASSERT(plugin != nullptr);

if (plugin == nullptr)
break;
CARLA_SAFE_ASSERT_BREAK(plugin != nullptr);

plugin->setId(i);

@@ -299,7 +289,7 @@ struct CarlaEngineProtectedData {
#endif
}

void doNextPluginAction(const bool unlock)
void doNextPluginAction(const bool unlock) noexcept
{
switch (nextAction.opcode)
{
@@ -351,7 +341,7 @@ struct CarlaEngineProtectedData {
}
}

~ScopedActionLock()
~ScopedActionLock() noexcept
{
fData->nextAction.mutex.unlock();
}


+ 2
- 2
source/backend/engine/CarlaEngineOsc.hpp View File

@@ -68,12 +68,12 @@ public:

const char* getServerPathTCP() const noexcept
{
return (const char*)fServerPathTCP;
return fServerPathTCP.getBuffer();
}

const char* getServerPathUDP() const noexcept
{
return (const char*)fServerPathUDP;
return fServerPathUDP.getBuffer();
}

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


+ 37
- 12
source/carla_backend.py View File

@@ -155,29 +155,35 @@ ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x4

# Plugin is a bridge.
# This hint is required because "bridge" itself is not a plugin type.
PLUGIN_IS_BRIDGE = 0x01
PLUGIN_IS_BRIDGE = 0x001

# Plugin is hard real-time safe.
PLUGIN_IS_RTSAFE = 0x02
PLUGIN_IS_RTSAFE = 0x002

# Plugin is a synth (produces sound).
PLUGIN_IS_SYNTH = 0x04
PLUGIN_IS_SYNTH = 0x004

# Plugin has its own custom UI.
# @see carla_show_custom_ui()
PLUGIN_HAS_CUSTOM_UI = 0x08
PLUGIN_HAS_CUSTOM_UI = 0x008

# Plugin can use internal Dry/Wet control.
PLUGIN_CAN_DRYWET = 0x10
PLUGIN_CAN_DRYWET = 0x010

# Plugin can use internal Volume control.
PLUGIN_CAN_VOLUME = 0x20
PLUGIN_CAN_VOLUME = 0x020

# Plugin can use internal (Stereo) Balance controls.
PLUGIN_CAN_BALANCE = 0x40
PLUGIN_CAN_BALANCE = 0x040

# Plugin can use internal (Mono) Panning control.
PLUGIN_CAN_PANNING = 0x80
PLUGIN_CAN_PANNING = 0x080

# Plugin needs a constant, fixed-size audio buffer.
PLUGIN_NEEDS_FIXED_BUFFERS = 0x100

# Plugin needs all UI events in a single/main thread.
PLUGIN_NEEDS_SINGLE_THREAD = 0x200

# ------------------------------------------------------------------------------------------------------------
# Plugin Options
@@ -395,6 +401,22 @@ PLUGIN_CATEGORY_UTILITY = 8
# Miscellaneous plugin (used to check if the plugin has a category).
PLUGIN_CATEGORY_OTHER = 9

# ------------------------------------------------------------------------------------------------------------
# Parameter Type
# Plugin parameter type.

# Null parameter type.
PARAMETER_UNKNOWN = 0

# Input parameter.
PARAMETER_INPUT = 1

# Ouput parameter.
PARAMETER_OUTPUT = 2

# Special (hidden) parameter.
PARAMETER_SPECIAL = 3

# ------------------------------------------------------------------------------------------------------------
# Internal Parameter Index
# Special parameters used internally in Carla.
@@ -750,16 +772,19 @@ EngineCallbackFunc = CFUNCTYPE(None, c_void_p, c_enum, c_uint, c_int, c_int, c_f
# Parameter data.
class ParameterData(Structure):
_fields_ = [
# This parameter type.
("type", c_enum),

# This parameter hints.
# @see ParameterHints
("hints", c_uint),

# Index as seen by Carla.
("index", c_int32),

# Real index as seen by plugins.
("rindex", c_int32),

# This parameter hints.
# @see ParameterHints
("hints", c_uint),

# Currently mapped MIDI CC.
# A value lower than 0 means invalid or unused.
# Maximum allowed value is 95 (0x5F).


+ 12
- 11
source/includes/CarlaMIDI.h View File

@@ -21,9 +21,10 @@
#define MAX_MIDI_CHANNELS 16
#define MAX_MIDI_NOTE 128
#define MAX_MIDI_VALUE 128
//#define MAX_MIDI_CTRL 128

#define MIDI_STATUS_BIT 0xF0
#define MIDI_CHANNEL_BIT 0x0F
#define MIDI_STATUS_BIT 0xF0
#define MIDI_CHANNEL_BIT 0x0F

// MIDI Messages List
#define MIDI_STATUS_NOTE_OFF 0x80 // note (0-127), velocity (0-127)
@@ -34,17 +35,17 @@
#define MIDI_STATUS_CHANNEL_PRESSURE 0xD0 // pressure (0-127), none
#define MIDI_STATUS_PITCH_WHEEL_CONTROL 0xE0 // LSB (0-127), MSB (0-127)

#define MIDI_IS_STATUS_NOTE_OFF(status) (((status) < 0xF0) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_NOTE_OFF)
#define MIDI_IS_STATUS_NOTE_ON(status) (((status) < 0xF0) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_NOTE_ON)
#define MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) (((status) < 0xF0) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_POLYPHONIC_AFTERTOUCH)
#define MIDI_IS_STATUS_CONTROL_CHANGE(status) (((status) < 0xF0) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_CONTROL_CHANGE)
#define MIDI_IS_STATUS_PROGRAM_CHANGE(status) (((status) < 0xF0) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_PROGRAM_CHANGE)
#define MIDI_IS_STATUS_CHANNEL_PRESSURE(status) (((status) < 0xF0) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_CHANNEL_PRESSURE)
#define MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) (((status) < 0xF0) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_PITCH_WHEEL_CONTROL)
#define MIDI_IS_STATUS_NOTE_OFF(status) (((status) < MIDI_STATUS_BIT) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_NOTE_OFF)
#define MIDI_IS_STATUS_NOTE_ON(status) (((status) < MIDI_STATUS_BIT) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_NOTE_ON)
#define MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) (((status) < MIDI_STATUS_BIT) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_POLYPHONIC_AFTERTOUCH)
#define MIDI_IS_STATUS_CONTROL_CHANGE(status) (((status) < MIDI_STATUS_BIT) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_CONTROL_CHANGE)
#define MIDI_IS_STATUS_PROGRAM_CHANGE(status) (((status) < MIDI_STATUS_BIT) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_PROGRAM_CHANGE)
#define MIDI_IS_STATUS_CHANNEL_PRESSURE(status) (((status) < MIDI_STATUS_BIT) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_CHANNEL_PRESSURE)
#define MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) (((status) < MIDI_STATUS_BIT) && ((status) & MIDI_STATUS_BIT) == MIDI_STATUS_PITCH_WHEEL_CONTROL)

// MIDI Utils
#define MIDI_GET_STATUS_FROM_DATA(data) ((data[0] < 0xF0) ? data[0] & MIDI_STATUS_BIT : data[0])
#define MIDI_GET_CHANNEL_FROM_DATA(data) ((data[0] < 0xF0) ? data[0] & MIDI_CHANNEL_BIT : 0)
#define MIDI_GET_STATUS_FROM_DATA(data) ((data[0] < MIDI_STATUS_BIT) ? data[0] & MIDI_STATUS_BIT : data[0])
#define MIDI_GET_CHANNEL_FROM_DATA(data) ((data[0] < MIDI_STATUS_BIT) ? data[0] & MIDI_CHANNEL_BIT : 0)

// Control Change Messages List
#define MIDI_CONTROL_BANK_SELECT 0x00 // 0-127, MSB


+ 19
- 0
source/utils/CarlaBackendUtils.hpp View File

@@ -144,6 +144,25 @@ const char* PluginCategory2Str(const PluginCategory category)
return nullptr;
}

static inline
const char* ParameterType2Str(const ParameterType type)
{
switch (type)
{
case PARAMETER_UNKNOWN:
return "PARAMETER_UNKNOWN";
case PARAMETER_INPUT:
return "PARAMETER_INPUT";
case PARAMETER_OUTPUT:
return "PARAMETER_OUTPUT";
case PARAMETER_SPECIAL:
return "PARAMETER_SPECIAL";
}

carla_stderr("CarlaBackend::ParameterType2Str(%i) - invalid type", type);
return nullptr;
}

static inline
const char* InternalParameterIndex2Str(const InternalParameterIndex index)
{


Loading…
Cancel
Save