refactoring time representation into multuple traits

This commit is contained in:
🪞👃🪞 2024-10-26 13:38:14 +03:00
parent a25548c39c
commit 5a18a2023d
4 changed files with 149 additions and 72 deletions

View file

@ -113,24 +113,28 @@ pub struct PhrasePlayer<E: Engine> {
_engine: PhantomData<E>,
/// Phrase being played
pub phrase: Option<Arc<RwLock<Phrase>>>,
/// Notes currently held at input
pub notes_in: Arc<RwLock<[bool; 128]>>,
/// Notes currently held at output
pub notes_out: Arc<RwLock<[bool; 128]>>,
/// Next phrase
pub next_phrase: Option<Arc<RwLock<Phrase>>>,
/// Current point in playing phrase
pub now: Arc<AtomicUsize>,
/// Frames remaining until switch to next phrase
pub switch_at: Option<AtomicUsize>,
/// Play input through output.
pub monitoring: bool,
/// Write input to sequence.
pub recording: bool,
/// Overdub input to sequence.
pub overdub: bool,
/// Send all notes off
pub reset: bool, // TODO?: after Some(nframes)
/// Output from current sequence.
pub midi_out: Option<Port<MidiOut>>,
/// MIDI output buffer
pub midi_out_buf: Vec<Vec<Vec<u8>>>,
/// Send all notes off
pub reset: bool, // TODO?: after Some(nframes)
/// Notes currently held at input
pub notes_in: Arc<RwLock<[bool; 128]>>,
/// Notes currently held at output
pub notes_out: Arc<RwLock<[bool; 128]>>,
}
/// Focus layout of sequencer app
impl<E: Engine> FocusGrid<SequencerFocus> for Sequencer<E> {
@ -326,6 +330,9 @@ impl<E: Engine> PhrasePlayer<E> {
Self {
_engine: Default::default(),
phrase: None,
next_phrase: None,
now: Arc::new(0.into()),
switch_at: None,
notes_in: Arc::new(RwLock::new([false;128])),
notes_out: Arc::new(RwLock::new([false;128])),
monitoring: false,
@ -334,7 +341,6 @@ impl<E: Engine> PhrasePlayer<E> {
midi_out: None,
midi_out_buf: vec![Vec::with_capacity(16);16384],
reset: true,
now: Arc::new(0.into()),
}
}
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }