mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
use edn_command on all midi pool commands
This commit is contained in:
parent
efbabe6248
commit
50b7d8a23d
8 changed files with 194 additions and 188 deletions
|
|
@ -1,14 +1,8 @@
|
|||
use crate::*;
|
||||
|
||||
pub trait MidiPlayerApi: MidiRecordApi + MidiPlaybackApi + Send + Sync {}
|
||||
|
||||
impl MidiPlayerApi for MidiPlayer {}
|
||||
|
||||
pub trait HasPlayer {
|
||||
fn player (&self) -> &impl MidiPlayerApi;
|
||||
fn player_mut (&mut self) -> &mut impl MidiPlayerApi;
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! has_player {
|
||||
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
impl $(<$($L),*$($T $(: $U)?),*>)? HasPlayer for $Struct $(<$($L),*$($T),*>)? {
|
||||
|
|
@ -17,7 +11,8 @@ pub trait HasPlayer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait MidiPlayerApi: MidiRecordApi + MidiPlaybackApi + Send + Sync {}
|
||||
impl MidiPlayerApi for MidiPlayer {}
|
||||
/// Contains state for playing a clip
|
||||
pub struct MidiPlayer {
|
||||
/// State of clock and playhead
|
||||
|
|
@ -83,17 +78,11 @@ impl MidiPlayer {
|
|||
..Default::default()
|
||||
})
|
||||
}
|
||||
pub fn play_status (&self) -> impl Content<TuiOut> {
|
||||
ClipSelected::play_clip(self)
|
||||
}
|
||||
pub fn next_status (&self) -> impl Content<TuiOut> {
|
||||
ClipSelected::next_clip(self)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Debug for MidiPlayer {
|
||||
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||
f.debug_struct("MidiPlayer")
|
||||
.field("clock", &self.clock)
|
||||
.field("clock", &self.clock)
|
||||
.field("play_clip", &self.play_clip)
|
||||
.field("next_clip", &self.next_clip)
|
||||
.finish()
|
||||
|
|
@ -129,7 +118,6 @@ impl HasMidiOuts for MidiPlayer {
|
|||
fn midi_outs_mut (&mut self) -> &mut Vec<JackPort<MidiOut>> { &mut self.midi_outs }
|
||||
fn midi_note (&mut self) -> &mut Vec<u8> { &mut self.note_buf }
|
||||
}
|
||||
|
||||
/// Hosts the JACK callback for a single MIDI player
|
||||
pub struct PlayerAudio<'a, T: MidiPlayerApi>(
|
||||
/// Player
|
||||
|
|
@ -139,7 +127,6 @@ pub struct PlayerAudio<'a, T: MidiPlayerApi>(
|
|||
/// Note chunk buffer
|
||||
pub &'a mut Vec<Vec<Vec<u8>>>,
|
||||
);
|
||||
|
||||
/// JACK process callback for a sequencer's clip player/recorder.
|
||||
impl<T: MidiPlayerApi> Audio for PlayerAudio<'_, T> {
|
||||
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
|
|
@ -166,7 +153,6 @@ impl<T: MidiPlayerApi> Audio for PlayerAudio<'_, T> {
|
|||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
||||
impl MidiRecordApi for MidiPlayer {
|
||||
fn recording (&self) -> bool {
|
||||
self.recording
|
||||
|
|
@ -190,13 +176,11 @@ impl MidiRecordApi for MidiPlayer {
|
|||
&self.notes_in
|
||||
}
|
||||
}
|
||||
|
||||
impl MidiPlaybackApi for MidiPlayer {
|
||||
fn notes_out (&self) -> &Arc<RwLock<[bool; 128]>> {
|
||||
&self.notes_out
|
||||
}
|
||||
}
|
||||
|
||||
impl HasPlayClip for MidiPlayer {
|
||||
fn reset (&self) -> bool {
|
||||
self.reset
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue