From 50ccb7e0f4447d66e61883bcd6b2f147de03f7a2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 29 Jan 2019 10:21:40 +0100 Subject: Dynamic AU res id based on plugin unique id Signed-off-by: falkTX --- distrho/DistrhoPlugin.hpp | 2 +- distrho/src/DistrhoPluginAUexport.cpp | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp index 1da2bdb6..9eecce6c 100644 --- a/distrho/DistrhoPlugin.hpp +++ b/distrho/DistrhoPlugin.hpp @@ -771,7 +771,7 @@ protected: /** Get the plugin unique Id.@n - This value is used by LADSPA, DSSI and VST plugin formats. + This value is used by LADSPA, DSSI, VST and AU plugin formats. @see d_cconst() */ virtual int64_t getUniqueId() const = 0; diff --git a/distrho/src/DistrhoPluginAUexport.cpp b/distrho/src/DistrhoPluginAUexport.cpp index 2c1f749f..e60f1ba1 100644 --- a/distrho/src/DistrhoPluginAUexport.cpp +++ b/distrho/src/DistrhoPluginAUexport.cpp @@ -21,7 +21,7 @@ // ----------------------------------------------------------------------- -void au_generate_r(const char* const basename) +int au_generate_r(const char* const basename) { USE_NAMESPACE_DISTRHO @@ -72,6 +72,23 @@ void au_generate_r(const char* const basename) rFile << "#define DISTRHO_PLUGIN_DESCRIPTION \"" + description + "\"\n"; } + // res id + if (const int64_t uniqueId = plugin.getUniqueId()) + { + if (uniqueId < 0) + { + d_stderr2("AU plugin Id cannot be negative"); + return 1; + } + if (uniqueId >= UINT32_MAX) + { + d_stderr2("AU plugin Id cannot be higher than uint32"); + return 1; + } + + rFile << "#define DISTRHO_PLUGIN_AU_RES_ID \"" + String(uniqueId) + "\"\n"; + } + #ifndef DEBUG // version { @@ -88,6 +105,8 @@ void au_generate_r(const char* const basename) rFile.close(); std::cout << " done!" << std::endl; + + return 0; } // ----------------------------------------------------------------------- @@ -100,8 +119,7 @@ int main(int argc, char* argv[]) return 1; } - au_generate_r(argv[1]); - return 0; + return au_generate_r(argv[1]); } // ----------------------------------------------------------------------- -- cgit v1.2.3 From 3176b34ebedc15d74ca8fd5537e318aff8874697 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Tue, 29 Jan 2019 21:14:01 +1000 Subject: Au fixes4 (#121) * Update sample rate from AU * Fix resid, it is uint16 and not a string --- distrho/src/DistrhoPluginAU.cpp | 9 +++++++++ distrho/src/DistrhoPluginAUexport.cpp | 7 +++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/distrho/src/DistrhoPluginAU.cpp b/distrho/src/DistrhoPluginAU.cpp index 9fad0e75..d18e1eb4 100644 --- a/distrho/src/DistrhoPluginAU.cpp +++ b/distrho/src/DistrhoPluginAU.cpp @@ -221,6 +221,8 @@ protected: destBuffer[i] = (float *)outBuffer.mBuffers[i].mData; } + updateSampleRate(); + updateParameterInputs(); fPlugin.run(srcBuffer, destBuffer, inFramesToProcess); @@ -241,6 +243,8 @@ protected: if ((err = AUEffectBase::Initialize()) != noErr) return err; + updateSampleRate(); + fPlugin.activate(); // FIXME this does not seem right @@ -312,6 +316,11 @@ private: } } + void updateSampleRate() + { + d_lastSampleRate = GetSampleRate(); + } + DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginAU) }; diff --git a/distrho/src/DistrhoPluginAUexport.cpp b/distrho/src/DistrhoPluginAUexport.cpp index e60f1ba1..1b2d0cd0 100644 --- a/distrho/src/DistrhoPluginAUexport.cpp +++ b/distrho/src/DistrhoPluginAUexport.cpp @@ -80,13 +80,12 @@ int au_generate_r(const char* const basename) d_stderr2("AU plugin Id cannot be negative"); return 1; } - if (uniqueId >= UINT32_MAX) + if (uniqueId >= UINT16_MAX) { - d_stderr2("AU plugin Id cannot be higher than uint32"); - return 1; + d_stderr2("AU plugin Id cannot be higher than uint16"); } - rFile << "#define DISTRHO_PLUGIN_AU_RES_ID \"" + String(uniqueId) + "\"\n"; + rFile << "#define DISTRHO_PLUGIN_AU_RES_ID " + String(uniqueId % UINT16_MAX) + "\n"; } #ifndef DEBUG -- cgit v1.2.3