make 'now' fields Arc<AtomicUsize>

This commit is contained in:
🪞👃🪞 2024-10-23 00:33:01 +03:00
parent c88cb86532
commit 694aed6d9b
3 changed files with 7 additions and 4 deletions

View file

@ -101,6 +101,8 @@ pub struct PhraseEditor<E: Engine> {
pub notes_in: Arc<RwLock<[bool; 128]>>,
/// Notes currently held at output
pub notes_out: Arc<RwLock<[bool; 128]>>,
/// Current position of global playhead
pub now: Arc<AtomicUsize>,
}
/// Phrase player.
pub struct PhrasePlayer<E: Engine> {
@ -112,7 +114,7 @@ pub struct PhrasePlayer<E: Engine> {
/// Notes currently held at output
pub notes_out: Arc<RwLock<[bool; 128]>>,
/// Current point in playing phrase
pub now: usize,
pub now: Arc<AtomicUsize>,
/// Play input through output.
pub monitoring: bool,
/// Write input to sequence.
@ -234,6 +236,7 @@ impl<E: Engine> PhraseEditor<E> {
focused: false,
entered: false,
mode: false,
now: Arc::new(0.into()),
}
}
}
@ -310,7 +313,7 @@ impl<E: Engine> PhrasePlayer<E> {
midi_out: None,
midi_out_buf: vec![Vec::with_capacity(16);16384],
reset: true,
now: 0,
now: Arc::new(0.into()),
}
}
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }

View file

@ -102,7 +102,7 @@ impl Content for PhraseEditor<Tui> {
|to:[u16;2]|Ok(Some(to.clip_h(1))),
move|to: &mut TuiOutput|{
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 clamp = clamp.expect("time_axis of sequencer expected to be clamped");
for x in 0..clamp/time_zoom {