From ad6a332268db5c8a1a8e7728175054e96fd35044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Mon, 5 Jul 2021 23:45:16 +0200 Subject: [PATCH] Piano: Add velocity and pitch support As Piano will later move to the RollNote defintions of LibDSP, it's a good idea to already insert velocity and pitch support, even though it's currently not used. --- Userland/Applications/Piano/Music.h | 2 ++ Userland/Applications/Piano/RollWidget.cpp | 2 +- Userland/Applications/Piano/Track.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/Piano/Music.h b/Userland/Applications/Piano/Music.h index bfb4a4c930..a1080155e9 100644 --- a/Userland/Applications/Piano/Music.h +++ b/Userland/Applications/Piano/Music.h @@ -42,6 +42,8 @@ struct RollNote { u32 on_sample; u32 off_sample; + u8 pitch; + i8 velocity; }; enum Direction { diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp index 3886337302..d53e0ef64e 100644 --- a/Userland/Applications/Piano/RollWidget.cpp +++ b/Userland/Applications/Piano/RollWidget.cpp @@ -228,7 +228,7 @@ void RollWidget::mousemove_event(GUI::MouseEvent& event) u32 on_sample = roll_length * (static_cast(min(x0, x1)) / m_num_notes); u32 off_sample = (roll_length * (static_cast(max(x0, x1) + 1) / m_num_notes)) - 1; m_track_manager.current_track().set_roll_note(m_drag_note, on_sample, off_sample); - m_note_drag_location = RollNote({ on_sample, off_sample }); + m_note_drag_location = RollNote { on_sample, off_sample, (u8)m_drag_note, 0 }; update(); } diff --git a/Userland/Applications/Piano/Track.cpp b/Userland/Applications/Piano/Track.cpp index 9de5b3a1ae..dea1bf4217 100644 --- a/Userland/Applications/Piano/Track.cpp +++ b/Userland/Applications/Piano/Track.cpp @@ -272,7 +272,7 @@ void Track::sync_roll(int note) void Track::set_roll_note(int note, u32 on_sample, u32 off_sample) { - RollNote new_roll_note = { on_sample, off_sample }; + RollNote new_roll_note = { on_sample, off_sample, (u8)note, 0 }; VERIFY(note >= 0 && note < note_count); VERIFY(new_roll_note.off_sample < roll_length);