From 43ccfff24a7b7bf24d013722c92a0c097f891ed1 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Tue, 14 Jan 2025 16:52:06 +0100 Subject: [PATCH] more minor cleanups --- midi/src/midi_pool_cmd.rs | 1 + tek/src/lib.rs | 67 ++++++--------------------------------- 2 files changed, 11 insertions(+), 57 deletions(-) diff --git a/midi/src/midi_pool_cmd.rs b/midi/src/midi_pool_cmd.rs index ba2f677f..0fe636a7 100644 --- a/midi/src/midi_pool_cmd.rs +++ b/midi/src/midi_pool_cmd.rs @@ -1,4 +1,5 @@ use crate::*; +use KeyCode::*; #[derive(Clone, PartialEq, Debug)] pub enum PoolCommand { Show(bool), diff --git a/tek/src/lib.rs b/tek/src/lib.rs index 313b90ee..801882b0 100644 --- a/tek/src/lib.rs +++ b/tek/src/lib.rs @@ -6,14 +6,13 @@ #![feature(impl_trait_in_assoc_type)] #![feature(type_alias_impl_trait)] pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering::{self, *}}}; -pub(crate) use std::error::Error; /// Standard result type. -pub type Usually = std::result::Result>; +pub type Usually = std::result::Result>; /// Standard optional result type. -pub type Perhaps = std::result::Result, Box>; +pub type Perhaps = std::result::Result, Box>; pub use ::tek_time::{self, *}; -pub use ::tek_jack::{self, *, jack::{*, contrib::*}}; -pub use ::tek_midi::{self, *, midly::{*, num::*, live::*}}; +pub use ::tek_jack::{self, *, jack::*}; +pub use ::tek_midi::{self, *, midly::{MidiMessage, num::*, live::*}}; pub use ::tek_sampler::{self, *}; pub use ::tek_plugin::{self, *}; pub use ::tek_tui::{ @@ -910,64 +909,18 @@ audio!(|self: App, client, scope|{ } } } - // Update track sequencers - let tracks = &mut self.tracks; - let note_buf = &mut self.note_buf; - let midi_buf = &mut self.midi_buf; - if Control::Quit == TracksAudio(tracks, note_buf, midi_buf).process(client, scope) { - return Control::Quit + for track in self.tracks.iter_mut() { + if PlayerAudio( + track.player_mut(), &mut self.note_buf, &mut self.midi_buf + ).process(client, scope) == Control::Quit { + return Control::Quit + } } - - // TODO: update timeline position in editor. - // must be in sync with clip's playback. since - // a clip can be on multiple tracks and launched - // at different times, add a playhead with the - // playing track's color. - //self.now.set(0.); - //if let Selection::Clip(t, s) = self.selected { - //let clip = self.scenes.get(s).map(|scene|scene.clips.get(t)); - //if let Some(Some(Some(clip))) = clip { - //if let Some(track) = self.tracks().get(t) { - //if let Some((ref started_at, Some(ref playing))) = track.player.play_clip { - //let clip = clip.read().unwrap(); - //if *playing.read().unwrap() == *clip { - //let pulse = self.current().pulse.get(); - //let start = started_at.pulse.get(); - //let now = (pulse - start) % clip.length as f64; - //self.now.set(now); - //} - //} - //} - //} - //} - // End profiling cycle self.perf.update(t0, scope); Control::Continue }); -/// Hosts the JACK callback for a collection of tracks -struct TracksAudio<'a>( - // Track collection - &'a mut [Track], - /// Note buffer - &'a mut Vec, - /// Note chunk buffer - &'a mut Vec>>, -); -impl Audio for TracksAudio<'_> { - fn process (&mut self, client: &Client, scope: &ProcessScope) -> Control { - let model = &mut self.0; - let note_buffer = &mut self.1; - let output_buffer = &mut self.2; - for track in model.iter_mut() { - if PlayerAudio(track.player_mut(), note_buffer, output_buffer).process(client, scope) == Control::Quit { - return Control::Quit - } - } - Control::Continue - } -} fn help_tag <'a> (before: &'a str, key: &'a str, after: &'a str) -> impl Content + 'a { let lo = TuiTheme::g(128); let hi = TuiTheme::orange();