mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:27:35 +00:00
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.
This commit is contained in:
parent
a861d2b728
commit
aea8a040b3
11 changed files with 83 additions and 132 deletions
|
@ -9,6 +9,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "Music.h"
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibDSP/Keyboard.h>
|
||||
#include <LibGUI/Frame.h>
|
||||
|
||||
class TrackManager;
|
||||
|
@ -18,14 +20,11 @@ class KeysWidget final : public GUI::Frame {
|
|||
public:
|
||||
virtual ~KeysWidget() override = default;
|
||||
|
||||
int key_code_to_key(int key_code) const;
|
||||
static i8 key_code_to_key(int key_code);
|
||||
int mouse_note() const;
|
||||
|
||||
void set_key(int key, Switch);
|
||||
bool note_is_set(int note) const;
|
||||
|
||||
private:
|
||||
explicit KeysWidget(TrackManager&);
|
||||
KeysWidget(NonnullRefPtr<LibDSP::Keyboard>);
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
|
@ -34,9 +33,9 @@ private:
|
|||
|
||||
int note_for_event_position(Gfx::IntPoint const&) const;
|
||||
|
||||
TrackManager& m_track_manager;
|
||||
void set_key(i8 key, LibDSP::Keyboard::Switch);
|
||||
|
||||
u8 m_key_on[note_count] { 0 };
|
||||
NonnullRefPtr<LibDSP::Keyboard> m_keyboard;
|
||||
|
||||
bool m_mouse_down { false };
|
||||
int m_mouse_note { -1 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue