-
Notifications
You must be signed in to change notification settings - Fork 20
Revamp audio plugins module #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
63109fe
f1e01ae
a5b4eba
c5a54f2
5399fa9
32a8f6b
56ee120
6545c05
49d9f80
58f39b9
41fd89a
ac51df2
d4e0757
740f203
0df36f2
12e0d3d
8e2fc72
5c8c00a
785f073
f306a44
c231431
61c6f54
36ddee8
cf7a324
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,8 @@ | |
|
|
||
| #include "mpe/events.h" | ||
|
|
||
| #include "audioplugins/audiopluginstypes.h" | ||
|
|
||
| #include "log.h" | ||
|
|
||
| namespace muse::audio { | ||
|
|
@@ -167,86 +169,91 @@ struct AudioEngineConfig { | |
| }; | ||
|
|
||
| using AudioSourceName = std::string; | ||
| using AudioResourceId = std::string; | ||
| using AudioResourceIdList = std::vector<AudioResourceId>; | ||
| using AudioResourceVendor = std::string; | ||
| using AudioResourceAttributes = std::map<String, String>; | ||
| using AudioUnitConfig = std::map<std::string, std::string>; | ||
|
|
||
| static const String PLAYBACK_SETUP_DATA_ATTRIBUTE(u"playbackSetupData"); | ||
| static const String CATEGORIES_ATTRIBUTE(u"categories"); | ||
|
|
||
| using AudioResourceId = muse::audioplugins::AudioResourceId; | ||
| using AudioResourceIdList = muse::audioplugins::AudioResourceIdList; | ||
| using AudioResourceVendor = muse::audioplugins::AudioResourceVendor; | ||
| using AudioResourceAttributes = muse::audioplugins::AudioResourceAttributes; | ||
| using AudioResourceMeta = muse::audioplugins::AudioResourceMeta; | ||
| using AudioResourceMetaList = muse::audioplugins::AudioResourceMetaList; | ||
| using AudioResourceMetaSet = muse::audioplugins::AudioResourceMetaSet; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should simply break the connection between audio and audioplugins Maybe it makes sense to rename audioplugins to something else, like userplugins So, as it was:
Audio plugins must have their own types, and we need to convert one type to another
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think right now it would be enough to do something like this:
i.e. make it one to one This may look strange now, but in essence this is exactly what we need Then we can continue to:
|
||
|
|
||
| // Wire-format identifiers for the formats the muse audio engine dispatches | ||
| // directly. The strings here are the canonical names persisted in the JSON | ||
| // plugin cache. VST and MuseSampler also own their own per-module copies of | ||
| // the matching string in their respective public headers; a round-trip test | ||
| // in muse_audio_tests asserts they stay in sync. | ||
| // | ||
| // constexpr std::string_view (not inline std::string) so that the values are | ||
| // available at compile time and don't participate in static initialization | ||
| // order — the RESOURCE_TYPE_NAMES map below depends on them. | ||
| inline constexpr std::string_view FLUID_SOUNDFONT_TYPE_NAME = "FluidSoundfont"; | ||
| inline constexpr std::string_view NATIVE_EFFECT_TYPE_NAME = "NativeEffect"; | ||
|
|
||
| // audio::AudioResourceType is an audio-engine-internal enum used to dispatch | ||
| // synth/fx routing. It is intentionally kept separate from the framework's | ||
| // opaque audioplugins::AudioResourceType (a std::string identifier persisted | ||
| // by the audioplugins module). Map between them at the boundary via | ||
| // resourceTypeFromString() / resourceTypeName(). The enum lists only the | ||
| // formats the audio engine actually routes; apps with broader plugin support | ||
| // (e.g. Audacity's LV2/AU/Nyquist) define their own enum and bridge. | ||
| enum class AudioResourceType { | ||
| Undefined = -1, | ||
| FluidSoundfont, | ||
| VstPlugin, | ||
| NativeEffect, | ||
| MuseSamplerSoundPack, | ||
| Lv2Plugin, | ||
| AudioUnit, | ||
| NyquistPlugin, | ||
| }; | ||
|
|
||
| static const std::map<AudioResourceType, QString> RESOURCE_TYPE_MAP = { | ||
| { AudioResourceType::Undefined, "undefined" }, | ||
| { AudioResourceType::MuseSamplerSoundPack, "muse_sampler_sound_pack" }, | ||
| { AudioResourceType::FluidSoundfont, "fluid_soundfont" }, | ||
| { AudioResourceType::VstPlugin, "vst_plugin" }, | ||
| { AudioResourceType::NativeEffect, "muse_plugin" }, | ||
| { AudioResourceType::Lv2Plugin, "lv2_plugin" }, | ||
| { AudioResourceType::AudioUnit, "audio_unit" }, | ||
| { AudioResourceType::NyquistPlugin, "nyquist_plugin" }, | ||
| static const std::map<AudioResourceType, std::string> RESOURCE_TYPE_NAMES = { | ||
| { AudioResourceType::FluidSoundfont, std::string(FLUID_SOUNDFONT_TYPE_NAME) }, | ||
| { AudioResourceType::VstPlugin, "VstPlugin" }, | ||
| { AudioResourceType::NativeEffect, std::string(NATIVE_EFFECT_TYPE_NAME) }, | ||
| { AudioResourceType::MuseSamplerSoundPack, "MuseSamplerSoundPack" }, | ||
| }; | ||
|
|
||
| struct AudioResourceMeta { | ||
| AudioResourceId id; | ||
| AudioResourceVendor vendor; | ||
| AudioResourceAttributes attributes; | ||
| AudioResourceType type = AudioResourceType::Undefined; | ||
| bool hasNativeEditorSupport = false; | ||
| inline const std::string& resourceTypeName(AudioResourceType type) | ||
| { | ||
| auto it = RESOURCE_TYPE_NAMES.find(type); | ||
| if (it != RESOURCE_TYPE_NAMES.end()) { | ||
| return it->second; | ||
| } | ||
| static const std::string empty; | ||
| return empty; | ||
| } | ||
|
|
||
| const String& attributeVal(const String& key) const | ||
| { | ||
| auto search = attributes.find(key); | ||
| if (search != attributes.cend()) { | ||
| return search->second; | ||
| inline AudioResourceType resourceTypeFromString(const std::string& name) | ||
| { | ||
| for (const auto& kv : RESOURCE_TYPE_NAMES) { | ||
| if (kv.second == name) { | ||
| return kv.first; | ||
| } | ||
|
|
||
| static String empty; | ||
| return empty; | ||
| } | ||
| return AudioResourceType::Undefined; | ||
| } | ||
|
|
||
| bool isValid() const | ||
| { | ||
| return !id.empty() | ||
| && !vendor.empty() | ||
| && type != AudioResourceType::Undefined; | ||
| } | ||
| inline bool isResourceType(const AudioResourceMeta& meta, AudioResourceType type) | ||
| { | ||
| return resourceTypeFromString(meta.type) == type; | ||
| } | ||
|
|
||
| bool operator==(const AudioResourceMeta& other) const | ||
| { | ||
| return id == other.id | ||
| && vendor == other.vendor | ||
| && type == other.type | ||
| && hasNativeEditorSupport == other.hasNativeEditorSupport | ||
| && attributes == other.attributes; | ||
| } | ||
| static const String PLAYBACK_SETUP_DATA_ATTRIBUTE(u"playbackSetupData"); | ||
| static const String HAS_NATIVE_EDITOR_SUPPORT_ATTRIBUTE(u"hasNativeEditorSupport"); | ||
|
|
||
| bool operator!=(const AudioResourceMeta& other) const | ||
| { | ||
| return !(*this == other); | ||
| } | ||
| inline bool hasNativeEditorSupport(const AudioResourceMeta& meta) | ||
| { | ||
| return muse::audioplugins::boolAttribute(meta, HAS_NATIVE_EDITOR_SUPPORT_ATTRIBUTE); | ||
| } | ||
|
|
||
| bool operator<(const AudioResourceMeta& other) const | ||
| { | ||
| return id < other.id | ||
| || vendor < other.vendor; | ||
| } | ||
| static const std::map<AudioResourceType, QString> RESOURCE_TYPE_MAP = { | ||
| { AudioResourceType::Undefined, "undefined" }, | ||
| { AudioResourceType::MuseSamplerSoundPack, "muse_sampler_sound_pack" }, | ||
| { AudioResourceType::FluidSoundfont, "fluid_soundfont" }, | ||
| { AudioResourceType::VstPlugin, "vst_plugin" }, | ||
| { AudioResourceType::NativeEffect, "muse_plugin" }, | ||
| }; | ||
|
|
||
| using AudioResourceMetaList = std::vector<AudioResourceMeta>; | ||
| using AudioResourceMetaSet = std::set<AudioResourceMeta>; | ||
|
|
||
| static const AudioResourceId MUSE_REVERB_ID("Muse Reverb"); | ||
|
|
||
| enum class AudioFxType { | ||
|
|
@@ -304,14 +311,11 @@ struct AudioFxParams { | |
|
|
||
| AudioFxType type() const | ||
| { | ||
| switch (resourceMeta.type) { | ||
| switch (resourceTypeFromString(resourceMeta.type)) { | ||
| case AudioResourceType::VstPlugin: return AudioFxType::VstFx; | ||
| case AudioResourceType::NativeEffect: return AudioFxType::MuseFx; | ||
| case AudioResourceType::AudioUnit: | ||
| case AudioResourceType::Lv2Plugin: | ||
| case AudioResourceType::FluidSoundfont: | ||
| case AudioResourceType::MuseSamplerSoundPack: | ||
| case AudioResourceType::NyquistPlugin: | ||
| case AudioResourceType::Undefined: break; | ||
| } | ||
|
|
||
|
|
@@ -383,16 +387,13 @@ enum class AudioSourceType { | |
| MuseSampler | ||
| }; | ||
|
|
||
| inline AudioSourceType sourceTypeFromResourceType(AudioResourceType type) | ||
| inline AudioSourceType sourceTypeFromResourceType(const muse::audioplugins::AudioResourceType& metaType) | ||
| { | ||
| switch (type) { | ||
| switch (resourceTypeFromString(metaType)) { | ||
| case AudioResourceType::FluidSoundfont: return AudioSourceType::Fluid; | ||
| case AudioResourceType::VstPlugin: return AudioSourceType::Vsti; | ||
| case AudioResourceType::MuseSamplerSoundPack: return AudioSourceType::MuseSampler; | ||
| case AudioResourceType::AudioUnit: | ||
| case AudioResourceType::Lv2Plugin: | ||
| case AudioResourceType::NativeEffect: | ||
| case AudioResourceType::NyquistPlugin: | ||
| case AudioResourceType::Undefined: break; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain the purpose of this change? Not only does it create circular dependencies between the modules, but it also looks conceptually incorrect. AudioResource can be anything (soundfont, MuseSounds, etc.), not only audio plugins