Audacity 3.2.0
Functions
anonymous_namespace{LadspaInstance.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{LadspaInstance.cpp}::ClampInputControlValue ( const LADSPA_PortRangeHint hint,
float  val,
float  lower,
float  upper 
)

Definition at line 61 of file LadspaInstance.cpp.

63{
64 if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) && val < lower)
65 val = lower;
66 if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) && val > upper)
67 val = upper;
68 return val;
69}
#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{LadspaInstance.cpp}::InputControlPortBounds ( const LADSPA_PortRangeHint hint,
double  sampleRate 
)

Definition at line 54 of file LadspaInstance.cpp.

55{
56 // Find lower and upper bound values for ths hint
57 const auto multiplier =
59 return { hint.LowerBound * multiplier, hint.UpperBound * multiplier };
60}
#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{LadspaInstance.cpp}::InputControlPortDefaultValue ( const LADSPA_PortRangeHint hint,
double  sampleRate 
)

Definition at line 70 of file LadspaInstance.cpp.

72{
73 // See comments in library header ladspa.h about interpretation of macros
74 const auto bounds = InputControlPortBounds(hint, sampleRate);
75
76 // Function to find low, middle, or high default values
77 const auto combine = [bounds,
79 ](float lowWeight, float highWeight){
80 auto [lower, upper] = bounds;
81 return logarithmic
82 ? exp(log(lower) * lowWeight + log(upper) * highWeight)
83 : lower * lowWeight + upper * highWeight;
84 };
85
86 auto [lower, upper] = bounds;
87 auto val = 1.0f;
88 // Four bits of the descriptor describe mutually exclusive cases
91 default:
92 break;
94 val = lower; break;
96 val = combine(0.75, 0.25); break;
98 val = combine(0.5, 0.5); break;
100 val = combine(0.25, 0.75); break;
102 val = upper; break;
104 val = 0.0f; break;
106 val = 1.0f; break;
108 val = 100.0f; break;
110 val = 440.0f; break;
111 }
112
113 return ClampInputControlValue(hint, val, lower, upper);
114}
#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
float ClampInputControlValue(const LADSPA_PortRangeHint &hint, float val, float lower, float upper)
std::pair< float, float > InputControlPortBounds(const LADSPA_PortRangeHint &hint, double sampleRate)

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.

Here is the call graph for this function: