mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
flatten midi playback some more
This commit is contained in:
parent
e2172f287c
commit
f57589e83a
1 changed files with 38 additions and 36 deletions
|
|
@ -21,19 +21,19 @@ pub trait MidiPlaybackApi: HasPlayPhrase + HasClock + HasMidiOuts {
|
||||||
fn play (
|
fn play (
|
||||||
&mut self, scope: &ProcessScope, note_buf: &mut Vec<u8>, out: &mut [Vec<Vec<u8>>]
|
&mut self, scope: &ProcessScope, note_buf: &mut Vec<u8>, out: &mut [Vec<Vec<u8>>]
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
if !self.clock().is_rolling() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
let playing = self.play_phrase();
|
||||||
|
if let Some((started, phrase)) = playing {
|
||||||
|
// If a phrase is playing, write a chunk of MIDI events from it to the output buffer
|
||||||
let mut next = false;
|
let mut next = false;
|
||||||
// Write MIDI events from currently playing phrase (if any) to MIDI output buffer
|
|
||||||
if self.clock().is_rolling() {
|
|
||||||
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;
|
||||||
// If no phrase is playing, prepare for switchover immediately
|
|
||||||
next = self.play_phrase().is_none();
|
|
||||||
let phrase = self.play_phrase();
|
|
||||||
let started0 = &self.clock().started;
|
let started0 = &self.clock().started;
|
||||||
let timebase = self.clock().timebase();
|
let timebase = self.clock().timebase();
|
||||||
let notes_out = self.notes_out();
|
let notes_out = self.notes_out();
|
||||||
let next_phrase = self.next_phrase();
|
let next_phrase = self.next_phrase();
|
||||||
if let Some((started, phrase)) = phrase {
|
|
||||||
// First sample to populate. Greater than 0 means that the first
|
// First sample to populate. Greater than 0 means that the first
|
||||||
// pulse of the phrase falls somewhere in the middle of the chunk.
|
// pulse of the phrase falls somewhere in the middle of the chunk.
|
||||||
let sample = started.sample.get() as usize;
|
let sample = started.sample.get() as usize;
|
||||||
|
|
@ -61,9 +61,11 @@ pub trait MidiPlaybackApi: HasPlayPhrase + HasClock + HasMidiOuts {
|
||||||
Self::play_pulse(phrase, pulse, sample, note_buf, out, notes)
|
Self::play_pulse(phrase, pulse, sample, note_buf, out, notes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
next
|
next
|
||||||
|
} else {
|
||||||
|
// If no phrase is playing, prepare for switchover immediately
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn play_pulse (
|
fn play_pulse (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue