mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
make 'now' fields Arc<AtomicUsize>
This commit is contained in:
parent
c88cb86532
commit
694aed6d9b
3 changed files with 7 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ pub use clap;
|
||||||
pub use std::sync::{Arc, Mutex, LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
pub use std::sync::{Arc, Mutex, LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||||
pub use std::collections::BTreeMap;
|
pub use std::collections::BTreeMap;
|
||||||
pub use once_cell::sync::Lazy;
|
pub use once_cell::sync::Lazy;
|
||||||
pub use std::sync::atomic::{Ordering, AtomicBool};
|
pub use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize};
|
||||||
pub use std::rc::Rc;
|
pub use std::rc::Rc;
|
||||||
pub use std::cell::RefCell;
|
pub use std::cell::RefCell;
|
||||||
pub use std::marker::PhantomData;
|
pub use std::marker::PhantomData;
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,8 @@ pub struct PhraseEditor<E: Engine> {
|
||||||
pub notes_in: Arc<RwLock<[bool; 128]>>,
|
pub notes_in: Arc<RwLock<[bool; 128]>>,
|
||||||
/// Notes currently held at output
|
/// Notes currently held at output
|
||||||
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
||||||
|
/// Current position of global playhead
|
||||||
|
pub now: Arc<AtomicUsize>,
|
||||||
}
|
}
|
||||||
/// Phrase player.
|
/// Phrase player.
|
||||||
pub struct PhrasePlayer<E: Engine> {
|
pub struct PhrasePlayer<E: Engine> {
|
||||||
|
|
@ -112,7 +114,7 @@ pub struct PhrasePlayer<E: Engine> {
|
||||||
/// Notes currently held at output
|
/// Notes currently held at output
|
||||||
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
||||||
/// Current point in playing phrase
|
/// Current point in playing phrase
|
||||||
pub now: usize,
|
pub now: Arc<AtomicUsize>,
|
||||||
/// Play input through output.
|
/// Play input through output.
|
||||||
pub monitoring: bool,
|
pub monitoring: bool,
|
||||||
/// Write input to sequence.
|
/// Write input to sequence.
|
||||||
|
|
@ -234,6 +236,7 @@ impl<E: Engine> PhraseEditor<E> {
|
||||||
focused: false,
|
focused: false,
|
||||||
entered: false,
|
entered: false,
|
||||||
mode: false,
|
mode: false,
|
||||||
|
now: Arc::new(0.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +313,7 @@ impl<E: Engine> PhrasePlayer<E> {
|
||||||
midi_out: None,
|
midi_out: None,
|
||||||
midi_out_buf: vec![Vec::with_capacity(16);16384],
|
midi_out_buf: vec![Vec::with_capacity(16);16384],
|
||||||
reset: true,
|
reset: true,
|
||||||
now: 0,
|
now: Arc::new(0.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }
|
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
|to:[u16;2]|Ok(Some(to.clip_h(1))),
|
|to:[u16;2]|Ok(Some(to.clip_h(1))),
|
||||||
move|to: &mut TuiOutput|{
|
move|to: &mut TuiOutput|{
|
||||||
if let Some(_) = phrase {
|
if let Some(_) = phrase {
|
||||||
let now = 0; // TODO FIXME: self.now % phrase.read().unwrap().length;
|
let now = self.now.load(Ordering::Relaxed); // TODO FIXME: self.now % phrase.read().unwrap().length;
|
||||||
let ScaledAxis { start: first_beat, scale: time_zoom, clamp, .. } = time_axis;
|
let ScaledAxis { start: first_beat, scale: time_zoom, clamp, .. } = time_axis;
|
||||||
let clamp = clamp.expect("time_axis of sequencer expected to be clamped");
|
let clamp = clamp.expect("time_axis of sequencer expected to be clamped");
|
||||||
for x in 0..clamp/time_zoom {
|
for x in 0..clamp/time_zoom {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue