mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
draw in sequencer
This commit is contained in:
parent
31f8ec5362
commit
b6c093b355
3 changed files with 62 additions and 38 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use super::Sequencer;
|
||||
|
||||
pub fn handle (state: &mut Sequencer,event: &Event) -> Result<(), Box<dyn Error>> {
|
||||
pub fn handle (state: &mut Sequencer, event: &Event) -> Result<(), Box<dyn Error>> {
|
||||
|
||||
if let Event::Key(event) = event {
|
||||
|
||||
|
|
@ -11,6 +11,34 @@ pub fn handle (state: &mut Sequencer,event: &Event) -> Result<(), Box<dyn Error>
|
|||
state.exit();
|
||||
}
|
||||
},
|
||||
KeyCode::Down => {
|
||||
state.cursor.0 = if state.cursor.0 >= 3 {
|
||||
0
|
||||
} else {
|
||||
state.cursor.0 + 1
|
||||
}
|
||||
},
|
||||
KeyCode::Up => {
|
||||
state.cursor.0 = if state.cursor.0 == 0 {
|
||||
3
|
||||
} else {
|
||||
state.cursor.0 - 1
|
||||
}
|
||||
},
|
||||
KeyCode::Left => {
|
||||
state.cursor.1 = if state.cursor.1 == 0 {
|
||||
63
|
||||
} else {
|
||||
state.cursor.1 - 1
|
||||
}
|
||||
},
|
||||
KeyCode::Right => {
|
||||
state.cursor.1 = if state.cursor.1 == 63 {
|
||||
0
|
||||
} else {
|
||||
state.cursor.1 + 1
|
||||
}
|
||||
},
|
||||
KeyCode::Char('[') => {
|
||||
if state.cursor.2 > 0 {
|
||||
state.cursor.2 = state.cursor.2 - 1
|
||||
|
|
@ -19,36 +47,15 @@ pub fn handle (state: &mut Sequencer,event: &Event) -> Result<(), Box<dyn Error>
|
|||
KeyCode::Char(']') => {
|
||||
state.cursor.2 = state.cursor.2 + 1
|
||||
},
|
||||
KeyCode::Down => {
|
||||
state.cursor.1 = if state.cursor.1 >= 3 {
|
||||
0
|
||||
} else {
|
||||
state.cursor.1 + 1
|
||||
KeyCode::Char('a') => {
|
||||
let row = state.cursor.0 as usize;
|
||||
let step = state.cursor.1 as usize;
|
||||
let duration = state.cursor.2 as usize;
|
||||
state.sequence[row][step] = Some(super::Event::NoteOn(35, 128));
|
||||
if state.cursor.2 > 0 {
|
||||
state.sequence[row][step + duration] = Some(super::Event::NoteOff(35));
|
||||
}
|
||||
},
|
||||
KeyCode::Up => {
|
||||
state.cursor.1 = if state.cursor.1 == 0 {
|
||||
3
|
||||
} else {
|
||||
state.cursor.1 - 1
|
||||
}
|
||||
},
|
||||
KeyCode::Left => {
|
||||
state.cursor.0 = if state.cursor.0 == 0 {
|
||||
63
|
||||
} else {
|
||||
state.cursor.0 - 1
|
||||
}
|
||||
},
|
||||
KeyCode::Right => {
|
||||
state.cursor.0 = if state.cursor.0 == 63 {
|
||||
0
|
||||
} else {
|
||||
state.cursor.0 + 1
|
||||
}
|
||||
},
|
||||
KeyCode::Char('A') => {
|
||||
},
|
||||
_ => {
|
||||
println!("{event:?}");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue