From 53148852c03fc5a0a914cefda6f3850bd9aebdd0 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 20 Nov 2022 16:47:37 +0000 Subject: Implement custom State::fileTypes for MOD Signed-off-by: falkTX --- distrho/DistrhoPlugin.hpp | 21 +++++++++++++++++++++ distrho/src/DistrhoPluginInternal.hpp | 9 +++++++++ distrho/src/DistrhoPluginLV2export.cpp | 9 +++++++++ 3 files changed, 39 insertions(+) diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp index 02d2cda7..79b65a8c 100644 --- a/distrho/DistrhoPlugin.hpp +++ b/distrho/DistrhoPlugin.hpp @@ -763,6 +763,27 @@ struct State { */ String description; + #ifdef __MOD_DEVICES__ + /** + The file types that a filename path state supports, written as a comma-separated string without whitespace. + Currently supported file types are: + - audioloop: Audio Loops, meant to be used for looper-style plugins + - audiorecording: Audio Recordings, triggered by plugins and stored in the unit + - audiosample: One-shot Audio Samples, meant to be used for sampler-style plugins + - audiotrack: Audio Tracks, meant to be used as full-performance/song or backtrack + - cabsim: Speaker Cabinets, meant as small IR audio files + - h2drumkit: Hydrogen Drumkits, must use h2drumkit file extension + - ir: Impulse Responses + - midiclip: MIDI Clips, to be used in sync with host tempo, must have mid or midi file extension + - midisong: MIDI Songs, meant to be used as full-performance/song or backtrack + - sf2: SF2 Instruments, must have sf2 or sf3 file extension + - sfz: SFZ Instruments, must have sfz file extension + + @note This is a custom extension only valid in builds MOD Audio. + */ + String fileTypes; + #endif + /** Default constructor for a null state. */ diff --git a/distrho/src/DistrhoPluginInternal.hpp b/distrho/src/DistrhoPluginInternal.hpp index 30b31355..413654d7 100644 --- a/distrho/src/DistrhoPluginInternal.hpp +++ b/distrho/src/DistrhoPluginInternal.hpp @@ -859,6 +859,15 @@ public: return fData->states[index].description; } + #ifdef __MOD_DEVICES__ + const String& getStateFileTypes(const uint32_t index) const noexcept + { + DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->stateCount, sFallbackString); + + return fData->states[index].fileTypes; + } + #endif + # if DISTRHO_PLUGIN_WANT_FULL_STATE String getStateValue(const char* const key) const { diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp index 24d9e229..8b93e7c7 100644 --- a/distrho/src/DistrhoPluginLV2export.cpp +++ b/distrho/src/DistrhoPluginLV2export.cpp @@ -393,9 +393,18 @@ void lv2_generate_ttl(const char* const basename) } if ((hints & kStateIsFilenamePath) == kStateIsFilenamePath) + { + #ifdef __MOD_DEVICES__ + const String& fileTypes(plugin.getStateFileTypes(i)); + if (fileTypes.isNotEmpty()) + pluginString += " mod:fileTypes \"" + fileTypes + "\" ; \n"; + #endif pluginString += " rdfs:range atom:Path .\n\n"; + } else + { pluginString += " rdfs:range atom:String .\n\n"; + } hasHostVisibleState = true; } -- cgit v1.2.3