1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +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:
kleines Filmröllchen 2022-05-14 01:11:23 +02:00 committed by Linus Groh
parent a861d2b728
commit aea8a040b3
11 changed files with 83 additions and 132 deletions

View file

@ -13,8 +13,10 @@
TrackManager::TrackManager()
: m_transport(make_ref_counted<LibDSP::Transport>(120, 4))
, m_keyboard(make_ref_counted<LibDSP::Keyboard>(m_transport))
{
add_track();
m_tracks[m_current_track]->set_active(true);
}
void TrackManager::time_forward(int amount)
@ -59,36 +61,16 @@ void TrackManager::reset()
m_transport->set_time(0);
for (auto& track : m_tracks)
for (auto& track : m_tracks) {
track->reset();
}
void TrackManager::set_keyboard_note(int note, Switch note_switch)
{
m_tracks[m_current_track]->set_keyboard_note(note, note_switch);
}
void TrackManager::set_octave(Direction direction)
{
if (direction == Up) {
if (m_octave < octave_max)
++m_octave;
} else {
if (m_octave > octave_min)
--m_octave;
}
}
void TrackManager::set_octave(int octave)
{
if (octave <= octave_max && octave >= octave_min) {
m_octave = octave;
track->set_active(false);
}
m_tracks[m_current_track]->set_active(true);
}
void TrackManager::add_track()
{
m_tracks.append(make<Track>(m_transport));
m_tracks.append(make<Track>(m_transport, m_keyboard));
}
int TrackManager::next_track_index() const