mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
launch pt.8: fixed countdown, broke switchover
This commit is contained in:
parent
c20d49cd45
commit
1fe4ea89af
1 changed files with 20 additions and 14 deletions
|
|
@ -70,6 +70,7 @@ impl PhrasePlayer {
|
|||
fn play (&mut self, scope: &ProcessScope) {
|
||||
let sample0 = scope.last_frame_time() as usize;
|
||||
let samples = scope.n_frames() as usize;
|
||||
let mut next = false;
|
||||
// Write MIDI events from currently playing phrase (if any) to MIDI output buffer
|
||||
if let Some((start, ref phrase)) = self.playing() {
|
||||
// First sample to populate. Greater than 0 means that the first
|
||||
|
|
@ -90,7 +91,10 @@ impl PhrasePlayer {
|
|||
for (sample, pulse) in pulses {
|
||||
// If a next phrase is enqueued, and we're past the end of the current one,
|
||||
// break the loop here (FIXME count pulse correctly)
|
||||
if self.next_phrase.is_some() && pulse >= phrase.length { break }
|
||||
if self.next_phrase.is_some() && pulse >= phrase.length {
|
||||
next = true;
|
||||
break
|
||||
}
|
||||
let pulse = pulse % phrase.length;
|
||||
// Output each MIDI event from phrase at appropriate frames of output buffer:
|
||||
for message in phrase.notes[pulse].iter() {
|
||||
|
|
@ -107,20 +111,22 @@ impl PhrasePlayer {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Handle next enqueued phrase, if any:
|
||||
if let Some((start, phrase)) = self.enqueued() {
|
||||
// If it's time to switch to the next phrase:
|
||||
if start <= sample0 {
|
||||
// Samples elapsed since phrase was supposed to start
|
||||
let skipped = sample0 - start;
|
||||
// Switch over to enqueued phrase
|
||||
let started = Instant::from_sample(&self.clock.timebase(), start as f64);
|
||||
self.phrase = Some((started, phrase));
|
||||
// Unset enqueuement (TODO: where to implement looping?)
|
||||
self.next_phrase = None
|
||||
// If it's time for the next enqueued phrase, handle it here:
|
||||
if next {
|
||||
if let Some((start, phrase)) = self.enqueued() {
|
||||
// If it's time to switch to the next phrase:
|
||||
if start <= sample0 {
|
||||
// Samples elapsed since phrase was supposed to start
|
||||
let skipped = sample0 - start;
|
||||
// Switch over to enqueued phrase
|
||||
let started = Instant::from_sample(&self.clock.timebase(), start as f64);
|
||||
self.phrase = Some((started, phrase));
|
||||
// Unset enqueuement (TODO: where to implement looping?)
|
||||
self.next_phrase = None
|
||||
}
|
||||
// TODO fill in remaining ticks of chunk from next phrase.
|
||||
// ?? just call self.play(scope) again, since enqueuement is off ???
|
||||
}
|
||||
// TODO fill in remaining ticks of chunk from next phrase.
|
||||
// ?? just call self.play(scope) again, since enqueuement is off ???
|
||||
}
|
||||
}
|
||||
fn record (&mut self, scope: &ProcessScope) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue