From 160b82b0d8f7150806bcf2bc6639135f2c5722bb Mon Sep 17 00:00:00 2001 From: Esther Alter Date: Thu, 16 May 2024 04:04:10 -0400 Subject: [PATCH 1/2] clear_notes_on_qwerty_octave --- Cargo.lock | 14 +++++++------- Cargo.toml | 6 +++--- input/src/lib.rs | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 90ae694..c4d6a9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,7 +105,7 @@ dependencies = [ [[package]] name = "audio" -version = "0.2.3" +version = "0.2.4" dependencies = [ "chrono", "common", @@ -238,7 +238,7 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cacophony" -version = "0.2.3" +version = "0.2.4" dependencies = [ "audio", "clap", @@ -396,7 +396,7 @@ dependencies = [ [[package]] name = "common" -version = "0.2.3" +version = "0.2.4" dependencies = [ "clap", "directories", @@ -1008,7 +1008,7 @@ dependencies = [ [[package]] name = "input" -version = "0.2.3" +version = "0.2.4" dependencies = [ "clap", "common", @@ -1034,7 +1034,7 @@ dependencies = [ [[package]] name = "io" -version = "0.2.3" +version = "0.2.4" dependencies = [ "audio", "common", @@ -1880,7 +1880,7 @@ checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "render" -version = "0.2.3" +version = "0.2.4" dependencies = [ "audio", "colorgrad", @@ -2211,7 +2211,7 @@ dependencies = [ [[package]] name = "text" -version = "0.2.3" +version = "0.2.4" dependencies = [ "common", "csv", diff --git a/Cargo.toml b/Cargo.toml index 4fde32e..c3dbab4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = ["audio", "common", "input", "io", "render", "text"] [workspace.package] -version = "0.2.3" +version = "0.2.4" authors = ["Esther Alter "] description = "A minimalist and ergonomic MIDI sequencer" documentation = "https://github.com/subalterngames/cacophony" @@ -86,7 +86,7 @@ speech_dispatcher_0_9 = ["text/speech_dispatcher_0_9"] [package] name = "cacophony" -version = "0.2.3" +version = "0.2.4" authors = ["Esther Alter "] description = "A minimalist and ergonomic MIDI sequencer" documentation = "https://github.com/subalterngames/cacophony" @@ -122,7 +122,7 @@ path = "text" name = "Cacophony" identifier = "com.subalterngames.cacophony" icon = ["icon/32.png", "icon/64.png", "icon/128.png", "icon/256.png"] -version = "0.2.3" +version = "0.2.4" resources = ["data/*"] copyright = "Copyright (c) Subaltern Games LLC 2023. All rights reserved." short_description = "A minimalist and ergonomic MIDI sequencer." diff --git a/input/src/lib.rs b/input/src/lib.rs index 5e216e6..83253a7 100644 --- a/input/src/lib.rs +++ b/input/src/lib.rs @@ -70,9 +70,9 @@ pub struct Input { events: Vec, /// The MIDI connection. midi_conn: Option, - // Note-on MIDI messages. These will be sent immediately to the synthesizer to be played. + /// Note-on MIDI messages. These will be sent immediately to the synthesizer to be played. pub note_on_messages: Vec<[u8; 3]>, - // Note-off MIDI messages. These will be sent immediately to the synthesizer. + /// Note-off MIDI messages. These will be sent immediately to the synthesizer. pub note_off_keys: Vec, /// Note-on events that don't have corresponding off events. note_on_events: Vec, @@ -206,10 +206,12 @@ impl Input { } // Octave up. if events.contains(&InputEvent::OctaveUp) && self.qwerty_octave < MAX_OCTAVE { + self.clear_notes_on_qwerty_octave(); self.qwerty_octave += 1; } // Octave down. if events.contains(&InputEvent::OctaveDown) && self.qwerty_octave > 0 { + self.clear_notes_on_qwerty_octave(); self.qwerty_octave -= 1; } // Qwerty note-off. @@ -420,6 +422,14 @@ impl Input { (9 - self.qwerty_octave) * 12 + note } + /// When a qwerty note is pressed, followed by an octave change, clear all note-on events. + fn clear_notes_on_qwerty_octave(&mut self) { + // Qwerty note-off. + for (_, qwerty_note_off) in QWERTY_NOTE_EVENTS.iter() { + self.note_off_keys.push(self.get_pitch(*qwerty_note_off)); + } + } + #[cfg(debug_assertions)] fn listen_for_note_offs(&mut self) { if self.happened(&InputEvent::NotesOff) { From 4f23919b95bb4d102e0d952edadc20f5b8ec58e2 Mon Sep 17 00:00:00 2001 From: Esther Alter Date: Thu, 16 May 2024 04:05:55 -0400 Subject: [PATCH 2/2] changelog --- changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.md b/changelog.md index f612491..51db921 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # 0.2.x +## 0.2.4 + +- Fixed: If note is played via a qwerty key press, and then an octave is changed via a qwerty key press, there won't be a note-off event. + ## 0.2.3 - Optimized text and rectangle rendering, which reduces CPU usage by around 5%.