| @@ -18,21 +18,27 @@ WINDRES ?= windres | |||
| DEBUG ?= false | |||
| ifeq ($(DEBUG),true) | |||
| BASE_FLAGS = -O0 -g -Wall -Wextra | |||
| BASE_FLAGS = -O0 -g | |||
| BASE_FLAGS += -DDEBUG | |||
| STRIP = true # FIXME | |||
| else | |||
| BASE_FLAGS = -O2 -ffast-math -mtune=generic -msse -mfpmath=sse -Wall -Wextra | |||
| BASE_FLAGS = -O2 -ffast-math -mtune=generic -msse -mfpmath=sse | |||
| BASE_FLAGS += -DNDEBUG | |||
| endif | |||
| BASE_FLAGS += -ansi -pedantic -pedantic-errors -Wall -Wextra -Wformat=2 -Wunused-parameter -Wuninitialized | |||
| BASE_FLAGS += -Wcast-qual -Wconversion -Wsign-conversion -Wlogical-op -Waggregate-return | |||
| BASE_FLAGS += -fipa-pure-const -Wsuggest-attribute=noreturn #pure,const,noreturn | |||
| BASE_FLAGS += -Wno-vla -isystem /usr/include/qt4/ | |||
| 32BIT_FLAGS = -m32 | |||
| 64BIT_FLAGS = -m64 | |||
| BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 $(CFLAGS) | |||
| BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -Wc++-compat -Wunsuffixed-float-constants -Wwrite-strings $(CFLAGS) | |||
| BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x $(CXXFLAGS) | |||
| LINK_FLAGS = $(LDFLAGS) | |||
| # BUILD_CXX_FLAGS += -Wzero-as-null-pointer-constant | |||
| ifneq ($(DEBUG),true) | |||
| BUILD_CXX_FLAGS += -DQT_NO_DEBUG -DQT_NO_DEBUG_STREAM -DQT_NO_DEBUG_OUTPUT | |||
| endif | |||
| @@ -217,7 +217,8 @@ enum InternalParametersIndex { | |||
| PARAMETER_VOLUME = -4, //!< Volume parameter, range 0.0...1.27; default is 1.0. | |||
| PARAMETER_BALANCE_LEFT = -5, //!< Stereo Balance-Left parameter, range -1.0...1.0; default is -1.0. | |||
| PARAMETER_BALANCE_RIGHT = -6, //!< Stereo Balance-Right parameter, range -1.0...1.0; default is 1.0. | |||
| PARAMETER_PANNING = -7 //!< Mono Panning parameter, range -1.0...1.0; default is 0.0. | |||
| PARAMETER_PANNING = -7, //!< Mono Panning parameter, range -1.0...1.0; default is 0.0. | |||
| PARAMETER_MAX = -8 //!< Max value, defined for convenience | |||
| }; | |||
| /*! | |||
| @@ -576,6 +577,19 @@ struct ParameterRanges { | |||
| step(0.01f), | |||
| stepSmall(0.0001f), | |||
| stepLarge(0.1f) {} | |||
| void fixDefault() | |||
| { | |||
| fixValue(def); | |||
| } | |||
| void fixValue(float& value) const | |||
| { | |||
| if (value < min) | |||
| value = min; | |||
| else if (value > max) | |||
| value = max; | |||
| } | |||
| }; | |||
| /*! | |||
| @@ -593,8 +607,7 @@ struct MidiProgramData { | |||
| ~MidiProgramData() | |||
| { | |||
| if (name) | |||
| free((void*)name); | |||
| std::free((void*)name); | |||
| } | |||
| }; | |||
| @@ -616,14 +629,9 @@ struct CustomData { | |||
| ~CustomData() | |||
| { | |||
| if (type) | |||
| ::free((void*)type); | |||
| if (key) | |||
| ::free((void*)key); | |||
| if (value) | |||
| ::free((void*)value); | |||
| std::free((void*)type); | |||
| std::free((void*)key); | |||
| std::free((void*)value); | |||
| } | |||
| }; | |||
| @@ -70,11 +70,13 @@ enum EnginePortType { | |||
| /*! | |||
| * Audio port type. | |||
| * \see CarlaEngineAudioPort | |||
| */ | |||
| kEnginePortTypeAudio = 1, | |||
| /*! | |||
| * Event port type. | |||
| ** \see CarlaEngineEventPort | |||
| */ | |||
| kEnginePortTypeEvent = 2 | |||
| }; | |||
| @@ -254,9 +256,9 @@ struct EngineOptions { | |||
| forceStereo(false), | |||
| preferPluginBridges(false), | |||
| preferUiBridges(true), | |||
| #ifdef WANT_DSSI | |||
| #ifdef WANT_DSSI | |||
| useDssiVstChunks(false), | |||
| #endif | |||
| #endif | |||
| maxParameters(MAX_DEFAULT_PARAMETERS), | |||
| oscUiTimeout(4000), | |||
| preferredBufferSize(512), | |||
| @@ -340,9 +342,8 @@ public: | |||
| virtual void initBuffer(CarlaEngine* const engine) = 0; | |||
| protected: | |||
| const bool isInput; | |||
| const ProcessMode processMode; | |||
| void* buffer; | |||
| const bool kIsInput; | |||
| const ProcessMode kProcessMode; | |||
| private: | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEnginePort) | |||
| @@ -380,6 +381,9 @@ public: | |||
| */ | |||
| virtual void initBuffer(CarlaEngine* const engine); | |||
| protected: | |||
| float* fBuffer; | |||
| private: | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineAudioPort) | |||
| }; | |||
| @@ -443,7 +447,8 @@ public: | |||
| virtual void writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t* const data, const uint8_t size); | |||
| private: | |||
| const uint32_t m_maxEventCount; | |||
| const uint32_t kMaxEventCount; | |||
| EngineEvent* fBuffer; | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineEventPort) | |||
| }; | |||
| @@ -512,12 +517,12 @@ public: | |||
| virtual const CarlaEnginePort* addPort(const EnginePortType portType, const char* const name, const bool isInput) = 0; | |||
| protected: | |||
| const EngineType engineType; | |||
| const ProcessMode processMode; | |||
| const EngineType kEngineType; | |||
| const ProcessMode kProcessMode; | |||
| private: | |||
| bool m_active; | |||
| uint32_t m_latency; | |||
| bool fActive; | |||
| uint32_t fLatency; | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineClient) | |||
| }; | |||
| @@ -575,12 +580,12 @@ public: | |||
| /*! | |||
| * Maximum client name size. | |||
| */ | |||
| virtual int maxClientNameSize(); | |||
| virtual unsigned int maxClientNameSize(); | |||
| /*! | |||
| * Maximum port name size. | |||
| */ | |||
| virtual int maxPortNameSize(); | |||
| virtual unsigned int maxPortNameSize(); | |||
| /*! | |||
| * Current number of plugins loaded. | |||
| @@ -658,13 +663,13 @@ public: | |||
| * Add new plugin.\n | |||
| * Returns the id of the plugin, or -1 if the operation failed. | |||
| */ | |||
| short addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr); | |||
| int addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr); | |||
| /*! | |||
| * Add new plugin, using native binary type.\n | |||
| * Returns the id of the plugin, or -1 if the operation failed. | |||
| */ | |||
| short addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr) | |||
| int addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr) | |||
| { | |||
| return addPlugin(BINARY_NATIVE, ptype, filename, name, label, extra); | |||
| } | |||
| @@ -672,7 +677,7 @@ public: | |||
| /*! | |||
| * Remove plugin with id \a id. | |||
| */ | |||
| bool removePlugin(const unsigned short id); | |||
| bool removePlugin(const unsigned int id); | |||
| /*! | |||
| * Remove all plugins. | |||
| @@ -842,6 +847,8 @@ protected: | |||
| #ifndef BUILD_BRIDGE | |||
| // Rack mode data | |||
| EngineEvent* getRackEventBuffer(const bool isInput); | |||
| //static const unsigned short MAX_EVENTS = 1024; | |||
| //EngineEvent fRackEventsIn[MAX_EVENTS]; | |||
| //EngineEvent fRackEventsOut[MAX_EVENTS]; | |||
| @@ -919,6 +926,7 @@ private: | |||
| void osc_send_bridge_set_inpeak(const int32_t portId); | |||
| void osc_send_bridge_set_outpeak(const int32_t portId); | |||
| #else | |||
| public: | |||
| void osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName); | |||
| void osc_send_control_add_plugin_end(const int32_t pluginId); | |||
| void osc_send_control_remove_plugin(const int32_t pluginId); | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Native Plugin API | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_NATIVE_H__ | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Native Plugin API | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_NATIVE_HPP__ | |||
| @@ -22,11 +22,8 @@ | |||
| #include "carla_native.h" | |||
| #include "carla_utils.hpp" | |||
| #ifdef WANT_LADSPA | |||
| # include "ladspa_rdf.hpp" | |||
| #endif | |||
| // Avoid including liblo here | |||
| // Avoid including extra libs here | |||
| struct LADSPA_RDF_Descriptor; | |||
| typedef void* lo_address; | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| @@ -35,7 +32,7 @@ CARLA_BACKEND_START_NAMESPACE | |||
| } // Fix editor indentation | |||
| #endif | |||
| #ifndef BUILD_BRIDGE | |||
| #if 0 //ndef BUILD_BRIDGE | |||
| enum PluginBridgeInfoType { | |||
| kPluginBridgeAudioCount, | |||
| kPluginBridgeMidiCount, | |||
| @@ -60,14 +57,14 @@ enum PluginBridgeInfoType { | |||
| }; | |||
| #endif | |||
| enum PluginPostEventType { | |||
| kPluginPostEventNull, | |||
| kPluginPostEventDebug, | |||
| kPluginPostEventParameterChange, // param, N, value | |||
| kPluginPostEventProgramChange, // index | |||
| kPluginPostEventMidiProgramChange, // index | |||
| kPluginPostEventNoteOn, // channel, note, velo | |||
| kPluginPostEventNoteOff // channel, note | |||
| enum PluginPostRtEventType { | |||
| kPluginPostRtEventNull, | |||
| kPluginPostRtEventDebug, | |||
| kPluginPostRtEventParameterChange, // param, N, value | |||
| kPluginPostRtEventProgramChange, // index | |||
| kPluginPostRtEventMidiProgramChange, // index | |||
| kPluginPostRtEventNoteOn, // channel, note, velo | |||
| kPluginPostRtEventNoteOff // channel, note | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| @@ -97,7 +94,7 @@ public: | |||
| * \param engine The engine which this plugin belongs to, must not be null | |||
| * \param id The 'id' of this plugin, must be between 0 and CarlaEngine::maxPluginNumber() | |||
| */ | |||
| CarlaPlugin(CarlaEngine* const engine, const unsigned short id); | |||
| CarlaPlugin(CarlaEngine* const engine, const unsigned int id); | |||
| /*! | |||
| * This is the destructor of the base plugin class. | |||
| @@ -167,13 +164,19 @@ public: | |||
| /*! | |||
| * Get the plugin's category (delay, filter, synth, etc). | |||
| */ | |||
| virtual PluginCategory category(); | |||
| virtual PluginCategory category() | |||
| { | |||
| return PLUGIN_CATEGORY_NONE; | |||
| } | |||
| /*! | |||
| * Get the plugin's native unique Id.\n | |||
| * May return 0 on plugin types that don't support Ids. | |||
| */ | |||
| virtual long uniqueId(); | |||
| virtual long uniqueId() | |||
| { | |||
| return 0; | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| // Information (count) | |||
| @@ -372,7 +375,7 @@ public: | |||
| * | |||
| * \see id() | |||
| */ | |||
| void setId(const unsigned short id); | |||
| void setId(const unsigned int id); | |||
| /*! | |||
| * Enable or disable the plugin according to \a yesNo. | |||
| @@ -416,6 +419,8 @@ public: | |||
| * | |||
| * \param sendOsc Send message change over OSC | |||
| * \param sendCallback Send message change to registered callback | |||
| * | |||
| * \note Pure-Stereo plugins only! | |||
| */ | |||
| void setBalanceLeft(double value, const bool sendOsc, const bool sendCallback); | |||
| @@ -425,14 +430,27 @@ public: | |||
| * | |||
| * \param sendOsc Send message change over OSC | |||
| * \param sendCallback Send message change to registered callback | |||
| * | |||
| * \note Pure-Stereo plugins only! | |||
| */ | |||
| void setBalanceRight(double value, const bool sendOsc, const bool sendCallback); | |||
| #ifndef BUILD_BRIDGE | |||
| /*! | |||
| * Set the plugin's output panning value to \a value.\n | |||
| * \a value must be between -1.0 and 1.0. | |||
| * | |||
| * \param sendOsc Send message change over OSC | |||
| * \param sendCallback Send message change to registered callback | |||
| * | |||
| * \note Force-Stereo plugins only! | |||
| */ | |||
| void setPanning(double value, const bool sendOsc, const bool sendCallback); | |||
| #if 0 //ndef BUILD_BRIDGE | |||
| /*! | |||
| * BridgePlugin call used to set internal data. | |||
| */ | |||
| //virtual int setOscBridgeInfo(const PluginBridgeInfoType type, const int argc, const lo_arg* const* const argv, const char* const types); | |||
| virtual int setOscBridgeInfo(const PluginBridgeInfoType type, const int argc, const lo_arg* const* const argv, const char* const types); | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| @@ -536,13 +554,6 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| // Set gui stuff | |||
| /*! | |||
| * Set the plugin's custom GUI container.\n | |||
| * | |||
| * \note This function must be always called from the main thread. | |||
| */ | |||
| //virtual void setGuiContainer(GuiContainer* const container); | |||
| /*! | |||
| * Show (or hide) the plugin's custom GUI according to \a yesNo. | |||
| * | |||
| @@ -589,6 +600,11 @@ public: | |||
| */ | |||
| virtual void bufferSizeChanged(const uint32_t newBufferSize); | |||
| /*! | |||
| * Tell the plugin the current sample rate has changed. | |||
| */ | |||
| virtual void sampleRateChanged(const double newSampleRate); | |||
| /*! | |||
| * Recreate latency audio buffers. | |||
| */ | |||
| @@ -641,7 +657,7 @@ public: | |||
| * Post pone an event of type \a type.\n | |||
| * The event will be processed later, but as soon as possible. | |||
| */ | |||
| void postponeEvent(const PluginPostEventType type, const int32_t value1, const int32_t value2, const double value3, const void* const cdata = nullptr); | |||
| void postponeEvent(const PluginPostRtEventType type, const int32_t value1, const int32_t value2, const double value3); | |||
| /*! | |||
| * Process all the post-poned events. | |||
| @@ -649,12 +665,6 @@ public: | |||
| */ | |||
| void postEventsRun(); | |||
| /*! | |||
| * Handle custom post event.\n | |||
| * Implementation depends on plugin type. | |||
| */ | |||
| virtual void postEventHandleCustom(const int32_t value1, const int32_t value2, const double value3, const void* const cdata); | |||
| /*! | |||
| * Tell the UI a parameter has changed. | |||
| */ | |||
| @@ -732,21 +742,31 @@ public: | |||
| }; | |||
| #ifndef BUILD_BRIDGE | |||
| static size_t getNativePluginCount(); | |||
| static const PluginDescriptor* getNativePluginDescriptor(const size_t index); | |||
| static CarlaPlugin* newNative(const Initializer& init); | |||
| static CarlaPlugin* newBridge(const Initializer& init, const BinaryType btype, const PluginType ptype, const void* const extra); | |||
| #endif | |||
| #ifdef WANT_LADSPA | |||
| static CarlaPlugin* newLADSPA(const Initializer& init, const void* const extra); | |||
| #endif | |||
| #ifdef WANT_DSSI | |||
| static CarlaPlugin* newDSSI(const Initializer& init, const void* const extra); | |||
| #endif | |||
| #ifdef WANT_LV2 | |||
| static CarlaPlugin* newLV2(const Initializer& init); | |||
| #endif | |||
| #ifdef WANT_VST | |||
| static CarlaPlugin* newVST(const Initializer& init); | |||
| #ifndef BUILD_BRIDGE | |||
| #endif | |||
| #ifdef WANT_LINUXSAMPLER | |||
| static CarlaPlugin* newGIG(const Initializer& init); | |||
| static CarlaPlugin* newSF2(const Initializer& init); | |||
| static CarlaPlugin* newSFZ(const Initializer& init); | |||
| static CarlaPlugin* newBridge(const Initializer& init, const BinaryType btype, const PluginType ptype, const void* const extra); | |||
| #endif | |||
| static size_t getNativePluginCount(); | |||
| static const PluginDescriptor* getNativePluginDescriptor(const size_t index); | |||
| #ifdef WANT_FLUIDSYNTH | |||
| static CarlaPlugin* newSF2(const Initializer& init); | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| @@ -9,7 +9,7 @@ include ../../Makefile.mk | |||
| # -------------------------------------------------------------- | |||
| BUILD_CXX_FLAGS += -fvisibility=hidden -fPIC -I. -I.. -I../../includes -I../../libs -I../../utils | |||
| BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore) | |||
| BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore) # liblo -isystem /opt/kxstudio/include/ | |||
| LINK_FLAGS += -shared | |||
| LINK_FLAGS += $(shell pkg-config --libs liblo QtCore) | |||
| @@ -49,16 +49,17 @@ endif | |||
| # -------------------------------------------------------------- | |||
| OBJS = \ | |||
| carla_engine.cpp.o | |||
| carla_engine.cpp.o \ | |||
| jack.cpp.o | |||
| # carla_engine_osc.cpp.o \ | |||
| # carla_engine_thread.cpp.o \ | |||
| # jack.cpp.o \ | |||
| # rtaudio.cpp.o | |||
| ifeq ($(WANT_RTAUDIO),true) | |||
| OBJS += \ | |||
| rtaudio-4.0.11/RtAudio.cpp.o \ | |||
| rtmidi-2.0.1/RtMidi.cpp.o | |||
| # OBJS += \ | |||
| # rtaudio-4.0.11/RtAudio.cpp.o \ | |||
| # rtmidi-2.0.1/RtMidi.cpp.o | |||
| endif | |||
| TARGET = ../carla_engine.so | |||
| @@ -56,7 +56,8 @@ HEADERS += \ | |||
| ../../includes/carla_midi.h \ | |||
| ../../utils/carla_utils.hpp \ | |||
| ../../utils/carla_backend_utils.hpp \ | |||
| ../../utils/carla_juce_utils.hpp | |||
| ../../utils/carla_juce_utils.hpp \ | |||
| ../../utils/carla_osc_utils.hpp | |||
| HEADERS += \ | |||
| plugin/DistrhoPluginInfo.h | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Engine | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_ENGINE_INTERNAL_HPP__ | |||
| @@ -39,14 +39,14 @@ const char* EngineType2Str(const EngineType type) | |||
| { | |||
| switch (type) | |||
| { | |||
| case EngineTypeNull: | |||
| return "EngineTypeNull"; | |||
| case EngineTypeJack: | |||
| return "EngineTypeJack"; | |||
| case EngineTypeRtAudio: | |||
| return "EngineTypeRtAudio"; | |||
| case EngineTypePlugin: | |||
| return "EngineTypePlugin"; | |||
| case kEngineTypeNull: | |||
| return "kEngineTypeNull"; | |||
| case kEngineTypeJack: | |||
| return "kEngineTypeJack"; | |||
| case kEngineTypeRtAudio: | |||
| return "kEngineTypeRtAudio"; | |||
| case kEngineTypePlugin: | |||
| return "kEngineTypePlugin"; | |||
| } | |||
| qWarning("CarlaBackend::EngineType2Str(%i) - invalid type", type); | |||
| @@ -58,12 +58,12 @@ const char* EnginePortType2Str(const EnginePortType type) | |||
| { | |||
| switch (type) | |||
| { | |||
| case EnginePortTypeNull: | |||
| return "EnginePortTypeNull"; | |||
| case EnginePortTypeAudio: | |||
| return "EnginePortTypeAudio"; | |||
| case EnginePortTypeEvent: | |||
| return "EnginePortTypeEvent"; | |||
| case kEnginePortTypeNull: | |||
| return "kEnginePortTypeNull"; | |||
| case kEnginePortTypeAudio: | |||
| return "kEnginePortTypeAudio"; | |||
| case kEnginePortTypeEvent: | |||
| return "kEnginePortTypeEvent"; | |||
| } | |||
| qWarning("CarlaBackend::EnginePortType2Str(%i) - invalid type", type); | |||
| @@ -75,18 +75,18 @@ const char* EngineControlEventType2Str(const EngineControlEventType type) | |||
| { | |||
| switch (type) | |||
| { | |||
| case EngineControlEventTypeNull: | |||
| return "EngineNullEvent"; | |||
| case EngineControlEventTypeParameter: | |||
| return "EngineControlEventTypeParameter"; | |||
| case EngineControlEventTypeMidiBank: | |||
| return "EngineControlEventTypeMidiBank"; | |||
| case EngineControlEventTypeMidiProgram: | |||
| return "EngineControlEventTypeMidiProgram"; | |||
| case EngineControlEventTypeAllSoundOff: | |||
| return "EngineControlEventTypeAllSoundOff"; | |||
| case EngineControlEventTypeAllNotesOff: | |||
| return "EngineControlEventTypeAllNotesOff"; | |||
| case kEngineControlEventTypeNull: | |||
| return "kEngineNullEvent"; | |||
| case kEngineControlEventTypeParameter: | |||
| return "kEngineControlEventTypeParameter"; | |||
| case kEngineControlEventTypeMidiBank: | |||
| return "kEngineControlEventTypeMidiBank"; | |||
| case kEngineControlEventTypeMidiProgram: | |||
| return "kEngineControlEventTypeMidiProgram"; | |||
| case kEngineControlEventTypeAllSoundOff: | |||
| return "kEngineControlEventTypeAllSoundOff"; | |||
| case kEngineControlEventTypeAllNotesOff: | |||
| return "kEngineControlEventTypeAllNotesOff"; | |||
| } | |||
| qWarning("CarlaBackend::EngineControlEventType2Str(%i) - invalid type", type); | |||
| @@ -103,6 +103,7 @@ const char* EngineControlEventType2Str(const EngineControlEventType type) | |||
| const uint32_t PATCHBAY_BUFFER_SIZE = 128; | |||
| const unsigned short PATCHBAY_EVENT_COUNT = 512; | |||
| const unsigned short RACK_EVENT_COUNT = 1024; | |||
| #if 0 | |||
| enum EnginePostEventType { | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Engine OSC | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_ENGINE_OSC_HPP__ | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Engine Thread | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_ENGINE_THREAD_HPP__ | |||
| @@ -66,24 +66,24 @@ public: | |||
| if (! engine) | |||
| { | |||
| buffer = nullptr; | |||
| fBuffer = nullptr; | |||
| return; | |||
| } | |||
| if (! m_port) | |||
| return CarlaEngineAudioPort::initBuffer(engine); | |||
| buffer = jackbridge_port_get_buffer(m_port, engine->getBufferSize()); | |||
| fBuffer = (float*)jackbridge_port_get_buffer(m_port, engine->getBufferSize()); | |||
| } | |||
| float* getBuffer() const | |||
| { | |||
| return (float*)buffer; | |||
| return fBuffer; | |||
| } | |||
| private: | |||
| jack_client_t* const m_client; | |||
| jack_port_t* const m_port; | |||
| jack_port_t* const m_port; | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineJackAudioPort) | |||
| }; | |||
| @@ -125,17 +125,17 @@ public: | |||
| if (! engine) | |||
| { | |||
| buffer = nullptr; | |||
| fBuffer = nullptr; | |||
| return; | |||
| } | |||
| if (! m_port) | |||
| return CarlaEngineEventPort::initBuffer(engine); | |||
| buffer = jackbridge_port_get_buffer(m_port, engine->getBufferSize()); | |||
| fBuffer = jackbridge_port_get_buffer(m_port, engine->getBufferSize()); | |||
| if (! isInput) | |||
| jackbridge_midi_clear_buffer(buffer); | |||
| if (! kIsInput) | |||
| jackbridge_midi_clear_buffer(fBuffer); | |||
| } | |||
| uint32_t getEventCount() | |||
| @@ -143,15 +143,15 @@ public: | |||
| if (! m_port) | |||
| return CarlaEngineEventPort::getEventCount(); | |||
| if (! isInput) | |||
| if (! kIsInput) | |||
| return 0; | |||
| CARLA_ASSERT(buffer); | |||
| CARLA_ASSERT(fBuffer); | |||
| if (! buffer) | |||
| if (! fBuffer) | |||
| return 0; | |||
| return jackbridge_midi_get_event_count(buffer); | |||
| return jackbridge_midi_get_event_count(fBuffer); | |||
| } | |||
| const EngineEvent* getEvent(const uint32_t index) | |||
| @@ -159,17 +159,17 @@ public: | |||
| if (! m_port) | |||
| return CarlaEngineEventPort::getEvent(index); | |||
| if (! isInput) | |||
| if (! kIsInput) | |||
| return nullptr; | |||
| CARLA_ASSERT(buffer); | |||
| CARLA_ASSERT(fBuffer); | |||
| if (! buffer) | |||
| if (! fBuffer) | |||
| return nullptr; | |||
| jack_midi_event_t jackEvent; | |||
| if (jackbridge_midi_event_get(&jackEvent, buffer, index) != 0 || jackEvent.size > 3) | |||
| if (jackbridge_midi_event_get(&jackEvent, fBuffer, index) != 0 || jackEvent.size > 3) | |||
| return nullptr; | |||
| m_retEvent.clear(); | |||
| @@ -183,25 +183,25 @@ public: | |||
| if (MIDI_IS_STATUS_CONTROL_CHANGE(midiStatus)) | |||
| { | |||
| const uint8_t midiControl = jackEvent.buffer[1]; | |||
| m_retEvent.type = EngineEventTypeControl; | |||
| m_retEvent.type = kEngineEventTypeControl; | |||
| if (MIDI_IS_CONTROL_BANK_SELECT(midiControl)) | |||
| { | |||
| const uint8_t midiBank = jackEvent.buffer[2]; | |||
| m_retEvent.ctrl.type = EngineControlEventTypeMidiBank; | |||
| m_retEvent.ctrl.type = kEngineControlEventTypeMidiBank; | |||
| m_retEvent.ctrl.parameter = midiBank; | |||
| m_retEvent.ctrl.value = 0.0; | |||
| } | |||
| else if (midiControl == MIDI_CONTROL_ALL_SOUND_OFF) | |||
| { | |||
| m_retEvent.ctrl.type = EngineControlEventTypeAllSoundOff; | |||
| m_retEvent.ctrl.type = kEngineControlEventTypeAllSoundOff; | |||
| m_retEvent.ctrl.parameter = 0; | |||
| m_retEvent.ctrl.value = 0.0; | |||
| } | |||
| else if (midiControl == MIDI_CONTROL_ALL_NOTES_OFF) | |||
| { | |||
| m_retEvent.ctrl.type = EngineControlEventTypeAllNotesOff; | |||
| m_retEvent.ctrl.type = kEngineControlEventTypeAllNotesOff; | |||
| m_retEvent.ctrl.parameter = 0; | |||
| m_retEvent.ctrl.value = 0.0; | |||
| } | |||
| @@ -209,7 +209,7 @@ public: | |||
| { | |||
| const uint8_t midiValue = jackEvent.buffer[2]; | |||
| m_retEvent.ctrl.type = EngineControlEventTypeParameter; | |||
| m_retEvent.ctrl.type = kEngineControlEventTypeParameter; | |||
| m_retEvent.ctrl.parameter = midiControl; | |||
| m_retEvent.ctrl.value = double(midiValue)/127; | |||
| } | |||
| @@ -217,15 +217,15 @@ public: | |||
| else if (MIDI_IS_STATUS_PROGRAM_CHANGE(midiStatus)) | |||
| { | |||
| const uint8_t midiProgram = jackEvent.buffer[1]; | |||
| m_retEvent.type = EngineEventTypeControl; | |||
| m_retEvent.type = kEngineEventTypeControl; | |||
| m_retEvent.ctrl.type = EngineControlEventTypeMidiProgram; | |||
| m_retEvent.ctrl.type = kEngineControlEventTypeMidiProgram; | |||
| m_retEvent.ctrl.parameter = midiProgram; | |||
| m_retEvent.ctrl.value = 0.0; | |||
| } | |||
| else | |||
| { | |||
| m_retEvent.type = EngineEventTypeMidi; | |||
| m_retEvent.type = kEngineEventTypeMidi; | |||
| m_retEvent.midi.data[0] = midiStatus; | |||
| m_retEvent.midi.data[1] = jackEvent.buffer[1]; | |||
| @@ -241,20 +241,20 @@ public: | |||
| if (! m_port) | |||
| return CarlaEngineEventPort::writeControlEvent(time, channel, type, parameter, value); | |||
| if (isInput) | |||
| if (kIsInput) | |||
| return; | |||
| CARLA_ASSERT(buffer); | |||
| CARLA_ASSERT(type != EngineControlEventTypeNull); | |||
| CARLA_ASSERT(fBuffer); | |||
| CARLA_ASSERT(type != kEngineControlEventTypeNull); | |||
| CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); | |||
| if (! buffer) | |||
| if (! fBuffer) | |||
| return; | |||
| if (type == EngineControlEventTypeNull) | |||
| if (type == kEngineControlEventTypeNull) | |||
| return; | |||
| if (channel >= MAX_MIDI_CHANNELS) | |||
| return; | |||
| if (type == EngineControlEventTypeParameter) | |||
| if (type == kEngineControlEventTypeParameter) | |||
| { | |||
| CARLA_ASSERT(! MIDI_IS_CONTROL_BANK_SELECT(parameter)); | |||
| } | |||
| @@ -264,31 +264,31 @@ public: | |||
| switch (type) | |||
| { | |||
| case EngineControlEventTypeNull: | |||
| case kEngineControlEventTypeNull: | |||
| break; | |||
| case EngineControlEventTypeParameter: | |||
| case kEngineControlEventTypeParameter: | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = parameter; | |||
| data[2] = value * 127; | |||
| size = 3; | |||
| break; | |||
| case EngineControlEventTypeMidiBank: | |||
| case kEngineControlEventTypeMidiBank: | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = MIDI_CONTROL_BANK_SELECT; | |||
| data[2] = value; | |||
| size = 3; | |||
| break; | |||
| case EngineControlEventTypeMidiProgram: | |||
| case kEngineControlEventTypeMidiProgram: | |||
| data[0] = MIDI_STATUS_PROGRAM_CHANGE + channel; | |||
| data[1] = value; | |||
| size = 2; | |||
| break; | |||
| case EngineControlEventTypeAllSoundOff: | |||
| case kEngineControlEventTypeAllSoundOff: | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = MIDI_CONTROL_ALL_SOUND_OFF; | |||
| size = 2; | |||
| break; | |||
| case EngineControlEventTypeAllNotesOff: | |||
| case kEngineControlEventTypeAllNotesOff: | |||
| data[0] = MIDI_STATUS_CONTROL_CHANGE + channel; | |||
| data[1] = MIDI_CONTROL_ALL_NOTES_OFF; | |||
| size = 2; | |||
| @@ -296,7 +296,7 @@ public: | |||
| } | |||
| if (size > 0) | |||
| jackbridge_midi_event_write(buffer, time, data, size); | |||
| jackbridge_midi_event_write(fBuffer, time, data, size); | |||
| } | |||
| void writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t* const data, const uint8_t size) | |||
| @@ -304,15 +304,15 @@ public: | |||
| if (! m_port) | |||
| return CarlaEngineEventPort::writeMidiEvent(time, channel, data, size); | |||
| if (isInput) | |||
| if (kIsInput) | |||
| return; | |||
| CARLA_ASSERT(buffer); | |||
| CARLA_ASSERT(fBuffer); | |||
| CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); | |||
| CARLA_ASSERT(data); | |||
| CARLA_ASSERT(size > 0); | |||
| if (! buffer) | |||
| if (! fBuffer) | |||
| return; | |||
| if (channel >= MAX_MIDI_CHANNELS) | |||
| return; | |||
| @@ -324,12 +324,14 @@ public: | |||
| jdata[0] = data[0] + channel; | |||
| jackbridge_midi_event_write(buffer, time, jdata, size); | |||
| jackbridge_midi_event_write(fBuffer, time, jdata, size); | |||
| } | |||
| private: | |||
| void* fBuffer; | |||
| jack_client_t* const m_client; | |||
| jack_port_t* const m_port; | |||
| jack_port_t* const m_port; | |||
| EngineEvent m_retEvent; | |||
| @@ -359,7 +361,7 @@ public: | |||
| { | |||
| qDebug("CarlaEngineClient::~CarlaEngineClient()"); | |||
| if (processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| if (kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| { | |||
| if (m_client) | |||
| jackbridge_client_close(m_client); | |||
| @@ -370,7 +372,7 @@ public: | |||
| { | |||
| qDebug("CarlaEngineClient::activate()"); | |||
| if (processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| if (kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| { | |||
| CARLA_ASSERT(m_client && ! isActive()); | |||
| @@ -385,7 +387,7 @@ public: | |||
| { | |||
| qDebug("CarlaEngineClient::deactivate()"); | |||
| if (processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| if (kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| { | |||
| CARLA_ASSERT(m_client && isActive()); | |||
| @@ -425,12 +427,12 @@ public: | |||
| { | |||
| switch (portType) | |||
| { | |||
| case EnginePortTypeNull: | |||
| case kEnginePortTypeNull: | |||
| break; | |||
| case EnginePortTypeAudio: | |||
| case kEnginePortTypeAudio: | |||
| port = jackbridge_port_register(m_client, name, JACK_DEFAULT_AUDIO_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| break; | |||
| case EnginePortTypeEvent: | |||
| case kEnginePortTypeEvent: | |||
| port = jackbridge_port_register(m_client, name, JACK_DEFAULT_MIDI_TYPE, isInput ? JackPortIsInput : JackPortIsOutput, 0); | |||
| break; | |||
| } | |||
| @@ -439,12 +441,12 @@ public: | |||
| // Create Engine port | |||
| switch (portType) | |||
| { | |||
| case EnginePortTypeNull: | |||
| case kEnginePortTypeNull: | |||
| break; | |||
| case EnginePortTypeAudio: | |||
| return new CarlaEngineJackAudioPort(isInput, processMode, m_client, port); | |||
| case EnginePortTypeEvent: | |||
| return new CarlaEngineJackEventPort(isInput, processMode, m_client, port); | |||
| case kEnginePortTypeAudio: | |||
| return new CarlaEngineJackAudioPort(isInput, kProcessMode, m_client, port); | |||
| case kEnginePortTypeEvent: | |||
| return new CarlaEngineJackEventPort(isInput, kProcessMode, m_client, port); | |||
| } | |||
| qCritical("CarlaJackEngineClient::addPort(%s, \"%s\", %s) - invalid type", EnginePortType2Str(portType), name, bool2str(isInput)); | |||
| @@ -467,7 +469,7 @@ public: | |||
| CarlaEngineJack() | |||
| : CarlaEngine() | |||
| #ifndef BUILD_BRIDGE | |||
| , m_rackPorts{nullptr} | |||
| , fRackPorts{nullptr} | |||
| #endif | |||
| { | |||
| qDebug("CarlaEngineJack::CarlaEngineJack()"); | |||
| @@ -492,22 +494,22 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| // Maximum values | |||
| int maxClientNameSize() | |||
| unsigned int maxClientNameSize() | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (options.processMode == PROCESS_MODE_SINGLE_CLIENT || options.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| #endif | |||
| return jackbridge_client_name_size() - 3; // reserve space for "_2" forced-stereo ports | |||
| return (unsigned int)jackbridge_client_name_size() - 3; // reserve space for "_2" forced-stereo ports | |||
| return CarlaEngine::maxClientNameSize(); | |||
| } | |||
| int maxPortNameSize() | |||
| unsigned int maxPortNameSize() | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (options.processMode == PROCESS_MODE_SINGLE_CLIENT || options.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| #endif | |||
| return jackbridge_port_name_size(); | |||
| return (unsigned int)jackbridge_port_name_size(); | |||
| return CarlaEngine::maxPortNameSize(); | |||
| } | |||
| @@ -527,8 +529,8 @@ public: | |||
| if (m_client) | |||
| { | |||
| bufferSize = jackbridge_get_buffer_size(m_client); | |||
| sampleRate = jackbridge_get_sample_rate(m_client); | |||
| fBufferSize = jackbridge_get_buffer_size(m_client); | |||
| fSampleRate = jackbridge_get_sample_rate(m_client); | |||
| jackbridge_set_buffer_size_callback(m_client, carla_jack_bufsize_callback, this); | |||
| jackbridge_set_sample_rate_callback(m_client, carla_jack_srate_callback, this); | |||
| @@ -537,22 +539,22 @@ public: | |||
| jackbridge_set_latency_callback(m_client, carla_jack_latency_callback, this); | |||
| jackbridge_on_shutdown(m_client, carla_jack_shutdown_callback, this); | |||
| if (options.processMode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| if (fOptions.processMode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| { | |||
| m_rackPorts[rackPortAudioIn1] = jackbridge_port_register(m_client, "audio-in1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); | |||
| m_rackPorts[rackPortAudioIn2] = jackbridge_port_register(m_client, "audio-in2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); | |||
| m_rackPorts[rackPortAudioOut1] = jackbridge_port_register(m_client, "audio-out1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); | |||
| m_rackPorts[rackPortAudioOut2] = jackbridge_port_register(m_client, "audio-out2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); | |||
| m_rackPorts[rackPortEventIn] = jackbridge_port_register(m_client, "events-in", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0); | |||
| m_rackPorts[rackPortEventOut] = jackbridge_port_register(m_client, "events-out", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0); | |||
| fRackPorts[rackPortAudioIn1] = jackbridge_port_register(m_client, "audio-in1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); | |||
| fRackPorts[rackPortAudioIn2] = jackbridge_port_register(m_client, "audio-in2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); | |||
| fRackPorts[rackPortAudioOut1] = jackbridge_port_register(m_client, "audio-out1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); | |||
| fRackPorts[rackPortAudioOut2] = jackbridge_port_register(m_client, "audio-out2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); | |||
| fRackPorts[rackPortEventIn] = jackbridge_port_register(m_client, "events-in", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0); | |||
| fRackPorts[rackPortEventOut] = jackbridge_port_register(m_client, "events-out", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0); | |||
| } | |||
| if (jackbridge_activate(m_client) == 0) | |||
| { | |||
| name = jackbridge_get_client_name(m_client); | |||
| name.toBasic(); | |||
| fName = jackbridge_get_client_name(m_client); | |||
| fName.toBasic(); | |||
| CarlaEngine::init(name); | |||
| CarlaEngine::init(fName); | |||
| return true; | |||
| } | |||
| else | |||
| @@ -601,14 +603,14 @@ public: | |||
| #else | |||
| if (jackbridge_deactivate(m_client) == 0) | |||
| { | |||
| if (options.processMode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| if (fOptions.processMode == PROCESS_MODE_CONTINUOUS_RACK) | |||
| { | |||
| jackbridge_port_unregister(m_client, m_rackPorts[rackPortAudioIn1]); | |||
| jackbridge_port_unregister(m_client, m_rackPorts[rackPortAudioIn2]); | |||
| jackbridge_port_unregister(m_client, m_rackPorts[rackPortAudioOut1]); | |||
| jackbridge_port_unregister(m_client, m_rackPorts[rackPortAudioOut2]); | |||
| jackbridge_port_unregister(m_client, m_rackPorts[rackPortEventIn]); | |||
| jackbridge_port_unregister(m_client, m_rackPorts[rackPortEventOut]); | |||
| jackbridge_port_unregister(m_client, fRackPorts[rackPortAudioIn1]); | |||
| jackbridge_port_unregister(m_client, fRackPorts[rackPortAudioIn2]); | |||
| jackbridge_port_unregister(m_client, fRackPorts[rackPortAudioOut1]); | |||
| jackbridge_port_unregister(m_client, fRackPorts[rackPortAudioOut2]); | |||
| jackbridge_port_unregister(m_client, fRackPorts[rackPortEventIn]); | |||
| jackbridge_port_unregister(m_client, fRackPorts[rackPortEventOut]); | |||
| } | |||
| if (jackbridge_client_close(m_client) == 0) | |||
| @@ -643,7 +645,7 @@ public: | |||
| EngineType type() const | |||
| { | |||
| return EngineTypeJack; | |||
| return kEngineTypeJack; | |||
| } | |||
| CarlaEngineClient* addClient(CarlaPlugin* const plugin) | |||
| @@ -663,11 +665,11 @@ public: | |||
| jackbridge_set_latency_callback(client, carla_jack_latency_callback, this); | |||
| jackbridge_on_shutdown(client, carla_jack_shutdown_callback, this); | |||
| #else | |||
| if (options.processMode == PROCESS_MODE_SINGLE_CLIENT) | |||
| if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT) | |||
| { | |||
| client = m_client; | |||
| } | |||
| else if (options.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| else if (fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
| { | |||
| client = jackbridge_client_open(plugin->name(), JackNullOption, nullptr); | |||
| jackbridge_set_process_callback(client, carla_jack_process_callback_plugin, plugin); | |||
| @@ -676,9 +678,9 @@ public: | |||
| #endif | |||
| #ifdef BUILD_BRIDGE | |||
| return new CarlaEngineJackClient(EngineTypeJack, PROCESS_MODE_MULTIPLE_CLIENTS, client); | |||
| return new CarlaEngineJackClient(kEngineTypeJack, PROCESS_MODE_MULTIPLE_CLIENTS, client); | |||
| #else | |||
| return new CarlaEngineJackClient(EngineTypeJack, options.processMode, client); | |||
| return new CarlaEngineJackClient(kEngineTypeJack, fOptions.processMode, client); | |||
| #endif | |||
| } | |||
| @@ -687,10 +689,10 @@ public: | |||
| protected: | |||
| void handleJackBufferSizeCallback(const uint32_t newBufferSize) | |||
| { | |||
| bufferSize = newBufferSize; | |||
| fBufferSize = newBufferSize; | |||
| #ifndef BUILD_BRIDGE | |||
| if (options.processHighPrecision) | |||
| if (fOptions.processHighPrecision) | |||
| return; | |||
| #endif | |||
| @@ -699,7 +701,7 @@ protected: | |||
| void handleJackSampleRateCallback(const double newSampleRate) | |||
| { | |||
| sampleRate = newSampleRate; | |||
| fSampleRate = newSampleRate; | |||
| } | |||
| void handleJackFreewheelCallback(const bool isFreewheel) | |||
| @@ -717,32 +719,32 @@ protected: | |||
| m_pos.unique_1 = m_pos.unique_2 + 1; // invalidate | |||
| m_state = jackbridge_transport_query(m_client, &m_pos); | |||
| timeInfo.playing = (m_state != JackTransportStopped); | |||
| fTimeInfo.playing = (m_state != JackTransportStopped); | |||
| if (m_pos.unique_1 == m_pos.unique_2) | |||
| { | |||
| timeInfo.frame = m_pos.frame; | |||
| timeInfo.time = m_pos.usecs; | |||
| fTimeInfo.frame = m_pos.frame; | |||
| fTimeInfo.time = m_pos.usecs; | |||
| if (m_pos.valid & JackPositionBBT) | |||
| { | |||
| timeInfo.valid = timeInfo.ValidBBT; | |||
| timeInfo.bbt.bar = m_pos.bar; | |||
| timeInfo.bbt.beat = m_pos.beat; | |||
| timeInfo.bbt.tick = m_pos.tick; | |||
| timeInfo.bbt.barStartTick = m_pos.bar_start_tick; | |||
| timeInfo.bbt.beatsPerBar = m_pos.beats_per_bar; | |||
| timeInfo.bbt.beatType = m_pos.beat_type; | |||
| timeInfo.bbt.ticksPerBeat = m_pos.ticks_per_beat; | |||
| timeInfo.bbt.beatsPerMinute = m_pos.beats_per_minute; | |||
| fTimeInfo.valid = EngineTimeInfo::ValidBBT; | |||
| fTimeInfo.bbt.bar = m_pos.bar; | |||
| fTimeInfo.bbt.beat = m_pos.beat; | |||
| fTimeInfo.bbt.tick = m_pos.tick; | |||
| fTimeInfo.bbt.barStartTick = m_pos.bar_start_tick; | |||
| fTimeInfo.bbt.beatsPerBar = m_pos.beats_per_bar; | |||
| fTimeInfo.bbt.beatType = m_pos.beat_type; | |||
| fTimeInfo.bbt.ticksPerBeat = m_pos.ticks_per_beat; | |||
| fTimeInfo.bbt.beatsPerMinute = m_pos.beats_per_minute; | |||
| } | |||
| else | |||
| timeInfo.valid = 0; | |||
| fTimeInfo.valid = 0; | |||
| } | |||
| else | |||
| { | |||
| timeInfo.frame = 0; | |||
| timeInfo.valid = 0; | |||
| fTimeInfo.frame = 0; | |||
| fTimeInfo.valid = 0; | |||
| } | |||
| #if 0 | |||
| @@ -940,7 +942,7 @@ protected: | |||
| void handleJackLatencyCallback(const jack_latency_callback_mode_t mode) | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| if (options.processMode != PROCESS_MODE_SINGLE_CLIENT) | |||
| if (fOptions.processMode != PROCESS_MODE_SINGLE_CLIENT) | |||
| return; | |||
| #endif | |||
| @@ -992,7 +994,7 @@ private: | |||
| rackPortCount = 8 | |||
| }; | |||
| jack_port_t* m_rackPorts[rackPortCount]; | |||
| jack_port_t* fRackPorts[rackPortCount]; | |||
| #endif | |||
| // ------------------------------------- | |||
| @@ -1119,10 +1121,10 @@ private: | |||
| if (plugin && plugin->enabled()) | |||
| { | |||
| plugin->engineProcessLock(); | |||
| //plugin->engineProcessLock(); | |||
| plugin->initBuffers(); | |||
| processPlugin(plugin, nframes); | |||
| plugin->engineProcessUnlock(); | |||
| //plugin->engineProcessUnlock(); | |||
| } | |||
| return 0; | |||
| @@ -53,12 +53,12 @@ public: | |||
| switch (portType) | |||
| { | |||
| case EnginePortTypeNull: | |||
| case kEnginePortTypeNull: | |||
| break; | |||
| case EnginePortTypeAudio: | |||
| return new CarlaEngineAudioPort(isInput, processMode); | |||
| case EnginePortTypeEvent: | |||
| return new CarlaEngineEventPort(isInput, processMode); | |||
| case kEnginePortTypeAudio: | |||
| return new CarlaEngineAudioPort(isInput, kProcessMode); | |||
| case kEnginePortTypeEvent: | |||
| return new CarlaEngineEventPort(isInput, kProcessMode); | |||
| } | |||
| qCritical("CarlaEngineRtAudioClient::addPort(%s, \"%s\", %s) - invalid type", EnginePortType2Str(portType), name, bool2str(isInput)); | |||
| @@ -91,8 +91,8 @@ public: | |||
| m_outBuf2 = nullptr; | |||
| // just to make sure | |||
| options.forceStereo = true; | |||
| options.processMode = PROCESS_MODE_CONTINUOUS_RACK; | |||
| fOptions.forceStereo = true; | |||
| fOptions.processMode = PROCESS_MODE_CONTINUOUS_RACK; | |||
| } | |||
| ~CarlaEngineRtAudio() | |||
| @@ -112,8 +112,8 @@ public: | |||
| return false; | |||
| } | |||
| bufferSize = options.preferredBufferSize; | |||
| sampleRate = options.preferredSampleRate; | |||
| fBufferSize = fOptions.preferredBufferSize; | |||
| fSampleRate = fOptions.preferredSampleRate; | |||
| RtAudio::StreamParameters iParams, oParams; | |||
| iParams.deviceId = audio.getDefaultInputDevice(); | |||
| @@ -139,7 +139,7 @@ public: | |||
| m_audioInterleaved = true; | |||
| try { | |||
| audio.openStream(&oParams, &iParams, RTAUDIO_FLOAT32, sampleRate, &bufferSize, carla_rtaudio_process_callback, this, &rtOptions); | |||
| audio.openStream(&oParams, &iParams, RTAUDIO_FLOAT32, fSampleRate, &fBufferSize, carla_rtaudio_process_callback, this, &rtOptions); | |||
| } | |||
| catch (RtError& e) | |||
| { | |||
| @@ -156,12 +156,12 @@ public: | |||
| return false; | |||
| } | |||
| sampleRate = audio.getStreamSampleRate(); | |||
| fSampleRate = audio.getStreamSampleRate(); | |||
| m_inBuf1 = new float [bufferSize]; | |||
| m_inBuf2 = new float [bufferSize]; | |||
| m_outBuf1 = new float [bufferSize]; | |||
| m_outBuf2 = new float [bufferSize]; | |||
| m_inBuf1 = new float[fBufferSize]; | |||
| m_inBuf2 = new float[fBufferSize]; | |||
| m_outBuf1 = new float[fBufferSize]; | |||
| m_outBuf2 = new float[fBufferSize]; | |||
| //midiIn = new MidiInAlsa(clientName, 512); | |||
| //midiIn->openVirtualPort("control-in"); | |||
| @@ -171,10 +171,10 @@ public: | |||
| //midiOut->openVirtualPort("control-out"); | |||
| //midiOut->openVirtualPort("midi-out"); | |||
| name = clientName; | |||
| name.toBasic(); | |||
| fName = clientName; | |||
| fName.toBasic(); | |||
| CarlaEngine::init(name); | |||
| CarlaEngine::init(fName); | |||
| return true; | |||
| } | |||
| @@ -245,12 +245,12 @@ public: | |||
| EngineType type() const | |||
| { | |||
| return EngineTypeRtAudio; | |||
| return kEngineTypeRtAudio; | |||
| } | |||
| CarlaEngineClient* addClient(CarlaPlugin* const) | |||
| { | |||
| return new CarlaEngineRtAudioClient(EngineTypeRtAudio, options.processMode); | |||
| return new CarlaEngineRtAudioClient(kEngineTypeRtAudio, fOptions.processMode); | |||
| } | |||
| // ------------------------------------- | |||
| @@ -294,7 +294,7 @@ protected: | |||
| float* outBuf[2] = { m_outBuf1, m_outBuf2 }; | |||
| // initialize events input | |||
| memset(rackEventsIn, 0, sizeof(EngineEvent)*MAX_EVENTS); | |||
| //memset(rackEventsIn, 0, sizeof(EngineEvent)*MAX_EVENTS); | |||
| { | |||
| // TODO | |||
| } | |||
| @@ -166,17 +166,17 @@ void DistrhoPlugin3BandEQ::d_setParameterValue(uint32_t index, float value) | |||
| outVol = std::exp( (fMaster/48.0f) * 48 / cfAMP_DB); | |||
| break; | |||
| case paramLowMidFreq: | |||
| fLowMidFreq = std::min<float>(value, fMidHighFreq); | |||
| fLowMidFreq = std::fmin(value, fMidHighFreq); | |||
| freqLP = fLowMidFreq; //fLowMidFreq * (fLowMidFreq / 24000.0f) * (fLowMidFreq / 24000.0f); | |||
| xLP = std::exp(-2.0 * cfPI * freqLP / d_sampleRate()); | |||
| a0LP = 1.0 - xLP; | |||
| xLP = std::exp(-2.0f * cfPI * freqLP / (float)d_sampleRate()); | |||
| a0LP = 1.0f - xLP; | |||
| b1LP = -xLP; | |||
| break; | |||
| case paramMidHighFreq: | |||
| fMidHighFreq = std::max<float>(value, fLowMidFreq); | |||
| fMidHighFreq = std::fmax(value, fLowMidFreq); | |||
| freqHP = fMidHighFreq; //fMidHighFreq * (fMidHighFreq / 24000.0f) * (fMidHighFreq / 24000.0f); | |||
| xHP = std::exp(-2.0 * cfPI * freqHP / d_sampleRate()); | |||
| a0HP = 1.0 - xHP; | |||
| xHP = std::exp(-2.0f * cfPI * freqHP / (float)d_sampleRate()); | |||
| a0HP = 1.0f - xHP; | |||
| b1HP = -xHP; | |||
| break; | |||
| } | |||
| @@ -209,11 +209,11 @@ void DistrhoPlugin3BandEQ::d_setProgram(uint32_t index) | |||
| void DistrhoPlugin3BandEQ::d_activate() | |||
| { | |||
| xLP = std::exp(-2.0 * cfPI * freqLP / d_sampleRate()); | |||
| xLP = std::exp(-2.0f * cfPI * freqLP / (float)d_sampleRate()); | |||
| a0LP = 1.0f - xLP; | |||
| b1LP = -xLP; | |||
| xHP = std::exp(-2.0 * cfPI * freqHP / d_sampleRate()); | |||
| xHP = std::exp(-2.0f * cfPI * freqHP / (float)d_sampleRate()); | |||
| a0HP = 1.0f - xHP; | |||
| b1HP = -xHP; | |||
| } | |||
| @@ -36,14 +36,14 @@ public: | |||
| protected: | |||
| // Information | |||
| unsigned int d_width() | |||
| int d_width() | |||
| { | |||
| return DistrhoArtwork3BandEQ::backgroundWidth; | |||
| return (int)DistrhoArtwork3BandEQ::backgroundWidth; | |||
| } | |||
| unsigned int d_height() | |||
| int d_height() | |||
| { | |||
| return DistrhoArtwork3BandEQ::backgroundHeight; | |||
| return (int)DistrhoArtwork3BandEQ::backgroundHeight; | |||
| } | |||
| // DSP Callbacks | |||
| @@ -166,17 +166,17 @@ void DistrhoPlugin3BandSplitter::d_setParameterValue(uint32_t index, float value | |||
| outVol = std::exp( (fMaster/48.0f) * 48 / cfAMP_DB); | |||
| break; | |||
| case paramLowMidFreq: | |||
| fLowMidFreq = std::min<float>(value, fMidHighFreq); | |||
| fLowMidFreq = std::fmin(value, fMidHighFreq); | |||
| freqLP = fLowMidFreq; //fLowMidFreq * (fLowMidFreq / 24000.0f) * (fLowMidFreq / 24000.0f); | |||
| xLP = std::exp(-2.0 * cfPI * freqLP / d_sampleRate()); | |||
| a0LP = 1.0 - xLP; | |||
| xLP = std::exp(-2.0f * cfPI * freqLP / (float)d_sampleRate()); | |||
| a0LP = 1.0f - xLP; | |||
| b1LP = -xLP; | |||
| break; | |||
| case paramMidHighFreq: | |||
| fMidHighFreq = std::max<float>(value, fLowMidFreq); | |||
| fMidHighFreq = std::fmax(value, fLowMidFreq); | |||
| freqHP = fMidHighFreq; //fMidHighFreq * (fMidHighFreq / 24000.0f) * (fMidHighFreq / 24000.0f); | |||
| xHP = std::exp(-2.0 * cfPI * freqHP / d_sampleRate()); | |||
| a0HP = 1.0 - xHP; | |||
| xHP = std::exp(-2.0f * cfPI * freqHP / (float)d_sampleRate()); | |||
| a0HP = 1.0f - xHP; | |||
| b1HP = -xHP; | |||
| break; | |||
| } | |||
| @@ -209,11 +209,11 @@ void DistrhoPlugin3BandSplitter::d_setProgram(uint32_t index) | |||
| void DistrhoPlugin3BandSplitter::d_activate() | |||
| { | |||
| xLP = std::exp(-2.0 * cfPI * freqLP / d_sampleRate()); | |||
| xLP = std::exp(-2.0f * cfPI * freqLP / (float)d_sampleRate()); | |||
| a0LP = 1.0f - xLP; | |||
| b1LP = -xLP; | |||
| xHP = std::exp(-2.0 * cfPI * freqHP / d_sampleRate()); | |||
| xHP = std::exp(-2.0f * cfPI * freqHP / (float)d_sampleRate()); | |||
| a0HP = 1.0f - xHP; | |||
| b1HP = -xHP; | |||
| } | |||
| @@ -36,12 +36,12 @@ public: | |||
| protected: | |||
| // Information | |||
| unsigned int d_width() | |||
| int d_width() | |||
| { | |||
| return DistrhoArtwork3BandSplitter::backgroundWidth; | |||
| } | |||
| unsigned int d_height() | |||
| int d_height() | |||
| { | |||
| return DistrhoArtwork3BandSplitter::backgroundHeight; | |||
| } | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #include "carla_native.h" | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #include "carla_native.hpp" | |||
| @@ -29,7 +29,7 @@ START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| static PluginDescriptor tBandEqDesc = { | |||
| static const PluginDescriptor tBandEqDesc = { | |||
| /* category */ ::PLUGIN_CATEGORY_EQ, | |||
| /* hints */ static_cast<PluginHints>(::PLUGIN_IS_RTSAFE | ::PLUGIN_HAS_GUI), | |||
| /* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #include "carla_native.hpp" | |||
| @@ -29,7 +29,7 @@ START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| static PluginDescriptor tBandSplitterDesc = { | |||
| static const PluginDescriptor tBandSplitterDesc = { | |||
| /* category */ ::PLUGIN_CATEGORY_EQ, | |||
| /* hints */ static_cast<PluginHints>(::PLUGIN_IS_RTSAFE | ::PLUGIN_HAS_GUI), | |||
| /* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #include "carla_native.hpp" | |||
| @@ -46,7 +46,6 @@ public: | |||
| setCentralWidget(&widget); | |||
| setFixedSize(ui.getWidth(), ui.getHeight()); | |||
| setWindowTitle(DISTRHO_PLUGIN_NAME); | |||
| } | |||
| ~UICarla() | |||
| @@ -111,7 +110,7 @@ protected: | |||
| } | |||
| # endif | |||
| void uiResize(unsigned int width, unsigned int height) | |||
| void uiResize(int width, int height) | |||
| { | |||
| setFixedSize(width, height); | |||
| } | |||
| @@ -182,7 +181,7 @@ private: | |||
| # endif | |||
| } | |||
| static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height) | |||
| static void uiResizeCallback(void* ptr, int width, int height) | |||
| { | |||
| if (UICarla* _this_ = (UICarla*)ptr) | |||
| _this_->uiResize(width, height); | |||
| @@ -2,21 +2,21 @@ | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #include "carla_midi.h" | |||
| #include "carla_native.h" | |||
| #include "carla_midi.h" | |||
| #include <stdlib.h> | |||
| @@ -2,21 +2,21 @@ | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #include "carla_midi.h" | |||
| #include "carla_native.h" | |||
| #include "carla_midi.h" | |||
| #include <stdlib.h> | |||
| @@ -100,7 +100,7 @@ void DistrhoPluginPingPongPan::d_setParameterValue(uint32_t index, float value) | |||
| { | |||
| case paramFreq: | |||
| fFreq = value; | |||
| waveSpeed = (cf2PI * fFreq / 100.0f)/d_sampleRate(); | |||
| waveSpeed = (cf2PI * fFreq / 100.0f)/(float)d_sampleRate(); | |||
| break; | |||
| case paramWidth: | |||
| fWidth = value; | |||
| @@ -126,7 +126,7 @@ void DistrhoPluginPingPongPan::d_setProgram(uint32_t index) | |||
| void DistrhoPluginPingPongPan::d_activate() | |||
| { | |||
| waveSpeed = (cf2PI * fFreq / 100.0f)/d_sampleRate(); | |||
| waveSpeed = (cf2PI * fFreq / 100.0f)/(float)d_sampleRate(); | |||
| } | |||
| void DistrhoPluginPingPongPan::d_deactivate() | |||
| @@ -143,7 +143,7 @@ void DistrhoPluginPingPongPan::d_run(float** inputs, float** outputs, uint32_t f | |||
| for (uint32_t i=0; i < frames; i++) | |||
| { | |||
| pan = std::min<float>(std::max<float>(sin(wavePos) * (fWidth/100.0f), -1.0f), 1.0f); | |||
| pan = std::fmin(std::fmax(std::sin(wavePos) * (fWidth/100.0f), -1.0f), 1.0f); | |||
| if ((wavePos += waveSpeed) >= cf2PI) | |||
| wavePos -= cf2PI; | |||
| @@ -36,12 +36,12 @@ public: | |||
| protected: | |||
| // Information | |||
| unsigned int d_width() | |||
| int d_width() | |||
| { | |||
| return DistrhoArtworkPingPongPan::backgroundWidth; | |||
| } | |||
| unsigned int d_height() | |||
| int d_height() | |||
| { | |||
| return DistrhoArtworkPingPongPan::backgroundHeight; | |||
| } | |||
| @@ -2,25 +2,25 @@ | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| // for UINT32_MAX | |||
| #define __STDC_LIMIT_MACROS | |||
| #include <cstdint> | |||
| #include "carla_midi.h" | |||
| #include "carla_native.hpp" | |||
| #include "carla_midi.h" | |||
| #include "zynaddsubfx/Misc/Master.h" | |||
| #include "zynaddsubfx/Misc/Util.h" | |||
| @@ -2,23 +2,25 @@ | |||
| * Carla common MIDI code | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_MIDI_H__ | |||
| #define __CARLA_MIDI_H__ | |||
| #define MAX_MIDI_CHANNELS 16 | |||
| #define MAX_MIDI_NOTE 128 | |||
| #define MAX_MIDI_VALUE 128 | |||
| // MIDI Messages List | |||
| #define MIDI_STATUS_NOTE_OFF 0x80 // note (0-127), velocity (0-127) | |||
| @@ -69,7 +69,7 @@ struct ParameterRanges { | |||
| this->stepLarge = stepLarge; | |||
| } | |||
| void fixRange(float& value) const | |||
| void fixValue(float& value) const | |||
| { | |||
| if (value < min) | |||
| value = min; | |||
| @@ -45,14 +45,14 @@ public: | |||
| #if DISTRHO_PLUGIN_IS_SYNTH | |||
| void d_uiSendNote(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity); | |||
| #endif | |||
| void d_uiResize(unsigned int width, unsigned int height); | |||
| void d_uiResize(int width, int height); | |||
| // --------------------------------------------- | |||
| protected: | |||
| // Information | |||
| virtual unsigned int d_width() = 0; | |||
| virtual unsigned int d_height() = 0; | |||
| virtual int d_width() = 0; | |||
| virtual int d_height() = 0; | |||
| // DSP Callbacks | |||
| virtual void d_parameterChanged(uint32_t index, float value) = 0; | |||
| @@ -17,7 +17,7 @@ | |||
| #ifndef __DISTRHO_UI_OPENGL_H__ | |||
| #define __DISTRHO_UI_OPENGL_H__ | |||
| #include "src/DistrhoDefines.h" | |||
| #include "src/DistrhoMacros.h" | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| @@ -101,8 +101,8 @@ public: | |||
| protected: | |||
| // Information | |||
| virtual unsigned int d_width() = 0; | |||
| virtual unsigned int d_height() = 0; | |||
| virtual int d_width() = 0; | |||
| virtual int d_height() = 0; | |||
| // DSP Callbacks | |||
| virtual void d_parameterChanged(uint32_t index, float value) = 0; | |||
| @@ -17,7 +17,7 @@ | |||
| #ifndef __DISTRHO_UI_OPENGL_EXT_H__ | |||
| #define __DISTRHO_UI_OPENGL_EXT_H__ | |||
| #include "src/DistrhoDefines.h" | |||
| #include "src/DistrhoMacros.h" | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| @@ -249,8 +249,8 @@ public: | |||
| protected: | |||
| // Information | |||
| virtual unsigned int d_width() = 0; | |||
| virtual unsigned int d_height() = 0; | |||
| virtual int d_width() = 0; | |||
| virtual int d_height() = 0; | |||
| // DSP Callbacks | |||
| virtual void d_parameterChanged(uint32_t index, float value) = 0; | |||
| @@ -102,7 +102,7 @@ public: | |||
| d_string(int value) | |||
| { | |||
| size_t strBufSize = abs(value/10) + 3; | |||
| size_t strBufSize = (unsigned int)abs(value/10) + 3; | |||
| char strBuf[strBufSize]; | |||
| snprintf(strBuf, strBufSize, "%d", value); | |||
| @@ -81,7 +81,7 @@ void UI::d_uiSendNote(bool onOff, uint8_t channel, uint8_t note, uint8_t velocit | |||
| } | |||
| #endif | |||
| void UI::d_uiResize(unsigned int width, unsigned int height) | |||
| void UI::d_uiResize(int width, int height) | |||
| { | |||
| data->uiResizeCallback(width, height); | |||
| } | |||
| @@ -51,7 +51,7 @@ typedef void (*setParamFunc) (void* ptr, uint32_t index, float value); | |||
| typedef void (*setStateFunc) (void* ptr, const char* key, const char* value); | |||
| typedef void (*uiEditParamFunc) (void* ptr, uint32_t index, bool started); | |||
| typedef void (*uiSendNoteFunc) (void* ptr, bool onOff, uint8_t channel, uint8_t note, uint8_t velo); | |||
| typedef void (*uiResizeFunc) (void* ptr, unsigned int width, unsigned int height); | |||
| typedef void (*uiResizeFunc) (void* ptr, int width, int height); | |||
| extern double d_lastUiSampleRate; | |||
| @@ -140,7 +140,7 @@ struct UIPrivateData { | |||
| uiSendNoteCallbackFunc(ptr, onOff, channel, note, velocity); | |||
| } | |||
| void uiResizeCallback(unsigned int width, unsigned int height) | |||
| void uiResizeCallback(int width, int height) | |||
| { | |||
| if (uiResizeCallbackFunc) | |||
| uiResizeCallbackFunc(ptr, width, height); | |||
| @@ -201,13 +201,13 @@ public: | |||
| ui->d_uiIdle(); | |||
| } | |||
| unsigned int getWidth() | |||
| int getWidth() | |||
| { | |||
| assert(ui); | |||
| return ui ? ui->d_width() : 0; | |||
| } | |||
| unsigned int getHeight() | |||
| int getHeight() | |||
| { | |||
| assert(ui); | |||
| return ui ? ui->d_height() : 0; | |||
| @@ -14,7 +14,7 @@ | |||
| * For a full copy of the license see the LGPL.txt file | |||
| */ | |||
| #include "DistrhoDefines.h" | |||
| #include "DistrhoMacros.h" | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| @@ -14,7 +14,7 @@ | |||
| * For a full copy of the license see the LGPL.txt file | |||
| */ | |||
| #include "DistrhoDefines.h" | |||
| #include "DistrhoMacros.h" | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| @@ -168,15 +168,15 @@ Size& Size::operator/=(int d) | |||
| Size& Size::operator*=(float m) | |||
| { | |||
| _width *= m; | |||
| _height *= m; | |||
| _width = (int)((float)_width * m); | |||
| _height = (int)((float)_height * m); | |||
| return *this; | |||
| } | |||
| Size& Size::operator/=(float d) | |||
| { | |||
| _width /= d; | |||
| _height /= d; | |||
| _width = (int)((float)_width / d); | |||
| _height = (int)((float)_height / d); | |||
| return *this; | |||
| } | |||
| @@ -729,7 +729,7 @@ public: | |||
| if (view) | |||
| { | |||
| #if DISTRHO_OS_LINUX | |||
| PuglInternals* impl = puglGetInternalsImpl(view); | |||
| PuglInternals* impl = puglGetInternalsImpl(view); | |||
| Display* display = impl->display; | |||
| Window window = impl->win; | |||
| XRaiseWindow(display, window); | |||
| @@ -1073,7 +1073,7 @@ void OpenGLExtUI::d_onDisplay() | |||
| int layerDataSize = knob->_layerSize * knob->_layerSize * 4; | |||
| int imageDataSize = layerDataSize * knob->_layerCount; | |||
| int imageDataOffset = imageDataSize - layerDataSize - layerDataSize * rint(vper*(knob->_layerCount-1)); | |||
| int imageDataOffset = imageDataSize - layerDataSize - layerDataSize * int(vper * float(knob->_layerCount-1)); | |||
| glRasterPos2i(knob->_pos.getX(), knob->_pos.getY()+knob->_area.getHeight()); | |||
| glDrawPixels(knob->_layerSize, knob->_layerSize, knob->_image.getFormat(), knob->_image.getType(), knob->_image.getData() + imageDataOffset); | |||
| @@ -1093,10 +1093,10 @@ void OpenGLExtUI::d_onDisplay() | |||
| if (slider->_endPos.getX() > slider->_startPos.getX()) | |||
| // horizontal | |||
| x += rint(vper * (slider->_area.getWidth()-slider->getWidth())); | |||
| x += int(vper * float(slider->_area.getWidth() - slider->getWidth())); | |||
| else | |||
| // vertical | |||
| y += slider->_area.getHeight() - rint(vper * (slider->_area.getHeight()-slider->getHeight())); | |||
| y += slider->_area.getHeight() - int(vper * float(slider->_area.getHeight() - slider->getHeight())); | |||
| #if 0 // DEBUG | |||
| glColor3i(160, 90, 161); | |||
| @@ -1175,8 +1175,8 @@ void OpenGLExtUI::d_onMotion(int x, int y) | |||
| if (movX != 0) | |||
| { | |||
| int d = (d_uiGetModifiers() & MODIFIER_SHIFT) ? 2000 : 200; | |||
| float value = knob->_value + (knob->_max - knob->_min) / d * movX; | |||
| float d = (d_uiGetModifiers() & MODIFIER_SHIFT) ? 2000 : 200; | |||
| float value = knob->_value + float(knob->_max - knob->_min) / d * float(movX); | |||
| if (value < knob->_min) | |||
| value = knob->_min; | |||
| @@ -1198,8 +1198,8 @@ void OpenGLExtUI::d_onMotion(int x, int y) | |||
| if (movY != 0) | |||
| { | |||
| int d = (d_uiGetModifiers() & MODIFIER_SHIFT) ? 2000 : 200; | |||
| float value = knob->_value + (knob->_max - knob->_min) / d * movY; | |||
| float d = (d_uiGetModifiers() & MODIFIER_SHIFT) ? 2000 : 200; | |||
| float value = knob->_value + float(knob->_max - knob->_min) / d * float(movY); | |||
| if (value < knob->_min) | |||
| value = knob->_min; | |||
| @@ -1241,10 +1241,10 @@ void OpenGLExtUI::d_onMotion(int x, int y) | |||
| if (horizontal) | |||
| // horizontal | |||
| vper = float(x - slider->_area.getX()) / slider->_area.getWidth(); | |||
| vper = float(x - slider->_area.getX()) / float(slider->_area.getWidth()); | |||
| else | |||
| // vertical | |||
| vper = float(y - slider->_area.getY()) / slider->_area.getHeight(); | |||
| vper = float(y - slider->_area.getY()) / float(slider->_area.getHeight()); | |||
| float value = slider->_max - vper * (slider->_max - slider->_min); | |||
| @@ -1397,10 +1397,10 @@ void OpenGLExtUI::d_onMouse(int button, bool press, int x, int y) | |||
| if (slider->_endPos.getX() > slider->_startPos.getX()) | |||
| // horizontal | |||
| vper = float(x - slider->_area.getX()) / slider->_area.getWidth(); | |||
| vper = float(x - slider->_area.getX()) / float(slider->_area.getWidth()); | |||
| else | |||
| // vertical | |||
| vper = float(y - slider->_area.getY()) / slider->_area.getHeight(); | |||
| vper = float(y - slider->_area.getY()) / float(slider->_area.getHeight()); | |||
| float value = slider->_max - vper * (slider->_max - slider->_min); | |||
| @@ -122,7 +122,7 @@ typedef enum { | |||
| PUGL_KEY_SHIFT, | |||
| PUGL_KEY_CTRL, | |||
| PUGL_KEY_ALT, | |||
| PUGL_KEY_SUPER, | |||
| PUGL_KEY_SUPER | |||
| } PuglKey; | |||
| /** | |||
| @@ -132,7 +132,7 @@ typedef enum { | |||
| PUGL_MOD_SHIFT = 1, /**< Shift key */ | |||
| PUGL_MOD_CTRL = 1 << 1, /**< Control key */ | |||
| PUGL_MOD_ALT = 1 << 2, /**< Alt/Option key */ | |||
| PUGL_MOD_SUPER = 1 << 3, /**< Mod4/Command/Windows key */ | |||
| PUGL_MOD_SUPER = 1 << 3 /**< Mod4/Command/Windows key */ | |||
| } PuglMod; | |||
| /** | |||
| @@ -225,7 +225,7 @@ puglCreate(PuglNativeWindow parent, | |||
| int height, | |||
| bool resizable, | |||
| bool addToDesktop = true, | |||
| const char* x11Display = NULL); | |||
| const char* x11Display = nullptr); | |||
| /** | |||
| Set the handle to be passed to all callbacks. | |||
| @@ -64,7 +64,7 @@ puglCreate(PuglNativeWindow parent, | |||
| PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); | |||
| PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals)); | |||
| if (!view || !impl) { | |||
| return NULL; | |||
| return nullptr; | |||
| } | |||
| view->impl = impl; | |||
| @@ -88,7 +88,7 @@ puglCreate(PuglNativeWindow parent, | |||
| glXQueryVersion(impl->display, &glxMajor, &glxMinor); | |||
| printf("GLX-Version %d.%d\n", glxMajor, glxMinor); | |||
| impl->ctx = glXCreateContext(impl->display, vi, 0, GL_TRUE); | |||
| impl->ctx = glXCreateContext(impl->display, vi, nullptr, GL_TRUE); | |||
| Window xParent = parent | |||
| ? (Window)parent | |||
| @@ -108,7 +108,7 @@ puglCreate(PuglNativeWindow parent, | |||
| impl->win = XCreateWindow( | |||
| impl->display, xParent, | |||
| 0, 0, view->width, view->height, 0, vi->depth, InputOutput, vi->visual, | |||
| 0, 0, (unsigned int)view->width, (unsigned int)view->height, 0, vi->depth, InputOutput, vi->visual, | |||
| CWBorderPixel | CWColormap | CWEventMask, &attr); | |||
| XSizeHints sizeHints; | |||
| @@ -267,13 +267,13 @@ puglProcessEvents(PuglView* view) | |||
| view->redisplay = false; | |||
| break; | |||
| case MotionNotify: | |||
| setModifiers(view, event.xmotion.state); | |||
| setModifiers(view, (int)event.xmotion.state); | |||
| if (view->motionFunc) { | |||
| view->motionFunc(view, event.xmotion.x, event.xmotion.y); | |||
| } | |||
| break; | |||
| case ButtonPress: | |||
| setModifiers(view, event.xbutton.state); | |||
| setModifiers(view, (int)event.xbutton.state); | |||
| if (event.xbutton.button >= 4 && event.xbutton.button <= 7) { | |||
| if (view->scrollFunc) { | |||
| float dx = 0, dy = 0; | |||
| @@ -289,23 +289,23 @@ puglProcessEvents(PuglView* view) | |||
| } | |||
| // nobreak | |||
| case ButtonRelease: | |||
| setModifiers(view, event.xbutton.state); | |||
| setModifiers(view, (int)event.xbutton.state); | |||
| if (view->mouseFunc && | |||
| (event.xbutton.button < 4 || event.xbutton.button > 7)) { | |||
| view->mouseFunc(view, | |||
| event.xbutton.button, event.type == ButtonPress, | |||
| (int)event.xbutton.button, event.type == ButtonPress, | |||
| event.xbutton.x, event.xbutton.y); | |||
| } | |||
| break; | |||
| case KeyPress: { | |||
| setModifiers(view, event.xkey.state); | |||
| setModifiers(view, (int)event.xkey.state); | |||
| KeySym sym; | |||
| char str[5]; | |||
| int n = XLookupString(&event.xkey, str, 4, &sym, NULL); | |||
| int n = XLookupString(&event.xkey, str, 4, &sym, nullptr); | |||
| PuglKey key = keySymToSpecial(sym); | |||
| if (!key && view->keyboardFunc) { | |||
| if (n == 1) { | |||
| view->keyboardFunc(view, true, str[0]); | |||
| view->keyboardFunc(view, true, (uint32_t)str[0]); | |||
| } else { | |||
| fprintf(stderr, "warning: Unknown key %X\n", (int)sym); | |||
| } | |||
| @@ -314,7 +314,7 @@ puglProcessEvents(PuglView* view) | |||
| } | |||
| } break; | |||
| case KeyRelease: { | |||
| setModifiers(view, event.xkey.state); | |||
| setModifiers(view, (int)event.xkey.state); | |||
| bool repeated = false; | |||
| if (view->ignoreKeyRepeat && | |||
| XEventsQueued(view->impl->display, QueuedAfterReading)) { | |||
| @@ -330,10 +330,10 @@ puglProcessEvents(PuglView* view) | |||
| if (!repeated && view->keyboardFunc) { | |||
| KeySym sym = XKeycodeToKeysym( | |||
| view->impl->display, event.xkey.keycode, 0); | |||
| view->impl->display, (KeyCode)event.xkey.keycode, 0); | |||
| PuglKey special = keySymToSpecial(sym); | |||
| if (!special) { | |||
| view->keyboardFunc(view, false, sym); | |||
| view->keyboardFunc(view, false, (uint32_t)sym); | |||
| } else if (view->specialFunc) { | |||
| view->specialFunc(view, false, special); | |||
| } | |||
| @@ -369,7 +369,7 @@ puglPostRedisplay(PuglView* view) | |||
| PuglNativeWindow | |||
| puglGetNativeWindow(PuglView* view) | |||
| { | |||
| return view->impl->win; | |||
| return static_cast<PuglNativeWindow>(view->impl->win); | |||
| } | |||
| PuglInternals* | |||
| @@ -152,6 +152,8 @@ const char* InternalParametersIndex2Str(const InternalParametersIndex& index) | |||
| return "PARAMETER_BALANCE_RIGHT"; | |||
| case PARAMETER_PANNING: | |||
| return "PARAMETER_PANNING"; | |||
| case PARAMETER_MAX: | |||
| return "PARAMETER_MAX"; | |||
| } | |||
| qWarning("CarlaBackend::InternalParametersIndex2Str(%i) - invalid index", index); | |||
| @@ -300,7 +302,7 @@ const char* ProcessMode2Str(const ProcessMode& mode) | |||
| // ------------------------------------------------- | |||
| static inline | |||
| uintptr_t getAddressFromPointer(void* const ptr) | |||
| uintptr_t getAddressFromPointer(void* ptr) | |||
| { | |||
| qDebug("CarlaBackend::getAddressFromPointer(%p)", ptr); | |||
| CARLA_ASSERT(ptr != nullptr); | |||
| @@ -310,7 +312,7 @@ uintptr_t getAddressFromPointer(void* const ptr) | |||
| } | |||
| static inline | |||
| void* getPointerFromAddress(const uintptr_t& addr) | |||
| void* getPointerFromAddress(uintptr_t& addr) | |||
| { | |||
| CARLA_ASSERT(addr != 0); | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla OSC utils | |||
| * Copyright (C) 2012-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_OSC_UTILS_HPP__ | |||
| @@ -42,14 +42,13 @@ struct CarlaOscData { | |||
| void free() | |||
| { | |||
| if (path) | |||
| ::free((void*)path); | |||
| std::free((void*)path); | |||
| if (source) | |||
| ::lo_address_free(source); | |||
| lo_address_free(source); | |||
| if (target) | |||
| ::lo_address_free(target); | |||
| lo_address_free(target); | |||
| path = nullptr; | |||
| source = nullptr; | |||
| @@ -2,17 +2,17 @@ | |||
| * Carla common utils | |||
| * Copyright (C) 2011-2013 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 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 COPYING file | |||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||
| */ | |||
| #ifndef __CARLA_UTILS_HPP__ | |||
| @@ -103,8 +103,8 @@ void carla_usleep(const unsigned int usecs) | |||
| static inline | |||
| void carla_setenv(const char* const key, const char* const value) | |||
| { | |||
| CARLA_ASSERT(key); | |||
| CARLA_ASSERT(value); | |||
| CARLA_ASSERT(key != nullptr); | |||
| CARLA_ASSERT(value != nullptr); | |||
| #ifdef Q_OS_WIN | |||
| SetEnvironmentVariableA(key, value); | |||
| @@ -119,7 +119,7 @@ void carla_setenv(const char* const key, const char* const value) | |||
| static inline | |||
| void carla_setprocname(const char* const name) | |||
| { | |||
| CARLA_ASSERT(name); | |||
| CARLA_ASSERT(name != nullptr); | |||
| #if defined(Q_OS_HAIKU) | |||
| if ((thread_id this_thread = find_thread(nullptr)) != B_NAME_NOT_FOUND) | |||
| @@ -145,9 +145,12 @@ template<typename T> | |||
| static inline | |||
| void carla_fill(T* data, const unsigned int size, const T v) | |||
| { | |||
| CARLA_ASSERT(data); | |||
| CARLA_ASSERT(data != nullptr); | |||
| CARLA_ASSERT(size > 0); | |||
| if (data == nullptr) | |||
| return; | |||
| for (unsigned int i=0; i < size; i++) | |||
| *data++ = v; | |||
| } | |||
| @@ -170,7 +173,10 @@ void carla_zeroFloat(float* data, const unsigned size) | |||
| static inline | |||
| void carla_zeroMem(void* const memory, const size_t numBytes) | |||
| { | |||
| CARLA_ASSERT(memory); | |||
| CARLA_ASSERT(memory != nullptr); | |||
| if (memory == nullptr) | |||
| return; | |||
| std::memset(memory, 0, numBytes); | |||
| } | |||
| @@ -278,8 +284,6 @@ private: | |||
| // ------------------------------------------------- | |||
| // CarlaString class | |||
| // TODO - use "size_t bufferLen" | |||
| class CarlaString | |||
| { | |||
| public: | |||
| @@ -288,94 +292,77 @@ public: | |||
| explicit CarlaString() | |||
| { | |||
| buffer = ::strdup(""); | |||
| bufferLen = 0; | |||
| _init(); | |||
| _dup(nullptr); | |||
| } | |||
| explicit CarlaString(char* const strBuf) | |||
| { | |||
| if (strBuf) | |||
| { | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| } | |||
| else | |||
| { | |||
| buffer = ::strdup(""); | |||
| bufferLen = 0; | |||
| } | |||
| _init(); | |||
| _dup(strBuf); | |||
| } | |||
| explicit CarlaString(const char* const strBuf) | |||
| { | |||
| if (strBuf) | |||
| { | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| } | |||
| else | |||
| { | |||
| buffer = ::strdup(""); | |||
| bufferLen = 0; | |||
| } | |||
| _init(); | |||
| _dup(strBuf); | |||
| } | |||
| explicit CarlaString(const int value) | |||
| { | |||
| const size_t strBufSize = ::abs(value/10) + 3; | |||
| const size_t strBufSize = (unsigned int)std::abs(value/10) + 3; | |||
| char strBuf[strBufSize]; | |||
| ::snprintf(strBuf, strBufSize, "%d", value); | |||
| std::snprintf(strBuf, strBufSize, "%d", value); | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| _init(); | |||
| _dup(strBuf, strBufSize); | |||
| } | |||
| explicit CarlaString(const unsigned int value, const bool hexadecimal = false) | |||
| { | |||
| const size_t strBufSize = value/10 + 2 + (hexadecimal ? 2 : 0); | |||
| char strBuf[strBufSize]; | |||
| ::snprintf(strBuf, strBufSize, hexadecimal ? "%u" : "0x%x", value); | |||
| std::snprintf(strBuf, strBufSize, hexadecimal ? "0x%x" : "%u", value); | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| _init(); | |||
| _dup(strBuf, strBufSize); | |||
| } | |||
| explicit CarlaString(const long int value) | |||
| { | |||
| const size_t strBufSize = ::labs(value/10) + 3; | |||
| const size_t strBufSize = (unsigned long)std::abs(value/10) + 3; | |||
| char strBuf[strBufSize]; | |||
| ::snprintf(strBuf, strBufSize, "%ld", value); | |||
| std::snprintf(strBuf, strBufSize, "%ld", value); | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| _init(); | |||
| _dup(strBuf, strBufSize); | |||
| } | |||
| explicit CarlaString(const unsigned long int value, const bool hexadecimal = false) | |||
| { | |||
| const size_t strBufSize = value/10 + 2 + (hexadecimal ? 2 : 0); | |||
| char strBuf[strBufSize]; | |||
| ::snprintf(strBuf, strBufSize, hexadecimal ? "%lu" : "0x%lx", value); | |||
| std::snprintf(strBuf, strBufSize, hexadecimal ? "0x%lx" : "%lu", value); | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| _init(); | |||
| _dup(strBuf, strBufSize); | |||
| } | |||
| explicit CarlaString(const float value) | |||
| { | |||
| char strBuf[0xff]; | |||
| ::snprintf(strBuf, 0xff, "%f", value); | |||
| std::snprintf(strBuf, 0xff, "%f", value); | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| _dup(strBuf); | |||
| } | |||
| explicit CarlaString(const double value) | |||
| { | |||
| char strBuf[0xff]; | |||
| ::snprintf(strBuf, 0xff, "%g", value); | |||
| std::snprintf(strBuf, 0xff, "%g", value); | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| _init(); | |||
| _dup(strBuf); | |||
| } | |||
| // --------------------------------------------- | |||
| @@ -383,8 +370,8 @@ public: | |||
| CarlaString(const CarlaString& str) | |||
| { | |||
| buffer = ::strdup(str.buffer); | |||
| bufferLen = ::strlen(buffer); | |||
| _init(); | |||
| _dup(str.buffer); | |||
| } | |||
| // --------------------------------------------- | |||
| @@ -393,7 +380,8 @@ public: | |||
| ~CarlaString() | |||
| { | |||
| CARLA_ASSERT(buffer); | |||
| ::free(buffer); | |||
| delete[] buffer; | |||
| } | |||
| // --------------------------------------------- | |||
| @@ -414,31 +402,35 @@ public: | |||
| return (bufferLen != 0); | |||
| } | |||
| #ifdef __USE_GNU | |||
| #if __USE_GNU && 0 | |||
| bool contains(const char* const strBuf, const bool ignoreCase = false) const | |||
| #else | |||
| bool contains(const char* const strBuf) const | |||
| #endif | |||
| { | |||
| if (! strBuf) | |||
| if (strBuf == nullptr) | |||
| return false; | |||
| if (bufferLen == 0) | |||
| return false; | |||
| #ifdef __USE_GNU | |||
| if (ignoreCase) | |||
| return (::strcasestr(buffer, strBuf) != nullptr); | |||
| return (std::strcasestr(buffer, strBuf) != nullptr); | |||
| else | |||
| #endif | |||
| return (::strstr(buffer, strBuf) != nullptr); | |||
| return (std::strstr(buffer, strBuf) != nullptr); | |||
| } | |||
| #ifdef __USE_GNU | |||
| bool contains(const CarlaString& str, const bool ignoreCase = false) const | |||
| { | |||
| return contains(str.buffer, ignoreCase); | |||
| } | |||
| #else | |||
| bool contains(const char* const strBuf) const | |||
| { | |||
| if (strBuf == nullptr) | |||
| return false; | |||
| if (bufferLen == 0) | |||
| return false; | |||
| return (std::strstr(buffer, strBuf) != nullptr); | |||
| } | |||
| bool contains(const CarlaString& str) const | |||
| { | |||
| return contains(str.buffer); | |||
| @@ -460,14 +452,14 @@ public: | |||
| void replace(const char before, const char after) | |||
| { | |||
| if (after == 0) | |||
| if (after == '\0') | |||
| return; | |||
| for (size_t i=0; i < bufferLen; i++) | |||
| { | |||
| if (buffer[i] == before) | |||
| buffer[i] = after; | |||
| else if (buffer[i] == 0) | |||
| else if (buffer[i] == '\0') | |||
| break; | |||
| } | |||
| } | |||
| @@ -475,7 +467,7 @@ public: | |||
| void truncate(const size_t n) | |||
| { | |||
| for (size_t i=n; i < bufferLen; i++) | |||
| buffer[i] = 0; | |||
| buffer[i] = '\0'; | |||
| } | |||
| void toBasic() | |||
| @@ -497,19 +489,23 @@ public: | |||
| void toLower() | |||
| { | |||
| static const char charDiff = 'a' - 'A'; | |||
| for (size_t i=0; i < bufferLen; i++) | |||
| { | |||
| if (buffer[i] >= 'A' && buffer[i] <= 'Z') | |||
| buffer[i] += 32; | |||
| buffer[i] += charDiff; | |||
| } | |||
| } | |||
| void toUpper() | |||
| { | |||
| static const char charDiff = 'a' - 'A'; | |||
| for (size_t i=0; i < bufferLen; i++) | |||
| { | |||
| if (buffer[i] >= 'a' && buffer[i] <= 'z') | |||
| buffer[i] -= 32; | |||
| buffer[i] -= charDiff; | |||
| } | |||
| } | |||
| @@ -528,7 +524,7 @@ public: | |||
| bool operator==(const char* const strBuf) const | |||
| { | |||
| return (strBuf && ::strcmp(buffer, strBuf) == 0); | |||
| return (strBuf != nullptr && std::strcmp(buffer, strBuf) == 0); | |||
| } | |||
| bool operator==(const CarlaString& str) const | |||
| @@ -548,18 +544,7 @@ public: | |||
| CarlaString& operator=(const char* const strBuf) | |||
| { | |||
| ::free(buffer); | |||
| if (strBuf) | |||
| { | |||
| buffer = ::strdup(strBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| } | |||
| else | |||
| { | |||
| buffer = ::strdup(""); | |||
| bufferLen = 0; | |||
| } | |||
| _dup(strBuf); | |||
| return *this; | |||
| } | |||
| @@ -571,15 +556,13 @@ public: | |||
| CarlaString& operator+=(const char* const strBuf) | |||
| { | |||
| const size_t newBufSize = ::strlen(buffer) + (strBuf ? ::strlen(strBuf) : 0) + 1; | |||
| const size_t newBufSize = std::strlen(buffer) + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1; | |||
| char newBuf[newBufSize]; | |||
| ::strcpy(newBuf, buffer); | |||
| ::strcat(newBuf, strBuf); | |||
| ::free(buffer); | |||
| std::strcpy(newBuf, buffer); | |||
| std::strcat(newBuf, strBuf); | |||
| buffer = ::strdup(newBuf); | |||
| bufferLen = ::strlen(buffer); | |||
| _dup(newBuf, newBufSize); | |||
| return *this; | |||
| } | |||
| @@ -591,11 +574,11 @@ public: | |||
| CarlaString operator+(const char* const strBuf) | |||
| { | |||
| const size_t newBufSize = ::strlen(buffer) + (strBuf ? ::strlen(strBuf) : 0) + 1; | |||
| const size_t newBufSize = std::strlen(buffer) + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1; | |||
| char newBuf[newBufSize]; | |||
| ::strcpy(newBuf, buffer); | |||
| ::strcat(newBuf, strBuf); | |||
| std::strcpy(newBuf, buffer); | |||
| std::strcat(newBuf, strBuf); | |||
| return CarlaString(newBuf); | |||
| } | |||
| @@ -610,10 +593,58 @@ public: | |||
| private: | |||
| char* buffer; | |||
| size_t bufferLen; | |||
| bool firstInit; | |||
| void _init() | |||
| { | |||
| buffer = nullptr; | |||
| bufferLen = 0; | |||
| firstInit = true; | |||
| } | |||
| void _recalcLen() | |||
| // allocate string strBuf if not null | |||
| // size > 0 only if strBuf is valid | |||
| void _dup(const char* const strBuf, const size_t size = 0) | |||
| { | |||
| bufferLen = ::strlen(buffer); | |||
| if (strBuf != nullptr) | |||
| { | |||
| // don't recreate string if contents match | |||
| if (firstInit || std::strcmp(buffer, strBuf) != 0) | |||
| { | |||
| if (! firstInit) | |||
| { | |||
| CARLA_ASSERT(buffer); | |||
| delete[] buffer; | |||
| } | |||
| bufferLen = (size > 0) ? size : std::strlen(strBuf); | |||
| buffer = new char[bufferLen]; | |||
| std::strcpy(buffer, strBuf); | |||
| firstInit = false; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| CARLA_ASSERT(size == 0); | |||
| // don't recreate null string | |||
| if (firstInit || bufferLen != 0) | |||
| { | |||
| if (! firstInit) | |||
| { | |||
| CARLA_ASSERT(buffer); | |||
| delete[] buffer; | |||
| } | |||
| bufferLen = 0; | |||
| buffer = new char[1]; | |||
| buffer[0] = 0; | |||
| firstInit = false; | |||
| } | |||
| } | |||
| } | |||
| CARLA_LEAK_DETECTOR(CarlaString) | |||
| @@ -624,11 +655,11 @@ static inline | |||
| CarlaString operator+(const char* const strBufBefore, const CarlaString& strAfter) | |||
| { | |||
| const char* const strBufAfter = (const char*)strAfter; | |||
| const size_t newBufSize = (strBufBefore ? ::strlen(strBufBefore) : 0) + ::strlen(strBufAfter) + 1; | |||
| const size_t newBufSize = ((strBufBefore != nullptr) ? std::strlen(strBufBefore) : 0) + std::strlen(strBufAfter) + 1; | |||
| char newBuf[newBufSize]; | |||
| ::strcpy(newBuf, strBufBefore); | |||
| ::strcat(newBuf, strBufAfter); | |||
| std::strcpy(newBuf, strBufBefore); | |||
| std::strcat(newBuf, strBufAfter); | |||
| return CarlaString(newBuf); | |||
| } | |||