@@ -29,12 +29,12 @@ | |||||
#include "CarlaBackendUtils.hpp" | #include "CarlaBackendUtils.hpp" | ||||
#include "CarlaMathUtils.hpp" | #include "CarlaMathUtils.hpp" | ||||
#include "juce_core.h" | |||||
#include "linuxsampler/EngineFactory.h" | #include "linuxsampler/EngineFactory.h" | ||||
#include <linuxsampler/Sampler.h> | #include <linuxsampler/Sampler.h> | ||||
// FIXME | |||||
#include <QtCore/QFileInfo> | |||||
#include <QtCore/QStringList> | |||||
// ----------------------------------------------------------------------- | |||||
namespace LinuxSampler { | namespace LinuxSampler { | ||||
@@ -68,19 +68,14 @@ public: | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// LinuxSampler virtual methods | // LinuxSampler virtual methods | ||||
void Play() override | |||||
{ | |||||
} | |||||
void Play() override {} | |||||
void Stop() override {} | |||||
bool IsPlaying() override | bool IsPlaying() override | ||||
{ | { | ||||
return (fEngine->isRunning() && fPlugin->isEnabled()); | return (fEngine->isRunning() && fPlugin->isEnabled()); | ||||
} | } | ||||
void Stop() override | |||||
{ | |||||
} | |||||
uint MaxSamplesPerCycle() override | uint MaxSamplesPerCycle() override | ||||
{ | { | ||||
return fEngine->getBufferSize(); | return fEngine->getBufferSize(); | ||||
@@ -123,9 +118,7 @@ class MidiInputPortPlugin : public MidiInputPort | |||||
{ | { | ||||
public: | public: | ||||
MidiInputPortPlugin(MidiInputDevice* const device, const int portNum) | MidiInputPortPlugin(MidiInputDevice* const device, const int portNum) | ||||
: MidiInputPort(device, portNum) | |||||
{ | |||||
} | |||||
: MidiInputPort(device, portNum) {} | |||||
~MidiInputPortPlugin() override {} | ~MidiInputPortPlugin() override {} | ||||
}; | }; | ||||
@@ -137,20 +130,13 @@ class MidiInputDevicePlugin : public MidiInputDevice | |||||
{ | { | ||||
public: | public: | ||||
MidiInputDevicePlugin(Sampler* const sampler) | MidiInputDevicePlugin(Sampler* const sampler) | ||||
: MidiInputDevice(std::map<String, DeviceCreationParameter*>(), sampler) | |||||
{ | |||||
} | |||||
: MidiInputDevice(std::map<String, DeviceCreationParameter*>(), sampler) {} | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// LinuxSampler virtual methods | // LinuxSampler virtual methods | ||||
void Listen() override | |||||
{ | |||||
} | |||||
void StopListen() override | |||||
{ | |||||
} | |||||
void Listen() override {} | |||||
void StopListen() override {} | |||||
String Driver() override | String Driver() override | ||||
{ | { | ||||
@@ -172,11 +158,12 @@ public: | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
using juce::File; | |||||
using juce::StringArray; | |||||
CARLA_BACKEND_START_NAMESPACE | CARLA_BACKEND_START_NAMESPACE | ||||
#if 0 | |||||
} | |||||
#endif | |||||
// ----------------------------------------------------------------------- | |||||
class LinuxSamplerPlugin : public CarlaPlugin | class LinuxSamplerPlugin : public CarlaPlugin | ||||
{ | { | ||||
@@ -411,19 +398,16 @@ public: | |||||
if (fUses16Outs) | if (fUses16Outs) | ||||
{ | { | ||||
QStringList midiProgramList(QString(value).split(":", QString::SkipEmptyParts)); | |||||
StringArray midiProgramList(StringArray::fromTokens(value, ":", "")); | |||||
if (midiProgramList.count() == MAX_MIDI_CHANNELS) | |||||
if (midiProgramList.size() == MAX_MIDI_CHANNELS) | |||||
{ | { | ||||
uint i = 0; | |||||
foreach (const QString& midiProg, midiProgramList) | |||||
uint8_t channel = 0; | |||||
for (juce::String *it=midiProgramList.begin(), *end=midiProgramList.end(); it != end; ++it) | |||||
{ | { | ||||
CARLA_SAFE_ASSERT_BREAK(i < MAX_MIDI_CHANNELS); | |||||
bool ok; | |||||
int index = midiProg.toInt(&ok); | |||||
const int index(it->getIntValue()); | |||||
if (ok && index >= 0 && index < static_cast<int>(pData->midiprog.count)) | |||||
if (index >= 0 && index < static_cast<int>(pData->midiprog.count)) | |||||
{ | { | ||||
const uint32_t bank = pData->midiprog.data[index].bank; | const uint32_t bank = pData->midiprog.data[index].bank; | ||||
const uint32_t program = pData->midiprog.data[index].program; | const uint32_t program = pData->midiprog.data[index].program; | ||||
@@ -431,27 +415,26 @@ public: | |||||
/*if (pData->engine->isOffline()) | /*if (pData->engine->isOffline()) | ||||
{ | { | ||||
fEngineChannels[i]->PrepareLoadInstrument(pData->filename, rIndex); | |||||
fEngineChannels[i]->LoadInstrument(); | |||||
fEngineChannels[channel]->PrepareLoadInstrument(pData->filename, rIndex); | |||||
fEngineChannels[channel]->LoadInstrument(); | |||||
} | } | ||||
else*/ | else*/ | ||||
{ | { | ||||
fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], fEngineChannels[i]); | |||||
fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], fEngineChannels[channel]); | |||||
} | } | ||||
fCurMidiProgs[i] = index; | |||||
fCurMidiProgs[channel] = index; | |||||
if (pData->ctrlChannel == static_cast<int32_t>(i)) | |||||
if (pData->ctrlChannel == static_cast<int32_t>(channel)) | |||||
{ | { | ||||
pData->midiprog.current = index; | pData->midiprog.current = index; | ||||
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, index, 0, 0.0f, nullptr); | pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, index, 0, 0.0f, nullptr); | ||||
} | } | ||||
} | } | ||||
++i; | |||||
++channel; | |||||
} | } | ||||
CARLA_SAFE_ASSERT(i == MAX_MIDI_CHANNELS); | |||||
CARLA_SAFE_ASSERT(channel == MAX_MIDI_CHANNELS); | |||||
} | } | ||||
} | } | ||||
@@ -1361,26 +1344,11 @@ CarlaPlugin* CarlaPlugin::newLinuxSampler(const Initializer& init, const char* c | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// Check if file exists | // Check if file exists | ||||
{ | |||||
QFileInfo file(init.filename); | |||||
if (! file.exists()) | |||||
{ | |||||
init.engine->setLastError("Requested file does not exist"); | |||||
return nullptr; | |||||
} | |||||
if (! file.isFile()) | |||||
{ | |||||
init.engine->setLastError("Requested file is not valid"); | |||||
return nullptr; | |||||
} | |||||
if (! file.isReadable()) | |||||
{ | |||||
init.engine->setLastError("Requested file is not readable"); | |||||
return nullptr; | |||||
} | |||||
if (! File(init.filename).existsAsFile()) | |||||
{ | |||||
init.engine->setLastError("Requested file is not valid or does not exist"); | |||||
return nullptr; | |||||
} | } | ||||
LinuxSamplerPlugin* const plugin(new LinuxSamplerPlugin(init.engine, init.id, format, use16Outs)); | LinuxSamplerPlugin* const plugin(new LinuxSamplerPlugin(init.engine, init.id, format, use16Outs)); | ||||
@@ -36,10 +36,9 @@ extern "C" { | |||||
#include "rtmempool/rtmempool-lv2.h" | #include "rtmempool/rtmempool-lv2.h" | ||||
} | } | ||||
// FIXME | |||||
#include <QtCore/QDir> | |||||
#include <QtCore/QFile> | |||||
#include <QtCore/QUrl> | |||||
#include "juce_core.h" | |||||
using juce::File; | |||||
#define URI_CARLA_ATOM_WORKER "http://kxstudio.sf.net/ns/carla/atomWorker" | #define URI_CARLA_ATOM_WORKER "http://kxstudio.sf.net/ns/carla/atomWorker" | ||||
#define URI_CARLA_FRONTEND_WIN_ID "http://kxstudio.sf.net/ns/carla/frontendWinId" | #define URI_CARLA_FRONTEND_WIN_ID "http://kxstudio.sf.net/ns/carla/frontendWinId" | ||||
@@ -971,10 +970,11 @@ public: | |||||
if (fLv2Options.windowTitle == nullptr) | if (fLv2Options.windowTitle == nullptr) | ||||
return; | return; | ||||
QString guiTitle(QString("%1 (GUI)").arg(pData->name)); | |||||
CarlaString guiTitle(pData->name); | |||||
guiTitle += " (GUI)"; | |||||
delete[] fLv2Options.windowTitle; | delete[] fLv2Options.windowTitle; | ||||
fLv2Options.windowTitle = carla_strdup(guiTitle.toUtf8().constData()); | |||||
fLv2Options.windowTitle = guiTitle.dup(); | |||||
fLv2Options.opts[Lv2PluginOptions::WindowTitle].size = (uint32_t)std::strlen(fLv2Options.windowTitle); | fLv2Options.opts[Lv2PluginOptions::WindowTitle].size = (uint32_t)std::strlen(fLv2Options.windowTitle); | ||||
fLv2Options.opts[Lv2PluginOptions::WindowTitle].value = fLv2Options.windowTitle; | fLv2Options.opts[Lv2PluginOptions::WindowTitle].value = fLv2Options.windowTitle; | ||||
@@ -3926,9 +3926,7 @@ public: | |||||
bridgeBinary += ".exe"; | bridgeBinary += ".exe"; | ||||
#endif | #endif | ||||
QFile file(bridgeBinary.buffer()); | |||||
if (! file.exists()) | |||||
if (! File(bridgeBinary.buffer()).existsAsFile()) | |||||
return nullptr; | return nullptr; | ||||
return bridgeBinary.dup(); | return bridgeBinary.dup(); | ||||
@@ -4555,16 +4553,17 @@ public: | |||||
{ | { | ||||
if (! is_lv2_feature_supported(fRdfDescriptor->Features[j].URI)) | if (! is_lv2_feature_supported(fRdfDescriptor->Features[j].URI)) | ||||
{ | { | ||||
QString msg(QString("Plugin wants a feature that is not supported:\n%1").arg(fRdfDescriptor->Features[j].URI)); | |||||
CarlaString msg("Plugin wants a feature that is not supported:\n"); | |||||
msg += fRdfDescriptor->Features[j].URI; | |||||
if (LV2_IS_FEATURE_REQUIRED(fRdfDescriptor->Features[j].Type)) | if (LV2_IS_FEATURE_REQUIRED(fRdfDescriptor->Features[j].Type)) | ||||
{ | { | ||||
canContinue = false; | canContinue = false; | ||||
pData->engine->setLastError(msg.toUtf8().constData()); | |||||
pData->engine->setLastError(msg); | |||||
break; | break; | ||||
} | } | ||||
else | else | ||||
carla_stderr("%s", msg.toUtf8().constData()); | |||||
carla_stderr("%s", msg.buffer()); | |||||
} | } | ||||
} | } | ||||
@@ -5085,8 +5084,9 @@ public: | |||||
// --------------------------------------------------------------- | // --------------------------------------------------------------- | ||||
// initialize ui data | // initialize ui data | ||||
QString guiTitle(QString("%1 (GUI)").arg(pData->name)); | |||||
fLv2Options.windowTitle = carla_strdup(guiTitle.toUtf8().constData()); | |||||
CarlaString guiTitle(pData->name); | |||||
guiTitle += " (GUI)"; | |||||
fLv2Options.windowTitle = guiTitle.dup(); | |||||
fLv2Options.opts[Lv2PluginOptions::WindowTitle].size = (uint32_t)std::strlen(fLv2Options.windowTitle); | fLv2Options.opts[Lv2PluginOptions::WindowTitle].size = (uint32_t)std::strlen(fLv2Options.windowTitle); | ||||
fLv2Options.opts[Lv2PluginOptions::WindowTitle].value = fLv2Options.windowTitle; | fLv2Options.opts[Lv2PluginOptions::WindowTitle].value = fLv2Options.windowTitle; | ||||
@@ -5414,8 +5414,7 @@ private: | |||||
CARLA_SAFE_ASSERT_RETURN(path != nullptr && path[0] != '\0', nullptr); | CARLA_SAFE_ASSERT_RETURN(path != nullptr && path[0] != '\0', nullptr); | ||||
carla_debug("carla_lv2_state_make_path(%p, \"%s\")", handle, path); | carla_debug("carla_lv2_state_make_path(%p, \"%s\")", handle, path); | ||||
QDir dir; | |||||
dir.mkpath(path); | |||||
File(path).createDirectory(); | |||||
return strdup(path); | return strdup(path); | ||||
} | } | ||||
@@ -5425,8 +5424,7 @@ private: | |||||
CARLA_SAFE_ASSERT_RETURN(absolute_path != nullptr && absolute_path[0] != '\0', nullptr); | CARLA_SAFE_ASSERT_RETURN(absolute_path != nullptr && absolute_path[0] != '\0', nullptr); | ||||
carla_debug("carla_lv2_state_map_abstract_path(%p, \"%s\")", handle, absolute_path); | carla_debug("carla_lv2_state_map_abstract_path(%p, \"%s\")", handle, absolute_path); | ||||
QDir dir(absolute_path); | |||||
return strdup(dir.canonicalPath().toUtf8().constData()); | |||||
return strdup(File(absolute_path).getRelativePathFrom(File::getCurrentWorkingDirectory()).toRawUTF8()); | |||||
} | } | ||||
static char* carla_lv2_state_map_absolute_path(LV2_State_Map_Path_Handle handle, const char* abstract_path) | static char* carla_lv2_state_map_absolute_path(LV2_State_Map_Path_Handle handle, const char* abstract_path) | ||||
@@ -5435,8 +5433,7 @@ private: | |||||
CARLA_SAFE_ASSERT_RETURN(abstract_path != nullptr && abstract_path[0] != '\0', nullptr); | CARLA_SAFE_ASSERT_RETURN(abstract_path != nullptr && abstract_path[0] != '\0', nullptr); | ||||
carla_debug("carla_lv2_state_map_absolute_path(%p, \"%s\")", handle, abstract_path); | carla_debug("carla_lv2_state_map_absolute_path(%p, \"%s\")", handle, abstract_path); | ||||
QDir dir(abstract_path); | |||||
return strdup(dir.absolutePath().toUtf8().constData()); | |||||
return strdup(File(abstract_path).getFullPathName().toRawUTF8()); | |||||
} | } | ||||
static LV2_State_Status carla_lv2_state_store(LV2_State_Handle handle, uint32_t key, const void* value, size_t size, uint32_t type, uint32_t flags) | static LV2_State_Status carla_lv2_state_store(LV2_State_Handle handle, uint32_t key, const void* value, size_t size, uint32_t type, uint32_t flags) | ||||
@@ -74,7 +74,7 @@ DssiPlugin.cpp.o: DssiPlugin.cpp $(DSSI_PLUGIN_CPP_DEPS) | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | ||||
Lv2Plugin.cpp.o: Lv2Plugin.cpp $(LV2_PLUGIN_CPP_DEPS) | Lv2Plugin.cpp.o: Lv2Plugin.cpp $(LV2_PLUGIN_CPP_DEPS) | ||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||||
VstPlugin.cpp.o: VstPlugin.cpp $(VST_PLUGIN_CPP_DEPS) | VstPlugin.cpp.o: VstPlugin.cpp $(VST_PLUGIN_CPP_DEPS) | ||||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | ||||
@@ -92,6 +92,6 @@ FluidSynthPlugin.cpp.o: FluidSynthPlugin.cpp $(FLUIDSYNTH_PLUGIN_CPP_DEPS) | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(FLUIDSYNTH_FLAGS) -c -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) $(FLUIDSYNTH_FLAGS) -c -o $@ | ||||
LinuxSamplerPlugin.cpp.o: LinuxSamplerPlugin.cpp $(LINUXSAMPLER_PLUGIN_CPP_DEPS) | LinuxSamplerPlugin.cpp.o: LinuxSamplerPlugin.cpp $(LINUXSAMPLER_PLUGIN_CPP_DEPS) | ||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINUXSAMPLER_FLAGS) $(QTCORE_FLAGS) -c -o $@ | |||||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINUXSAMPLER_FLAGS) -c -o $@ | |||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- |
@@ -13,9 +13,6 @@ BUILD_CXX_FLAGS += -I../backend -I../includes -I../utils -isystem ../modules | |||||
BUILD_CXX_FLAGS += -I../includes/ladspa -I../includes/vst -I../includes/vst3 | BUILD_CXX_FLAGS += -I../includes/ladspa -I../includes/vst -I../includes/vst3 | ||||
#-Wno-multichar | #-Wno-multichar | ||||
BUILD_CXX_FLAGS += $(QTCORE_FLAGS) | |||||
LINK_FLAGS += $(QTCORE_LIBS) | |||||
ifeq ($(MACOS),true) | ifeq ($(MACOS),true) | ||||
BUILD_CXX_FLAGS += -ObjC++ | BUILD_CXX_FLAGS += -ObjC++ | ||||
endif | endif | ||||
@@ -47,12 +47,10 @@ | |||||
#include <iostream> | #include <iostream> | ||||
#include "juce_audio_basics.h" | #include "juce_audio_basics.h" | ||||
using juce::File; | |||||
using juce::FloatVectorOperations; | using juce::FloatVectorOperations; | ||||
// FIXME | |||||
#include <QtCore/QDir> | |||||
#include <QtCore/QFileInfo> | |||||
#include <QtCore/QUrl> | |||||
using juce::String; | |||||
using juce::StringArray; | |||||
#define DISCOVERY_OUT(x, y) std::cout << "\ncarla-discovery::" << x << "::" << y << std::endl; | #define DISCOVERY_OUT(x, y) std::cout << "\ncarla-discovery::" << x << "::" << y << std::endl; | ||||
@@ -965,41 +963,43 @@ static void do_lv2_check(const char* const bundle, const bool init) | |||||
Lv2WorldClass& lv2World(Lv2WorldClass::getInstance()); | Lv2WorldClass& lv2World(Lv2WorldClass::getInstance()); | ||||
// Convert bundle filename to URI | // Convert bundle filename to URI | ||||
QString qBundle(QUrl::fromLocalFile(bundle).toString()); | |||||
if (! qBundle.endsWith(OS_SEP_STR)) | |||||
qBundle += OS_SEP_STR; | |||||
CarlaString sBundle("file://"); | |||||
sBundle += bundle; | |||||
if (! sBundle.endsWith(OS_SEP)) | |||||
sBundle += OS_SEP_STR; | |||||
// Load bundle | // Load bundle | ||||
lv2World.load_bundle(qBundle.toUtf8().constData()); | |||||
lv2World.load_bundle(sBundle); | |||||
// Load plugins in this bundle | // Load plugins in this bundle | ||||
const Lilv::Plugins lilvPlugins(lv2World.get_all_plugins()); | const Lilv::Plugins lilvPlugins(lv2World.get_all_plugins()); | ||||
// Get all plugin URIs in this bundle | // Get all plugin URIs in this bundle | ||||
QStringList URIs; | |||||
StringArray URIs; | |||||
LILV_FOREACH(plugins, it, lilvPlugins) | LILV_FOREACH(plugins, it, lilvPlugins) | ||||
{ | { | ||||
Lilv::Plugin lilvPlugin(lilv_plugins_get(lilvPlugins, it)); | Lilv::Plugin lilvPlugin(lilv_plugins_get(lilvPlugins, it)); | ||||
if (const char* const uri = lilvPlugin.get_uri().as_string()) | if (const char* const uri = lilvPlugin.get_uri().as_string()) | ||||
URIs.append(QString(uri)); | |||||
URIs.addIfNotAlreadyThere(String(uri)); | |||||
} | } | ||||
if (URIs.count() == 0) | |||||
if (URIs.size() == 0) | |||||
{ | { | ||||
DISCOVERY_OUT("warning", "LV2 Bundle doesn't provide any plugins"); | DISCOVERY_OUT("warning", "LV2 Bundle doesn't provide any plugins"); | ||||
return; | return; | ||||
} | } | ||||
// Get & check every plugin-instance | // Get & check every plugin-instance | ||||
for (int i=0, count=URIs.count(); i < count; ++i) | |||||
for (int i=0, count=URIs.size(); i < count; ++i) | |||||
{ | { | ||||
const LV2_RDF_Descriptor* const rdfDescriptor(lv2_rdf_new(URIs.at(i).toUtf8().constData(), false)); | |||||
const LV2_RDF_Descriptor* const rdfDescriptor(lv2_rdf_new(URIs[i].toRawUTF8(), false)); | |||||
if (rdfDescriptor == nullptr || rdfDescriptor->URI == nullptr) | if (rdfDescriptor == nullptr || rdfDescriptor->URI == nullptr) | ||||
{ | { | ||||
DISCOVERY_OUT("error", "Failed to find LV2 plugin '" << URIs.at(i).toUtf8().constData() << "'"); | |||||
DISCOVERY_OUT("error", "Failed to find LV2 plugin '" << URIs[i].toRawUTF8() << "'"); | |||||
continue; | continue; | ||||
} | } | ||||
@@ -1606,30 +1606,18 @@ static void do_fluidsynth_check(const char* const filename, const bool init) | |||||
static void do_linuxsampler_check(const char* const filename, const char* const stype, const bool init) | static void do_linuxsampler_check(const char* const filename, const char* const stype, const bool init) | ||||
{ | { | ||||
#ifdef WANT_LINUXSAMPLER | #ifdef WANT_LINUXSAMPLER | ||||
const QFileInfo file(filename); | |||||
if (! file.exists()) | |||||
{ | |||||
DISCOVERY_OUT("error", "Requested file does not exist"); | |||||
return; | |||||
} | |||||
const File file(filename); | |||||
if (! file.isFile()) | |||||
if (! file.existsAsFile()) | |||||
{ | { | ||||
DISCOVERY_OUT("error", "Requested file is not valid"); | |||||
return; | |||||
} | |||||
if (! file.isReadable()) | |||||
{ | |||||
DISCOVERY_OUT("error", "Requested file is not readable"); | |||||
DISCOVERY_OUT("error", "Requested file is not valid or does not exist"); | |||||
return; | return; | ||||
} | } | ||||
if (init) | if (init) | ||||
const LinuxSamplerScopedEngine engine(filename, stype); | const LinuxSamplerScopedEngine engine(filename, stype); | ||||
else | else | ||||
LinuxSamplerScopedEngine::outputInfo(nullptr, 0, file.baseName().toUtf8().constData()); | |||||
LinuxSamplerScopedEngine::outputInfo(nullptr, 0, file.getFileNameWithoutExtension().toRawUTF8()); | |||||
#else | #else | ||||
DISCOVERY_OUT("error", stype << " support not available"); | DISCOVERY_OUT("error", stype << " support not available"); | ||||
return; | return; | ||||
@@ -1640,28 +1628,6 @@ static void do_linuxsampler_check(const char* const filename, const char* const | |||||
#endif | #endif | ||||
} | } | ||||
// -------------------------------------------------------------------------- | |||||
class ScopedWorkingDirSet | |||||
{ | |||||
public: | |||||
ScopedWorkingDirSet(const char* const filename) | |||||
: fPreviousPath(QDir::currentPath()) | |||||
{ | |||||
QDir dir(filename); | |||||
dir.cdUp(); | |||||
QDir::setCurrent(dir.absolutePath()); | |||||
} | |||||
~ScopedWorkingDirSet() | |||||
{ | |||||
QDir::setCurrent(fPreviousPath); | |||||
} | |||||
private: | |||||
const QString fPreviousPath; | |||||
}; | |||||
// ------------------------------ main entry point ------------------------------ | // ------------------------------ main entry point ------------------------------ | ||||
int main(int argc, char* argv[]) | int main(int argc, char* argv[]) | ||||
@@ -1676,8 +1642,6 @@ int main(int argc, char* argv[]) | |||||
const char* const filename = argv[2]; | const char* const filename = argv[2]; | ||||
const PluginType type = getPluginTypeFromString(stype); | const PluginType type = getPluginTypeFromString(stype); | ||||
const ScopedWorkingDirSet swds(filename); | |||||
CarlaString filenameStr(filename); | CarlaString filenameStr(filename); | ||||
filenameStr.toLower(); | filenameStr.toLower(); | ||||
@@ -28,7 +28,7 @@ | |||||
#define NULL nullptr | #define NULL nullptr | ||||
#include "CarlaLadspaUtils.hpp" | #include "CarlaLadspaUtils.hpp" | ||||
#include "CarlaDssiUtils.hpp" | |||||
#include "CarlaDssiUtils.cpp" | |||||
#include "CarlaLv2Utils.hpp" | #include "CarlaLv2Utils.hpp" | ||||
#include "CarlaVstUtils.hpp" | #include "CarlaVstUtils.hpp" | ||||
@@ -55,38 +55,17 @@ static void test_CarlaLadspaUtils() | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
namespace dssi_juce { | |||||
const char* find_dssi_ui(const char* const filename, const char* const label) noexcept; | |||||
#define HAVE_JUCE | |||||
#include "CarlaDssiUtils.cpp" | |||||
} | |||||
namespace dssi_qt { | |||||
const char* find_dssi_ui(const char* const filename, const char* const label) noexcept; | |||||
#undef HAVE_JUCE | |||||
#include "CarlaDssiUtils.cpp" | |||||
} | |||||
static void test_CarlaDssiUtils() noexcept | static void test_CarlaDssiUtils() noexcept | ||||
{ | { | ||||
const char* const ui_juce = dssi_juce::find_dssi_ui("/usr/lib/dssi/trivial_sampler.so", "aa"); | |||||
const char* const ui_qt = dssi_qt::find_dssi_ui("/usr/lib/dssi/trivial_sampler.so", "aa"); | |||||
CARLA_SAFE_ASSERT(ui_juce != nullptr); | |||||
CARLA_SAFE_ASSERT(ui_qt != nullptr); | |||||
const char* const ui = find_dssi_ui("/usr/lib/dssi/trivial_sampler.so", "aa"); | |||||
if (ui_juce != nullptr) | |||||
{ | |||||
carla_stdout("%s", ui_juce); | |||||
assert(std::strcmp(ui_juce, "/usr/lib/dssi/trivial_sampler/trivial_sampler_qt") == 0); | |||||
delete[] ui_juce; | |||||
} | |||||
CARLA_SAFE_ASSERT(ui != nullptr); | |||||
if (ui_qt != nullptr) | |||||
if (ui != nullptr) | |||||
{ | { | ||||
carla_stdout("%s", ui_qt); | |||||
assert(std::strcmp(ui_qt, "/usr/lib/dssi/trivial_sampler/trivial_sampler_qt") == 0); | |||||
delete[] ui_qt; | |||||
carla_stdout("%s", ui); | |||||
assert(std::strcmp(ui, "/usr/lib/dssi/trivial_sampler/trivial_sampler_qt") == 0); | |||||
delete[] ui; | |||||
} | } | ||||
} | } | ||||
@@ -61,10 +61,10 @@ | |||||
#include "lilv/lilvmm.hpp" | #include "lilv/lilvmm.hpp" | ||||
#include "sratom/sratom.h" | #include "sratom/sratom.h" | ||||
#ifdef HAVE_JUCE | |||||
# include "juce_core.h" | |||||
#else | |||||
#ifdef USE_QT | |||||
# include <QtCore/QStringList> | # include <QtCore/QStringList> | ||||
#else | |||||
# include "juce_core.h" | |||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -576,17 +576,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool doInit) | |||||
if (replaceNode.is_uri()) | if (replaceNode.is_uri()) | ||||
{ | { | ||||
#ifdef HAVE_JUCE | |||||
const juce::String replaceURI(replaceNode.as_uri()); | |||||
if (replaceURI.startsWith("urn:")) | |||||
{ | |||||
const int uniqueId(replaceURI.getTrailingIntValue()); | |||||
if (uniqueId > 0) | |||||
rdfDescriptor->UniqueID = static_cast<ulong>(uniqueId); | |||||
} | |||||
#else | |||||
#ifdef USE_QT | |||||
const QString replaceURI(replaceNode.as_uri()); | const QString replaceURI(replaceNode.as_uri()); | ||||
if (replaceURI.startsWith("urn:")) | if (replaceURI.startsWith("urn:")) | ||||
@@ -599,6 +589,16 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool doInit) | |||||
if (ok && uniqueId != 0) | if (ok && uniqueId != 0) | ||||
rdfDescriptor->UniqueID = uniqueId; | rdfDescriptor->UniqueID = uniqueId; | ||||
} | } | ||||
#else | |||||
const juce::String replaceURI(replaceNode.as_uri()); | |||||
if (replaceURI.startsWith("urn:")) | |||||
{ | |||||
const int uniqueId(replaceURI.getTrailingIntValue()); | |||||
if (uniqueId > 0) | |||||
rdfDescriptor->UniqueID = static_cast<ulong>(uniqueId); | |||||
} | |||||
#endif | #endif | ||||
} | } | ||||
} | } | ||||
@@ -1088,38 +1088,38 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool doInit) | |||||
// create a list of preset URIs (for checking appliesTo, sorting and unique-ness) | // create a list of preset URIs (for checking appliesTo, sorting and unique-ness) | ||||
// FIXME - check appliesTo? | // FIXME - check appliesTo? | ||||
#ifdef HAVE_JUCE | |||||
juce::StringArray presetListURIs; | |||||
#ifdef USE_QT | |||||
QStringList presetListURIs; | |||||
LILV_FOREACH(nodes, it, presetNodes) | LILV_FOREACH(nodes, it, presetNodes) | ||||
{ | { | ||||
Lilv::Node presetNode(presetNodes.get(it)); | Lilv::Node presetNode(presetNodes.get(it)); | ||||
juce::String presetURI(presetNode.as_uri()); | |||||
QString presetURI(presetNode.as_uri()); | |||||
if (presetURI.trim().isNotEmpty()) | |||||
presetListURIs.addIfNotAlreadyThere(presetURI); | |||||
if (! (presetURI.trimmed().isEmpty() || presetListURIs.contains(presetURI))) | |||||
presetListURIs.append(presetURI); | |||||
} | } | ||||
presetListURIs.sortNatural(); | |||||
presetListURIs.sort(); | |||||
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size()); | |||||
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count()); | |||||
#else | #else | ||||
QStringList presetListURIs; | |||||
juce::StringArray presetListURIs; | |||||
LILV_FOREACH(nodes, it, presetNodes) | LILV_FOREACH(nodes, it, presetNodes) | ||||
{ | { | ||||
Lilv::Node presetNode(presetNodes.get(it)); | Lilv::Node presetNode(presetNodes.get(it)); | ||||
QString presetURI(presetNode.as_uri()); | |||||
juce::String presetURI(presetNode.as_uri()); | |||||
if (! (presetURI.trimmed().isEmpty() || presetListURIs.contains(presetURI))) | |||||
presetListURIs.append(presetURI); | |||||
if (presetURI.trim().isNotEmpty()) | |||||
presetListURIs.addIfNotAlreadyThere(presetURI); | |||||
} | } | ||||
presetListURIs.sort(); | |||||
presetListURIs.sortNatural(); | |||||
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count()); | |||||
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size()); | |||||
#endif | #endif | ||||
// create presets with unique URIs | // create presets with unique URIs | ||||
@@ -1135,10 +1135,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool doInit) | |||||
if (const char* const presetURI = presetNode.as_uri()) | if (const char* const presetURI = presetNode.as_uri()) | ||||
{ | { | ||||
#ifdef HAVE_JUCE | |||||
const int index(presetListURIs.indexOf(juce::String(presetURI))); | |||||
#else | |||||
#ifdef USE_QT | |||||
const int index(presetListURIs.indexOf(QString(presetURI))); | const int index(presetListURIs.indexOf(QString(presetURI))); | ||||
#else | |||||
const int index(presetListURIs.indexOf(juce::String(presetURI))); | |||||
#endif | #endif | ||||
CARLA_SAFE_ASSERT_CONTINUE(index >= 0); | CARLA_SAFE_ASSERT_CONTINUE(index >= 0); | ||||