1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 19:15:08 +00:00
serenity/Userland/Applications/Piano/ProcessorParameterSlider.cpp
kleines Filmröllchen 0dc6fe9102 Piano: Use LibDSP to implement delay
This is the first step in transitioning Piano to a full LibDSP backend.
For now, the delay effect is replaced with a (mostly identical)
implementation in LibDSP.

The new ProcessorParameterSlider attaches to a LibDSP::Processor's
range parameter (LibDSP::ProcessorRangeParameter) and changes it
automatically. It also has the ability to update an external GUI::Label.
This is used for the three delay parameters and it will become useful
for auto-generating UI for Processors.
2021-08-31 17:03:55 +04:30

29 lines
1.1 KiB
C++

/*
* Copyright (c) 2021, kleines Filmröllchen <malu.bertsch@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "ProcessorParameterSlider.h"
ProcessorParameterSlider::ProcessorParameterSlider(Orientation orientation, LibDSP::ProcessorRangeParameter& parameter, RefPtr<GUI::Label> value_label)
: Slider(orientation)
, m_parameter(parameter)
, m_value_label(move(value_label))
{
set_range(m_parameter.min_value().raw(), m_parameter.max_value().raw());
set_value(m_parameter.value().raw());
set_step((m_parameter.min_value() - m_parameter.max_value()).raw() / 128);
set_tooltip(m_parameter.name());
on_change = [this](auto value) {
LibDSP::ParameterFixedPoint real_value;
real_value.raw() = value;
m_parameter.set_value_sneaky(real_value, LibDSP::Detail::ProcessorParameterSetValueTag {});
if (m_value_label)
m_value_label->set_text(String::formatted("{:.2f}", static_cast<double>(m_parameter)));
};
m_parameter.did_change_value = [this](auto value) {
set_value(value.raw());
};
}