-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
168b876
commit 9336043
Showing
11 changed files
with
212 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule chowdsp_utils
updated
9 files
Submodule clap-juce-extensions
updated
16 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#if HAS_CLAP_JUCE_EXTENSIONS | ||
|
||
#include "PresetDiscovery.h" | ||
#include "PresetManager.h" | ||
|
||
namespace state::presets::discovery | ||
{ | ||
static constexpr clap_plugin_id plugin_id { | ||
.abi = "clap", | ||
.id = CHOWMULTITOOL_CLAP_ID, | ||
}; | ||
|
||
static auto getUserPresetsFolder() | ||
{ | ||
chowdsp::SharedPluginSettings pluginSettings; | ||
pluginSettings->initialise (settingsFilePath, 0); | ||
|
||
static constexpr auto propertyID = chowdsp::presets::frontend::SettingsInterface::userPresetsDirID; | ||
if (! pluginSettings->hasProperty (propertyID)) | ||
return juce::File {}; | ||
|
||
const auto userPresetsPath = pluginSettings->getProperty<juce::String> (propertyID); | ||
return juce::File { userPresetsPath }; | ||
} | ||
|
||
//============================================================================== | ||
struct FactoryPresetsProvider : chowdsp::presets::discovery::EmbeddedPresetsProvider | ||
{ | ||
static constexpr clap_preset_discovery_provider_descriptor descriptor { | ||
.clap_version = CLAP_VERSION_INIT, | ||
.id = "org.chowdsp.ChowMultiTool.factory-presets", | ||
.name = "ChowMultiTool Factory Presets Provider", | ||
.vendor = "ChowDSP" | ||
}; | ||
|
||
static constexpr clap_preset_discovery_location factoryPresetsLocation { | ||
.flags = CLAP_PRESET_DISCOVERY_IS_FACTORY_CONTENT, | ||
.name = "ChowMultiTool Factory Presets Location", | ||
.kind = CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN, | ||
.location = nullptr, | ||
}; | ||
|
||
explicit FactoryPresetsProvider (const clap_preset_discovery_indexer* indexer) | ||
: EmbeddedPresetsProvider (plugin_id, descriptor, factoryPresetsLocation, indexer) | ||
{ | ||
} | ||
|
||
std::vector<chowdsp::presets::Preset> getPresets() override | ||
{ | ||
return PresetManager::getFactoryPresets(); | ||
} | ||
}; | ||
|
||
//============================================================================== | ||
struct UserPresetsProvider : chowdsp::presets::discovery::FilePresetsProvider | ||
{ | ||
static constexpr clap_preset_discovery_provider_descriptor descriptor { | ||
.clap_version = CLAP_VERSION_INIT, | ||
.id = "org.chowdsp.ChowMultiTool.user-presets", | ||
.name = "ChowMultiTool User Presets Provider", | ||
.vendor = "User" | ||
}; | ||
|
||
|
||
static constexpr clap_preset_discovery_filetype filetype { | ||
.name = "User Preset Filetype", | ||
.description = "User preset filetype for ChowMultiTool", | ||
.file_extension = "chowpreset", | ||
}; | ||
|
||
explicit UserPresetsProvider (const clap_preset_discovery_indexer* indexer) | ||
: FilePresetsProvider (plugin_id, descriptor, filetype, indexer) | ||
{ | ||
} | ||
|
||
bool fillInLocation(clap_preset_discovery_location& location) override | ||
{ | ||
const auto userPresetsFolder = getUserPresetsFolder(); | ||
if (userPresetsFolder == juce::File {} || ! userPresetsFolder.isDirectory()) | ||
return false; | ||
|
||
location.name = "ChowMultiTool User Presets Location"; | ||
location.location = userPresetsFolder.getFullPathName().toRawUTF8(); | ||
return true; | ||
} | ||
}; | ||
|
||
//============================================================================== | ||
uint32_t count (const clap_preset_discovery_factory*) | ||
{ | ||
const auto userPresetsFolder = getUserPresetsFolder(); | ||
if (userPresetsFolder == juce::File {} || ! userPresetsFolder.isDirectory()) | ||
return 1; | ||
return 2; | ||
} | ||
|
||
const clap_preset_discovery_provider_descriptor_t* get_descriptor ( | ||
const clap_preset_discovery_factory*, | ||
uint32_t index) | ||
{ | ||
if (index == 0) | ||
return &FactoryPresetsProvider::descriptor; | ||
|
||
if (index == 1) | ||
return &UserPresetsProvider::descriptor; | ||
|
||
return nullptr; | ||
} | ||
|
||
const clap_preset_discovery_provider_t* create ( | ||
const clap_preset_discovery_factory*, | ||
const clap_preset_discovery_indexer_t* indexer, | ||
const char* provider_id) | ||
{ | ||
if (strcmp (provider_id, FactoryPresetsProvider::descriptor.id) == 0) | ||
{ | ||
auto* provider = new FactoryPresetsProvider { indexer }; | ||
return provider->provider(); | ||
} | ||
|
||
if (strcmp (provider_id, UserPresetsProvider::descriptor.id) == 0) | ||
{ | ||
auto* provider = new UserPresetsProvider { indexer }; | ||
return provider->provider(); | ||
} | ||
|
||
return nullptr; | ||
} | ||
} // namespace state::presets::discovery | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <pch.h> | ||
|
||
namespace state::presets::discovery | ||
{ | ||
uint32_t count (const clap_preset_discovery_factory* factory); | ||
|
||
const clap_preset_discovery_provider_descriptor_t* get_descriptor ( | ||
const clap_preset_discovery_factory* factory, | ||
uint32_t index); | ||
|
||
const clap_preset_discovery_provider_t* create ( | ||
const clap_preset_discovery_factory* factory, | ||
const clap_preset_discovery_indexer_t* indexer, | ||
const char* provider_id); | ||
} // namespace state::presets::discovery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters