mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: enqueue synced (!!!)
This commit is contained in:
parent
2d1c901b8c
commit
89dcc2afe2
5 changed files with 26 additions and 15 deletions
|
|
@ -115,12 +115,10 @@ pub struct PhrasePlayer<E: Engine> {
|
|||
_engine: PhantomData<E>,
|
||||
/// Global timebase
|
||||
pub clock: Arc<TransportTime>,
|
||||
/// Phrase being played
|
||||
pub phrase: Option<Arc<RwLock<Phrase>>>,
|
||||
/// Next phrase
|
||||
pub next_phrase: Option<Arc<RwLock<Phrase>>>,
|
||||
/// Current point in playing phrase
|
||||
pub now: Arc<AtomicUsize>,
|
||||
/// Start time and phrase being played
|
||||
pub phrase: Option<(AtomicUsize, Option<Arc<RwLock<Phrase>>>)>,
|
||||
/// Start time and next phrase
|
||||
pub next_phrase: Option<(AtomicUsize, Option<Arc<RwLock<Phrase>>>)>,
|
||||
/// Frames remaining until switch to next phrase
|
||||
pub switch_at: Option<AtomicUsize>,
|
||||
/// Play input through output.
|
||||
|
|
@ -336,7 +334,6 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
clock: clock.clone(),
|
||||
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])),
|
||||
|
|
@ -351,6 +348,15 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }
|
||||
pub fn toggle_record (&mut self) { self.recording = !self.recording; }
|
||||
pub fn toggle_overdub (&mut self) { self.overdub = !self.overdub; }
|
||||
pub fn enqueue_next (&mut self, start_at: usize, phrase: Option<&Arc<RwLock<Phrase>>>) {
|
||||
self.next_phrase = Some((start_at.into(), phrase.map(|p|p.clone())));
|
||||
self.reset = true;
|
||||
}
|
||||
pub fn frames_since_start (&self) -> Option<usize> {
|
||||
self.phrase.as_ref()
|
||||
.map(|(started,_)|started.load(Ordering::Relaxed))
|
||||
.map(|started|started - self.clock.frame())
|
||||
}
|
||||
}
|
||||
/// Displays and edits phrase length
|
||||
pub struct PhraseLength<E: Engine> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue