mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
refactor midi player api
This commit is contained in:
parent
a26a1f2967
commit
71e19c9800
11 changed files with 159 additions and 183 deletions
|
|
@ -91,79 +91,6 @@ impl TuiTheme {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_midi_player {
|
||||
($Struct:ident $(:: $field:ident)*) => {
|
||||
impl HasPhrase for $Struct {
|
||||
fn reset (&self) -> bool {
|
||||
self$(.$field)*.reset
|
||||
}
|
||||
fn reset_mut (&mut self) -> &mut bool {
|
||||
&mut self$(.$field)*.reset
|
||||
}
|
||||
fn play_phrase (&self) -> &Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
&self$(.$field)*.play_phrase
|
||||
}
|
||||
fn play_phrase_mut (&mut self) -> &mut Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
&mut self$(.$field)*.play_phrase
|
||||
}
|
||||
fn next_phrase (&self) -> &Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
&self$(.$field)*.next_phrase
|
||||
}
|
||||
fn next_phrase_mut (&mut self) -> &mut Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
&mut self$(.$field)*.next_phrase
|
||||
}
|
||||
}
|
||||
impl MidiInputApi for $Struct {
|
||||
fn midi_ins (&self) -> &Vec<Port<jack::MidiIn>> {
|
||||
&self$(.$field)*.midi_ins
|
||||
}
|
||||
fn midi_ins_mut (&mut self) -> &mut Vec<Port<jack::MidiIn>> {
|
||||
&mut self$(.$field)*.midi_ins
|
||||
}
|
||||
fn recording (&self) -> bool {
|
||||
self$(.$field)*.recording
|
||||
}
|
||||
fn recording_mut (&mut self) -> &mut bool {
|
||||
&mut self$(.$field)*.recording
|
||||
}
|
||||
fn monitoring (&self) -> bool {
|
||||
self$(.$field)*.monitoring
|
||||
}
|
||||
fn monitoring_mut (&mut self) -> &mut bool {
|
||||
&mut self$(.$field)*.monitoring
|
||||
}
|
||||
fn overdub (&self) -> bool {
|
||||
self$(.$field)*.overdub
|
||||
}
|
||||
fn overdub_mut (&mut self) -> &mut bool {
|
||||
&mut self$(.$field)*.overdub
|
||||
}
|
||||
fn notes_in (&self) -> &Arc<RwLock<[bool; 128]>> {
|
||||
&self$(.$field)*.notes_in
|
||||
}
|
||||
}
|
||||
impl MidiOutputApi for $Struct {
|
||||
fn midi_outs (&self) -> &Vec<Port<jack::MidiOut>> {
|
||||
&self$(.$field)*.midi_outs
|
||||
}
|
||||
fn midi_outs_mut (&mut self) -> &mut Vec<Port<jack::MidiOut>> {
|
||||
&mut self$(.$field)*.midi_outs
|
||||
}
|
||||
fn midi_note (&mut self) -> &mut Vec<u8> {
|
||||
&mut self$(.$field)*.note_buf
|
||||
}
|
||||
fn notes_out (&self) -> &Arc<RwLock<[bool; 128]>> {
|
||||
&self$(.$field)*.notes_in
|
||||
}
|
||||
}
|
||||
impl MidiPlayerApi for $Struct {}
|
||||
}
|
||||
}
|
||||
|
||||
impl_midi_player!(SequencerTui::player);
|
||||
impl_midi_player!(ArrangerTrack::player);
|
||||
impl_midi_player!(PhrasePlayerModel);
|
||||
|
||||
use std::fmt::{Debug, Formatter, Error};
|
||||
type DebugResult = std::result::Result<(), Error>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue