From aea8a040b350243b4c8f5e50a9c44e58e18c0288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sat, 14 May 2022 01:11:23 +0200 Subject: Piano: Use LibDSP::Keyboard for all keyboard-playing logic The only major functional change is that the Track now needs to know whether it's active or not, in order to listen to the keyboard (or not). There are some bugs exposed/created by this, mainly: * KeysWidget sometimes shows phantom notes. Those do not actually exist as far as debugging has revealed and do not play in the synth. * The keyboard can lock up Piano when rapidly pressing keys. This appears to be a HashMap bug; I invested significant time in bugfixing but got nowhere. --- Userland/Applications/Piano/KnobsWidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Userland/Applications/Piano/KnobsWidget.cpp') diff --git a/Userland/Applications/Piano/KnobsWidget.cpp b/Userland/Applications/Piano/KnobsWidget.cpp index 17fe3486fa..74281af578 100644 --- a/Userland/Applications/Piano/KnobsWidget.cpp +++ b/Userland/Applications/Piano/KnobsWidget.cpp @@ -35,7 +35,7 @@ KnobsWidget::KnobsWidget(TrackManager& track_manager, MainWidget& main_widget) m_values_container->set_fixed_height(10); m_volume_value = m_values_container->add(String::number(m_track_manager.current_track().volume())); - m_octave_value = m_values_container->add(String::number(m_track_manager.octave())); + m_octave_value = m_values_container->add(String::number(m_track_manager.keyboard()->virtual_keyboard_octave())); m_knobs_container = add(); m_knobs_container->set_layout(); @@ -57,13 +57,13 @@ KnobsWidget::KnobsWidget(TrackManager& track_manager, MainWidget& main_widget) m_octave_knob = m_knobs_container->add(); m_octave_knob->set_tooltip("Z: octave down, X: octave up"); m_octave_knob->set_range(octave_min - 1, octave_max - 1); - m_octave_knob->set_value((octave_max - 1) - (m_track_manager.octave() - 1)); + m_octave_knob->set_value((octave_max - 1) - (m_track_manager.keyboard()->virtual_keyboard_octave() - 1)); m_octave_knob->set_step(1); m_octave_knob->on_change = [this](int value) { int new_octave = octave_max - value; if (m_change_underlying) m_main_widget.set_octave_and_ensure_note_change(new_octave); - VERIFY(new_octave == m_track_manager.octave()); + VERIFY(new_octave == m_track_manager.keyboard()->virtual_keyboard_octave()); m_octave_value->set_text(String::number(new_octave)); }; @@ -117,7 +117,7 @@ void KnobsWidget::update_knobs() m_change_underlying = false; m_volume_knob->set_value(volume_max - m_track_manager.current_track().volume()); - m_octave_knob->set_value(octave_max - m_track_manager.octave()); + m_octave_knob->set_value(octave_max - m_track_manager.keyboard()->virtual_keyboard_octave()); m_change_underlying = true; } -- cgit v1.2.3