mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-11 22:26:44 +01:00
wip: refactor pt.41 (57e) nice
This commit is contained in:
parent
c875d87c33
commit
8856353eab
32 changed files with 911 additions and 1019 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::*;
|
||||
|
||||
pub trait HasTracks<T: ArrangerTrackApi> {
|
||||
pub trait HasTracks<T: ArrangerTrackApi>: Send + Sync {
|
||||
fn tracks (&self) -> &Vec<T>;
|
||||
fn tracks_mut (&mut self) -> &mut Vec<T>;
|
||||
fn track_add (&mut self, name: Option<&str>, color: Option<ItemColor>)-> Usually<&mut T>;
|
||||
|
|
@ -31,7 +31,7 @@ pub enum ArrangerTrackCommand {
|
|||
//}
|
||||
//}
|
||||
|
||||
pub trait ArrangerTrackApi: Sized {
|
||||
pub trait ArrangerTrackApi: PlayerApi + Send + Sync + Sized {
|
||||
/// Name of track
|
||||
fn name (&self) -> Arc<RwLock<String>>;
|
||||
/// Preferred width of track column
|
||||
|
|
@ -40,8 +40,6 @@ pub trait ArrangerTrackApi: Sized {
|
|||
fn width_mut (&mut self) -> &mut usize;
|
||||
/// Identifying color of track
|
||||
fn color (&self) -> ItemColor;
|
||||
/// The MIDI player for the track
|
||||
fn player (&self) -> &impl PlayerApi;
|
||||
|
||||
fn longest_name (tracks: &[Self]) -> usize {
|
||||
tracks.iter().map(|s|s.name().read().unwrap().len()).fold(0, usize::max)
|
||||
|
|
@ -59,3 +57,29 @@ pub trait ArrangerTrackApi: Sized {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Hosts the JACK callback for a collection of tracks
|
||||
pub struct TracksAudio<'a, T: ArrangerTrackApi, H: HasTracks<T>>(
|
||||
// Track collection
|
||||
pub &'a mut H,
|
||||
/// Note buffer
|
||||
pub &'a mut Vec<u8>,
|
||||
/// Note chunk buffer
|
||||
pub &'a mut Vec<Vec<Vec<u8>>>,
|
||||
/// Marker
|
||||
pub PhantomData<T>,
|
||||
);
|
||||
|
||||
impl<'a, T: ArrangerTrackApi, H: HasTracks<T>> Audio for TracksAudio<'a, T, H> {
|
||||
#[inline] 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.tracks_mut().iter_mut() {
|
||||
if PlayerAudio(track, note_buffer, output_buffer).process(client, scope) == Control::Quit {
|
||||
return Control::Quit
|
||||
}
|
||||
}
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue