From 77231730fde571540f64146cbc2c26381fd48da1 Mon Sep 17 00:00:00 2001 From: pierre Date: Sat, 23 Jul 2022 17:40:47 +0200 Subject: [PATCH] add buttons to increase/decrese octave when selecting root notes --- src/components/root_note_form.rs | 46 +++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/components/root_note_form.rs b/src/components/root_note_form.rs index 0ec26dc..6931b7a 100644 --- a/src/components/root_note_form.rs +++ b/src/components/root_note_form.rs @@ -20,6 +20,8 @@ pub struct RootNoteFormProps { pub enum RootNoteFormMessages { RootNoteChanged(usize, MidiNote), + IncreaseOctave, + DecreaseOctave, Done, Reset, Cancel, @@ -57,6 +59,18 @@ impl Component for RootNotesForm { self.sample_files[index].root = note.into_byte(); true } + RootNoteFormMessages::IncreaseOctave => { + self.sample_files.iter_mut().for_each(|s| { + s.root = (s.root + 12).clamp(0, 127); + }); + true + } + RootNoteFormMessages::DecreaseOctave => { + self.sample_files.iter_mut().for_each(|s| { + s.root = (s.root - 12).clamp(0, 127); + }); + true + } RootNoteFormMessages::Done => { ctx.props().on_done.emit(self.sample_files.clone()); false @@ -115,15 +129,29 @@ impl Component for RootNotesForm { {samples} -