| @@ -1363,17 +1363,6 @@ typedef struct { | |||
| */ | |||
| const double* sampleRates; | |||
| #ifdef __cplusplus | |||
| /*! | |||
| * Clear data. | |||
| */ | |||
| void clear() noexcept | |||
| { | |||
| hints = 0x0; | |||
| bufferSizes = nullptr; | |||
| sampleRates = nullptr; | |||
| } | |||
| #endif | |||
| } EngineDriverDeviceInfo; | |||
| /** @} */ | |||
| @@ -18,9 +18,13 @@ ifeq ($(HAVE_FFMPEG),true) | |||
| BUILD_CXX_FLAGS += -DHAVE_FFMPEG | |||
| endif | |||
| # ifeq ($(HAVE_JUCE),true) | |||
| # BUILD_CXX_FLAGS += -DHAVE_JUCE | |||
| # endif | |||
| ifeq ($(HAVE_JUCE),true) | |||
| BUILD_CXX_FLAGS += -DHAVE_JUCE | |||
| endif | |||
| ifeq ($(HAVE_OPENGL),true) | |||
| BUILD_CXX_FLAGS += -DHAVE_OPENGL | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| @@ -30,10 +30,6 @@ | |||
| #include "CarlaStateUtils.hpp" | |||
| #include "CarlaMIDI.h" | |||
| #include <QtCore/QFile> | |||
| #include <QtCore/QFileInfo> | |||
| #include <QtCore/QTextStream> | |||
| #ifdef HAVE_JUCE | |||
| # include "juce_audio_basics.h" | |||
| using juce::FloatVectorOperations; | |||
| @@ -41,16 +37,16 @@ using juce::FloatVectorOperations; | |||
| # include <cmath> | |||
| #endif | |||
| #include <QtCore/QFile> | |||
| #include <QtCore/QFileInfo> | |||
| #include <QtCore/QTextStream> | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| #if 0 | |||
| } // Fix editor indentation | |||
| #endif | |||
| // Engine helper macro, sets lastError and returns false/NULL | |||
| #define CARLA_SAFE_ASSERT_RETURN_ERR(cond, err) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return false; } | |||
| #define CARLA_SAFE_ASSERT_RETURN_ERRN(cond, err) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return nullptr; } | |||
| // ----------------------------------------------------------------------- | |||
| // Fallback data | |||
| @@ -33,6 +33,12 @@ CARLA_BACKEND_START_NAMESPACE | |||
| // ----------------------------------------------------------------------- | |||
| // Engine helper macro, sets lastError and returns false/NULL | |||
| #define CARLA_SAFE_ASSERT_RETURN_ERR(cond, err) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return false; } | |||
| #define CARLA_SAFE_ASSERT_RETURN_ERRN(cond, err) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); setLastError(err); return nullptr; } | |||
| // ----------------------------------------------------------------------- | |||
| static inline | |||
| const char* EngineType2Str(const EngineType type) | |||
| { | |||
| @@ -22,14 +22,14 @@ | |||
| #include "List.hpp" | |||
| #include "jackbridge/JackBridge.hpp" | |||
| #include <cmath> | |||
| #include <QtCore/QStringList> | |||
| #ifdef HAVE_JUCE | |||
| # include "juce_audio_basics.h" | |||
| using juce::FloatVectorOperations; | |||
| #endif | |||
| #include <cmath> | |||
| #include <QtCore/QStringList> | |||
| #define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon" | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| @@ -1960,11 +1960,11 @@ private: | |||
| bool portIsCV = (jackPortFlags & JackPortIsControlVoltage); | |||
| unsigned int canvasPortFlags = 0x0; | |||
| canvasPortFlags |= portIsInput ? PATCHBAY_PORT_IS_INPUT : PATCHBAY_PORT_IS_OUTPUT; | |||
| canvasPortFlags |= portIsAudio ? PATCHBAY_PORT_IS_AUDIO : PATCHBAY_PORT_IS_MIDI; | |||
| canvasPortFlags |= portIsInput ? PATCHBAY_PORT_IS_INPUT : 0x0; | |||
| canvasPortFlags |= portIsAudio ? PATCHBAY_PORT_TYPE_AUDIO : PATCHBAY_PORT_TYPE_MIDI; | |||
| if (portIsAudio && portIsCV) | |||
| canvasPortFlags |= PATCHBAY_PORT_IS_CV; | |||
| canvasPortFlags |= PATCHBAY_PORT_TYPE_CV; | |||
| PortNameToId portNameToId(groupId, fLastPortId++, portName, fullPortName); | |||
| fUsedPortNames.append(portNameToId); | |||
| @@ -22,9 +22,11 @@ | |||
| #include "CarlaEngineInternal.hpp" | |||
| #include "CarlaBackendUtils.hpp" | |||
| #include "CarlaMIDI.h" | |||
| #include "RtList.hpp" | |||
| #include "juce_audio_basics.h" | |||
| // #include "RtList.hpp" | |||
| #include "juce_audio_devices.h" | |||
| using namespace juce; | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| @@ -33,12 +35,23 @@ CARLA_BACKEND_START_NAMESPACE | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Juce Engine | |||
| static const char** gRetNames = nullptr; | |||
| static OwnedArray<AudioIODeviceType> gJuceDeviceTypes; | |||
| static void initJuceDevices() | |||
| { | |||
| static AudioDeviceManager manager; | |||
| if (gJuceDeviceTypes.size() == 0) | |||
| manager.createAudioDeviceTypes(gJuceDeviceTypes); | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Juce Engine | |||
| class CarlaEngineJuce : public CarlaEngine/*, | |||
| public juce::AudioIODeviceCallback*/ | |||
| public AudioIODeviceCallback*/ | |||
| { | |||
| public: | |||
| CarlaEngineJuce() | |||
| @@ -121,7 +134,7 @@ protected: | |||
| private: | |||
| //juce::AudioIODeviceType* fDeviceType; | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineJuce) | |||
| //JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineJuce) | |||
| }; | |||
| // ----------------------------------------- | |||
| @@ -133,54 +146,138 @@ CarlaEngine* CarlaEngine::newJuce(const AudioApi /*api*/) | |||
| size_t CarlaEngine::getJuceApiCount() | |||
| { | |||
| return 0; | |||
| initJuceDevices(); | |||
| return gJuceDeviceTypes.size(); | |||
| } | |||
| const char* CarlaEngine::getJuceApiName(const unsigned int /*index*/) | |||
| const char* CarlaEngine::getJuceApiName(const unsigned int index) | |||
| { | |||
| return nullptr; | |||
| initJuceDevices(); | |||
| if ((int)index >= gJuceDeviceTypes.size()) | |||
| return nullptr; | |||
| AudioIODeviceType* const deviceType(gJuceDeviceTypes[index]); | |||
| if (deviceType == nullptr) | |||
| return nullptr; | |||
| return deviceType->getTypeName().toRawUTF8(); | |||
| } | |||
| const char* const* CarlaEngine::getJuceApiDeviceNames(const unsigned int /*index*/) | |||
| const char* const* CarlaEngine::getJuceApiDeviceNames(const unsigned int index) | |||
| { | |||
| #if 0 | |||
| juce::ScopedPointer<juce::AudioIODeviceType> deviceType; | |||
| initJuceDevices(); | |||
| switch(index) | |||
| { | |||
| case 0: | |||
| deviceType = juce::AudioIODeviceType::createAudioIODeviceType_JACK(); | |||
| break; | |||
| default: | |||
| //setLastError(""); | |||
| if ((int)index >= gJuceDeviceTypes.size()) | |||
| return nullptr; | |||
| } | |||
| AudioIODeviceType* const deviceType(gJuceDeviceTypes[index]); | |||
| if (deviceType == nullptr) | |||
| { | |||
| //setLastError(""); | |||
| return nullptr; | |||
| } | |||
| deviceType->scanForDevices(); | |||
| const juce::StringArray devNames(deviceType->getDeviceNames()); | |||
| const int devNameCount(devNames.size()); | |||
| StringArray deviceNames(deviceType->getDeviceNames()); | |||
| const int deviceNameCount(deviceNames.size()); | |||
| if (devNameCount <= 0) | |||
| if (deviceNameCount <= 0) | |||
| return nullptr; | |||
| gRetNames = new const char*[devNameCount+1]; | |||
| if (gRetNames != nullptr) | |||
| { | |||
| for (int i=0; gRetNames[i] != nullptr; ++i) | |||
| delete[] gRetNames[i]; | |||
| delete[] gRetNames; | |||
| } | |||
| gRetNames = new const char*[deviceNameCount+1]; | |||
| for (unsigned int i=0; i < devNameCount; ++i) | |||
| gRetNames[i] = carla_strdup(devNames[i].toRawUTF8()); | |||
| for (int i=0; i < deviceNameCount; ++i) | |||
| gRetNames[i] = carla_strdup(deviceNames[i].toRawUTF8()); | |||
| gRetNames[devNameCount] = nullptr; | |||
| #endif | |||
| gRetNames[deviceNameCount] = nullptr; | |||
| return gRetNames; | |||
| } | |||
| const EngineDriverDeviceInfo* CarlaEngine::getJuceDeviceInfo(const unsigned int index, const char* const deviceName) | |||
| { | |||
| initJuceDevices(); | |||
| if ((int)index >= gJuceDeviceTypes.size()) | |||
| return nullptr; | |||
| AudioIODeviceType* const deviceType(gJuceDeviceTypes[index]); | |||
| if (deviceType == nullptr) | |||
| return nullptr; | |||
| deviceType->scanForDevices(); | |||
| ScopedPointer<AudioIODevice> device(deviceType->createDevice(deviceName, deviceName)); | |||
| if (device == nullptr) | |||
| return nullptr; | |||
| static EngineDriverDeviceInfo devInfo = { 0x0, nullptr, nullptr }; | |||
| static uint32_t dummyBufferSizes[11] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 }; | |||
| static double dummySampleRates[14] = { 22050.0, 32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, 0.0 }; | |||
| // reset | |||
| devInfo.hints = ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE | ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE; | |||
| // cleanup | |||
| if (devInfo.bufferSizes != nullptr && devInfo.bufferSizes != dummyBufferSizes) | |||
| { | |||
| delete[] devInfo.bufferSizes; | |||
| devInfo.bufferSizes = nullptr; | |||
| } | |||
| if (devInfo.sampleRates != nullptr && devInfo.sampleRates != dummySampleRates) | |||
| { | |||
| delete[] devInfo.sampleRates; | |||
| devInfo.sampleRates = nullptr; | |||
| } | |||
| if (device->hasControlPanel()) | |||
| devInfo.hints |= ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL; | |||
| if (size_t bufferSizesCount = device->getNumBufferSizesAvailable()) | |||
| { | |||
| uint32_t* const bufferSizes(new uint32_t[bufferSizesCount+1]); | |||
| for (size_t i=0; i < bufferSizesCount; ++i) | |||
| bufferSizes[i] = device->getBufferSizeSamples(i); | |||
| bufferSizes[bufferSizesCount] = 0; | |||
| devInfo.bufferSizes = bufferSizes; | |||
| } | |||
| else | |||
| { | |||
| devInfo.bufferSizes = dummyBufferSizes; | |||
| } | |||
| if (size_t sampleRatesCount = device->getNumSampleRates()) | |||
| { | |||
| double* const sampleRates(new double[sampleRatesCount+1]); | |||
| for (size_t i=0; i < sampleRatesCount; ++i) | |||
| sampleRates[i] = device->getSampleRate(i); | |||
| sampleRates[sampleRatesCount] = 0.0; | |||
| devInfo.sampleRates = sampleRates; | |||
| } | |||
| else | |||
| { | |||
| devInfo.sampleRates = dummySampleRates; | |||
| } | |||
| return &devInfo; | |||
| } | |||
| // ----------------------------------------- | |||
| CARLA_BACKEND_END_NAMESPACE | |||
| @@ -24,8 +24,7 @@ | |||
| #include "rtmidi/RtMidi.h" | |||
| #ifdef USE_JUCE | |||
| #include "juce_audio_basics.h" | |||
| # include "juce_audio_basics.h" | |||
| using juce::FloatVectorOperations; | |||
| #endif | |||
| @@ -94,10 +93,6 @@ public: | |||
| fAudio(api), | |||
| fAudioBufIn(nullptr), | |||
| fAudioBufOut(nullptr), | |||
| #ifdef CARLA_PROPER_CPP11_SUPPORT | |||
| fAudioBufRackIn{nullptr}, | |||
| fAudioBufRackOut{nullptr}, | |||
| #endif | |||
| fAudioCountIn(0), | |||
| fAudioCountOut(0), | |||
| fAudioIsInterleaved(false), | |||
| @@ -108,10 +103,8 @@ public: | |||
| { | |||
| carla_debug("CarlaEngineRtAudio::CarlaEngineRtAudio(%i)", api); | |||
| #ifndef CARLA_PROPER_CPP11_SUPPORT | |||
| fAudioBufRackIn[0] = fAudioBufRackIn[1] = nullptr; | |||
| fAudioBufRackIn[0] = fAudioBufRackIn[1] = nullptr; | |||
| fAudioBufRackOut[0] = fAudioBufRackOut[1] = nullptr; | |||
| #endif | |||
| // just to make sure | |||
| pData->options.forceStereo = true; | |||
| @@ -148,7 +141,7 @@ public: | |||
| CARLA_ASSERT(fAudioCountIn == 0); | |||
| CARLA_ASSERT(fAudioCountOut == 0); | |||
| CARLA_ASSERT(! fAudioIsReady); | |||
| CARLA_ASSERT(clientName != nullptr); | |||
| CARLA_ASSERT(clientName != nullptr && clientName[0] != '\0'); | |||
| carla_debug("CarlaEngineRtAudio::init(\"%s\")", clientName); | |||
| RtAudio::StreamParameters iParams, oParams; | |||
| @@ -396,13 +389,13 @@ public: | |||
| return "OSS"; | |||
| case RtAudio::UNIX_JACK: | |||
| #if defined(CARLA_OS_WIN) | |||
| return "JACK with WinMM"; | |||
| return "JACK with WinMM"; | |||
| #elif defined(CARLA_OS_MAC) | |||
| return "JACK with CoreMidi"; | |||
| return "JACK with CoreMidi"; | |||
| #elif defined(CARLA_OS_LINUX) | |||
| return "JACK with ALSA-MIDI"; | |||
| return "JACK with ALSA-MIDI"; | |||
| #else | |||
| return "JACK (RtAudio)"; | |||
| return "JACK (RtAudio)"; | |||
| #endif | |||
| case RtAudio::MACOSX_CORE: | |||
| return "CoreAudio"; | |||
| @@ -1503,15 +1496,6 @@ const char* const* CarlaEngine::getRtAudioApiDeviceNames(const unsigned int inde | |||
| RtAudio rtAudio(api); | |||
| if (gRetNames != nullptr) | |||
| { | |||
| int i=0; | |||
| while (gRetNames[i] != nullptr) | |||
| delete[] gRetNames[i++]; | |||
| delete[] gRetNames; | |||
| gRetNames = nullptr; | |||
| } | |||
| const unsigned int devCount(rtAudio.getDeviceCount()); | |||
| if (devCount == 0) | |||
| @@ -1529,6 +1513,13 @@ const char* const* CarlaEngine::getRtAudioApiDeviceNames(const unsigned int inde | |||
| const unsigned int realDevCount(devNames.count()); | |||
| if (gRetNames != nullptr) | |||
| { | |||
| for (int i=0; gRetNames[i] != nullptr; ++i) | |||
| delete[] gRetNames[i]; | |||
| delete[] gRetNames; | |||
| } | |||
| gRetNames = new const char*[realDevCount+1]; | |||
| for (unsigned int i=0; i < realDevCount; ++i) | |||
| @@ -1570,9 +1561,9 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const unsigned i | |||
| if (i == devCount) | |||
| return nullptr; | |||
| static EngineDriverDeviceInfo devInfo; | |||
| static uint32_t dummyBufferSizes[11] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 }; | |||
| static double dummySampleRates[14] = { 22050.0, 32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, 0.0 }; | |||
| static EngineDriverDeviceInfo devInfo = { 0x0, nullptr, nullptr }; | |||
| static uint32_t dummyBufferSizes[11] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 }; | |||
| static double dummySampleRates[14] = { 22050.0, 32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, 0.0 }; | |||
| // reset | |||
| devInfo.hints = 0x0; | |||
| @@ -1587,7 +1578,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const unsigned i | |||
| if (size_t sampleRatesCount = rtAudioDevInfo.sampleRates.size()) | |||
| { | |||
| double* sampleRates(new double[sampleRatesCount+1]); | |||
| double* const sampleRates(new double[sampleRatesCount+1]); | |||
| for (size_t i=0; i < sampleRatesCount; ++i) | |||
| sampleRates[i] = rtAudioDevInfo.sampleRates[i]; | |||
| @@ -23,10 +23,10 @@ OBJS = $(OBJSp) \ | |||
| CarlaEngineJack.cpp.o \ | |||
| CarlaEngineRtAudio.cpp.o | |||
| # ifeq ($(HAVE_JUCE),true) | |||
| # OBJS += \ | |||
| # CarlaEngineJuce.cpp.o | |||
| # endif | |||
| ifeq ($(HAVE_JUCE),true) | |||
| OBJS += \ | |||
| CarlaEngineJuce.cpp.o | |||
| endif | |||
| HEADERS = \ | |||
| ../CarlaBackend.h ../CarlaEngine.hpp ../CarlaPlugin.hpp \ | |||
| @@ -19,12 +19,13 @@ | |||
| #ifdef HAVE_JUCE | |||
| #include "JuceHeader.h" | |||
| //#include "JuceHeader.h" | |||
| using juce::VSTPluginFormat; | |||
| //using juce::VSTPluginFormat; | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| #if 0 | |||
| class JucePlugin : public CarlaPlugin | |||
| { | |||
| public: | |||
| @@ -58,6 +59,7 @@ private: | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(JucePlugin) | |||
| }; | |||
| #endif | |||
| CARLA_BACKEND_END_NAMESPACE | |||
| @@ -69,7 +71,7 @@ CarlaPlugin* CarlaPlugin::newJuce(const Initializer& init) | |||
| { | |||
| carla_debug("CarlaPlugin::newJuce({%p, \"%s\", \"%s\", \"%s\"})", init.engine, init.filename, init.name, init.label); | |||
| #ifdef HAVE_JUCE | |||
| #if 0 //def HAVE_JUCE | |||
| JucePlugin* const plugin(new JucePlugin(init.engine, init.id)); | |||
| //if (! plugin->init(init.filename, init.name, init.label)) | |||
| @@ -10,10 +10,21 @@ include ../Makefile.mk | |||
| # Common | |||
| LINK_FLAGS += $(shell pkg-config --libs liblo) | |||
| LINK_FLAGS += $(QTCORE_LIBS) | |||
| LINK_FLAGS += $(QTXML_LIBS) | |||
| LINK_FLAGS += $(RTMEMPOOL_LIBS) | |||
| ifeq ($(HAVE_JUCE),true) | |||
| LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS) | |||
| LINK_FLAGS += $(JUCE_AUDIO_DEVICES_LIBS) | |||
| LINK_FLAGS += $(JUCE_CORE_LIBS) | |||
| # LINK_FLAGS += $(JUCE_DATA_STRUCTURES_LIBS) | |||
| LINK_FLAGS += $(JUCE_EVENTS_LIBS) | |||
| # LINK_FLAGS += $(JUCE_GRAPHICS_LIBS) | |||
| # LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS) | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Engine | |||
| @@ -22,13 +33,6 @@ LINK_FLAGS += $(RTMIDI_LIBS) | |||
| LINK_FLAGS += $(JACKBRIDGE_LIBS) | |||
| # LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS) | |||
| # LINK_FLAGS += $(JUCE_CORE_LIBS) | |||
| # LINK_FLAGS += $(JUCE_DATA_STRUCTURES_LIBS) | |||
| # LINK_FLAGS += $(JUCE_EVENTS_LIBS) | |||
| # LINK_FLAGS += $(JUCE_GRAPHICS_LIBS) | |||
| # LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS) | |||
| # -------------------------------------------------------------- | |||
| # Plugin | |||
| @@ -79,24 +83,28 @@ LIBS += ../libcarla_plugin.a | |||
| LIBS += ../../modules/carla_native.a | |||
| LIBS += ../../modules/jackbridge.a | |||
| # LIBS += ../../modules/juce_audio_basics.a | |||
| # LIBS += ../../modules/juce_core.a | |||
| # LIBS += ../../modules/juce_data_structures.a | |||
| # LIBS += ../../modules/juce_events.a | |||
| # LIBS += ../../modules/juce_graphics.a | |||
| # LIBS += ../../modules/juce_gui_basics.a | |||
| LIBS += ../../modules/rtaudio.a | |||
| LIBS += ../../modules/rtmidi.a | |||
| LIBS += ../../modules/rtmempool.a | |||
| ifeq ($(HAVE_OPENGL),true) | |||
| LIBS += ../../modules/dgl.a | |||
| endif | |||
| ifeq ($(CARLA_PLUGIN_SUPPORT),true) | |||
| LIBS += ../../modules/lilv.a | |||
| endif | |||
| ifeq ($(HAVE_JUCE),true) | |||
| LIBS += ../../modules/juce_audio_basics.a | |||
| LIBS += ../../modules/juce_audio_devices.a | |||
| LIBS += ../../modules/juce_core.a | |||
| # LIBS += ../../modules/juce_data_structures.a | |||
| LIBS += ../../modules/juce_events.a | |||
| # LIBS += ../../modules/juce_graphics.a | |||
| # LIBS += ../../modules/juce_gui_basics.a | |||
| endif | |||
| ifeq ($(HAVE_OPENGL),true) | |||
| LIBS += ../../modules/dgl.a | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| OBJS = \ | |||