extract Sequencer model

This commit is contained in:
🪞👃🪞 2024-07-13 17:11:28 +03:00
parent f347ca838b
commit aa478099d9
14 changed files with 211 additions and 348 deletions

46
src/model/sequencer.rs Normal file
View file

@ -0,0 +1,46 @@
use crate::{core::*, model::Phrase};
pub struct Sequencer {
pub phrase: Option<Arc<RwLock<Phrase>>>,
pub mode: bool,
pub buffer: Buffer,
pub now: usize,
pub ppq: usize,
pub note_cursor: usize,
pub note_start: usize,
pub time_cursor: usize,
pub time_start: usize,
pub time_zoom: usize,
pub focused: bool,
pub entered: bool,
/// Highlight input keys
pub notes_in: [bool; 128],
/// Highlight output keys
pub notes_out: [bool; 128],
}
impl Sequencer {
pub fn new () -> Self {
Self {
buffer: Buffer::empty(Rect::default()),
entered: false,
focused: false,
mode: false,
note_cursor: 0,
note_start: 0,
notes_in: [false;128],
notes_out: [false;128],
phrase: None,
time_cursor: 0,
time_start: 0,
time_zoom: 12,
now: 0,
ppq: 96
}
}
pub fn show (&mut self, phrase: Option<&Arc<RwLock<Phrase>>>) {
self.phrase = phrase.map(Clone::clone);
}
}