mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46: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) {
|
fn play (&mut self, scope: &ProcessScope) {
|
||||||
let sample0 = scope.last_frame_time() as usize;
|
let sample0 = scope.last_frame_time() as usize;
|
||||||
let samples = scope.n_frames() 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
|
// Write MIDI events from currently playing phrase (if any) to MIDI output buffer
|
||||||
if let Some((start, ref phrase)) = self.playing() {
|
if let Some((start, ref phrase)) = self.playing() {
|
||||||
// First sample to populate. Greater than 0 means that the first
|
// First sample to populate. Greater than 0 means that the first
|
||||||
|
|
@ -90,7 +91,10 @@ impl PhrasePlayer {
|
||||||
for (sample, pulse) in pulses {
|
for (sample, pulse) in pulses {
|
||||||
// If a next phrase is enqueued, and we're past the end of the current one,
|
// If a next phrase is enqueued, and we're past the end of the current one,
|
||||||
// break the loop here (FIXME count pulse correctly)
|
// 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;
|
let pulse = pulse % phrase.length;
|
||||||
// Output each MIDI event from phrase at appropriate frames of output buffer:
|
// Output each MIDI event from phrase at appropriate frames of output buffer:
|
||||||
for message in phrase.notes[pulse].iter() {
|
for message in phrase.notes[pulse].iter() {
|
||||||
|
|
@ -107,20 +111,22 @@ impl PhrasePlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle next enqueued phrase, if any:
|
// If it's time for the next enqueued phrase, handle it here:
|
||||||
if let Some((start, phrase)) = self.enqueued() {
|
if next {
|
||||||
// If it's time to switch to the next phrase:
|
if let Some((start, phrase)) = self.enqueued() {
|
||||||
if start <= sample0 {
|
// If it's time to switch to the next phrase:
|
||||||
// Samples elapsed since phrase was supposed to start
|
if start <= sample0 {
|
||||||
let skipped = sample0 - start;
|
// Samples elapsed since phrase was supposed to start
|
||||||
// Switch over to enqueued phrase
|
let skipped = sample0 - start;
|
||||||
let started = Instant::from_sample(&self.clock.timebase(), start as f64);
|
// Switch over to enqueued phrase
|
||||||
self.phrase = Some((started, phrase));
|
let started = Instant::from_sample(&self.clock.timebase(), start as f64);
|
||||||
// Unset enqueuement (TODO: where to implement looping?)
|
self.phrase = Some((started, phrase));
|
||||||
self.next_phrase = None
|
// 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) {
|
fn record (&mut self, scope: &ProcessScope) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue