From 7e990e8a5ab6bddf1541dba6b0e02e1703eb9bd9 Mon Sep 17 00:00:00 2001 From: waxfrenzy Date: Sun, 10 Nov 2002 20:10:13 +0000 Subject: [PATCH] Now uses LADSPA default hints if specified --- .../Plugins/LADSPAPlugin/LADSPAPlugin.C | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/SpiralSound/Plugins/LADSPAPlugin/LADSPAPlugin.C b/SpiralSound/Plugins/LADSPAPlugin/LADSPAPlugin.C index 41e12cb..a966a82 100644 --- a/SpiralSound/Plugins/LADSPAPlugin/LADSPAPlugin.C +++ b/SpiralSound/Plugins/LADSPAPlugin/LADSPAPlugin.C @@ -18,6 +18,7 @@ #include #include #include +#include #include "SpiralIcon.xpm" #include "LADSPAPlugin.h" @@ -545,7 +546,7 @@ bool LADSPAPlugin::UpdatePlugin(unsigned long UniqueID, bool PortClampReset) for (int n=0; nPortRangeHints[Port].LowerBound; + } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(HintDesc) && + LADSPA_IS_HINT_BOUNDED_ABOVE(HintDesc)) { + Default=PlugDesc->PortRangeHints[Port].LowerBound; + } else if (LADSPA_IS_HINT_BOUNDED_BELOW(HintDesc) && + LADSPA_IS_HINT_BOUNDED_ABOVE(HintDesc)) { + // These hints require both upper and lower bounds + float lp = 0.0f, up = 0.0f; + float min = PlugDesc->PortRangeHints[Port].LowerBound; + float max = PlugDesc->PortRangeHints[Port].UpperBound; + if (LADSPA_IS_HINT_DEFAULT_LOW(HintDesc)) { + lp = 0.75f; + up = 0.25f; + } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(HintDesc)) { + lp = 0.5f; + up = 0.5f; + } else if (LADSPA_IS_HINT_DEFAULT_HIGH(HintDesc)) { + lp = 0.25f; + up = 0.75f; + } + + if (LADSPA_IS_HINT_LOGARITHMIC(HintDesc)) { + Default = exp(log(min) * lp + log(max) * up); + } else { + Default = min * lp + max * up; + } + } + if (LADSPA_IS_HINT_SAMPLE_RATE(HintDesc)) { + Default *= m_HostInfo->SAMPLERATE; + } + if (LADSPA_IS_HINT_INTEGER(HintDesc)) { + Default = floorf(Default); + } + } + } #else +// No LADSPA_VERSION - implies no defaults #warning ************************************ #warning Your LADSPA header is out of date! #warning Please get the latest sdk from @@ -582,7 +630,7 @@ bool LADSPAPlugin::UpdatePlugin(unsigned long UniqueID, bool PortClampReset) m_PortMin.push_back(Min); m_PortMax.push_back(Max); m_PortClamp.push_back(true); - m_PortDefault.push_back(defolt); + m_PortDefault.push_back(Default); } }