| @@ -82,12 +82,13 @@ source/bridges/jackplugin/libjack.so.0 | |||||
| source/frontend/Makefile | source/frontend/Makefile | ||||
| source/tests/ansi-pedantic-test_* | source/tests/ansi-pedantic-test_* | ||||
| source/tests/CarlaString | source/tests/CarlaString | ||||
| source/tests/CarlaUtils | |||||
| source/tests/EngineEvents | source/tests/EngineEvents | ||||
| source/tests/PipeServer | source/tests/PipeServer | ||||
| source/tests/Print | source/tests/Print | ||||
| source/tests/RtLinkedList | source/tests/RtLinkedList | ||||
| source/tests/RtLinkedListGnu | source/tests/RtLinkedListGnu | ||||
| source/tests/Utils | |||||
| # Docs | # Docs | ||||
| doc/CarlaBackend/ | doc/CarlaBackend/ | ||||
| @@ -859,26 +859,18 @@ typedef enum { | |||||
| */ | */ | ||||
| ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25, | ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25, | ||||
| /*! | |||||
| * A patchbay port value has changed. | |||||
| * @param pluginId Client Id | |||||
| * @param value1 Port Id | |||||
| * @param value3 New port value | |||||
| */ | |||||
| ENGINE_CALLBACK_PATCHBAY_PORT_VALUE_CHANGED = 26, // TODO | |||||
| /*! | /*! | ||||
| * A patchbay connection has been added. | * A patchbay connection has been added. | ||||
| * @param pluginId Connection Id | * @param pluginId Connection Id | ||||
| * @param valueStr Out group and port plus in group and port, in "og:op:ig:ip" syntax. | * @param valueStr Out group and port plus in group and port, in "og:op:ig:ip" syntax. | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27, | |||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 26, | |||||
| /*! | /*! | ||||
| * A patchbay connection has been removed. | * A patchbay connection has been removed. | ||||
| * @param pluginId Connection Id | * @param pluginId Connection Id | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28, | |||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 27, | |||||
| /*! | /*! | ||||
| * Engine started. | * Engine started. | ||||
| @@ -888,62 +880,62 @@ typedef enum { | |||||
| * @see EngineProcessMode | * @see EngineProcessMode | ||||
| * @see EngineTransportMode | * @see EngineTransportMode | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_ENGINE_STARTED = 29, | |||||
| ENGINE_CALLBACK_ENGINE_STARTED = 28, | |||||
| /*! | /*! | ||||
| * Engine stopped. | * Engine stopped. | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_ENGINE_STOPPED = 30, | |||||
| ENGINE_CALLBACK_ENGINE_STOPPED = 29, | |||||
| /*! | /*! | ||||
| * Engine process mode has changed. | * Engine process mode has changed. | ||||
| * @param value1 New process mode | * @param value1 New process mode | ||||
| * @see EngineProcessMode | * @see EngineProcessMode | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31, | |||||
| ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 30, | |||||
| /*! | /*! | ||||
| * Engine transport mode has changed. | * Engine transport mode has changed. | ||||
| * @param value1 New transport mode | * @param value1 New transport mode | ||||
| * @see EngineTransportMode | * @see EngineTransportMode | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32, | |||||
| ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 31, | |||||
| /*! | /*! | ||||
| * Engine buffer-size changed. | * Engine buffer-size changed. | ||||
| * @param value1 New buffer size | * @param value1 New buffer size | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33, | |||||
| ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 32, | |||||
| /*! | /*! | ||||
| * Engine sample-rate changed. | * Engine sample-rate changed. | ||||
| * @param value3 New sample rate | * @param value3 New sample rate | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34, | |||||
| ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 33, | |||||
| /*! | /*! | ||||
| * Idle frontend.\n | * Idle frontend.\n | ||||
| * This is used by the engine during long operations that might block the frontend, | * This is used by the engine during long operations that might block the frontend, | ||||
| * giving it the possibility to idle while the operation is still in place. | * giving it the possibility to idle while the operation is still in place. | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_IDLE = 35, | |||||
| ENGINE_CALLBACK_IDLE = 34, | |||||
| /*! | /*! | ||||
| * Show a message as information. | * Show a message as information. | ||||
| * @param valueStr The message | * @param valueStr The message | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_INFO = 36, | |||||
| ENGINE_CALLBACK_INFO = 35, | |||||
| /*! | /*! | ||||
| * Show a message as an error. | * Show a message as an error. | ||||
| * @param valueStr The message | * @param valueStr The message | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_ERROR = 37, | |||||
| ENGINE_CALLBACK_ERROR = 36, | |||||
| /*! | /*! | ||||
| * The engine has crashed or malfunctioned and will no longer work. | * The engine has crashed or malfunctioned and will no longer work. | ||||
| */ | */ | ||||
| ENGINE_CALLBACK_QUIT = 38 | |||||
| ENGINE_CALLBACK_QUIT = 37 | |||||
| } EngineCallbackOpcode; | } EngineCallbackOpcode; | ||||
| @@ -798,7 +798,7 @@ public: | |||||
| #ifdef BUILD_BRIDGE | #ifdef BUILD_BRIDGE | ||||
| pData->options.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, nullptr, kRackPortCount); | |||||
| #endif | #endif | ||||
| // FIXME: Always enable JACK transport for now | // FIXME: Always enable JACK transport for now | ||||
| @@ -951,7 +951,7 @@ public: | |||||
| jackbridge_port_unregister(fClient, fRackPorts[kRackPortAudioOut2]); | jackbridge_port_unregister(fClient, fRackPorts[kRackPortAudioOut2]); | ||||
| jackbridge_port_unregister(fClient, fRackPorts[kRackPortEventIn]); | jackbridge_port_unregister(fClient, fRackPorts[kRackPortEventIn]); | ||||
| jackbridge_port_unregister(fClient, fRackPorts[kRackPortEventOut]); | jackbridge_port_unregister(fClient, fRackPorts[kRackPortEventOut]); | ||||
| carla_fill<jack_port_t*>(fRackPorts, kRackPortCount, nullptr); | |||||
| carla_fill<jack_port_t*>(fRackPorts, nullptr, kRackPortCount); | |||||
| } | } | ||||
| if (jackbridge_client_close(fClient)) | if (jackbridge_client_close(fClient)) | ||||
| @@ -1770,7 +1770,7 @@ protected: | |||||
| } | } | ||||
| #ifndef BUILD_BRIDGE | #ifndef BUILD_BRIDGE | ||||
| carla_fill<jack_port_t*>(fRackPorts, kRackPortCount, nullptr); | |||||
| carla_fill<jack_port_t*>(fRackPorts, nullptr, kRackPortCount); | |||||
| #endif | #endif | ||||
| fClient = nullptr; | fClient = nullptr; | ||||
| @@ -876,8 +876,8 @@ public: | |||||
| { | { | ||||
| // we need to pre-run the plugin so it can update its latency control-port | // we need to pre-run the plugin so it can update its latency control-port | ||||
| float tmpIn[aIns][2]; | |||||
| float tmpOut[aOuts][2]; | |||||
| float tmpIn [(aIns > 0) ? aIns : 1][2]; | |||||
| float tmpOut[(aOuts > 0) ? aOuts : 1][2]; | |||||
| for (uint32_t j=0; j < aIns; ++j) | for (uint32_t j=0; j < aIns; ++j) | ||||
| { | { | ||||
| @@ -53,7 +53,7 @@ public: | |||||
| carla_debug("FluidSynthPlugin::FluidSynthPlugin(%p, %i, %s)", engine, id, bool2str(use16Outs)); | carla_debug("FluidSynthPlugin::FluidSynthPlugin(%p, %i, %s)", engine, id, bool2str(use16Outs)); | ||||
| FLOAT_CLEAR(fParamBuffers, FluidSynthParametersMax); | FLOAT_CLEAR(fParamBuffers, FluidSynthParametersMax); | ||||
| carla_fill<int32_t>(fCurMidiProgs, MAX_MIDI_CHANNELS, 0); | |||||
| carla_fill<int32_t>(fCurMidiProgs, 0, MAX_MIDI_CHANNELS); | |||||
| // create settings | // create settings | ||||
| fSettings = new_fluid_settings(); | fSettings = new_fluid_settings(); | ||||
| @@ -317,7 +317,7 @@ public: | |||||
| fInstance->refreshParameterList(); | fInstance->refreshParameterList(); | ||||
| uint32_t aIns, aOuts, mIns, mOuts, params; | uint32_t aIns, aOuts, mIns, mOuts, params; | ||||
| aIns = aOuts = mIns = mOuts = params = 0; | |||||
| mIns = mOuts = 0; | |||||
| bool needsCtrlIn, needsCtrlOut; | bool needsCtrlIn, needsCtrlOut; | ||||
| needsCtrlIn = needsCtrlOut = false; | needsCtrlIn = needsCtrlOut = false; | ||||
| @@ -836,8 +836,8 @@ public: | |||||
| { | { | ||||
| // we need to pre-run the plugin so it can update its latency control-port | // we need to pre-run the plugin so it can update its latency control-port | ||||
| float tmpIn[aIns][2]; | |||||
| float tmpOut[aOuts][2]; | |||||
| float tmpIn [(aIns > 0) ? aIns : 1][2]; | |||||
| float tmpOut[(aOuts > 0) ? aOuts : 1][2]; | |||||
| for (uint32_t j=0; j < aIns; ++j) | for (uint32_t j=0; j < aIns; ++j) | ||||
| { | { | ||||
| @@ -404,7 +404,7 @@ public: | |||||
| { | { | ||||
| carla_debug("Lv2Plugin::Lv2Plugin(%p, %i)", engine, id); | carla_debug("Lv2Plugin::Lv2Plugin(%p, %i)", engine, id); | ||||
| carla_fill<LV2_Feature*>(fFeatures, kFeatureCountAll+1, nullptr); | |||||
| carla_fill<LV2_Feature*>(fFeatures, nullptr, kFeatureCountAll+1); | |||||
| for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i) | for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i) | ||||
| fCustomURIDs.append(nullptr); | fCustomURIDs.append(nullptr); | ||||
| @@ -2188,8 +2188,8 @@ public: | |||||
| { | { | ||||
| // we need to pre-run the plugin so it can update its latency control-port | // we need to pre-run the plugin so it can update its latency control-port | ||||
| float tmpIn[aIns][2]; | |||||
| float tmpOut[aOuts][2]; | |||||
| float tmpIn [(aIns > 0) ? aIns : 1][2]; | |||||
| float tmpOut[(aOuts > 0) ? aOuts : 1][2]; | |||||
| for (uint32_t j=0; j < aIns; ++j) | for (uint32_t j=0; j < aIns; ++j) | ||||
| { | { | ||||
| @@ -148,7 +148,7 @@ public: | |||||
| { | { | ||||
| carla_debug("NativePlugin::NativePlugin(%p, %i)", engine, id); | carla_debug("NativePlugin::NativePlugin(%p, %i)", engine, id); | ||||
| carla_fill<int32_t>(fCurMidiProgs, MAX_MIDI_CHANNELS, 0); | |||||
| carla_fill<int32_t>(fCurMidiProgs, 0, MAX_MIDI_CHANNELS); | |||||
| carla_zeroStruct<NativeMidiEvent>(fMidiEvents, kPluginMaxMidiEvents*2); | carla_zeroStruct<NativeMidiEvent>(fMidiEvents, kPluginMaxMidiEvents*2); | ||||
| carla_zeroStruct<NativeTimeInfo>(fTimeInfo); | carla_zeroStruct<NativeTimeInfo>(fTimeInfo); | ||||
| @@ -1164,8 +1164,7 @@ public: | |||||
| for (i=0; i < count; ++i) | for (i=0; i < count; ++i) | ||||
| { | { | ||||
| const NativeMidiProgram* const mpDesc(fDescriptor->get_midi_program_info(fHandle, i)); | const NativeMidiProgram* const mpDesc(fDescriptor->get_midi_program_info(fHandle, i)); | ||||
| CARLA_ASSERT(mpDesc != nullptr); | |||||
| CARLA_ASSERT(mpDesc->name != nullptr); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(mpDesc != nullptr); | |||||
| pData->midiprog.data[i].bank = mpDesc->bank; | pData->midiprog.data[i].bank = mpDesc->bank; | ||||
| pData->midiprog.data[i].program = mpDesc->program; | pData->midiprog.data[i].program = mpDesc->program; | ||||
| @@ -2384,7 +2384,7 @@ private: | |||||
| : numEvents(0), | : numEvents(0), | ||||
| reserved(0) | reserved(0) | ||||
| { | { | ||||
| carla_fill<VstEvent*>(data, kPluginMaxMidiEvents*2, nullptr); | |||||
| carla_fill<VstEvent*>(data, nullptr, kPluginMaxMidiEvents*2); | |||||
| } | } | ||||
| } fEvents; | } fEvents; | ||||
| @@ -202,7 +202,7 @@ public: | |||||
| fIsResizable(true) | fIsResizable(true) | ||||
| #endif | #endif | ||||
| { | { | ||||
| carla_fill<LV2_Feature*>(fFeatures, kFeatureCount+1, nullptr); | |||||
| carla_fill<LV2_Feature*>(fFeatures, nullptr, kFeatureCount+1); | |||||
| for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i) | for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i) | ||||
| fCustomURIDs.append(nullptr); | fCustomURIDs.append(nullptr); | ||||
| @@ -107,7 +107,6 @@ class CarlaMultiW(QTabWidget): | |||||
| parent.PatchbayPortAddedCallback.connect(self.fPatchbay.slot_handlePatchbayPortAddedCallback) | parent.PatchbayPortAddedCallback.connect(self.fPatchbay.slot_handlePatchbayPortAddedCallback) | ||||
| parent.PatchbayPortRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRemovedCallback) | parent.PatchbayPortRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRemovedCallback) | ||||
| parent.PatchbayPortRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRenamedCallback) | parent.PatchbayPortRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRenamedCallback) | ||||
| parent.PatchbayPortValueChangedCallback.connect(self.fPatchbay.slot_handlePatchbayPortValueChangedCallback) | |||||
| parent.PatchbayConnectionAddedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionAddedCallback) | parent.PatchbayConnectionAddedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionAddedCallback) | ||||
| parent.PatchbayConnectionRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionRemovedCallback) | parent.PatchbayConnectionRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionRemovedCallback) | ||||
| @@ -634,20 +634,14 @@ ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED = 24 | |||||
| # @param valueStr New port name | # @param valueStr New port name | ||||
| ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25 | ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25 | ||||
| # A patchbay port value has changed. | |||||
| # @param pluginId Client Id | |||||
| # @param value1 Port Id | |||||
| # @param value3 New port value | |||||
| ENGINE_CALLBACK_PATCHBAY_PORT_VALUE_CHANGED = 26 | |||||
| # A patchbay connection has been added. | # A patchbay connection has been added. | ||||
| # @param pluginId Connection Id | # @param pluginId Connection Id | ||||
| # @param valueStr Out group, port plus in group and port, in "og:op:ig:ip" syntax. | # @param valueStr Out group, port plus in group and port, in "og:op:ig:ip" syntax. | ||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 27 | |||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 26 | |||||
| # A patchbay connection has been removed. | # A patchbay connection has been removed. | ||||
| # @param pluginId Connection Id | # @param pluginId Connection Id | ||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28 | |||||
| ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 27 | |||||
| # Engine started. | # Engine started. | ||||
| # @param value1 Process mode | # @param value1 Process mode | ||||
| @@ -655,44 +649,44 @@ ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 28 | |||||
| # @param valuestr Engine driver | # @param valuestr Engine driver | ||||
| # @see EngineProcessMode | # @see EngineProcessMode | ||||
| # @see EngineTransportMode | # @see EngineTransportMode | ||||
| ENGINE_CALLBACK_ENGINE_STARTED = 29 | |||||
| ENGINE_CALLBACK_ENGINE_STARTED = 28 | |||||
| # Engine stopped. | # Engine stopped. | ||||
| ENGINE_CALLBACK_ENGINE_STOPPED = 30 | |||||
| ENGINE_CALLBACK_ENGINE_STOPPED = 29 | |||||
| # Engine process mode has changed. | # Engine process mode has changed. | ||||
| # @param value1 New process mode | # @param value1 New process mode | ||||
| # @see EngineProcessMode | # @see EngineProcessMode | ||||
| ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 31 | |||||
| ENGINE_CALLBACK_PROCESS_MODE_CHANGED = 30 | |||||
| # Engine transport mode has changed. | # Engine transport mode has changed. | ||||
| # @param value1 New transport mode | # @param value1 New transport mode | ||||
| # @see EngineTransportMode | # @see EngineTransportMode | ||||
| ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 32 | |||||
| ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED = 31 | |||||
| # Engine buffer-size changed. | # Engine buffer-size changed. | ||||
| # @param value1 New buffer size | # @param value1 New buffer size | ||||
| ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 33 | |||||
| ENGINE_CALLBACK_BUFFER_SIZE_CHANGED = 32 | |||||
| # Engine sample-rate changed. | # Engine sample-rate changed. | ||||
| # @param value3 New sample rate | # @param value3 New sample rate | ||||
| ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 34 | |||||
| ENGINE_CALLBACK_SAMPLE_RATE_CHANGED = 33 | |||||
| # Idle frontend. | # Idle frontend. | ||||
| # This is used by the engine during long operations that might block the frontend, | # This is used by the engine during long operations that might block the frontend, | ||||
| # giving it the possibility to idle while the operation is still in place. | # giving it the possibility to idle while the operation is still in place. | ||||
| ENGINE_CALLBACK_IDLE = 35 | |||||
| ENGINE_CALLBACK_IDLE = 34 | |||||
| # Show a message as information. | # Show a message as information. | ||||
| # @param valueStr The message | # @param valueStr The message | ||||
| ENGINE_CALLBACK_INFO = 36 | |||||
| ENGINE_CALLBACK_INFO = 35 | |||||
| # Show a message as an error. | # Show a message as an error. | ||||
| # @param valueStr The message | # @param valueStr The message | ||||
| ENGINE_CALLBACK_ERROR = 37 | |||||
| ENGINE_CALLBACK_ERROR = 36 | |||||
| # The engine has crashed or malfunctioned and will no longer work. | # The engine has crashed or malfunctioned and will no longer work. | ||||
| ENGINE_CALLBACK_QUIT = 38 | |||||
| ENGINE_CALLBACK_QUIT = 37 | |||||
| # ------------------------------------------------------------------------------------------------------------ | # ------------------------------------------------------------------------------------------------------------ | ||||
| # Engine Option | # Engine Option | ||||
| @@ -149,7 +149,6 @@ class HostWindow(QMainWindow): | |||||
| PatchbayPortAddedCallback = pyqtSignal(int, int, int, str) | PatchbayPortAddedCallback = pyqtSignal(int, int, int, str) | ||||
| PatchbayPortRemovedCallback = pyqtSignal(int, int) | PatchbayPortRemovedCallback = pyqtSignal(int, int) | ||||
| PatchbayPortRenamedCallback = pyqtSignal(int, int, str) | PatchbayPortRenamedCallback = pyqtSignal(int, int, str) | ||||
| PatchbayPortValueChangedCallback = pyqtSignal(int, int, float) | |||||
| PatchbayConnectionAddedCallback = pyqtSignal(int, int, int, int, int) | PatchbayConnectionAddedCallback = pyqtSignal(int, int, int, int, int) | ||||
| PatchbayConnectionRemovedCallback = pyqtSignal(int, int, int) | PatchbayConnectionRemovedCallback = pyqtSignal(int, int, int) | ||||
| EngineStartedCallback = pyqtSignal(int, int, str) | EngineStartedCallback = pyqtSignal(int, int, str) | ||||
| @@ -1303,8 +1302,6 @@ def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr): | |||||
| gCarla.gui.PatchbayPortRemovedCallback.emit(pluginId, value1) | gCarla.gui.PatchbayPortRemovedCallback.emit(pluginId, value1) | ||||
| elif action == ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED: | elif action == ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED: | ||||
| gCarla.gui.PatchbayPortRenamedCallback.emit(pluginId, value1, valueStr) | gCarla.gui.PatchbayPortRenamedCallback.emit(pluginId, value1, valueStr) | ||||
| elif action == ENGINE_CALLBACK_PATCHBAY_PORT_VALUE_CHANGED: | |||||
| gCarla.gui.PatchbayPortValueChangedCallback.emit(pluginId, value1, value3) | |||||
| elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED: | elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED: | ||||
| gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")] | gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")] | ||||
| gCarla.gui.PatchbayConnectionAddedCallback.emit(pluginId, gOut, pOut, gIn, pIn) | gCarla.gui.PatchbayConnectionAddedCallback.emit(pluginId, gOut, pOut, gIn, pIn) | ||||
| @@ -67,89 +67,29 @@ class PluginInfo(object): | |||||
| def __init__(self, parent, pluginId): | def __init__(self, parent, pluginId): | ||||
| object.__init__(self) | object.__init__(self) | ||||
| self.fGroupId = None | |||||
| self.fPluginId = pluginId | self.fPluginId = pluginId | ||||
| self.fParameterList = [] # type, index, min, max | |||||
| self.reloadParameters() | |||||
| def close(self): | |||||
| for paramType, paramIndex, paramMin, paramMax in self.fParameterList: | |||||
| patchcanvas.removePort(self.fGroupId, -paramIndex-1) | |||||
| #------------------------------------------------------------------ | #------------------------------------------------------------------ | ||||
| def reloadAll(self): | |||||
| self.reloadParameters() | |||||
| def reloadParameters(self): | |||||
| # TODO | |||||
| return | |||||
| # Remove all previous parameters | |||||
| self.close() | |||||
| hasGroup, groupId = patchcanvas.getPluginAsGroup(self.fPluginId) | |||||
| if not hasGroup: | |||||
| self.fGroupId = None | |||||
| return | |||||
| self.fGroupId = groupId | |||||
| # Reset | |||||
| self.fParameterList = [] | |||||
| if gCarla.host is None: | |||||
| return | |||||
| parameterCount = gCarla.host.get_parameter_count(self.fPluginId) | |||||
| if parameterCount <= 0 or parameterCount > 25: | |||||
| return | |||||
| for i in range(parameterCount): | |||||
| paramInfo = gCarla.host.get_parameter_info(self.fPluginId, i) | |||||
| paramData = gCarla.host.get_parameter_data(self.fPluginId, i) | |||||
| paramRanges = gCarla.host.get_parameter_ranges(self.fPluginId, i) | |||||
| paramValue = gCarla.host.get_current_parameter_value(self.fPluginId, i) | |||||
| if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT): | |||||
| #if paramData['type'] != PARAMETER_INPUT: | |||||
| continue | |||||
| if (paramData['hints'] & PARAMETER_IS_AUTOMABLE) == 0: | |||||
| continue | |||||
| portId = -i-1 | |||||
| portMode = patchcanvas.PORT_MODE_OUTPUT if paramData['type'] == PARAMETER_OUTPUT else patchcanvas.PORT_MODE_INPUT | |||||
| portValue = (paramValue - paramRanges['min']) / (paramRanges['max'] - paramRanges['min']) | |||||
| patchcanvas.addPort(groupId, portId, paramInfo['name'], portMode, patchcanvas.PORT_TYPE_PARAMETER) | |||||
| patchcanvas.setPortValue(groupId, portId, portValue) | |||||
| self.fParameterList.append((paramData['type'], i, paramRanges['min'], paramRanges['max'])) | |||||
| def setId(self, idx): | |||||
| self.fPluginId = idx | |||||
| #------------------------------------------------------------------ | #------------------------------------------------------------------ | ||||
| def setId(self, idx): | |||||
| self.fPluginId = idx | |||||
| def close(self): | |||||
| pass | |||||
| def setParameterValue(self, parameterId, value): | |||||
| if self.fGroupId is None: | |||||
| return | |||||
| def setName(self, name): | |||||
| pass | |||||
| paramRanges = gCarla.host.get_parameter_ranges(self.fPluginId, parameterId) | |||||
| portValue = (value - paramRanges['min']) / (paramRanges['max'] - paramRanges['min']) | |||||
| patchcanvas.setPortValue(self.fGroupId, -parameterId-1, portValue) | |||||
| def setParameterValue(self, parameterId, value): | |||||
| pass | |||||
| #------------------------------------------------------------------ | |||||
| def reloadAll(self): | |||||
| pass | |||||
| def idleSlow(self): | def idleSlow(self): | ||||
| # Update parameter outputs | |||||
| for paramType, paramIndex, paramMin, paramMax in self.fParameterList: | |||||
| if paramType == PARAMETER_OUTPUT: | |||||
| portValue = (gCarla.host.get_current_parameter_value(self.fPluginId, paramIndex) - paramMin) / (paramMax - paramMin) | |||||
| patchcanvas.setPortValue(self.fGroupId, -paramIndex-1, portValue) | |||||
| pass | |||||
| # ------------------------------------------------------------------------------------------------ | # ------------------------------------------------------------------------------------------------ | ||||
| # Patchbay widget | # Patchbay widget | ||||
| @@ -299,7 +239,6 @@ class CarlaPatchbayW(QFrame): | |||||
| parent.PatchbayPortAddedCallback.connect(self.slot_handlePatchbayPortAddedCallback) | parent.PatchbayPortAddedCallback.connect(self.slot_handlePatchbayPortAddedCallback) | ||||
| parent.PatchbayPortRemovedCallback.connect(self.slot_handlePatchbayPortRemovedCallback) | parent.PatchbayPortRemovedCallback.connect(self.slot_handlePatchbayPortRemovedCallback) | ||||
| parent.PatchbayPortRenamedCallback.connect(self.slot_handlePatchbayPortRenamedCallback) | parent.PatchbayPortRenamedCallback.connect(self.slot_handlePatchbayPortRenamedCallback) | ||||
| parent.PatchbayPortValueChangedCallback.connect(self.slot_handlePatchbayPortValueChangedCallback) | |||||
| parent.PatchbayConnectionAddedCallback.connect(self.slot_handlePatchbayConnectionAddedCallback) | parent.PatchbayConnectionAddedCallback.connect(self.slot_handlePatchbayConnectionAddedCallback) | ||||
| parent.PatchbayConnectionRemovedCallback.connect(self.slot_handlePatchbayConnectionRemovedCallback) | parent.PatchbayConnectionRemovedCallback.connect(self.slot_handlePatchbayConnectionRemovedCallback) | ||||
| @@ -455,6 +394,12 @@ class CarlaPatchbayW(QFrame): | |||||
| def recheckPluginHints(self, hints): | def recheckPluginHints(self, hints): | ||||
| pass | pass | ||||
| def notePressed(self, note): | |||||
| pass | |||||
| def noteReleased(self, note): | |||||
| pass | |||||
| # ----------------------------------------------------------------- | # ----------------------------------------------------------------- | ||||
| def clearSideStuff(self): | def clearSideStuff(self): | ||||
| @@ -972,10 +917,6 @@ class CarlaPatchbayW(QFrame): | |||||
| patchcanvas.renamePort(groupId, portId, newPortName) | patchcanvas.renamePort(groupId, portId, newPortName) | ||||
| QTimer.singleShot(0, self.fMiniCanvasPreview.update) | QTimer.singleShot(0, self.fMiniCanvasPreview.update) | ||||
| @pyqtSlot(int, int, float) | |||||
| def slot_handlePatchbayPortValueChangedCallback(self, groupId, portId, value): | |||||
| patchcanvas.setPortValue(groupId, portId, value) | |||||
| @pyqtSlot(int, int, int, int, int) | @pyqtSlot(int, int, int, int, int) | ||||
| def slot_handlePatchbayConnectionAddedCallback(self, connectionId, groupOutId, portOutId, groupInId, portInId): | def slot_handlePatchbayConnectionAddedCallback(self, connectionId, groupOutId, portOutId, groupInId, portInId): | ||||
| patchcanvas.connectPorts(connectionId, groupOutId, portOutId, groupInId, portInId) | patchcanvas.connectPorts(connectionId, groupOutId, portOutId, groupInId, portInId) | ||||
| @@ -32,8 +32,8 @@ | |||||
| #endif | #endif | ||||
| /* Set Version */ | /* Set Version */ | ||||
| #define CARLA_VERSION_HEX 0x01093 | |||||
| #define CARLA_VERSION_STRING "1.9.3 (2.0-beta1)" | |||||
| #define CARLA_VERSION_HEX 0x01094 | |||||
| #define CARLA_VERSION_STRING "1.9.4 (2.0-beta2)" | |||||
| /* Check OS */ | /* Check OS */ | ||||
| #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) | #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) | ||||
| @@ -52,7 +52,7 @@ | |||||
| #if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64) | #if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64) | ||||
| # define CARLA_OS_WIN | # define CARLA_OS_WIN | ||||
| #elif ! defined(CARLA_OS_HAIKU) | |||||
| #elif defined(CARLA_OS_LINUX) || defined(CARLA_OS_MAC) | |||||
| # define CARLA_OS_UNIX | # define CARLA_OS_UNIX | ||||
| #endif | #endif | ||||
| @@ -60,20 +60,20 @@ | |||||
| #if defined(HAVE_CPP11_SUPPORT) | #if defined(HAVE_CPP11_SUPPORT) | ||||
| # define CARLA_PROPER_CPP11_SUPPORT | # define CARLA_PROPER_CPP11_SUPPORT | ||||
| #elif defined(__cplusplus) | #elif defined(__cplusplus) | ||||
| # if __cplusplus >= 201103L || (defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405) || __has_extension(cxx_noexcept) | |||||
| # if __cplusplus >= 201103L || (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && defined(__GXX_EXPERIMENTAL_CXX0X__)) || __has_extension(cxx_noexcept) | |||||
| # define CARLA_PROPER_CPP11_SUPPORT | # define CARLA_PROPER_CPP11_SUPPORT | ||||
| # if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) && ! __has_extension(cxx_override_control) | |||||
| # if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || (defined(__CLANG__) && ! __has_extension(cxx_override_control)) | |||||
| # define override // gcc4.7+ only | # define override // gcc4.7+ only | ||||
| # define final // gcc4.7+ only | # define final // gcc4.7+ only | ||||
| # endif | # endif | ||||
| # endif | # endif | ||||
| #endif | #endif | ||||
| #if defined(__cplusplus) && !defined(CARLA_PROPER_CPP11_SUPPORT) | |||||
| #if defined(__cplusplus) && ! defined(CARLA_PROPER_CPP11_SUPPORT) | |||||
| # define noexcept throw() | # define noexcept throw() | ||||
| # define override | # define override | ||||
| # define final | # define final | ||||
| # define nullptr (0) | |||||
| # define nullptr NULL | |||||
| #endif | #endif | ||||
| /* Common includes */ | /* Common includes */ | ||||
| @@ -87,21 +87,25 @@ | |||||
| /* Define various string format types */ | /* Define various string format types */ | ||||
| #if defined(CARLA_OS_WIN64) | #if defined(CARLA_OS_WIN64) | ||||
| # define P_INT64 "%I64i" | # define P_INT64 "%I64i" | ||||
| # define P_UINT64 "%I64u" | |||||
| # define P_INTPTR "%I64i" | # define P_INTPTR "%I64i" | ||||
| # define P_UINTPTR "%I64x" | # define P_UINTPTR "%I64x" | ||||
| # define P_SIZE "%I64u" | # define P_SIZE "%I64u" | ||||
| #elif defined(CARLA_OS_WIN32) | #elif defined(CARLA_OS_WIN32) | ||||
| # define P_INT64 "%I64i" | # define P_INT64 "%I64i" | ||||
| # define P_UINT64 "%I64u" | |||||
| # define P_INTPTR "%i" | # define P_INTPTR "%i" | ||||
| # define P_UINTPTR "%x" | # define P_UINTPTR "%x" | ||||
| # define P_SIZE "%u" | # define P_SIZE "%u" | ||||
| #elif defined(__WORDSIZE) && __WORDSIZE == 64 | #elif defined(__WORDSIZE) && __WORDSIZE == 64 | ||||
| # define P_INT64 "%li" | # define P_INT64 "%li" | ||||
| # define P_UINT64 "%lu" | |||||
| # define P_INTPTR "%li" | # define P_INTPTR "%li" | ||||
| # define P_UINTPTR "%lx" | # define P_UINTPTR "%lx" | ||||
| # define P_SIZE "%lu" | # define P_SIZE "%lu" | ||||
| #else | #else | ||||
| # define P_INT64 "%lli" | # define P_INT64 "%lli" | ||||
| # define P_UINT64 "%llu" | |||||
| # define P_INTPTR "%i" | # define P_INTPTR "%i" | ||||
| # define P_UINTPTR "%x" | # define P_UINTPTR "%x" | ||||
| # define P_SIZE "%u" | # define P_SIZE "%u" | ||||
| @@ -37,7 +37,7 @@ struct RawMidiEvent { | |||||
| : time(0), | : time(0), | ||||
| size(0) | size(0) | ||||
| { | { | ||||
| carla_fill<uint8_t>(data, MAX_EVENT_DATA_SIZE, 0); | |||||
| carla_fill<uint8_t>(data, 0, MAX_EVENT_DATA_SIZE); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -863,17 +863,6 @@ def renamePort(group_id, port_id, new_port_name): | |||||
| qCritical("PatchCanvas::renamePort(%i, %i, %s) - Unable to find port to rename" % (group_id, port_id, new_port_name.encode())) | qCritical("PatchCanvas::renamePort(%i, %i, %s) - Unable to find port to rename" % (group_id, port_id, new_port_name.encode())) | ||||
| def setPortValue(group_id, port_id, value): | |||||
| if canvas.debug: | |||||
| qDebug("PatchCanvas::setPortValue(%i, %i, %f)" % (group_id, port_id, value)) | |||||
| for port in canvas.port_list: | |||||
| if port.group_id == group_id and port.port_id == port_id: | |||||
| port.widget.setPortValue(value) | |||||
| return | |||||
| qCritical("PatchCanvas::setPortValue(%i, %i, %f) - Unable to find port" % (group_id, port_id, value)) | |||||
| def connectPorts(connection_id, group_out_id, port_out_id, group_in_id, port_in_id): | def connectPorts(connection_id, group_out_id, port_out_id, group_in_id, port_in_id): | ||||
| if canvas.debug: | if canvas.debug: | ||||
| qDebug("PatchCanvas::connectPorts(%i, %i, %i, %i, %i)" % (connection_id, group_out_id, port_out_id, group_in_id, port_in_id)) | qDebug("PatchCanvas::connectPorts(%i, %i, %i, %i, %i)" % (connection_id, group_out_id, port_out_id, group_in_id, port_in_id)) | ||||
| @@ -1787,8 +1776,6 @@ class CanvasPort(QGraphicsItem): | |||||
| self.m_port_font.setPixelSize(canvas.theme.port_font_size) | self.m_port_font.setPixelSize(canvas.theme.port_font_size) | ||||
| self.m_port_font.setWeight(canvas.theme.port_font_state) | self.m_port_font.setWeight(canvas.theme.port_font_state) | ||||
| self.m_port_value = 1.0 | |||||
| self.m_line_mov = None | self.m_line_mov = None | ||||
| self.m_hover_item = None | self.m_hover_item = None | ||||
| self.m_last_selected_state = False | self.m_last_selected_state = False | ||||
| @@ -1830,13 +1817,6 @@ class CanvasPort(QGraphicsItem): | |||||
| self.m_port_type = port_type | self.m_port_type = port_type | ||||
| self.update() | self.update() | ||||
| def setPortValue(self, value): | |||||
| if self.m_port_value == value: | |||||
| return | |||||
| self.m_port_value = value | |||||
| self.update() | |||||
| def setPortName(self, port_name): | def setPortName(self, port_name): | ||||
| if QFontMetrics(self.m_port_font).width(port_name) < QFontMetrics(self.m_port_font).width(self.m_port_name): | if QFontMetrics(self.m_port_font).width(port_name) < QFontMetrics(self.m_port_font).width(self.m_port_name): | ||||
| QTimer.singleShot(0, canvas.scene.update) | QTimer.singleShot(0, canvas.scene.update) | ||||
| @@ -2081,39 +2061,15 @@ class CanvasPort(QGraphicsItem): | |||||
| polygon += QPointF(poly_locx[3], canvas.theme.port_height) | polygon += QPointF(poly_locx[3], canvas.theme.port_height) | ||||
| polygon += QPointF(poly_locx[4], canvas.theme.port_height) | polygon += QPointF(poly_locx[4], canvas.theme.port_height) | ||||
| if self.m_port_value == 1.0 or canvas.theme.port_bg_pixmap: | |||||
| # normal paint | |||||
| if canvas.theme.port_bg_pixmap: | |||||
| portRect = polygon.boundingRect() | |||||
| portPos = portRect.topLeft() | |||||
| painter.drawTiledPixmap(portRect, canvas.theme.port_bg_pixmap, portPos) | |||||
| else: | |||||
| painter.setBrush(poly_color) #.lighter(200)) | |||||
| painter.setPen(poly_pen) | |||||
| painter.drawPolygon(polygon) | |||||
| if canvas.theme.port_bg_pixmap: | |||||
| portRect = polygon.boundingRect() | |||||
| portPos = portRect.topLeft() | |||||
| painter.drawTiledPixmap(portRect, canvas.theme.port_bg_pixmap, portPos) | |||||
| else: | else: | ||||
| # incomplete paint | |||||
| painter.setPen(poly_pen) | |||||
| painter.drawPolygon(polygon) | |||||
| sub = QPolygonF() | |||||
| painter.setBrush(poly_color) #.lighter(200)) | |||||
| if self.m_port_mode == PORT_MODE_INPUT: | |||||
| sub += QPointF(poly_locx[0], 0) | |||||
| sub += QPointF(poly_locx[2]*self.m_port_value, 0) | |||||
| sub += QPointF(poly_locx[2]*self.m_port_value, canvas.theme.port_height) | |||||
| sub += QPointF(poly_locx[0], canvas.theme.port_height) | |||||
| else: | |||||
| sub += QPointF(poly_locx[2], 0) | |||||
| sub += QPointF(poly_locx[0]*self.m_port_value, 0) | |||||
| sub += QPointF(poly_locx[0]*self.m_port_value, canvas.theme.port_height) | |||||
| sub += QPointF(poly_locx[2], canvas.theme.port_height) | |||||
| painter.setBrush(poly_color) | |||||
| painter.setPen(poly_pen) | |||||
| painter.drawPolygon(polygon.intersected(sub)) | |||||
| painter.setPen(poly_pen) | |||||
| painter.drawPolygon(polygon) | |||||
| painter.setPen(text_pen) | painter.setPen(text_pen) | ||||
| painter.setFont(self.m_port_font) | painter.setFont(self.m_port_font) | ||||
| @@ -0,0 +1,508 @@ | |||||
| /* | |||||
| * Carla Utility Tests | |||||
| * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com> | |||||
| * | |||||
| * 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. | |||||
| */ | |||||
| #ifdef NDEBUG | |||||
| # error Build this file with debug ON please | |||||
| #endif | |||||
| #undef HAVE_JUCE | |||||
| #include "CarlaUtils.hpp" | |||||
| #include "CarlaMathUtils.hpp" | |||||
| #include "CarlaBackendUtils.hpp" | |||||
| #include "CarlaEngineUtils.hpp" | |||||
| // #include "CarlaBridgeUtils.hpp" | |||||
| // #include "CarlaDssiUtils.hpp" | |||||
| // #include "CarlaJuceUtils.hpp" | |||||
| // #include "CarlaLadspaUtils.hpp" | |||||
| // #include "CarlaLibUtils.hpp" | |||||
| // #include "CarlaLv2Utils.hpp" | |||||
| // #include "CarlaOscUtils.hpp" | |||||
| // #include "CarlaPipeUtils.hpp" | |||||
| // #include "CarlaShmUtils.hpp" | |||||
| // #include "CarlaStateUtils.hpp" | |||||
| // #include "CarlaVstUtils.hpp" | |||||
| // #include "CarlaLibCounter.hpp" | |||||
| // #include "CarlaLogThread.hpp" | |||||
| // #include "CarlaMutex.hpp" | |||||
| // #include "CarlaRingBuffer.hpp" | |||||
| // #include "CarlaString.hpp" | |||||
| // #include "CarlaThread.hpp" | |||||
| // #include "List.hpp" | |||||
| // #include "Lv2AtomQueue.hpp" | |||||
| // #include "RtList.hpp" | |||||
| // #include "JucePluginWindow.hpp" | |||||
| // ----------------------------------------------------------------------- | |||||
| static void test_CarlaUtils() | |||||
| { | |||||
| // ------------------------------------------------------------------- | |||||
| // misc functions | |||||
| { | |||||
| bool2str(false); | |||||
| bool2str(true); | |||||
| pass(); | |||||
| char strBuf[1]; | |||||
| nullStrBuf(strBuf); | |||||
| } | |||||
| // ------------------------------------------------------------------- | |||||
| // string print functions | |||||
| { | |||||
| carla_debug("DEBUG"); | |||||
| carla_stdout("STDOUT %s", bool2str(true)); | |||||
| carla_stderr("STDERR %s", bool2str(false)); | |||||
| carla_stderr2("STDERR2 " P_UINT64, 0xffffffff); // 4294967295 | |||||
| } | |||||
| // ------------------------------------------------------------------- | |||||
| // carla_*sleep | |||||
| { | |||||
| //carla_sleep(1); | |||||
| //carla_msleep(1); | |||||
| } | |||||
| // ------------------------------------------------------------------- | |||||
| // carla_setenv | |||||
| { | |||||
| carla_setenv("THIS", "THAT"); | |||||
| assert(std::strcmp(std::getenv("THIS"), "THAT") == 0); | |||||
| } | |||||
| // ------------------------------------------------------------------- | |||||
| // carla_strdup | |||||
| { | |||||
| // with variables | |||||
| const char* const str1(carla_strdup("string1")); | |||||
| const char* const strF(carla_strdup_free(strdup("string2"))); | |||||
| delete[] str1; | |||||
| delete[] strF; | |||||
| // without variables | |||||
| delete[] carla_strdup("string3"); | |||||
| delete[] carla_strdup_free(strdup("string4")); | |||||
| // common use case in Carla code | |||||
| struct TestStruct { | |||||
| const char* str1; | |||||
| const char* str2; | |||||
| const char* str3; | |||||
| const char* str4; | |||||
| TestStruct() | |||||
| : str1(carla_strdup("str1")), | |||||
| str2(carla_strdup("str2")), | |||||
| str3(nullptr), | |||||
| str4(carla_strdup("str4")) {} | |||||
| ~TestStruct() noexcept | |||||
| { | |||||
| if (str1 != nullptr) | |||||
| { | |||||
| delete[] str1; | |||||
| str1 = nullptr; | |||||
| } | |||||
| if (str2 != nullptr) | |||||
| { | |||||
| delete[] str2; | |||||
| str2 = nullptr; | |||||
| } | |||||
| if (str3 != nullptr) | |||||
| { | |||||
| delete[] str3; | |||||
| str3 = nullptr; | |||||
| } | |||||
| if (str4 != nullptr) | |||||
| { | |||||
| delete[] str4; | |||||
| str4 = nullptr; | |||||
| } | |||||
| } | |||||
| }; | |||||
| TestStruct a, b, c; | |||||
| } | |||||
| // ------------------------------------------------------------------- | |||||
| // memory functions | |||||
| { | |||||
| int a[] = { 4, 3, 2, 1 }; | |||||
| int b[] = { 1, 2, 3, 4 }; | |||||
| carla_add(a, b, 4); | |||||
| assert(a[0] == 5); | |||||
| assert(a[1] == 5); | |||||
| assert(a[2] == 5); | |||||
| assert(a[3] == 5); | |||||
| int c[] = { 4, 3, 2, 1 }; | |||||
| carla_add(b, c, 4); | |||||
| assert(a[0] == b[0]); | |||||
| assert(a[1] == b[1]); | |||||
| assert(a[2] == b[2]); | |||||
| assert(a[3] == b[3]); | |||||
| carla_copy(a, c, 2); | |||||
| carla_copy(b+2, c+2, 2); | |||||
| assert(a[0] == c[0]); | |||||
| assert(a[1] == c[1]); | |||||
| assert(b[2] == c[2]); | |||||
| assert(b[3] == c[3]); | |||||
| carla_copy(c, a, 4); | |||||
| assert(a[0] == c[0]); | |||||
| assert(a[1] == c[1]); | |||||
| assert(a[2] == c[2]); | |||||
| assert(a[3] == c[3]); | |||||
| carla_fill(a, 0, 4); | |||||
| assert(a[0] == 0); | |||||
| assert(a[1] == 0); | |||||
| assert(a[2] == 0); | |||||
| assert(a[3] == 0); | |||||
| carla_fill(a, -11, 4); | |||||
| assert(a[0] == -11); | |||||
| assert(a[1] == -11); | |||||
| assert(a[2] == -11); | |||||
| assert(a[3] == -11); | |||||
| carla_fill(a+0, 17, 2); | |||||
| carla_fill(a+2, 23, 2); | |||||
| assert(a[0] == 17); | |||||
| assert(a[1] == 17); | |||||
| assert(a[2] == 23); | |||||
| assert(a[3] == 23); | |||||
| carla_zeroBytes(a, sizeof(int)*4); | |||||
| assert(a[0] == 0); | |||||
| assert(a[1] == 0); | |||||
| assert(a[2] == 0); | |||||
| assert(a[3] == 0); | |||||
| char strBuf[501]; | |||||
| strBuf[0] = strBuf[499] = strBuf[500] = '!'; | |||||
| carla_zeroChar(strBuf, 501); | |||||
| for (int i=0; i<501; ++i) | |||||
| assert(strBuf[i] == '\0'); | |||||
| int d = 1527, e = 0; | |||||
| carla_add(&d, &d, 1); | |||||
| carla_add(&d, &e, 1); | |||||
| carla_add(&e, &d, 1); | |||||
| assert(d == 1527*2); | |||||
| assert(d == e); | |||||
| e = -e; | |||||
| carla_add(&d, &e, 1); | |||||
| assert(d == 0); | |||||
| carla_copy(&d, &e, 1); | |||||
| assert(d == -1527*2); | |||||
| assert(d == e); | |||||
| carla_fill(&d, 9999, 1); | |||||
| carla_fill(&e, 123, 1); | |||||
| assert(d == 9999); | |||||
| assert(e == 123); | |||||
| carla_zeroStruct(d); | |||||
| assert(d == 0); | |||||
| carla_copyStruct(d, e); | |||||
| assert(d != 0); | |||||
| assert(d == e); | |||||
| carla_fill(a+0, 1, 1); | |||||
| carla_fill(a+1, 2, 1); | |||||
| carla_fill(a+2, 3, 1); | |||||
| carla_fill(a+3, 4, 1); | |||||
| assert(a[0] == 1); | |||||
| assert(a[1] == 2); | |||||
| assert(a[2] == 3); | |||||
| assert(a[3] == 4); | |||||
| carla_copyStruct(c, a, 4); | |||||
| assert(c[0] == a[0]); | |||||
| assert(c[1] == a[1]); | |||||
| assert(c[2] == a[2]); | |||||
| assert(c[3] == a[3]); | |||||
| carla_zeroStruct(c, 4); | |||||
| assert(c[0] == 0); | |||||
| assert(c[1] == 0); | |||||
| assert(c[2] == 0); | |||||
| assert(c[3] == 0); | |||||
| float fl[5]; | |||||
| carla_fill(fl, 1.11f, 5); | |||||
| assert(fl[0] == 1.11f); | |||||
| assert(fl[1] == 1.11f); | |||||
| assert(fl[2] == 1.11f); | |||||
| assert(fl[3] == 1.11f); | |||||
| assert(fl[4] == 1.11f); | |||||
| carla_add(fl, fl, 5); | |||||
| assert(fl[0] == 1.11f*2); | |||||
| assert(fl[1] == 1.11f*2); | |||||
| assert(fl[2] == 1.11f*2); | |||||
| assert(fl[3] == 1.11f*2); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 4); | |||||
| assert(fl[0] == 1.11f*4); | |||||
| assert(fl[1] == 1.11f*4); | |||||
| assert(fl[2] == 1.11f*4); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 3); | |||||
| assert(fl[0] == 1.11f*8); | |||||
| assert(fl[1] == 1.11f*8); | |||||
| assert(fl[2] == 1.11f*8); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 2); | |||||
| assert(fl[0] == 1.11f*16); | |||||
| assert(fl[1] == 1.11f*16); | |||||
| assert(fl[2] == 1.11f*8); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 1); | |||||
| assert(fl[0] == 1.11f*32); | |||||
| assert(fl[1] == 1.11f*16); | |||||
| assert(fl[2] == 1.11f*8); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| } | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| static void test_CarlaMathUtils() | |||||
| { | |||||
| // ------------------------------------------------------------------- | |||||
| // math functions (base) | |||||
| // Return the lower of 2 values, with 'min' as the minimum possible value. | |||||
| assert(carla_min(0, 0, 0) == 0); | |||||
| assert(carla_min(0, 3, 0) == 0); | |||||
| assert(carla_min(3, 0, 0) == 0); | |||||
| assert(carla_min(0, 0, 3) == 3); | |||||
| assert(carla_min(0, 1, 3) == 3); | |||||
| assert(carla_min(0, 2, 3) == 3); | |||||
| assert(carla_min(0, 3, 3) == 3); | |||||
| assert(carla_min(0, 4, 3) == 3); | |||||
| assert(carla_min(5, 0, 3) == 3); | |||||
| assert(carla_min(5, 1, 3) == 3); | |||||
| assert(carla_min(5, 2, 3) == 3); | |||||
| assert(carla_min(5, 3, 3) == 3); | |||||
| assert(carla_min(5, 4, 3) == 4); | |||||
| assert(carla_min(5, 5, 3) == 5); | |||||
| assert(carla_min(5, 6, 3) == 5); | |||||
| assert(carla_min(2, -2, 0) == 0); | |||||
| assert(carla_min(2, -1, 0) == 0); | |||||
| assert(carla_min(2, 0, 0) == 0); | |||||
| assert(carla_min(2, 1, 0) == 1); | |||||
| assert(carla_min(2, 2, 0) == 2); | |||||
| assert(carla_min(5, -6, 3) == 3); | |||||
| assert(carla_min(5, -5, 3) == 3); | |||||
| assert(carla_min(5, -4, 3) == 3); | |||||
| assert(carla_min(5, -3, 3) == 3); | |||||
| assert(carla_min(5, -2, 3) == 3); | |||||
| assert(carla_min(5, -1, 3) == 3); | |||||
| assert(carla_min(5, 0, 3) == 3); | |||||
| assert(carla_min(5, 1, 3) == 3); | |||||
| assert(carla_min(5, 2, 3) == 3); | |||||
| assert(carla_min(5, 3, 3) == 3); | |||||
| assert(carla_min(5, 4, 3) == 4); | |||||
| assert(carla_min(5, 5, 3) == 5); | |||||
| assert(carla_min(5, 6, 3) == 5); | |||||
| assert(carla_min(5, -6, -3) == -3); | |||||
| assert(carla_min(5, -5, -3) == -3); | |||||
| assert(carla_min(5, -4, -3) == -3); | |||||
| assert(carla_min(5, -3, -3) == -3); | |||||
| assert(carla_min(5, -2, -3) == -2); | |||||
| assert(carla_min(5, -1, -3) == -1); | |||||
| assert(carla_min(5, 0, -3) == 0); | |||||
| assert(carla_min(5, 1, -3) == 1); | |||||
| assert(carla_min(5, 2, -3) == 2); | |||||
| assert(carla_min(5, 3, -3) == 3); | |||||
| assert(carla_min(5, 4, -3) == 4); | |||||
| assert(carla_min(5, 5, -3) == 5); | |||||
| assert(carla_min(5, 6, -3) == 5); | |||||
| // Return the lower positive of 2 values. | |||||
| assert(carla_minPositive(0, 0) == 0); | |||||
| assert(carla_minPositive(0, 1) == 0); | |||||
| assert(carla_minPositive(0, 2) == 0); | |||||
| assert(carla_minPositive(0, 3) == 0); | |||||
| assert(carla_minPositive(1, 0) == 0); | |||||
| assert(carla_minPositive(1, 1) == 1); | |||||
| assert(carla_minPositive(1, 2) == 1); | |||||
| assert(carla_minPositive(1, 3) == 1); | |||||
| assert(carla_minPositive(3, 0) == 0); | |||||
| assert(carla_minPositive(3, 1) == 1); | |||||
| assert(carla_minPositive(3, 2) == 2); | |||||
| assert(carla_minPositive(3, 3) == 3); | |||||
| assert(carla_minPositive(-1, 0) == 0); | |||||
| assert(carla_minPositive(-1, 1) == 1); | |||||
| assert(carla_minPositive(-1, 2) == 2); | |||||
| assert(carla_minPositive(-1, 3) == 3); | |||||
| // Return the higher of 2 values, with 'max' as the maximum possible value. | |||||
| assert(carla_max(0, 0, 0) == 0); | |||||
| assert(carla_max(0, 3, 0) == 0); | |||||
| assert(carla_max(3, 0, 0) == 0); | |||||
| assert(carla_max(0, 0, 3) == 0); | |||||
| assert(carla_max(0, 1, 3) == 1); | |||||
| assert(carla_max(0, 2, 3) == 2); | |||||
| assert(carla_max(0, 3, 3) == 3); | |||||
| assert(carla_max(0, 4, 3) == 3); | |||||
| assert(carla_max(5, 0, 3) == 3); | |||||
| assert(carla_max(5, 1, 3) == 3); | |||||
| assert(carla_max(5, 2, 3) == 3); | |||||
| assert(carla_max(5, 3, 3) == 3); | |||||
| assert(carla_max(5, 4, 3) == 3); | |||||
| assert(carla_max(5, 5, 3) == 3); | |||||
| assert(carla_max(5, 6, 3) == 3); | |||||
| // Fix bounds of 'value' between 'min' and 'max'. | |||||
| assert(carla_fixValue(0, 1, -1) == 0); | |||||
| assert(carla_fixValue(0, 1, 0) == 0); | |||||
| assert(carla_fixValue(0, 1, 1) == 1); | |||||
| assert(carla_fixValue(0, 1, 2) == 1); | |||||
| assert(carla_fixValue(0.0, 1.0, -1.0) == 0.0); | |||||
| assert(carla_fixValue(0.0, 1.0, 0.0) == 0.0); | |||||
| assert(carla_fixValue(0.0, 1.0, 1.0) == 1.0); | |||||
| assert(carla_fixValue(0.0, 1.0, 2.0) == 1.0); | |||||
| assert(carla_fixValue(0.0, 1.0, -0.1) == 0.0); | |||||
| assert(carla_fixValue(0.0, 1.0, 1.1) == 1.0); | |||||
| // Get next power of 2. | |||||
| assert(carla_nextPowerOf2(0) == 0); | |||||
| assert(carla_nextPowerOf2(1) == 1); | |||||
| assert(carla_nextPowerOf2(2) == 2); | |||||
| assert(carla_nextPowerOf2(4) == 4); | |||||
| assert(carla_nextPowerOf2(5) == 8); | |||||
| assert(carla_nextPowerOf2(6) == 8); | |||||
| assert(carla_nextPowerOf2(7) == 8); | |||||
| assert(carla_nextPowerOf2(8) == 8); | |||||
| assert(carla_nextPowerOf2(9) == 16); | |||||
| uint32_t power = 1; | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 2); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 4); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 8); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 16); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 32); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 64); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 128); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 256); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 512); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 1024); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 2048); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 4096); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 8192); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 16384); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 32768); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 65536); | |||||
| assert((power = carla_nextPowerOf2(power+1)) == 131072); | |||||
| // ------------------------------------------------------------------- | |||||
| // math functions (extended) | |||||
| // carla_addFloat, carla_copyFloat & carla_zeroFloat tests skipped | |||||
| // mostly unused due to juce::FloatVectorOperations | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| static void test_CarlaBackendUtils() | |||||
| { | |||||
| CARLA_BACKEND_USE_NAMESPACE | |||||
| carla_stdout(PluginOption2Str(PLUGIN_OPTION_FIXED_BUFFERS)); | |||||
| carla_stdout(BinaryType2Str(BINARY_NONE)); | |||||
| carla_stdout(PluginType2Str(PLUGIN_NONE)); | |||||
| carla_stdout(PluginCategory2Str(PLUGIN_CATEGORY_NONE)); | |||||
| carla_stdout(ParameterType2Str(PARAMETER_UNKNOWN)); | |||||
| carla_stdout(InternalParameterIndex2Str(PARAMETER_NULL)); | |||||
| carla_stdout(EngineCallbackOpcode2Str(ENGINE_CALLBACK_DEBUG)); | |||||
| carla_stdout(EngineOption2Str(ENGINE_OPTION_DEBUG)); | |||||
| carla_stdout(EngineProcessMode2Str(ENGINE_PROCESS_MODE_SINGLE_CLIENT)); | |||||
| carla_stdout(EngineTransportMode2Str(ENGINE_TRANSPORT_MODE_INTERNAL)); | |||||
| carla_stdout(FileCallbackOpcode2Str(FILE_CALLBACK_DEBUG)); | |||||
| carla_stdout(getPluginTypeAsString(PLUGIN_INTERNAL)); | |||||
| carla_stdout(PatchbayIcon2Str(PATCHBAY_ICON_APPLICATION)); | |||||
| getPluginTypeFromString("none"); | |||||
| getPluginCategoryFromName("cat"); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| static void test_CarlaEngineUtils() | |||||
| { | |||||
| CARLA_BACKEND_USE_NAMESPACE | |||||
| carla_stdout(EngineType2Str(kEngineTypeNull)); | |||||
| carla_stdout(EnginePortType2Str(kEnginePortTypeNull)); | |||||
| carla_stdout(EngineEventType2Str(kEngineEventTypeNull)); | |||||
| carla_stdout(EngineControlEventType2Str(kEngineControlEventTypeNull)); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| // main | |||||
| int main() | |||||
| { | |||||
| test_CarlaUtils(); | |||||
| test_CarlaMathUtils(); | |||||
| test_CarlaBackendUtils(); | |||||
| test_CarlaEngineUtils(); | |||||
| return 0; | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| @@ -6,19 +6,19 @@ | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| BASE_FLAGS = -Wall -Wextra -Werror -fPIC -DPIC -pipe -DREAL_BUILD | |||||
| BASE_FLAGS += -Wcast-qual -Wconversion -Wlogical-op | |||||
| BASE_FLAGS += -Wsign-conversion -Wuninitialized -Wunused-parameter | |||||
| BASE_FLAGS += -DDEBUG -O0 -g | |||||
| BASE_FLAGS += -I. -I../backend -I../includes -I../utils | |||||
| BASE_FLAGS += -isystem ../modules | |||||
| BASE_FLAGS = -Wall -Wextra -Werror -fPIC -DPIC -pipe -DREAL_BUILD -DDEBUG -O0 -g | |||||
| BASE_FLAGS += -I. -I../backend -I../includes -I../utils -isystem ../modules | |||||
| BASE_FLAGS += -Wcast-align -Wcast-qual -Wconversion -Wmissing-declarations -Wsign-conversion -Wuninitialized -Wunused-parameter | |||||
| BASE_FLAGS += -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings | |||||
| ifneq ($(CC),clang-3.4) | |||||
| BASE_FLAGS += -Wlogical-op | |||||
| endif | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| ANSI_FLAGS = $(BASE_FLAGS) -DBUILD_ANSI_TEST | ANSI_FLAGS = $(BASE_FLAGS) -DBUILD_ANSI_TEST | ||||
| ANSI_FLAGS += -ansi -pedantic -pedantic-errors -Waggregate-return | ANSI_FLAGS += -ansi -pedantic -pedantic-errors -Waggregate-return | ||||
| ANSI_FLAGS += -I../backend -I../includes | |||||
| ANSI_FLAGS += -L../backend -lcarla_standalone2 | |||||
| # ANSI_FLAGS += -L../backend -lcarla_standalone2 | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| @@ -28,13 +28,22 @@ GNU_CXX_FLAGS += -std=c++11 -std=gnu++11 -Wzero-as-null-pointer-constant | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| PEDANTIC_CXX_FLAGS = $(BASE_FLAGS) | PEDANTIC_CXX_FLAGS = $(BASE_FLAGS) | ||||
| PEDANTIC_CXX_FLAGS += -std=c++11 -pedantic -pedantic-errors -Wzero-as-null-pointer-constant -Wno-vla | |||||
| PEDANTIC_CXX_FLAGS += -std=c++11 -pedantic -pedantic-errors | |||||
| PEDANTIC_CXX_FLAGS += -isystem /opt/kxstudio/include | PEDANTIC_CXX_FLAGS += -isystem /opt/kxstudio/include | ||||
| PEDANTIC_CXX_FLAGS += -Wno-vla -Wno-vla-extension | |||||
| ifeq ($(CC),clang-3.4) | |||||
| PEDANTIC_CXX_FLAGS += -Wno-vla-extension | |||||
| else | |||||
| PEDANTIC_CXX_FLAGS += -Wunsafe-loop-optimizations -Wzero-as-null-pointer-constant | |||||
| endif | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| TARGETS = ansi-pedantic-test_c ansi-pedantic-test_c99 ansi-pedantic-test_cxx ansi-pedantic-test_cxx11 | |||||
| TARGETS += CarlaString EngineEvents PipeServer Print RtLinkedList RtLinkedListGnu Utils | |||||
| TARGETS = ansi-pedantic-test_c ansi-pedantic-test_c99 | |||||
| TARGETS += CarlaString CarlaUtils | |||||
| # ansi-pedantic-test_cxx ansi-pedantic-test_cxx11 | |||||
| # TARGETS += EngineEvents PipeServer Print RtLinkedList RtLinkedListGnu Utils | |||||
| all: $(TARGETS) | all: $(TARGETS) | ||||
| @@ -44,13 +53,23 @@ ansi-pedantic-test_c: ansi-pedantic-test.c ../backend/Carla*.h | |||||
| $(CC) $< $(ANSI_FLAGS) -Wc++-compat -o $@ | $(CC) $< $(ANSI_FLAGS) -Wc++-compat -o $@ | ||||
| ansi-pedantic-test_c99: ansi-pedantic-test.c ../backend/Carla*.h | ansi-pedantic-test_c99: ansi-pedantic-test.c ../backend/Carla*.h | ||||
| $(CC) $< $(ANSI_FLAGS) -std=c99 -Wc++-compat -o $@ | |||||
| $(CC) $< $(ANSI_FLAGS) -std=c99 -pedantic -pedantic-errors -Wc++-compat -o $@ | |||||
| ansi-pedantic-test_cxx: ansi-pedantic-test.c ../backend/Carla*.h | |||||
| ansi-pedantic-test_cxx: ansi-pedantic-test.cpp ../backend/Carla*.h | |||||
| $(CXX) $< $(ANSI_FLAGS) -o $@ | $(CXX) $< $(ANSI_FLAGS) -o $@ | ||||
| ansi-pedantic-test_cxx11: ansi-pedantic-test.c ../backend/Carla*.h | |||||
| $(CXX) $< $(ANSI_FLAGS) -std=c++11 -Wzero-as-null-pointer-constant -o $@ | |||||
| ansi-pedantic-test_cxx11: ansi-pedantic-test.cpp ../backend/Carla*.h | |||||
| $(CXX) $< $(ANSI_FLAGS) -std=c++11 -pedantic -pedantic-errors -o $@ | |||||
| # -------------------------------------------------------------- | |||||
| CarlaString: CarlaString.cpp ../utils/CarlaString.hpp | |||||
| $(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@ | |||||
| valgrind --leak-check=full ./$@ | |||||
| CarlaUtils: CarlaUtils.cpp ../utils/*.hpp | |||||
| $(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@ | |||||
| valgrind --leak-check=full ./$@ | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| @@ -62,10 +81,6 @@ CarlaMutex: CarlaMutex.cpp ../utils/CarlaMutex.hpp | |||||
| $(CXX) $< -lpthread -o $@ | $(CXX) $< -lpthread -o $@ | ||||
| valgrind --leak-check=full ./$@ | valgrind --leak-check=full ./$@ | ||||
| CarlaString: CarlaString.cpp ../utils/CarlaString.hpp | |||||
| $(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@ | |||||
| valgrind --leak-check=full ./$@ | |||||
| Engine: Engine.cpp | Engine: Engine.cpp | ||||
| $(CXX) $< \ | $(CXX) $< \ | ||||
| ../backend/standalone/CarlaStandalone.cpp.o \ | ../backend/standalone/CarlaStandalone.cpp.o \ | ||||
| @@ -101,10 +116,6 @@ RtLinkedListGnu: RtLinkedList.cpp ../utils/LinkedList.hpp ../utils/RtLinkedList. | |||||
| $(CXX) $< ../modules/rtmempool.a $(GNU_CXX_FLAGS) -lpthread -o $@ | $(CXX) $< ../modules/rtmempool.a $(GNU_CXX_FLAGS) -lpthread -o $@ | ||||
| valgrind ./$@ | valgrind ./$@ | ||||
| Utils: Utils.cpp ../utils/*.hpp | |||||
| $(CXX) $< $(PEDANTIC_CXX_FLAGS) -ldl -lpthread -o $@ | |||||
| valgrind ./$@ | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| Rewire.exe: Rewire.cpp.o | Rewire.exe: Rewire.cpp.o | ||||
| @@ -1,302 +0,0 @@ | |||||
| /* | |||||
| * Carla Utility Tests | |||||
| * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com> | |||||
| * | |||||
| * 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 "CarlaUtils.hpp" | |||||
| #include "CarlaBackendUtils.hpp" | |||||
| #include "CarlaBridgeUtils.hpp" | |||||
| // #include "CarlaDssiUtils.hpp" | |||||
| #include "CarlaJuceUtils.hpp" | |||||
| #include "CarlaLadspaUtils.hpp" | |||||
| // #include "CarlaLibUtils.hpp" | |||||
| // #include "CarlaLv2Utils.hpp" | |||||
| #include "CarlaMathUtils.hpp" | |||||
| #include "CarlaOscUtils.hpp" | |||||
| #include "CarlaPipeUtils.hpp" | |||||
| // #include "CarlaShmUtils.hpp" | |||||
| // #include "CarlaStateUtils.hpp" | |||||
| // #include "CarlaVstUtils.hpp" | |||||
| // #include "CarlaLibCounter.hpp" | |||||
| // #include "CarlaLogThread.hpp" | |||||
| // #include "CarlaMutex.hpp" | |||||
| // #include "CarlaRingBuffer.hpp" | |||||
| // #include "CarlaString.hpp" | |||||
| // #include "CarlaThread.hpp" | |||||
| // #include "List.hpp" | |||||
| // #include "Lv2AtomQueue.hpp" | |||||
| // #include "RtList.hpp" | |||||
| // #include "JucePluginWindow.hpp" | |||||
| struct MyStruct { | |||||
| char pad[100]; | |||||
| int i; | |||||
| double d; | |||||
| void* ptr; | |||||
| }; | |||||
| class MyLeakCheckedClass | |||||
| { | |||||
| public: | |||||
| MyLeakCheckedClass() noexcept {} | |||||
| ~MyLeakCheckedClass() noexcept {} | |||||
| private: | |||||
| char pad[100]; | |||||
| int i; | |||||
| double d; | |||||
| void* ptr; | |||||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MyLeakCheckedClass) | |||||
| }; | |||||
| #if 0 | |||||
| class MyThread : public CarlaThread | |||||
| { | |||||
| public: | |||||
| MyThread(CarlaMutex* const m) | |||||
| : CarlaThread("myThread"), | |||||
| fMu(m) | |||||
| { | |||||
| } | |||||
| protected: | |||||
| void run() override | |||||
| { | |||||
| carla_stderr("Thread started"); | |||||
| carla_stderr("Thread lock"); | |||||
| fMu->lock(); | |||||
| carla_stderr("Thread sleeping"); | |||||
| carla_sleep(3); | |||||
| carla_stderr("Thread unlock"); | |||||
| fMu->unlock(); | |||||
| carla_stderr("Thread sleep-waiting for stop"); | |||||
| while (! shouldExit()) | |||||
| carla_sleep(1); | |||||
| carla_stderr("Thread finished"); | |||||
| return; | |||||
| vstPluginCanDo(nullptr, "something"); | |||||
| } | |||||
| private: | |||||
| CarlaMutex* const fMu; | |||||
| }; | |||||
| #endif | |||||
| int main() | |||||
| { | |||||
| // misc functions | |||||
| bool2str(false); | |||||
| bool2str(true); | |||||
| pass(); | |||||
| // string print functions | |||||
| carla_debug("DEBUG"); | |||||
| carla_stdout("STDOUT"); | |||||
| carla_stderr("STDERR"); | |||||
| carla_stderr2("STDERR2"); | |||||
| // carla_*sleep | |||||
| carla_sleep(1); | |||||
| carla_msleep(1); | |||||
| // carla_setenv | |||||
| carla_setenv("THIS", "THAT"); | |||||
| assert(std::strcmp(std::getenv("THIS"), "THAT") == 0); | |||||
| // carla_strdup | |||||
| const char* const str1(carla_strdup("string1")); | |||||
| const char* const strF(carla_strdup_free(strdup("stringFree"))); | |||||
| delete[] str1; | |||||
| delete[] strF; | |||||
| { | |||||
| struct TestStruct { | |||||
| const char* str1; | |||||
| const char* str2; | |||||
| const char* str3; | |||||
| const char* str4; | |||||
| TestStruct() | |||||
| : str1(carla_strdup("str1")), | |||||
| str2(carla_strdup("str2")), | |||||
| str3(nullptr), | |||||
| str4(carla_strdup("str4")) {} | |||||
| ~TestStruct() | |||||
| { | |||||
| if (str1 != nullptr) | |||||
| { | |||||
| delete[] str1; | |||||
| str1 = nullptr; | |||||
| } | |||||
| if (str2 != nullptr) | |||||
| { | |||||
| delete[] str2; | |||||
| str2 = nullptr; | |||||
| } | |||||
| if (str3 != nullptr) | |||||
| { | |||||
| delete[] str3; | |||||
| str3 = nullptr; | |||||
| } | |||||
| if (str4 != nullptr) | |||||
| { | |||||
| delete[] str4; | |||||
| str4 = nullptr; | |||||
| } | |||||
| } | |||||
| }; | |||||
| TestStruct a, b, c; | |||||
| } | |||||
| // math/memory functions | |||||
| { | |||||
| assert(carla_min<int32_t>(0, -5, 8) == 8); | |||||
| assert(carla_max<int32_t>(0, -5, 8) == 0); | |||||
| assert(carla_fixValue<float>(0.0f, 1.0f, 1.1f) == 1.0f); | |||||
| int v1 = 6; | |||||
| int v2 = 8; | |||||
| const int v3 = 9; | |||||
| assert(v1 == 6 && v2 == 8 && v3 == 9); | |||||
| carla_copy<int>(&v1, &v2, 1); | |||||
| assert(v1 == 8 && v2 == 8 && v3 == 9); | |||||
| carla_copy<int>(&v2, &v3, 1); | |||||
| assert(v1 == 8 && v2 == 9 && v3 == 9); | |||||
| float fl[5]; | |||||
| carla_fill(fl, 5, 1.11f); | |||||
| assert(fl[0] == 1.11f); | |||||
| assert(fl[1] == 1.11f); | |||||
| assert(fl[2] == 1.11f); | |||||
| assert(fl[3] == 1.11f); | |||||
| assert(fl[4] == 1.11f); | |||||
| carla_add(fl, fl, 5); | |||||
| assert(fl[0] == 1.11f*2); | |||||
| assert(fl[1] == 1.11f*2); | |||||
| assert(fl[2] == 1.11f*2); | |||||
| assert(fl[3] == 1.11f*2); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 4); | |||||
| assert(fl[0] == 1.11f*4); | |||||
| assert(fl[1] == 1.11f*4); | |||||
| assert(fl[2] == 1.11f*4); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 3); | |||||
| assert(fl[0] == 1.11f*8); | |||||
| assert(fl[1] == 1.11f*8); | |||||
| assert(fl[2] == 1.11f*8); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 2); | |||||
| assert(fl[0] == 1.11f*16); | |||||
| assert(fl[1] == 1.11f*16); | |||||
| assert(fl[2] == 1.11f*8); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| carla_add(fl, fl, 1); | |||||
| assert(fl[0] == 1.11f*32); | |||||
| assert(fl[1] == 1.11f*16); | |||||
| assert(fl[2] == 1.11f*8); | |||||
| assert(fl[3] == 1.11f*4); | |||||
| assert(fl[4] == 1.11f*2); | |||||
| char ch[500]; | |||||
| carla_zeroChar(ch, 500); | |||||
| for (int i=0; i<500; ++i) | |||||
| assert(ch[i] == '\0'); | |||||
| } | |||||
| { | |||||
| MyStruct a, b, c[2], d[2]; | |||||
| carla_zeroMem(&a, sizeof(MyStruct)); | |||||
| carla_zeroStruct<MyStruct>(b); | |||||
| carla_zeroStruct<MyStruct>(c, 2); | |||||
| carla_copyStruct<MyStruct>(b, a); | |||||
| carla_copyStruct<MyStruct>(d, c, 2); | |||||
| } | |||||
| // Leak check | |||||
| { | |||||
| MyLeakCheckedClass a; | |||||
| MyLeakCheckedClass* const b(new MyLeakCheckedClass); | |||||
| delete b; | |||||
| } | |||||
| #if 0 | |||||
| // Mutex | |||||
| { | |||||
| CarlaMutex m; | |||||
| assert(! m.wasTryLockCalled()); | |||||
| assert(m.tryLock()); | |||||
| assert(m.wasTryLockCalled()); | |||||
| assert(! m.wasTryLockCalled()); // once | |||||
| m.unlock(); | |||||
| m.lock(); | |||||
| assert(! m.wasTryLockCalled()); | |||||
| { CarlaMutex::ScopedUnlocker su(m); } | |||||
| assert(! m.wasTryLockCalled()); | |||||
| m.unlock(); | |||||
| { CarlaMutex::ScopedLocker sl(m); } | |||||
| } | |||||
| // String | |||||
| { | |||||
| CarlaString a, b(2), c("haha"), d((uint)0x999, true), e(0.7f), f(0.9), g('u'); | |||||
| assert(g == "u"); | |||||
| } | |||||
| // Thread | |||||
| { | |||||
| CarlaMutex m; | |||||
| MyThread t(&m); | |||||
| carla_stdout("Thread init started"); | |||||
| t.start(); | |||||
| carla_stdout("Thread init finished, lock waiting..."); | |||||
| m.lock(); | |||||
| carla_stdout("Thread lock wait done"); | |||||
| m.unlock(); | |||||
| t.stop(-1); | |||||
| } | |||||
| #endif | |||||
| return 0; | |||||
| } | |||||
| @@ -1,6 +1,6 @@ | |||||
| /* | /* | ||||
| * ANSI pedantic test for the Carla Backend API | |||||
| * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||||
| * ANSI pedantic test for the Carla Backend & Host API | |||||
| * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com> | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
| * modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
| @@ -43,6 +43,7 @@ int main(int argc, char* argv[]) | |||||
| CarlaScalePointInfo j; | CarlaScalePointInfo j; | ||||
| CarlaTransportInfo k; | CarlaTransportInfo k; | ||||
| #if 0 | |||||
| const char* licenseText; | const char* licenseText; | ||||
| const char* fileExtensions; | const char* fileExtensions; | ||||
| @@ -79,7 +80,7 @@ int main(int argc, char* argv[]) | |||||
| if (carla_engine_init("JACK", "ansi-test")) | if (carla_engine_init("JACK", "ansi-test")) | ||||
| { | { | ||||
| if (carla_add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", NULL)) | |||||
| if (carla_add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", 0, NULL)) | |||||
| { | { | ||||
| carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); | carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); | ||||
| carla_transport_play(); | carla_transport_play(); | ||||
| @@ -91,6 +92,7 @@ int main(int argc, char* argv[]) | |||||
| carla_engine_close(); | carla_engine_close(); | ||||
| } | } | ||||
| #endif | |||||
| return 0; | return 0; | ||||
| @@ -0,0 +1 @@ | |||||
| ansi-pedantic-test.c | |||||
| @@ -27,7 +27,7 @@ CARLA_BACKEND_START_NAMESPACE | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| static inline | static inline | ||||
| const char* PluginOption2Str(const unsigned int option) noexcept | |||||
| const char* PluginOption2Str(const uint option) noexcept | |||||
| { | { | ||||
| switch (option) | switch (option) | ||||
| { | { | ||||
| @@ -253,8 +253,6 @@ const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept | |||||
| return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED"; | return "ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED"; | ||||
| case ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED: | case ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED: | ||||
| return "ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED"; | return "ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED"; | ||||
| case ENGINE_CALLBACK_PATCHBAY_PORT_VALUE_CHANGED: | |||||
| return "ENGINE_CALLBACK_PATCHBAY_PORT_VALUE_CHANGED"; | |||||
| case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED: | case ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED: | ||||
| return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED"; | return "ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED"; | ||||
| case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED: | case ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED: | ||||
| @@ -370,8 +368,6 @@ const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| // ----------------------------------------------------------------------- | |||||
| static inline | static inline | ||||
| const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept | const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept | ||||
| { | { | ||||
| @@ -389,6 +385,29 @@ const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| static inline | |||||
| const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept | |||||
| { | |||||
| switch (icon) | |||||
| { | |||||
| case PATCHBAY_ICON_APPLICATION: | |||||
| return "PATCHBAY_ICON_APPLICATION"; | |||||
| case PATCHBAY_ICON_PLUGIN: | |||||
| return "PATCHBAY_ICON_PLUGIN"; | |||||
| case PATCHBAY_ICON_HARDWARE: | |||||
| return "PATCHBAY_ICON_HARDWARE"; | |||||
| case PATCHBAY_ICON_CARLA: | |||||
| return "PATCHBAY_ICON_CARLA"; | |||||
| case PATCHBAY_ICON_DISTRHO: | |||||
| return "PATCHBAY_ICON_DISTRHO"; | |||||
| case PATCHBAY_ICON_FILE: | |||||
| return "PATCHBAY_ICON_FILE"; | |||||
| } | |||||
| carla_stderr("CarlaBackend::PatchbayIcon2Str(%i) - invalid icon", icon); | |||||
| return nullptr; | |||||
| } | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| static inline | static inline | ||||
| @@ -53,6 +53,25 @@ const T& carla_min(const T& v1, const T& v2, const T& min) noexcept | |||||
| return ((v1 <= min || v2 <= min) ? min : (v1 < v2 ? v1 : v2)); | return ((v1 <= min || v2 <= min) ? min : (v1 < v2 ? v1 : v2)); | ||||
| } | } | ||||
| /* | |||||
| * Return the lower positive of 2 values. | |||||
| * If one of the values is zero, returns zero. | |||||
| * If one value is negative but the other positive, returns the positive. | |||||
| * Returned value is guaranteed to be >= 0. | |||||
| */ | |||||
| template<typename T> | |||||
| static inline | |||||
| T carla_minPositive(const T& v1, const T& v2) noexcept | |||||
| { | |||||
| if (v1 == 0 || v2 == 0) | |||||
| return 0; | |||||
| if (v1 < 0) | |||||
| return (v2 > 0) ? v2 : 0; | |||||
| if (v2 < 0) | |||||
| return (v1 > 0) ? v1 : 0; | |||||
| return (v1 < v2 ? v1 : v2); | |||||
| } | |||||
| /* | /* | ||||
| * Return the higher of 2 values, with 'max' as the maximum possible value. | * Return the higher of 2 values, with 'max' as the maximum possible value. | ||||
| */ | */ | ||||
| @@ -321,7 +321,7 @@ void carla_copy(T* const dataDst, const T* const dataSrc, const size_t size) noe | |||||
| */ | */ | ||||
| template<typename T> | template<typename T> | ||||
| static inline | static inline | ||||
| void carla_fill(T* data, const size_t size, const T v) noexcept | |||||
| void carla_fill(T* data, const T v, const size_t size) noexcept | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | ||||
| CARLA_SAFE_ASSERT_RETURN(size > 0,); | CARLA_SAFE_ASSERT_RETURN(size > 0,); | ||||