From c6158ac7526c7be9d29ef25a07b4be7322f5ded3 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 30 Nov 2013 20:34:07 +0000 Subject: [PATCH] Forgot to add files --- source/backend/CarlaBackend.h | 1327 +++++++++++++++++++++++++++++ source/backend/CarlaHost.h | 752 ++++++++++++++++ source/includes/CarlaDefines.h | 230 +++++ source/tests/ansi-pedantic-test.c | 27 + 4 files changed, 2336 insertions(+) create mode 100644 source/backend/CarlaBackend.h create mode 100644 source/backend/CarlaHost.h create mode 100644 source/includes/CarlaDefines.h create mode 100644 source/tests/ansi-pedantic-test.c diff --git a/source/backend/CarlaBackend.h b/source/backend/CarlaBackend.h new file mode 100644 index 000000000..f66106148 --- /dev/null +++ b/source/backend/CarlaBackend.h @@ -0,0 +1,1327 @@ +/* + * Carla Backend API + * Copyright (C) 2011-2013 Filipe Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a full copy of the GNU General Public License see the doc/GPL.txt file. + */ + +#ifndef CARLA_BACKEND_HPP_INCLUDED +#define CARLA_BACKEND_HPP_INCLUDED + +#include "CarlaDefines.h" + +#ifdef CARLA_PROPER_CPP11_SUPPORT +# include +#else +# include +#endif + +#define STR_MAX 0xFF + +#ifdef __cplusplus +# define CARLA_BACKEND_START_NAMESPACE namespace CarlaBackend { +# define CARLA_BACKEND_END_NAMESPACE } +# define CARLA_BACKEND_USE_NAMESPACE using namespace CarlaBackend; +/* Start namespace */ +CARLA_BACKEND_START_NAMESPACE +#endif + +/*! + * @defgroup CarlaBackendAPI Carla Backend API + * + * The Carla Backend API. + * + * These are the base definitions for everything in the Carla backend code. + * @{ + */ + +/*! + * Maximum default number of loadable plugins. + */ +const unsigned int MAX_DEFAULT_PLUGINS = 99; + +/*! + * Maximum number of loadable plugins in rack mode. + */ +const unsigned int MAX_RACK_PLUGINS = 16; + +/*! + * Maximum number of loadable plugins in patchbay mode. + */ +const unsigned int MAX_PATCHBAY_PLUGINS = 255; + +/*! + * Maximum default number of parameters allowed. + * @see ENGINE_OPTION_MAX_PARAMETERS + */ +const unsigned int MAX_DEFAULT_PARAMETERS = 200; + +/*! + * @defgroup EngineDriverHints Engine Driver Device Hints + * + * Various engine driver device hints. + * @see CarlaEngine::getHints(), CarlaEngine::getDriverDeviceInfo() and carla_get_engine_driver_device_info() + * @{ + */ + +/*! + * Engine driver device has custom control-panel. + * @see ENGINE_OPTION_AUDIO_SHOW_CTRL_PANEL + */ +const unsigned int ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL = 0x1; + +/*! + * Engine driver device can change buffer-size on the fly. + */ +const unsigned int ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE = 0x2; + +/*! + * Engine driver device can change sample-rate on the fly. + */ +const unsigned int ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE = 0x4; + +/** @} */ + +/*! + * @defgroup PluginHints Plugin Hints + * + * Various plugin hints. + * @see CarlaPlugin::getHints() and carla_get_plugin_info() + * @{ + */ + +/*! + * Plugin is a bridge. + * This hint is required because "bridge" itself is not a plugin type. + */ +const unsigned int PLUGIN_IS_BRIDGE = 0x01; + +/*! + * Plugin is hard real-time safe. + */ +const unsigned int PLUGIN_IS_RTSAFE = 0x02; + +/*! + * Plugin is a synth (produces sound). + */ +const unsigned int PLUGIN_IS_SYNTH = 0x04; + +/*! + * Plugin has its own custom UI. + * @see CarlaPlugin::showCustomUI() and carla_show_custom_ui() + */ +const unsigned int PLUGIN_HAS_CUSTOM_UI = 0x08; + +/*! + * Plugin can use internal Dry/Wet control. + */ +const unsigned int PLUGIN_CAN_DRYWET = 0x10; + +/*! + * Plugin can use internal Volume control. + */ +const unsigned int PLUGIN_CAN_VOLUME = 0x20; + +/*! + * Plugin can use internal (Stereo) Balance controls. + */ +const unsigned int PLUGIN_CAN_BALANCE = 0x40; + +/*! + * Plugin can use internal (Mono) Panning control. + */ +const unsigned int PLUGIN_CAN_PANNING = 0x80; + +/** @} */ + +/*! + * @defgroup PluginOptions Plugin Options + * + * Various plugin options. + * @see CarlaPlugin::getOptionsAvailable(), CarlaPlugin::getOptionsEnabled() and carla_get_plugin_info() + * @{ + */ + +/*! + * Use constant/fixed-size audio buffers. + */ +const unsigned int PLUGIN_OPTION_FIXED_BUFFERS = 0x001; + +/*! + * Force mono plugin as stereo. + */ +const unsigned int PLUGIN_OPTION_FORCE_STEREO = 0x002; + +/*! + * Map MIDI programs to plugin programs. + */ +const unsigned int PLUGIN_OPTION_MAP_PROGRAM_CHANGES = 0x004; + +/*! + * Use chunks to save and restore data. + */ +const unsigned int PLUGIN_OPTION_USE_CHUNKS = 0x008; + +/*! + * Send MIDI control change events. + */ +const unsigned int PLUGIN_OPTION_SEND_CONTROL_CHANGES = 0x010; + +/*! + * Send MIDI channel pressure events. + */ +const unsigned int PLUGIN_OPTION_SEND_CHANNEL_PRESSURE = 0x020; + +/*! + * Send MIDI note after-touch events. + */ +const unsigned int PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH = 0x040; + +/*! + * Send MIDI pitch-bend events. + */ +const unsigned int PLUGIN_OPTION_SEND_PITCHBEND = 0x080; + +/*! + * Send MIDI all-sounds/notes-off events, single note-offs otherwise. + */ +const unsigned int PLUGIN_OPTION_SEND_ALL_SOUND_OFF = 0x100; + +/** @} */ + +/*! + * @defgroup ParameterHints Parameter Hints + * + * Various parameter hints. + * @see CarlaPlugin::getParameterData() and carla_get_parameter_data() + * @{ + */ + +/*! + * Parameter value is boolean. + * It's always at either minimum or maximum value. + */ +const unsigned int PARAMETER_IS_BOOLEAN = 0x001; + +/*! + * Parameter value is integer. + */ +const unsigned int PARAMETER_IS_INTEGER = 0x002; + +/*! + * Parameter value is logarithmic. + */ +const unsigned int PARAMETER_IS_LOGARITHMIC = 0x004; + +/*! + * Parameter is enabled. + * It can be viewed, changed and stored. + */ +const unsigned int PARAMETER_IS_ENABLED = 0x010; + +/*! + * Parameter is automable (real-time safe). + */ +const unsigned int PARAMETER_IS_AUTOMABLE = 0x020; + +/*! + * Parameter is read-only. + * It cannot be changed. + */ +const unsigned int PARAMETER_IS_READ_ONLY = 0x040; + +/*! + * Parameter needs sample rate to work. + * Value and ranges are multiplied by sample rate on usage and divided by sample rate on save. + */ +const unsigned int PARAMETER_USES_SAMPLERATE = 0x100; + +/*! + * Parameter uses scale points to define internal values in a meaningful way. + */ +const unsigned int PARAMETER_USES_SCALEPOINTS = 0x200; + +/*! + * Parameter uses custom text for displaying its value. + * @see CarlaPlugin::getParameterText() and carla_get_parameter_text() + */ +const unsigned int PARAMETER_USES_CUSTOM_TEXT = 0x400; + +/** @} */ + +/*! + * @defgroup PatchbayPortHints Patchbay Port Hints + * + * Various patchbay port hints. + * @{ + */ + +/*! + * Patchbay port is input. + * When this hint is not set, port is assumed to be output. + */ +const unsigned int PATCHBAY_PORT_IS_INPUT = 0x1; + +/*! + * Patchbay port is of Audio type. + */ +const unsigned int PATCHBAY_PORT_TYPE_AUDIO = 0x2; + +/*! + * Patchbay port is of CV type (Control Voltage). + */ +const unsigned int PATCHBAY_PORT_TYPE_CV = 0x4; + +/*! + * Patchbay port is of MIDI type. + */ +const unsigned int PATCHBAY_PORT_TYPE_MIDI = 0x8; + +/** @} */ + +/*! + * @defgroup CustomDataTypes Custom Data Types + * + * These types define how the @param value in the CustomData struct is stored. + * The types are valid URIs. Any non-string or non-simple type (not integral) is saved in a base64 encoded format. + * @see CustomData + * @{ + */ + +/*! + * Boolean string type URI. + * Only "true" and "false" are valid values. + */ +const char* const CUSTOM_DATA_TYPE_BOOLEAN = "http://kxstudio.sf.net/ns/carla/boolean"; + +/*! + * Chunk type URI. + */ +const char* const CUSTOM_DATA_TYPE_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"; + +/*! + * String type URI. + */ +const char* const CUSTOM_DATA_TYPE_STRING = "http://kxstudio.sf.net/ns/carla/string"; + +/** @} */ + +/*! + * @defgroup CustomDataKeys Custom Data Keys + * + * Pre-defined keys used internally in Carla. + * @see CustomData + * @{ + */ + +/*! + * Plugin options key. + */ +const char* const CUSTOM_DATA_KEY_PLUGIN_OPTIONS = "CarlaPluginOptions"; + +/*! + * UI position key. + */ +const char* const CUSTOM_DATA_KEY_UI_POSITION = "CarlaUiPosition"; + +/*! + * UI size key. + */ +const char* const CUSTOM_DATA_KEY_UI_SIZE = "CarlaUiSize"; + +/*! + * UI visible key. + */ +const char* const CUSTOM_DATA_KEY_UI_VISIBLE = "CarlaUiVisible"; + +/** @} */ + +/*! + * The binary type of a plugin. + */ +typedef enum { + /*! + * Null binary type. + */ + BINARY_NONE = 0, + + /*! + * POSIX 32bit binary. + */ + BINARY_POSIX32 = 1, + + /*! + * POSIX 64bit binary. + */ + BINARY_POSIX64 = 2, + + /*! + * Windows 32bit binary. + */ + BINARY_WIN32 = 3, + + /*! + * Windows 64bit binary. + */ + BINARY_WIN64 = 4, + + /*! + * Other binary type. + */ + BINARY_OTHER = 5 + +} BinaryType; + +/*! + * Plugin type. + * Some files are handled as if they were plugins. + */ +typedef enum { + /*! + * Null plugin type. + */ + PLUGIN_NONE = 0, + + /*! + * Internal plugin. + */ + PLUGIN_INTERNAL = 1, + + /*! + * LADSPA plugin. + */ + PLUGIN_LADSPA = 2, + + /*! + * DSSI plugin. + */ + PLUGIN_DSSI = 3, + + /*! + * LV2 plugin. + */ + PLUGIN_LV2 = 4, + + /*! + * VST plugin. + */ + PLUGIN_VST = 5, + + /*! + * AU plugin. + * @note MacOS only + */ + PLUGIN_AU = 6, + + /*! + * Csound file. + */ + PLUGIN_CSOUND = 7, + + /*! + * GIG file. + */ + PLUGIN_GIG = 8, + + /*! + * SF2 file (also known as SoundFont). + */ + PLUGIN_SF2 = 9, + + /*! + * SFZ file. + */ + PLUGIN_SFZ = 10 + +} PluginType; + +/*! + * Plugin category, which describes the functionality of a plugin. + */ +typedef enum { + /*! + * Null plugin category. + */ + PLUGIN_CATEGORY_NONE = 0, + + /*! + * A synthesizer or generator. + */ + PLUGIN_CATEGORY_SYNTH = 1, + + /*! + * A delay or reverb. + */ + PLUGIN_CATEGORY_DELAY = 2, + + /*! + * An equalizer. + */ + PLUGIN_CATEGORY_EQ = 3, + + /*! + * A filter. + */ + PLUGIN_CATEGORY_FILTER = 4, + + /*! + * A distortion plugin. + */ + PLUGIN_CATEGORY_DISTORTION = 5, + + /*! + * A 'dynamic' plugin (amplifier, compressor, gate, etc). + */ + PLUGIN_CATEGORY_DYNAMICS = 6, + + /*! + * A 'modulator' plugin (chorus, flanger, phaser, etc). + */ + PLUGIN_CATEGORY_MODULATOR = 7, + + /*! + * An 'utility' plugin (analyzer, converter, mixer, etc). + */ + PLUGIN_CATEGORY_UTILITY = 8, + + /*! + * Miscellaneous plugin (used to check if the plugin has a category). + */ + PLUGIN_CATEGORY_OTHER = 9 + +} PluginCategory; + +/*! + * Plugin parameter type. + */ +typedef enum { + /*! + * Unknown parameter type. + */ + PARAMETER_UNKNOWN = 0, + + /*! + * Input parameter. + */ + PARAMETER_INPUT = 1, + + /*! + * Output parameter. + */ + PARAMETER_OUTPUT = 2, + + /*! + * Special parameter. + * Used to report specific information to plugins. + */ + PARAMETER_SPECIAL = 3 + +} ParameterType; + +/*! + * Special parameters used internally in Carla. + * Plugins do not know about their existence. + */ +typedef enum { + /*! + * Null parameter. + */ + PARAMETER_NULL = -1, + + /*! + * Active parameter, boolean type. + * Default is 'false'. + */ + PARAMETER_ACTIVE = -2, + + /*! + * Dry/Wet parameter. + * Range 0.0...1.0; default is 1.0. + */ + PARAMETER_DRYWET = -3, + + /*! + * Volume parameter. + * Range 0.0...1.27; default is 1.0. + */ + PARAMETER_VOLUME = -4, + + /*! + * Stereo Balance-Left parameter. + * Range -1.0...1.0; default is -1.0. + */ + PARAMETER_BALANCE_LEFT = -5, + + /*! + * Stereo Balance-Right parameter. + * Range -1.0...1.0; default is 1.0. + */ + PARAMETER_BALANCE_RIGHT = -6, + + /*! + * Mono Panning parameter. + * Range -1.0...1.0; default is 0.0. + */ + PARAMETER_PANNING = -7, + + /*! + * MIDI Control channel, integer type. + * Range -1...15 (-1 = off). + */ + PARAMETER_CTRL_CHANNEL = -8, + + /*! + * Max value, defined only for convenience. + */ + PARAMETER_MAX = -9 + +} InternalParameterIndex; + +/*! + * Engine callback opcodes.\n + * Front-ends must never block indefinitely during a callback. + * @see EngineCallbackFunc, CarlaEngine::setCallback() and carla_set_engine_callback() + */ +typedef enum { + /*! + * Debug.\n + * This opcode is undefined and used only for testing purposes. + */ + ENGINE_CALLBACK_DEBUG = 0, + + /*! + * A plugin has been added. + * @param pluginId Plugin Id + * @param valueStr Plugin name + */ + ENGINE_CALLBACK_PLUGIN_ADDED = 1, + + /*! + * A plugin has been removed. + * @param pluginId Plugin Id + */ + ENGINE_CALLBACK_PLUGIN_REMOVED = 2, + + /*! + * A plugin has been renamed. + * @param pluginId Plugin Id + * @param valueStr New plugin name + */ + ENGINE_CALLBACK_PLUGIN_RENAMED = 3, + + /*! + * A plugin has become unavailable. + * @param pluginId Plugin Id + * @param valueStr Related error string + */ + ENGINE_CALLBACK_PLUGIN_UNAVAILABLE = 4, + + /*! + * A parameter value has changed. + * @param pluginId Plugin Id + * @param value1 Parameter index + * @param value3 New parameter value + */ + ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED = 5, + + /*! + * A parameter default has changed. + * @param pluginId Plugin Id + * @param value1 Parameter index + * @param value3 New default value + */ + ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED = 6, + + /*! + * A parameter's MIDI CC has changed. + * @param pluginId Plugin Id + * @param value1 Parameter index + * @param value2 New MIDI CC + */ + ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED = 7, + + /*! + * A parameter's MIDI channel has changed. + * @param pluginId Plugin Id + * @param value1 Parameter index + * @param value2 New MIDI channel + */ + ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 8, + + /*! + * The current program of a plugin has changed. + * @param pluginId Plugin Id + * @param value1 New program index + */ + ENGINE_CALLBACK_PROGRAM_CHANGED = 9, + + /*! + * The current MIDI program of a plugin has changed. + * @param pluginId Plugin Id + * @param value1 New MIDI bank + * @param value2 New MIDI program + */ + ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED = 10, + + /*! + * A plugin's custom UI state has changed. + * @param pluginId Plugin Id + * @param value1 New state, as follows:\n + * 0: UI is now hidden\n + * 1: UI is now visible\n + * -1: UI has crashed and should not be shown again + */ + ENGINE_CALLBACK_UI_STATE_CHANGED = 11, + + /*! + * A note has been pressed. + * @param pluginId Plugin Id + * @param value1 Channel + * @param value2 Note + * @param value3 Velocity + */ + ENGINE_CALLBACK_NOTE_ON = 12, + + /*! + * A note has been released. + * @param pluginId Plugin Id + * @param value1 Channel + * @param value2 Note + */ + ENGINE_CALLBACK_NOTE_OFF = 13, + + /*! + * A plugin needs update. + * @param pluginId Plugin Id + */ + ENGINE_CALLBACK_UPDATE = 14, + + /*! + * A plugin's data/information has changed. + * @param pluginId Plugin Id + */ + ENGINE_CALLBACK_RELOAD_INFO = 15, + + /*! + * A plugin's parameters have changed. + * @param pluginId Plugin Id + */ + ENGINE_CALLBACK_RELOAD_PARAMETERS = 16, + + /*! + * A plugin's programs have changed. + * @param pluginId Plugin Id + */ + ENGINE_CALLBACK_RELOAD_PROGRAMS = 17, + + /*! + * A plugin state has changed. + * @param pluginId Plugin Id + */ + ENGINE_CALLBACK_RELOAD_ALL = 18, + + /*! + * A patchbay client has been added. + * @param pluginId Client Id + * @param valueStr Client name and icon, as "name:icon" + */ + ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED = 19, + + /*! + * A patchbay client has been removed. + * @param pluginId Client Id + */ + ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 20, + + /*! + * A patchbay client has been renamed. + * @param pluginId Client Id + * @param valueStr New client name + */ + ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 21, + + /*! + * A patchbay client icon has changed. + * @param pluginId Client Id + * @param valueStr New icon name + */ + ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED = 22, + + /*! + * A patchbay port has been added. + * @param pluginId Client Id + * @param value1 Port Id + * @param value2 Port hints + * @param valueStr Port name + * @see PatchbayPortHints + */ + ENGINE_CALLBACK_PATCHBAY_PORT_ADDED = 23, + + /*! + * A patchbay port has been removed. + * @param pluginId Client Id + * @param value1 Port Id + */ + ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 24, + + /*! + * A patchbay port has been renamed. + * @param pluginId Client Id + * @param value1 Port Id + * @param valueStr New port name + */ + ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25, + + /*! + * A patchbay connection has been added. + * @param value1 Output port Id + * @param value2 Input port Id + */ + ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 26, + + /*! + * A patchbay connection has been removed. + * @param value1 Output port Id + * @param value2 Input port Id + */ + ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 27, + + /*! + * Engine started. + * @param value1 Process mode + * @param value2 Transport mode + * @param valuestr Engine driver + * @see EngineProcessMode + * @see EngineTransportMode + */ + ENGINE_CALLBACK_ENGINE_STARTED = 28, + + /*! + * Engine stopped. + */ + ENGINE_CALLBACK_ENGINE_STOPPED = 29, + + /*! + * Engine process mode has changed. + * @param value1 New process mode + * @see EngineProcessMode + */ + ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 30, + + /*! + * Engine transport mode has changed. + * @param value1 New transport mode + * @see EngineTransportMode + */ + ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 31, + + /*! + * Engine buffer-size changed. + * @param value1 New buffer size + */ + ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 32, + + /*! + * Engine sample-rate changed. + * @param value3 New sample rate + */ + ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 33, + + /*! + * Show a message as information. + * @param valueStr The message + */ + ENGINE_CALLBACK_INFO = 34, + + /*! + * Show a message as an error. + * @param valueStr The message + */ + ENGINE_CALLBACK_ERROR = 35, + + /*! + * The engine has crashed or malfunctioned and will no longer work. + */ + ENGINE_CALLBACK_QUIT = 36 + +} EngineCallbackOpcode; + +/*! + * Engine options. + * @see CarlaEngine::getOptions(), CarlaEngine::setOption() and carla_set_engine_option() + */ +typedef enum { + /*! + * Debug.\n + * This option is undefined and used only for testing purposes. + */ + ENGINE_OPTION_DEBUG = 0, + + /*! + * Set the engine processing mode.\n + * Default is ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS on Linux and ENGINE_PROCESS_MODE_CONTINUOUS_RACK for all other OSes. + * @see EngineProcessMode + */ + ENGINE_OPTION_PROCESS_MODE = 1, + + /*! + * Set the engine transport mode.\n + * Default is ENGINE_TRANSPORT_MODE_JACK on Linux and ENGINE_TRANSPORT_MODE_INTERNAL for all other OSes. + * @see EngineTransportMode + */ + ENGINE_OPTION_TRANSPORT_MODE = 2, + + /*! + * Force mono plugins as stereo, by running 2 instances at the same time.\n + * Default is false, but always true when process mode is ENGINE_PROCESS_MODE_CONTINUOUS_RACK. + * @note Not supported by all plugins + * @see PLUGIN_OPTION_FORCE_STEREO + */ + ENGINE_OPTION_FORCE_STEREO = 3, + + /*! + * Use plugin bridges whenever possible.\n + * Default is no, EXPERIMENTAL. + */ + ENGINE_OPTION_PREFER_PLUGIN_BRIDGES = 4, + + /*! + * Use UI bridges whenever possible, otherwise UIs will be directly handled in the main backend thread.\n + * Default is yes. + */ + ENGINE_OPTION_PREFER_UI_BRIDGES = 5, + + /*! + * Make custom plugin UIs always-on-top.\n + * Default is yes. + */ + ENGINE_OPTION_UIS_ALWAYS_ON_TOP = 6, + + /*! + * Maximum number of parameters allowed.\n + * Default is MAX_DEFAULT_PARAMETERS. + */ + ENGINE_OPTION_MAX_PARAMETERS = 7, + + /*! + * Timeout value for how much to wait for UI bridges to respond, in milliseconds.\n + * Default is 4000 (4 seconds). + */ + ENGINE_OPTION_UI_BRIDGES_TIMEOUT = 8, + + /*! + * Audio number of periods.\n + * Default is 2. + */ + ENGINE_OPTION_AUDIO_NUM_PERIODS = 9, + + /*! + * Audio buffer size.\n + * Default is 512. + */ + ENGINE_OPTION_AUDIO_BUFFER_SIZE = 10, + + /*! + * Audio sample rate.\n + * Default is 44100. + */ + ENGINE_OPTION_AUDIO_SAMPLE_RATE = 11, + + /*! + * Audio device (within a driver).\n + * Default unset. + */ + ENGINE_OPTION_AUDIO_DEVICE = 12, + + /*! + * Set path to the binary files.\n + * Default unset. + * @note Must be set for plugin and UI bridges to work + */ + ENGINE_OPTION_PATH_BINARIES = 13, + + /*! + * Set path to the resource files.\n + * Default unset. + * @note Must be set for some internal plugins to work + */ + ENGINE_OPTION_PATH_RESOURCES = 14 + +} EngineOption; + +/*! + * Engine process mode. + * @see ENGINE_OPTION_PROCESS_MODE + */ +typedef enum { + /*! + * Single client mode.\n + * Inputs and outputs are added as needed by plugins. + */ + ENGINE_PROCESS_MODE_SINGLE_CLIENT = 0, + + /*! + * Multiple client mode.\n + * It has 1 master client + 1 client per plugin. + */ + ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS = 1, + + /*! + * Single client, 'rack' mode.\n + * Processes plugins in order of Id, with forced stereo. + */ + ENGINE_PROCESS_MODE_CONTINUOUS_RACK = 2, + + /*! + * Single client, 'patchbay' mode. + */ + ENGINE_PROCESS_MODE_PATCHBAY = 3, + + /*! + * Special mode, used in plugin-bridges only. + */ + ENGINE_PROCESS_MODE_BRIDGE = 4 + +} EngineProcessMode; + +/*! + * All the available transport modes + * @see ENGINE_OPTION_TRANSPORT_MODE + */ +typedef enum { + /*! + * Internal transport mode. + */ + ENGINE_TRANSPORT_MODE_INTERNAL = 0, + + /*! + * Transport from JACK, only available if driver name is "JACK". + */ + ENGINE_TRANSPORT_MODE_JACK = 1, + + /*! + * Transport from host, used when Carla is a plugin. + */ + ENGINE_TRANSPORT_MODE_PLUGIN = 2, + + /*! + * Special mode, used in plugin-bridges only. + */ + ENGINE_TRANSPORT_MODE_BRIDGE = 3 + +} EngineTransportMode; + +/*! + * Opcodes sent from the backend to the frontend, asking for file related tasks. + * Front-end MUST always block-wait for user input. + */ +typedef enum { + /*! + * Debug. + * This opcode is undefined and used only for testing purposes. + */ + FILE_CALLBACK_DEBUG = 0, + + /*! + * Open file or folder. + */ + FILE_CALLBACK_OPEN = 1, + + /*! + * Save file or folder. + */ + FILE_CALLBACK_SAVE = 2 + +} FileCallbackOpcode; + +/*! + * Engine callback function. + * @see EngineCallbackType + */ +typedef void (*EngineCallbackFunc)(void* ptr, EngineCallbackOpcode action, unsigned int pluginId, int value1, int value2, float value3, const char* valueStr); + +/*! + * File callback function. + * @see FileCallbackType + */ +typedef const char* (*FileCallbackFunc)(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter); + +/*! + * Parameter data. + */ +typedef struct _ParameterData { + /*! + * + */ + ParameterType type; + + /*! + * + */ + int32_t index; + + /*! + * + */ + int32_t rindex; + + /*! + * + */ + unsigned int hints; + + /*! + * + */ + uint8_t midiChannel; + + /*! + * + */ + int16_t midiCC; + +#ifdef __cplusplus + /*! + * + */ + _ParameterData() noexcept + : type(PARAMETER_UNKNOWN), + index(PARAMETER_NULL), + rindex(-1), + hints(0x0), + midiChannel(0), + midiCC(-1) {} +#endif +} ParameterData; + +/*! + * Parameter ranges. + */ +typedef struct _ParameterRanges { + /*! + * Default value. + */ + float def; + + /*! + * Minimum value. + */ + float min; + + /*! + * Maximum value. + */ + float max; + + /*! + * Regular step value. + */ + float step; + + /*! + * Small step value. + */ + float stepSmall; + + /*! + * Large step value. + */ + float stepLarge; + +#ifdef __cplusplus + /*! + * + */ + _ParameterRanges() noexcept + : def(0.0f), + min(0.0f), + max(1.0f), + step(0.01f), + stepSmall(0.0001f), + stepLarge(0.1f) {} + + /*! + * Fix default value range. + */ + void fixDefault() noexcept + { + fixValue(def); + } + + /*! + * Fix a value within range. + */ + void fixValue(float& value) const noexcept + { + if (value <= min) + value = min; + else if (value > max) + value = max; + } + + /*! + * + */ + float getFixedValue(const float& value) const noexcept + { + if (value <= min) + return min; + if (value >= max) + return max; + return value; + } + + /*! + * Get a value normalized to 0.0<->1.0. + */ + float getNormalizedValue(const float& value) const noexcept + { + const float normValue((value - min) / (max - min)); + + if (normValue <= 0.0f) + return 0.0f; + if (normValue >= 1.0f) + return 1.0f; + return normValue; + } + + /*! + * Get a value normalized to 0.0<->1.0, but fix range first. + */ + float getFixedAndNormalizedValue(const float& value) const noexcept + { + if (value <= min) + return 0.0f; + if (value >= max) + return 1.0f; + + const float normValue((value - min) / (max - min)); + + if (normValue <= 0.0f) + return 0.0f; + if (normValue >= 1.0f) + return 1.0f; + + return normValue; + } + + /*! + * Get a proper value previously normalized to 0.0<->1.0. + */ + float getUnnormalizedValue(const float& value) const noexcept + { + return value * (max - min) + min; + } +#endif +} ParameterRanges; + +/*! + * MIDI Program data. + */ +typedef struct _MidiProgramData { + /*! + * + */ + uint32_t bank; + + /*! + * + */ + uint32_t program; + + /*! + * + */ + const char* name; + +#ifdef __cplusplus + /*! + * + */ + _MidiProgramData() noexcept + : bank(0), + program(0), + name(nullptr) {} +#endif +} MidiProgramData; + +/*! + * Custom data, for saving key:value 'dictionaries'. + */ +typedef struct _CustomData { + /*! + * Value type, in URI form. + * @see CustomDataTypes + */ + const char* type; + + /*! + * Key. + * @see CustomDataKeys + */ + const char* key; + + /*! + * Value. + */ + const char* value; + +#ifdef __cplusplus + _CustomData() noexcept + : type(nullptr), + key(nullptr), + value(nullptr) {} +#endif +} CustomData; + +/*! + * Engine driver device information. + */ +typedef struct _EngineDriverDeviceInfo { + /*! + * + */ + unsigned int hints; + + /*! + * + */ + const uint32_t* bufferSizes; // terminated with 0 + + /*! + * + */ + const double* sampleRates; // terminated with 0.0 + +#ifdef __cplusplus + /*! + * + */ + _EngineDriverDeviceInfo() + : hints(0x0), + bufferSizes(nullptr), + sampleRates(nullptr) {} +#endif +} EngineDriverDeviceInfo; + +/** @} */ + +#ifdef __cplusplus +/* Forward declarations of commonly used Carla classes */ +class CarlaEngine; +class CarlaPlugin; +/* End namespace */ +CARLA_BACKEND_END_NAMESPACE +#endif + +#endif /* CARLA_BACKEND_HPP_INCLUDED */ diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h new file mode 100644 index 000000000..67c419231 --- /dev/null +++ b/source/backend/CarlaHost.h @@ -0,0 +1,752 @@ +/* + * Carla Host API + * Copyright (C) 2011-2013 Filipe Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a full copy of the GNU General Public License see the doc/GPL.txt file. + */ + +#ifndef CARLA_HOST_HPP_INCLUDED +#define CARLA_HOST_HPP_INCLUDED + +#include "CarlaBackend.hpp" + +/*! + * @defgroup CarlaHostAPI Carla Host API + * + * The Carla Host API. + * + * This API makes it possible to use the Carla Backend in a Host application.\n + * All functions are C-compatible, making it possible to use this API in non-C++ hosts. + * + * None of the returned values in this API calls need to be deleted or free'd.\n + * When a function fails (returns false or NULL), use carla_get_last_error() to find out what went wrong. + * + * @{ + */ + +/*! + * @defgroup HelperTypedefs Helper typedefs + * + * Basic typedefs to help make code cleaner. + * @{ + */ +typedef CarlaBackend::BinaryType CarlaBinaryType; +typedef CarlaBackend::PluginType CarlaPluginType; +typedef CarlaBackend::PluginCategory CarlaPluginCategory; +typedef CarlaBackend::EngineCallbackFunc CarlaEngineCallbackFunc; +typedef CarlaBackend::EngineCallbackOpcode CarlaEngineCallbackOpcode; +typedef CarlaBackend::EngineOption CarlaEngineOption; +typedef CarlaBackend::FileCallbackFunc CarlaFileCallbackFunc; +typedef CarlaBackend::FileCallbackOpcode CarlaFileCallbackOpcode; +typedef CarlaBackend::ParameterData CarlaParameterData; +typedef CarlaBackend::ParameterRanges CarlaParameterRanges; +typedef CarlaBackend::MidiProgramData CarlaMidiProgramData; +typedef CarlaBackend::CustomData CarlaCustomData; +typedef CarlaBackend::EngineDriverDeviceInfo CarlaEngineDriverDeviceInfo; +/**@}*/ + +/*! + * Plugin information. + * \see carla_get_plugin_info() + */ +struct CarlaPluginInfo { + CarlaPluginType type; + CarlaPluginCategory category; + unsigned int hints; + unsigned int optionsAvailable; + unsigned int optionsEnabled; + const char* binary; + const char* name; + const char* label; + const char* maker; + const char* copyright; + const char* iconName; + int patchbayClientId; + long uniqueId; + +#ifndef DOXYGEN + CarlaPluginInfo() + : type(CarlaBackend::PLUGIN_NONE), + category(CarlaBackend::PLUGIN_CATEGORY_NONE), + hints(0x0), + optionsAvailable(0x0), + optionsEnabled(0x0), + binary(nullptr), + name(nullptr), + label(nullptr), + maker(nullptr), + copyright(nullptr), + iconName(nullptr), + patchbayClientId(0), + uniqueId(0) {} + + ~CarlaPluginInfo() + { + if (label != nullptr) + { + delete[] label; + label = nullptr; + } + if (maker != nullptr) + { + delete[] maker; + maker = nullptr; + } + if (copyright != nullptr) + { + delete[] copyright; + copyright = nullptr; + } + } +#endif +}; + +/*! + * Native plugin information. + * \see carla_get_internal_plugin_info() + */ +struct CarlaNativePluginInfo { + CarlaPluginCategory category; + unsigned int hints; + uint32_t audioIns; + uint32_t audioOuts; + uint32_t midiIns; + uint32_t midiOuts; + uint32_t parameterIns; + uint32_t parameterOuts; + const char* name; + const char* label; + const char* maker; + const char* copyright; + +#ifndef DOXYGEN + CarlaNativePluginInfo() + : category(CarlaBackend::PLUGIN_CATEGORY_NONE), + hints(0x0), + audioIns(0), + audioOuts(0), + midiIns(0), + midiOuts(0), + parameterIns(0), + parameterOuts(0), + name(nullptr), + label(nullptr), + maker(nullptr), + copyright(nullptr) {} +#endif +}; + +/*! + * Port count information, used for Audio and MIDI ports and parameters. + * \see carla_get_audio_port_count_info() + * \see carla_get_midi_port_count_info() + * \see carla_get_parameter_count_info() + */ +struct CarlaPortCountInfo { + uint32_t ins; + uint32_t outs; + uint32_t total; + +#ifndef DOXYGEN + CarlaPortCountInfo() + : ins(0), + outs(0), + total(0) {} +#endif +}; + +/*! + * Parameter information. + * \see carla_get_parameter_info() + */ +struct CarlaParameterInfo { + const char* name; + const char* symbol; + const char* unit; + uint32_t scalePointCount; + +#ifndef DOXYGEN + CarlaParameterInfo() + : name(nullptr), + symbol(nullptr), + unit(nullptr), + scalePointCount(0) {} + + ~CarlaParameterInfo() + { + if (name != nullptr) + { + delete[] name; + name = nullptr; + } + if (symbol != nullptr) + { + delete[] symbol; + symbol = nullptr; + } + if (unit != nullptr) + { + delete[] unit; + unit = nullptr; + } + } +#endif +}; + +/*! + * Parameter scale point information. + * \see carla_get_parameter_scalepoint_info() + */ +struct CarlaScalePointInfo { + float value; + const char* label; + +#ifndef DOXYGEN + CarlaScalePointInfo() + : value(0.0f), + label(nullptr) {} + + ~CarlaScalePointInfo() + { + if (label != nullptr) + { + delete[] label; + label = nullptr; + } + } +#endif +}; + +/*! + * Transport information. + * \see carla_get_transport_info() + */ +struct CarlaTransportInfo { + bool playing; + uint64_t frame; + int32_t bar; + int32_t beat; + int32_t tick; + double bpm; + +#ifndef DOXYGEN + CarlaTransportInfo() + : playing(false), + frame(0), + bar(0), + beat(0), + tick(0), + bpm(0.0) {} +#endif +}; + +/*! + * Get the complete license text of used third-party code and features.\n + * Returned string is in basic html format. + */ +CARLA_EXPORT const char* carla_get_extended_license_text(); + +/*! + * Get the supported file types in carla_load_filename().\n + * Returned string uses this syntax: + * \code + * "*.ext1;*.ext2;*.ext3" + * \endcode + */ +CARLA_EXPORT const char* carla_get_supported_file_types(); + +/*! + * Get how many engine drivers are available to use. + */ +CARLA_EXPORT unsigned int carla_get_engine_driver_count(); + +/*! + * Get the engine driver info for \a index. + */ +CARLA_EXPORT const char* carla_get_engine_driver_name(unsigned int index); + +/*! + * Get the device names of the engine driver at \a index. + */ +CARLA_EXPORT const char* const* carla_get_engine_driver_device_names(unsigned int index); + +/*! + * Get a device driver info. + */ +CARLA_EXPORT const CarlaEngineDriverDeviceInfo* carla_get_engine_driver_device_info(unsigned int index, const char* driverName); + +/*! + * Get how many internal plugins are available to use. + */ +CARLA_EXPORT unsigned int carla_get_internal_plugin_count(); + +/*! + * Get information about the internal plugin \a internalPluginId. + */ +CARLA_EXPORT const CarlaNativePluginInfo* carla_get_internal_plugin_info(unsigned int internalPluginId); + +/*! + * Initialize the engine with driver \a driverName, using \a clientName for its internal name.\n + * Make sure to call carla_engine_idle() at regular intervals afterwards. + */ +CARLA_EXPORT bool carla_engine_init(const char* driverName, const char* clientName); + +#ifdef BUILD_BRIDGE +/*! + * Initialize the engine in bridged mode. + */ +CARLA_EXPORT bool carla_engine_init_bridge(const char* audioBaseName, const char* controlBaseName, const char* clientName); +#endif + +/*! + * Close the running engine.\n + * This function always closes the engine even if it returns false.\n + * When false is returned, something went wrong when closing the engine, but it was still closed nonetheless. + */ +CARLA_EXPORT bool carla_engine_close(); + +/*! + * Idle the running engine.\n + * \note This should never be called if the engine is not running. + */ +CARLA_EXPORT void carla_engine_idle(); + +/*! + * Check if the engine is running. + */ +CARLA_EXPORT bool carla_is_engine_running(); + +/*! + * Tell the engine it's about to close.\n + * This is used to prevent the engine thread(s) from reactivating. + */ +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. + */ +CARLA_EXPORT void carla_set_engine_callback(CarlaEngineCallbackFunc func, void* ptr); + +/*! + * 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. + */ +CARLA_EXPORT void carla_set_engine_option(CarlaEngineOption option, int value, const char* valueStr); + +/*! + * Set the file callback function to \a func. + * Use \a ptr to pass a custom pointer to the callback. + */ +CARLA_EXPORT void carla_set_file_callback(CarlaFileCallbackFunc func, void* ptr); + +/*! + * Load \a filename of any type.\n + * 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() + */ +CARLA_EXPORT bool carla_load_filename(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. + */ +CARLA_EXPORT bool carla_load_project(const char* filename); + +/*! + * Save current project to \a filename.\n + * (project files have *.carxp extension) + */ +CARLA_EXPORT bool carla_save_project(const char* filename); + +/*! + * Connect patchbay ports \a portA and \a portB. + */ +CARLA_EXPORT bool carla_patchbay_connect(int portA, int portB); + +/*! + * Disconnect patchbay connection \a connectionId. + */ +CARLA_EXPORT bool carla_patchbay_disconnect(int connectionId); + +/*! + * Force the engine to resend all patchbay clients, ports and connections again. + */ +CARLA_EXPORT bool carla_patchbay_refresh(); + +/*! + * Start playback of the engine transport. + */ +CARLA_EXPORT void carla_transport_play(); + +/*! + * Pause the engine transport. + */ +CARLA_EXPORT void carla_transport_pause(); + +/*! + * Relocate the engine transport to \a frames. + */ +CARLA_EXPORT void carla_transport_relocate(uint32_t frames); + +/*! + * Get the current transport frame. + */ +CARLA_EXPORT uint64_t carla_get_current_transport_frame(); + +/*! + * Get the engine transport information. + */ +CARLA_EXPORT const CarlaTransportInfo* carla_get_transport_info(); + +/*! + * Add new plugin.\n + * If you don't know the binary type, use BINARY_NATIVE. + */ +CARLA_EXPORT bool carla_add_plugin(CarlaBinaryType btype, CarlaPluginType ptype, const char* filename, const char* name, const char* label, const void* extraPtr); + +/*! + * Remove plugin with id \a pluginId. + */ +CARLA_EXPORT bool carla_remove_plugin(unsigned int pluginId); + +/*! + * Remove all plugins. + */ +CARLA_EXPORT bool carla_remove_all_plugins(); + +/*! + * Rename plugin with id \a pluginId to \a newName. \n + * Returns the new name, or NULL if the operation failed. + */ +CARLA_EXPORT const char* carla_rename_plugin(unsigned int pluginId, const char* newName); + +/*! + * Clone plugin with id \a pluginId. + */ +CARLA_EXPORT bool carla_clone_plugin(unsigned int pluginId); + +/*! + * Prepare replace of plugin with id \a pluginId. \n + * The next call to carla_add_plugin() will use this id, replacing the current plugin. + * \note This function requires carla_add_plugin() to be called afterwards as soon as possible. + */ +CARLA_EXPORT bool carla_replace_plugin(unsigned int pluginId); + +/*! + * Switch plugins with id \a pluginIdA and \a pluginIdB. + */ +CARLA_EXPORT bool carla_switch_plugins(unsigned int pluginIdA, unsigned int pluginIdB); + +/*! + * Load the plugin state at \a filename.\n + * (Plugin states have *.carxs extension). + * \see carla_save_plugin_state() + */ +CARLA_EXPORT bool carla_load_plugin_state(unsigned int pluginId, const char* filename); + +/*! + * Load the plugin state at \a filename.\n + * (Plugin states have *.carxs extension). + * \see carla_load_plugin_state() + */ +CARLA_EXPORT bool carla_save_plugin_state(unsigned int pluginId, const char* filename); + +/*! + * Get a plugin's information. + */ +CARLA_EXPORT const CarlaPluginInfo* carla_get_plugin_info(unsigned int pluginId); + +/*! + * Get a plugin's audio port count information. + */ +CARLA_EXPORT const CarlaPortCountInfo* carla_get_audio_port_count_info(unsigned int pluginId); + +/*! + * Get a plugin's midi port count information. + */ +CARLA_EXPORT const CarlaPortCountInfo* carla_get_midi_port_count_info(unsigned int pluginId); + +/*! + * Get a plugin's parameter count information. + */ +CARLA_EXPORT const CarlaPortCountInfo* carla_get_parameter_count_info(unsigned int pluginId); + +/*! + * * Get a plugin's parameter information. + */ +CARLA_EXPORT const CarlaParameterInfo* carla_get_parameter_info(unsigned int pluginId, uint32_t parameterId); + +/*! + * Get a plugin's parameter scale point information. + */ +CARLA_EXPORT const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(unsigned int pluginId, uint32_t parameterId, uint32_t scalePointId); + +/*! + * Get a plugin's parameter data. + */ +CARLA_EXPORT const CarlaParameterData* carla_get_parameter_data(unsigned int pluginId, uint32_t parameterId); + +/*! + * Get a plugin's parameter ranges. + */ +CARLA_EXPORT const CarlaParameterRanges* carla_get_parameter_ranges(unsigned int pluginId, uint32_t parameterId); + +/*! + * Get a plugin's midi program data. + */ +CARLA_EXPORT const CarlaMidiProgramData* carla_get_midi_program_data(unsigned int pluginId, uint32_t midiProgramId); + +/*! + * Get a plugin's custom data. + */ +CARLA_EXPORT const CarlaCustomData* carla_get_custom_data(unsigned int pluginId, uint32_t customDataId); + +/*! + * Get a plugin's chunk data. + */ +CARLA_EXPORT const char* carla_get_chunk_data(unsigned int pluginId); + +/*! + * Get how many parameters a plugin has. + */ +CARLA_EXPORT uint32_t carla_get_parameter_count(unsigned int pluginId); + +/*! + * Get how many programs a plugin has. + */ +CARLA_EXPORT uint32_t carla_get_program_count(unsigned int pluginId); + +/*! + * Get how many midi programs a plugin has. + */ +CARLA_EXPORT uint32_t carla_get_midi_program_count(unsigned int pluginId); + +/*! + * Get how many custom data sets a plugin has. + * \see carla_prepare_for_save() + */ +CARLA_EXPORT uint32_t carla_get_custom_data_count(unsigned int pluginId); + +/*! + * Get a plugin's custom parameter text display. + * \see PARAMETER_USES_CUSTOM_TEXT + */ +CARLA_EXPORT const char* carla_get_parameter_text(unsigned int pluginId, uint32_t parameterId); + +/*! + * Get a plugin's program name. + */ +CARLA_EXPORT const char* carla_get_program_name(unsigned int pluginId, uint32_t programId); + +/*! + * Get a plugin's midi program name. + */ +CARLA_EXPORT const char* carla_get_midi_program_name(unsigned int pluginId, uint32_t midiProgramId); + +/*! + * Get the plugin's real name.\n + * This is the name the plugin uses to identify itself; may not be unique. + */ +CARLA_EXPORT const char* carla_get_real_plugin_name(unsigned int pluginId); + +/*! + * Get the current plugin's program index. + */ +CARLA_EXPORT int32_t carla_get_current_program_index(unsigned int pluginId); + +/*! + * Get the current plugin's midi program index. + */ +CARLA_EXPORT int32_t carla_get_current_midi_program_index(unsigned int pluginId); + +/*! + * Get a plugin's default parameter value. + */ +CARLA_EXPORT float carla_get_default_parameter_value(unsigned int pluginId, uint32_t parameterId); + +/*! + * Get a plugin's current parameter value. + */ +CARLA_EXPORT float carla_get_current_parameter_value(unsigned int pluginId, uint32_t parameterId); + +/*! + * Get a plugin's input peak value.\n + * \a portId must only be either 1 or 2 + */ +CARLA_EXPORT float carla_get_input_peak_value(unsigned int pluginId, unsigned short portId); + +/*! + * Get a plugin's output peak value.\n + * \a portId must only be either 1 or 2 + */ +CARLA_EXPORT float carla_get_output_peak_value(unsigned int pluginId, unsigned short portId); + +/*! + * Enable a plugin's option. + * \see PluginOptions + */ +CARLA_EXPORT void carla_set_option(unsigned int pluginId, unsigned int option, bool yesNo); + +/*! + * Enable or disable a plugin according to \a onOff. + */ +CARLA_EXPORT void carla_set_active(unsigned int pluginId, bool onOff); + +#ifndef BUILD_BRIDGE +/*! + * Change a plugin's internal drywet value to \a value. + */ +CARLA_EXPORT void carla_set_drywet(unsigned int pluginId, float value); + +/*! + * Change a plugin's internal volume value to \a value. + */ +CARLA_EXPORT void carla_set_volume(unsigned int pluginId, float value); + +/*! + * Change a plugin's internal balance-left value to \a value. + */ +CARLA_EXPORT void carla_set_balance_left(unsigned int pluginId, float value); + +/*! + * Change a plugin's internal balance-right value to \a value. + */ +CARLA_EXPORT void carla_set_balance_right(unsigned int pluginId, float value); + +/*! + * Change a plugin's internal panning value to \a value. + */ +CARLA_EXPORT void carla_set_panning(unsigned int pluginId, float value); +#endif + +/*! + * Change a plugin's internal control channel to \a channel. + */ +CARLA_EXPORT void carla_set_ctrl_channel(unsigned int pluginId, int8_t channel); + +/*! + * Set the plugin's parameter \a parameterId to \a value. + */ +CARLA_EXPORT void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, float value); + +#ifndef BUILD_BRIDGE +/*! + * Set the plugin's parameter \a parameterId midi channel to \a channel. + */ +CARLA_EXPORT void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterId, uint8_t channel); + +/*! + * Set the plugin's parameter \a parameterId midi cc to \a cc. + */ +CARLA_EXPORT void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, int16_t cc); +#endif + +/*! + * Change a plugin's program to \a programId. + */ +CARLA_EXPORT void carla_set_program(unsigned int pluginId, uint32_t programId); + +/*! + * Change a plugin's midi program to \a midiProgramId. + */ +CARLA_EXPORT void carla_set_midi_program(unsigned int pluginId, uint32_t midiProgramId); + +/*! + * Set a plugin's custom data set. + */ +CARLA_EXPORT void carla_set_custom_data(unsigned int pluginId, const char* type, const char* key, const char* value); + +/*! + * Set a plugin's chunk data. + */ +CARLA_EXPORT void carla_set_chunk_data(unsigned int pluginId, const char* chunkData); + +/*! + * Tell a plugin to prepare for save.\n + * This should be called before carla_get_custom_data_count(). + */ +CARLA_EXPORT void carla_prepare_for_save(unsigned int pluginId); + +#ifndef BUILD_BRIDGE +/*! + * Send a single note of a plugin.\n + * If \a note if 0, note-off is sent; note-on otherwise. + */ +CARLA_EXPORT void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity); +#endif + +/*! + * Tell a plugin to show its own custom UI. + * \see PLUGIN_HAS_CUSTOM_UI + */ +CARLA_EXPORT void carla_show_custom_ui(unsigned int pluginId, bool yesNo); + +/*! + * Get the current engine buffer size. + */ +CARLA_EXPORT uint32_t carla_get_buffer_size(); + +/*! + * Get the current engine sample rate. + */ +CARLA_EXPORT double carla_get_sample_rate(); + +/*! + * Get the last error. + */ +CARLA_EXPORT const char* carla_get_last_error(); + +/*! + * Get the current engine OSC URL (TCP). + */ +CARLA_EXPORT const char* carla_get_host_osc_url_tcp(); + +/*! + * Get the current engine OSC URL (UDP). + */ +CARLA_EXPORT const char* carla_get_host_osc_url_udp(); + +/*! + * Send NSM announce message. + */ +CARLA_EXPORT void carla_nsm_announce(const char* url, const char* appName, int pid); + +/*! + * Ready for handling NSM messages. + */ +CARLA_EXPORT void carla_nsm_ready(); + +/*! + * Reply to NSM open message. + * \see CALLBACK_NSM_OPEN + */ +CARLA_EXPORT void carla_nsm_reply_open(); + +/*! + * Reply to NSM save message. + * \see CALLBACK_NSM_SAVE + */ +CARLA_EXPORT void carla_nsm_reply_save(); + +#ifdef BUILD_BRIDGE +using CarlaBackend::CarlaEngine; +CARLA_EXPORT CarlaEngine* carla_get_standalone_engine(); +#endif + +/**@}*/ + +#endif // CARLA_HOST_HPP_INCLUDED diff --git a/source/includes/CarlaDefines.h b/source/includes/CarlaDefines.h new file mode 100644 index 000000000..0aa08b308 --- /dev/null +++ b/source/includes/CarlaDefines.h @@ -0,0 +1,230 @@ +/* + * Carla common defines + * Copyright (C) 2011-2013 Filipe Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a full copy of the GNU General Public License see the doc/GPL.txt file. + */ + +#ifndef CARLA_DEFINES_HPP_INCLUDED +#define CARLA_DEFINES_HPP_INCLUDED + +/* IDE Helper */ +#ifndef REAL_BUILD +# include "config.h" +#endif + +/* Set Version */ +#define CARLA_VERSION_HEX 0x01091 +#define CARLA_VERSION_STRING "1.9.1" + +/* Check OS */ +#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) +# define CARLA_OS_WIN64 +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +# define CARLA_OS_WIN32 +#elif defined(__APPLE__) +# define CARLA_OS_MAC +#elif defined(__HAIKU__) +# define CARLA_OS_HAIKU +#elif defined(__linux__) || defined(__linux) +# define CARLA_OS_LINUX +#else +# warning Unsupported platform! +#endif + +#if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64) +# define CARLA_OS_WIN +#elif ! defined(CARLA_OS_HAIKU) +# define CARLA_OS_UNIX +#endif + +/* Check for C++11 support */ +#if defined(HAVE_CPP11_SUPPORT) +# define CARLA_PROPER_CPP11_SUPPORT +#elif defined(__GNUC__) && defined(__cplusplus) +# if (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 +# define CARLA_PROPER_CPP11_SUPPORT +# if (__GNUC__ * 100 + __GNUC_MINOR__) < 407 +# define override // gcc4.7+ only +# define final // gcc4.7+ only +# endif +# endif +#endif + +#if defined(__cplusplus) && !defined(CARLA_PROPER_CPP11_SUPPORT) +# define override +# define final +# define noexcept throw() +# define nullptr (0) +#endif + +/* Common includes */ +#ifdef CARLA_OS_WIN +# include +# include +#else +# include +# ifndef __cdecl +# define __cdecl +# endif +#endif + +#ifndef __cplusplus +# include +#endif + +/* Define various string format types */ +#if defined(CARLA_OS_WIN64) +# define P_INT64 "%I64i" +# define P_INTPTR "%I64i" +# define P_UINTPTR "%I64x" +# define P_SIZE "%I64u" +#elif defined(CARLA_OS_WIN32) +# define P_INT64 "%I64i" +# define P_INTPTR "%i" +# define P_UINTPTR "%x" +# define P_SIZE "%u" +#elif __WORDSIZE == 64 +# define P_INT64 "%li" +# define P_INTPTR "%li" +# define P_UINTPTR "%lx" +# define P_SIZE "%lu" +#else +# define P_INT64 "%lli" +# define P_INTPTR "%i" +# define P_UINTPTR "%x" +# define P_SIZE "%u" +#endif + +/* Define BINARY_NATIVE */ +#if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX) +# if defined (__LP64__) || defined (_LP64) +# define BINARY_NATIVE BINARY_POSIX64 +# else +# define BINARY_NATIVE BINARY_POSIX32 +# endif +#elif defined(CARLA_OS_WIN) +# ifdef CARLA_OS_WIN64 +# define BINARY_NATIVE BINARY_WIN64 +# else +# define BINARY_NATIVE BINARY_WIN32 +# endif +#else +# warning Unknown binary native +# define BINARY_NATIVE BINARY_OTHER +#endif + +/* Define CARLA_ASSERT* */ +#if defined(CARLA_NO_ASSERTS) +# define CARLA_ASSERT(cond) +# define CARLA_ASSERT_INT(cond, value) +# define CARLA_ASSERT_INT2(cond, v1, v2) +#elif defined(NDEBUG) +# define CARLA_ASSERT CARLA_SAFE_ASSERT +# define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT +# define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2 +#else +# define CARLA_ASSERT(cond) assert(cond) +# define CARLA_ASSERT_INT(cond, value) assert(cond) +# define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond) +#endif + +/* Define CARLA_SAFE_ASSERT* */ +#define CARLA_SAFE_ASSERT(cond) if (cond) pass(); else carla_safe_assert (#cond, __FILE__, __LINE__); +#define CARLA_SAFE_ASSERT_INT(cond, value) if (cond) pass(); else carla_safe_assert_int (#cond, __FILE__, __LINE__, value); +#define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (cond) pass(); else carla_safe_assert_int2(#cond, __FILE__, __LINE__, v1, v2); + +#define CARLA_SAFE_ASSERT_BREAK(cond) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); break; } +#define CARLA_SAFE_ASSERT_CONTINUE(cond) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); continue; } +#define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); return ret; } + +/* Define CARLA_DECLARE_NON_COPY_CLASS */ +#ifdef CARLA_PROPER_CPP11_SUPPORT +# define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \ +private: \ + ClassName(ClassName&) = delete; \ + ClassName(const ClassName&) = delete; \ + ClassName& operator=(ClassName&) = delete; \ + ClassName& operator=(const ClassName&) = delete; +#else +# define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \ +private: \ + ClassName(ClassName&); \ + ClassName(const ClassName&); \ + ClassName& operator=(ClassName&); \ + ClassName& operator=(const ClassName&); +#endif + +/* Define CARLA_DECLARE_NON_COPY_STRUCT */ +#ifdef CARLA_PROPER_CPP11_SUPPORT +# define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \ + StructName(StructName&) = delete; \ + StructName(const StructName&) = delete; \ + StructName& operator=(StructName&) = delete; \ + StructName& operator=(const StructName&) = delete; +#else +# define CARLA_DECLARE_NON_COPY_STRUCT(StructName) +#endif + +/* Define CARLA_PREVENT_HEAP_ALLOCATION */ +#ifdef CARLA_PROPER_CPP11_SUPPORT +# define CARLA_PREVENT_HEAP_ALLOCATION \ +private: \ + static void* operator new(size_t) = delete; \ + static void operator delete(void*) = delete; +#else +# define CARLA_PREVENT_HEAP_ALLOCATION \ +private: \ + static void* operator new(size_t); \ + static void operator delete(void*); +#endif + +/* Define CARLA_EXPORT */ +#ifdef BUILD_BRIDGE +# define CARLA_EXPORT extern "C" +#else +# if defined(CARLA_OS_WIN) && ! defined(__WINE__) +# define CARLA_EXPORT extern "C" __declspec (dllexport) +# else +# define CARLA_EXPORT extern "C" __attribute__ ((visibility("default"))) +# endif +#endif + +/* Define PRE/POST_PACKED_STRUCTURE */ +#if defined(__GNUC__) +# define PRE_PACKED_STRUCTURE +# define POST_PACKED_STRUCTURE __attribute__((__packed__)) +#elif defined(_MSC_VER) +# define PRE_PACKED_STRUCTURE1 __pragma(pack(push,1)) +# define PRE_PACKED_STRUCTURE PRE_PACKED_STRUCTURE1 +# define POST_PACKED_STRUCTURE ;__pragma(pack(pop)) +#else +# define PRE_PACKED_STRUCTURE +# define POST_PACKED_STRUCTURE +#endif + +/* Define OS_SEP */ +#ifdef CARLA_OS_WIN +# define OS_SEP '\\' +# define OS_SEP_STR "\\" +#else +# define OS_SEP '/' +# define OS_SEP_STR "/" +#endif + +/* Useful typedefs */ +typedef unsigned long int ulong; +typedef unsigned short int ushort; +typedef unsigned int uint; + +#endif /* CARLA_DEFINES_HPP_INCLUDED */ diff --git a/source/tests/ansi-pedantic-test.c b/source/tests/ansi-pedantic-test.c new file mode 100644 index 000000000..3a90c8860 --- /dev/null +++ b/source/tests/ansi-pedantic-test.c @@ -0,0 +1,27 @@ +/* + * ANSI pedantic test for the Carla Backend API + * Copyright (C) 2013 Filipe Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a full copy of the GNU General Public License see the doc/GPL.txt file. + */ + +#include "CarlaBackend.h" + +int main(int argc, char* argv[]) +{ + return 0; + + /* unused */ + (void)argc; + (void)argv; +}