1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:27:34 +00:00

LibDSP: Allow ProcessorRangeParameter to specify if it's a log value

This doesn't affect the parameter's own behavior but is part of the
parameter meta-data, just as the name. If a parameter is logarithmic,
UI elements should represent it with an interface that scales
logarithmically.
This commit is contained in:
kleines Filmröllchen 2021-10-12 01:15:12 +02:00 committed by Andreas Kling
parent 98058f7efe
commit e7d84da3da
3 changed files with 18 additions and 9 deletions

View file

@ -26,6 +26,11 @@ enum class ParameterType : u8 {
Boolean,
};
enum class Logarithmic : bool {
No,
Yes
};
// Processors have modifiable parameters that should be presented to the UI in a uniform way without requiring the processor itself to implement custom interfaces.
class ProcessorParameter {
public:
@ -101,22 +106,25 @@ public:
class ProcessorRangeParameter final : public Detail::ProcessorParameterSingleValue<ParameterFixedPoint> {
public:
ProcessorRangeParameter(String name, ParameterFixedPoint min_value, ParameterFixedPoint max_value, ParameterFixedPoint initial_value)
ProcessorRangeParameter(String name, ParameterFixedPoint min_value, ParameterFixedPoint max_value, ParameterFixedPoint initial_value, Logarithmic logarithmic)
: Detail::ProcessorParameterSingleValue<ParameterFixedPoint>(move(name), ParameterType::Range, move(initial_value))
, m_min_value(move(min_value))
, m_max_value(move(max_value))
, m_default_value(move(initial_value))
, m_logarithmic(logarithmic)
{
VERIFY(initial_value <= max_value && initial_value >= min_value);
}
ProcessorRangeParameter(ProcessorRangeParameter const& to_copy)
: ProcessorRangeParameter(to_copy.name(), to_copy.min_value(), to_copy.max_value(), to_copy.value())
: ProcessorRangeParameter(to_copy.name(), to_copy.min_value(), to_copy.max_value(), to_copy.value(), to_copy.is_logarithmic())
{
}
ParameterFixedPoint min_value() const { return m_min_value; }
ParameterFixedPoint max_value() const { return m_max_value; }
ParameterFixedPoint range() const { return m_max_value - m_min_value; }
constexpr Logarithmic is_logarithmic() const { return m_logarithmic; }
ParameterFixedPoint default_value() const { return m_default_value; }
void set_value(ParameterFixedPoint value)
{
@ -128,6 +136,7 @@ private:
double const m_min_value;
double const m_max_value;
double const m_default_value;
Logarithmic const m_logarithmic;
};
template<typename EnumT>