Browse Source

Very crude SFZ lookup

tags/v1.9.11
falkTX 6 years ago
parent
commit
b6790c5dd3
2 changed files with 76 additions and 6 deletions
  1. +61
    -5
      source/backend/utils/CachedPlugins.cpp
  2. +15
    -1
      source/discovery/carla-discovery.cpp

+ 61
- 5
source/backend/utils/CachedPlugins.cpp View File

@@ -21,8 +21,16 @@
#include "CarlaString.hpp" #include "CarlaString.hpp"
#include "CarlaLv2Utils.hpp" #include "CarlaLv2Utils.hpp"


#include "water/containers/Array.h"
#include "water/files/File.h"

namespace CB = CarlaBackend; namespace CB = CarlaBackend;


using water::Array;
using water::File;
using water::String;
using water::StringArray;

static const char* const gNullCharPtr = ""; static const char* const gNullCharPtr = "";


static bool isCachedPluginType(const CB::PluginType ptype) static bool isCachedPluginType(const CB::PluginType ptype)
@@ -32,9 +40,9 @@ static bool isCachedPluginType(const CB::PluginType ptype)
case CB::PLUGIN_INTERNAL: case CB::PLUGIN_INTERNAL:
case CB::PLUGIN_LV2: case CB::PLUGIN_LV2:
case CB::PLUGIN_SFZ: case CB::PLUGIN_SFZ:
return false;
default:
return true; return true;
default:
return false;
} }
} }


@@ -57,6 +65,31 @@ _CarlaCachedPluginInfo::_CarlaCachedPluginInfo() noexcept


// ------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------


static Array<File> gSFZs;

void findSFZsIfNeeded(const char* const sfzPaths)
{
CARLA_SAFE_ASSERT_RETURN(sfzPaths != nullptr && sfzPaths[0] != '\0',);

static bool needsInit = true;

if (! needsInit)
return;
needsInit = false;

const StringArray splitPaths(StringArray::fromTokens(sfzPaths, CARLA_OS_SPLIT_STR, ""));

for (String path : splitPaths)
{
Array<File> results;

if (File(path).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, "*.sfz") > 0)
gSFZs.addArray(results);
}
}

// -------------------------------------------------------------------------------------------------------------------

const CarlaCachedPluginInfo* get_cached_plugin_internal(const NativePluginDescriptor& desc) const CarlaCachedPluginInfo* get_cached_plugin_internal(const NativePluginDescriptor& desc)
{ {
static CarlaCachedPluginInfo info; static CarlaCachedPluginInfo info;
@@ -430,9 +463,30 @@ const CarlaCachedPluginInfo* get_cached_plugin_lv2(Lv2WorldClass& lv2World, Lilv
return &info; return &info;
} }


const CarlaCachedPluginInfo* get_cached_plugin_sfz()
const CarlaCachedPluginInfo* get_cached_plugin_sfz(const File file)
{ {
static CarlaCachedPluginInfo info; static CarlaCachedPluginInfo info;

static CarlaString name;
name = file.getFileNameWithoutExtension().toRawUTF8();
name.replace('_',' ');

info.category = CB::PLUGIN_CATEGORY_SYNTH;
info.hints = CB::PLUGIN_IS_SYNTH;
// CB::PLUGIN_IS_RTSAFE

info.valid = true;
info.audioIns = 0;
info.audioOuts = 2;
info.midiIns = 1;
info.midiOuts = 0;
info.parameterIns = 0;
info.parameterOuts = 1;

info.name = name.buffer();
info.label = name.buffer();
info.maker = "";
info.copyright = "";
return &info; return &info;
} }


@@ -458,7 +512,8 @@ uint carla_get_cached_plugin_count(CB::PluginType ptype, const char* pluginPath)
} }


case CB::PLUGIN_SFZ: { case CB::PLUGIN_SFZ: {
return 0;
findSFZsIfNeeded(pluginPath);
return gSFZs.size();
} }


default: default:
@@ -495,7 +550,8 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(CB::PluginType ptype,
} }


case CB::PLUGIN_SFZ: { case CB::PLUGIN_SFZ: {
return get_cached_plugin_sfz();
CARLA_SAFE_ASSERT_BREAK(index < static_cast<uint>(gSFZs.size()));
return get_cached_plugin_sfz(gSFZs.getUnchecked(index));
} }


default: default:


+ 15
- 1
source/discovery/carla-discovery.cpp View File

@@ -291,7 +291,21 @@ static void print_cached_plugin(const CarlaCachedPluginInfo* const pinfo)


static void do_cached_check(const PluginType type) static void do_cached_check(const PluginType type)
{ {
const char* const plugPath = (type == PLUGIN_LV2) ? std::getenv("LV2_PATH") : nullptr;
const char* plugPath;

switch (type)
{
case PLUGIN_LV2:
plugPath = std::getenv("LV2_PATH");
break;
case PLUGIN_SFZ:
plugPath = std::getenv("SFZ_PATH");
break;
default:
plugPath = nullptr;
break;
}

const uint count = carla_get_cached_plugin_count(type, plugPath); const uint count = carla_get_cached_plugin_count(type, plugPath);


for (uint i=0; i<count; ++i) for (uint i=0; i<count; ++i)


Loading…
Cancel
Save