mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03: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:
parent
98058f7efe
commit
e7d84da3da
Notes:
sideshowbarker
2024-07-17 18:08:48 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/e7d84da3da Pull-request: https://github.com/SerenityOS/serenity/pull/12538 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/bgianfo
@ -11,9 +11,9 @@ namespace LibDSP::Effects {
|
||||
|
||||
Delay::Delay(NonnullRefPtr<Transport> transport)
|
||||
: EffectProcessor(move(transport))
|
||||
, m_delay_decay("Decay"sv, 0.01, 0.99, 0.33)
|
||||
, m_delay_time("Delay Time"sv, 3, 2000, 900)
|
||||
, m_dry_gain("Dry"sv, 0, 1, 0.9)
|
||||
, m_delay_decay("Decay"sv, 0.01, 0.99, 0.33, Logarithmic::No)
|
||||
, m_delay_time("Delay Time"sv, 3, 2000, 900, Logarithmic::Yes)
|
||||
, m_dry_gain("Dry"sv, 0, 1, 0.9, Logarithmic::No)
|
||||
{
|
||||
|
||||
m_parameters.append(m_delay_decay);
|
||||
|
@ -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>
|
||||
|
@ -17,10 +17,10 @@ namespace LibDSP::Synthesizers {
|
||||
Classic::Classic(NonnullRefPtr<Transport> transport)
|
||||
: LibDSP::SynthesizerProcessor(transport)
|
||||
, m_waveform("Waveform"sv, Waveform::Saw)
|
||||
, m_attack("Attack"sv, 0, 2000, 5)
|
||||
, m_decay("Decay"sv, 0, 20'000, 80)
|
||||
, m_sustain("Sustain"sv, 0, 1, 0.725)
|
||||
, m_release("Release", 0, 6'000, 120)
|
||||
, m_attack("Attack"sv, 0.01, 2000, 5, Logarithmic::Yes)
|
||||
, m_decay("Decay"sv, 0.01, 20'000, 80, Logarithmic::Yes)
|
||||
, m_sustain("Sustain"sv, 0.001, 1, 0.725, Logarithmic::No)
|
||||
, m_release("Release", 0.01, 6'000, 120, Logarithmic::Yes)
|
||||
{
|
||||
m_parameters.append(m_waveform);
|
||||
m_parameters.append(m_attack);
|
||||
|
Loading…
Reference in New Issue
Block a user