mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
wip: refactor pt.12, separate tek_snd
This commit is contained in:
parent
47c9cd2fe8
commit
2be7aee002
28 changed files with 955 additions and 766 deletions
37
crates/tek_snd/src/snd_sequencer.rs
Normal file
37
crates/tek_snd/src/snd_sequencer.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct MIDIPlayerAudio {
|
||||
model: Arc<RwLock<MIDIPlayer>>
|
||||
}
|
||||
|
||||
impl From<&Arc<RwLock<MIDIPlayer>>> for MIDIPlayerAudio {
|
||||
fn from (model: &Arc<RwLock<MIDIPlayer>>) -> Self {
|
||||
Self { model: model.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
/// JACK process callback for a sequencer's phrase player/recorder.
|
||||
impl Audio for MIDIPlayer {
|
||||
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
let has_midi_outputs = self.has_midi_outputs();
|
||||
let has_midi_inputs = self.has_midi_inputs();
|
||||
// Clear output buffer(s)
|
||||
self.clear(scope, false);
|
||||
// Write chunk of phrase to output, handle switchover
|
||||
if self.play(scope) {
|
||||
self.switchover(scope);
|
||||
}
|
||||
if has_midi_inputs {
|
||||
if self.recording || self.monitoring {
|
||||
// Record and/or monitor input
|
||||
self.record(scope)
|
||||
} else if has_midi_outputs && self.monitoring {
|
||||
// Monitor input to output
|
||||
self.monitor(scope)
|
||||
}
|
||||
}
|
||||
// Write to output port(s)
|
||||
self.write(scope);
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue