diff --git a/Cargo.lock b/Cargo.lock index 55dad1b..ebd9e3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,7 +106,7 @@ dependencies = [ [[package]] name = "audio" -version = "0.2.6" +version = "0.2.7" dependencies = [ "chrono", "common", @@ -243,7 +243,7 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cacophony" -version = "0.2.6" +version = "0.2.7" dependencies = [ "audio", "clap", @@ -396,7 +396,7 @@ dependencies = [ [[package]] name = "common" -version = "0.2.6" +version = "0.2.7" dependencies = [ "clap", "directories", @@ -1133,7 +1133,7 @@ dependencies = [ [[package]] name = "input" -version = "0.2.6" +version = "0.2.7" dependencies = [ "clap", "common", @@ -1160,7 +1160,7 @@ dependencies = [ [[package]] name = "io" -version = "0.2.6" +version = "0.2.7" dependencies = [ "audio", "common", @@ -1964,7 +1964,7 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "render" -version = "0.2.6" +version = "0.2.7" dependencies = [ "audio", "colorgrad", @@ -2309,7 +2309,7 @@ dependencies = [ [[package]] name = "text" -version = "0.2.6" +version = "0.2.7" dependencies = [ "common", "csv", diff --git a/Cargo.toml b/Cargo.toml index 5d3d030..1e1b172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = ["audio", "common", "input", "io", "render", "text"] [workspace.package] -version = "0.2.6" +version = "0.2.7" authors = ["Esther Alter "] description = "A minimalist and ergonomic MIDI sequencer" documentation = "https://github.com/subalterngames/cacophony" @@ -84,7 +84,7 @@ speech_dispatcher_0_9 = ["text/speech_dispatcher_0_9"] [package] name = "cacophony" -version = "0.2.6" +version = "0.2.7" authors = ["Esther Alter "] description = "A minimalist and ergonomic MIDI sequencer" documentation = "https://github.com/subalterngames/cacophony" @@ -120,7 +120,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.6" +version = "0.2.7" resources = ["data/*"] copyright = "Copyright (c) Subaltern Games LLC 2023. All rights reserved." short_description = "A minimalist and ergonomic MIDI sequencer." diff --git a/changelog.md b/changelog.md index 0f9ca7f..7a8ef82 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # 0.2.x +## 0.2.7 + +- Allow alphanumeric input in `--events events.txt`. + ## 0.2.6 - Fixed: If you let all notes in your music play (as opposed to stopping in the middle), it frequently becomes impossible to play or add new notes. diff --git a/input/src/debug_input_event.rs b/input/src/debug_input_event.rs new file mode 100644 index 0000000..d6d1ded --- /dev/null +++ b/input/src/debug_input_event.rs @@ -0,0 +1,7 @@ +use crate::InputEvent; + +#[cfg(debug_assertions)] +pub(crate) enum DebugInputEvent { + InputEvent(InputEvent), + Alphanumeric(char), +} diff --git a/input/src/lib.rs b/input/src/lib.rs index 79d7149..9f17d61 100644 --- a/input/src/lib.rs +++ b/input/src/lib.rs @@ -3,14 +3,20 @@ //! - `InputEvent` is an enum defining an event triggered by user input, e.g. a decrease in track volume. //! - `Input` maps raw qwerty keycode and raw MIDI messages (control bindings) to input events. It updates per frame, reading input and storing new events. +#[cfg(debug_assertions)] +mod debug_input_event; + mod input_event; mod keys; mod midi_binding; mod midi_conn; mod note_on; mod qwerty_binding; + use common::args::Args; use common::{State, MAX_NOTE, MIN_NOTE}; +#[cfg(debug_assertions)] +use debug_input_event::DebugInputEvent; use hashbrown::HashMap; use ini::Ini; pub use input_event::InputEvent; @@ -89,7 +95,8 @@ pub struct Input { /// Characters pressed on this frame. pub pressed_chars: Vec, /// Debug input events. - debug_inputs: Vec, + #[cfg(debug_assertions)] + debug_inputs: Vec, /// The MIDI time counter. time_counter: i16, } @@ -126,8 +133,11 @@ impl Input { let lines = s.split('\n'); for line in lines { match line.trim().parse::() { - Ok(e) => debug_inputs.push(e), - Err(_) => panic!("Failed to parse {}", line), + Ok(e) => debug_inputs.push(DebugInputEvent::InputEvent(e)), + Err(_) => line + .trim() + .chars() + .for_each(|c| debug_inputs.push(DebugInputEvent::Alphanumeric(c))), } } } @@ -193,8 +203,12 @@ impl Input { // DEBUG. if cfg!(debug_assertions) && !&self.debug_inputs.is_empty() { - let e = self.debug_inputs.remove(0); - events.push(e); + match self.debug_inputs.remove(0) { + // Push an event. + DebugInputEvent::InputEvent(e) => events.push(e), + // Push a char. + DebugInputEvent::Alphanumeric(c) => self.pressed_chars.push(c), + } } // Qwerty note input.