move pool to tek_midi; implement some Default

This commit is contained in:
🪞👃🪞 2025-01-11 23:11:43 +01:00
parent bb52555183
commit 1aa0551931
17 changed files with 779 additions and 775 deletions

View file

@ -23,9 +23,9 @@ pub struct MidiPlayer {
/// State of clock and playhead
pub clock: Clock,
/// Start time and clip being played
pub play_clip: Option<(Moment, Option<Arc<RwLock<MidiClip>>>)>,
pub play_clip: Option<(Moment, Option<Arc<RwLock<MidiClip>>>)>,
/// Start time and next clip
pub next_clip: Option<(Moment, Option<Arc<RwLock<MidiClip>>>)>,
pub next_clip: Option<(Moment, Option<Arc<RwLock<MidiClip>>>)>,
/// Play input through output.
pub monitoring: bool,
/// Write input to sequence.
@ -45,6 +45,26 @@ pub struct MidiPlayer {
/// MIDI output buffer
pub note_buf: Vec<u8>,
}
impl Default for MidiPlayer {
fn default () -> Self {
Self {
play_clip: None,
next_clip: None,
recording: false,
monitoring: false,
overdub: false,
notes_in: RwLock::new([false;128]).into(),
notes_out: RwLock::new([false;128]).into(),
note_buf: vec![0;8],
reset: true,
midi_ins: vec![],
midi_outs: vec![],
clock: Clock::default(),
}
}
}
impl MidiPlayer {
pub fn new (
jack: &Arc<RwLock<JackConnection>>,
@ -56,20 +76,11 @@ impl MidiPlayer {
let name = name.as_ref();
let clock = Clock::from(jack);
Ok(Self {
play_clip: Some((Moment::zero(&clock.timebase), clip.cloned())),
next_clip: None,
recording: false,
monitoring: false,
overdub: false,
notes_in: RwLock::new([false;128]).into(),
notes_out: RwLock::new([false;128]).into(),
note_buf: vec![0;8],
reset: true,
midi_ins: vec![JackPort::<MidiIn>::new(jack, format!("M/{name}"), midi_from)?,],
midi_outs: vec![JackPort::<MidiOut>::new(jack, format!("{name}/M"), midi_to)?, ],
play_clip: Some((Moment::zero(&clock.timebase), clip.cloned())),
clock,
..Default::default()
})
}
pub fn play_status (&self) -> impl Content<TuiOut> {