Audacity 3.2.0
Functions
anonymous_namespace{LadspaEffectBase.cpp} Namespace Reference

Functions

std::pair< float, float > InputControlPortBounds (const LADSPA_PortRangeHint &hint, double sampleRate)
 
float ClampInputControlValue (const LADSPA_PortRangeHint &hint, float val, float lower, float upper)
 
float InputControlPortDefaultValue (const LADSPA_PortRangeHint &hint, double sampleRate)
 

Function Documentation

◆ ClampInputControlValue()

float anonymous_namespace{LadspaEffectBase.cpp}::ClampInputControlValue ( const LADSPA_PortRangeHint hint,
float  val,
float  lower,
float  upper 
)

Definition at line 173 of file LadspaEffectBase.cpp.

175{
176 if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) && val < lower)
177 val = lower;
178 if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) && val > upper)
179 val = upper;
180 return val;
181}
#define LADSPA_IS_HINT_BOUNDED_BELOW(x)
Definition: ladspa.h:310
#define LADSPA_IS_HINT_BOUNDED_ABOVE(x)
Definition: ladspa.h:311
LADSPA_PortRangeHintDescriptor HintDescriptor
Definition: ladspa.h:340

References _LADSPA_PortRangeHint::HintDescriptor, LADSPA_IS_HINT_BOUNDED_ABOVE, and LADSPA_IS_HINT_BOUNDED_BELOW.

Referenced by InputControlPortDefaultValue().

Here is the caller graph for this function:

◆ InputControlPortBounds()

std::pair< float, float > anonymous_namespace{LadspaEffectBase.cpp}::InputControlPortBounds ( const LADSPA_PortRangeHint hint,
double  sampleRate 
)

Definition at line 166 of file LadspaEffectBase.cpp.

167{
168 // Find lower and upper bound values for ths hint
169 const auto multiplier =
171 return { hint.LowerBound * multiplier, hint.UpperBound * multiplier };
172}
#define LADSPA_IS_HINT_SAMPLE_RATE(x)
Definition: ladspa.h:313
LADSPA_Data LowerBound
Definition: ladspa.h:345
LADSPA_Data UpperBound
Definition: ladspa.h:350

References _LADSPA_PortRangeHint::HintDescriptor, LADSPA_IS_HINT_SAMPLE_RATE, _LADSPA_PortRangeHint::LowerBound, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and _LADSPA_PortRangeHint::UpperBound.

Referenced by InputControlPortDefaultValue().

Here is the caller graph for this function:

◆ InputControlPortDefaultValue()

float anonymous_namespace{LadspaEffectBase.cpp}::InputControlPortDefaultValue ( const LADSPA_PortRangeHint hint,
double  sampleRate 
)

Definition at line 182 of file LadspaEffectBase.cpp.

184{
185 // See comments in library header ladspa.h about interpretation of macros
186 const auto bounds = InputControlPortBounds(hint, sampleRate);
187
188 // Function to find low, middle, or high default values
189 const auto combine = [bounds,
191 ](float lowWeight, float highWeight){
192 auto [lower, upper] = bounds;
193 return logarithmic
194 ? exp(log(lower) * lowWeight + log(upper) * highWeight)
195 : lower * lowWeight + upper * highWeight;
196 };
197
198 auto [lower, upper] = bounds;
199 auto val = 1.0f;
200 // Four bits of the descriptor describe mutually exclusive cases
203 default:
204 break;
206 val = lower; break;
208 val = combine(0.75, 0.25); break;
210 val = combine(0.5, 0.5); break;
212 val = combine(0.25, 0.75); break;
214 val = upper; break;
216 val = 0.0f; break;
218 val = 1.0f; break;
220 val = 100.0f; break;
222 val = 440.0f; break;
223 }
224
225 return ClampInputControlValue(hint, val, lower, upper);
226}
#define LADSPA_HINT_DEFAULT_100
Definition: ladspa.h:303
#define LADSPA_HINT_DEFAULT_MAXIMUM
Definition: ladspa.h:290
#define LADSPA_HINT_DEFAULT_440
Definition: ladspa.h:308
#define LADSPA_HINT_DEFAULT_LOW
Definition: ladspa.h:272
#define LADSPA_HINT_DEFAULT_0
Definition: ladspa.h:295
#define LADSPA_IS_HINT_LOGARITHMIC(x)
Definition: ladspa.h:314
#define LADSPA_HINT_DEFAULT_HIGH
Definition: ladspa.h:286
#define LADSPA_HINT_DEFAULT_MASK
Definition: ladspa.h:258
#define LADSPA_HINT_DEFAULT_MIDDLE
Definition: ladspa.h:279
#define LADSPA_HINT_DEFAULT_1
Definition: ladspa.h:300
#define LADSPA_HINT_DEFAULT_MINIMUM
Definition: ladspa.h:265
#define LADSPA_HINT_DEFAULT_NONE
Definition: ladspa.h:261
std::pair< float, float > InputControlPortBounds(const LADSPA_PortRangeHint &hint, double sampleRate)
float ClampInputControlValue(const LADSPA_PortRangeHint &hint, float val, float lower, float upper)

References ClampInputControlValue(), _LADSPA_PortRangeHint::HintDescriptor, InputControlPortBounds(), LADSPA_HINT_DEFAULT_0, LADSPA_HINT_DEFAULT_1, LADSPA_HINT_DEFAULT_100, LADSPA_HINT_DEFAULT_440, LADSPA_HINT_DEFAULT_HIGH, LADSPA_HINT_DEFAULT_LOW, LADSPA_HINT_DEFAULT_MASK, LADSPA_HINT_DEFAULT_MAXIMUM, LADSPA_HINT_DEFAULT_MIDDLE, LADSPA_HINT_DEFAULT_MINIMUM, LADSPA_HINT_DEFAULT_NONE, LADSPA_IS_HINT_LOGARITHMIC, and anonymous_namespace{ClipSegmentTest.cpp}::sampleRate.

Referenced by LadspaEffectBase::InitializeControls().

Here is the call graph for this function:
Here is the caller graph for this function: