mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-10 21:56:42 +01:00
wip: refactor pt.21: 48 errors
This commit is contained in:
parent
2188bccd63
commit
b8708d6b2d
15 changed files with 313 additions and 355 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Arrangement {
|
||||
pub struct ArrangerModel {
|
||||
/// JACK client handle (needs to not be dropped for standalone mode to work).
|
||||
pub jack: Arc<RwLock<JackClient>>,
|
||||
/// Global timebase
|
||||
|
|
@ -9,15 +9,15 @@ pub struct Arrangement {
|
|||
/// Name of arranger
|
||||
pub name: Arc<RwLock<String>>,
|
||||
/// Collection of phrases.
|
||||
pub phrases: Arc<RwLock<Vec<Phrase>>>,
|
||||
pub phrases: Arc<RwLock<PhrasePool>>,
|
||||
/// Collection of tracks.
|
||||
pub tracks: Vec<ArrangementTrack>,
|
||||
pub tracks: Vec<ArrangerTrack>,
|
||||
/// Collection of scenes.
|
||||
pub scenes: Vec<ArrangementScene>,
|
||||
pub scenes: Vec<ArrangerScene>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ArrangementTrack {
|
||||
pub struct ArrangerTrack {
|
||||
/// Name of track
|
||||
pub name: Arc<RwLock<String>>,
|
||||
/// Preferred width of track column
|
||||
|
|
@ -29,7 +29,7 @@ pub struct ArrangementTrack {
|
|||
}
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct ArrangementScene {
|
||||
pub struct ArrangerScene {
|
||||
/// Name of scene
|
||||
pub name: Arc<RwLock<String>>,
|
||||
/// Clips in scene, one per track
|
||||
|
|
@ -38,7 +38,7 @@ pub struct ArrangementScene {
|
|||
pub color: ItemColor,
|
||||
}
|
||||
|
||||
impl Arrangement {
|
||||
impl ArrangerModel {
|
||||
pub fn is_stopped (&self) -> bool {
|
||||
*self.clock.playing.read().unwrap() == Some(TransportState::Stopped)
|
||||
}
|
||||
|
|
@ -50,9 +50,9 @@ impl Arrangement {
|
|||
}
|
||||
pub fn track_add (
|
||||
&mut self, name: Option<&str>, color: Option<ItemColor>
|
||||
) -> Usually<&mut ArrangementTrack> {
|
||||
) -> Usually<&mut ArrangerTrack> {
|
||||
let name = name.map_or_else(||self.track_default_name(), |x|x.to_string());
|
||||
self.tracks.push(ArrangementTrack {
|
||||
self.tracks.push(ArrangerTrack {
|
||||
width: name.len() + 2,
|
||||
color: color.unwrap_or_else(||ItemColor::random()),
|
||||
player: MIDIPlayer::new(&self.jack, &self.clock, name.as_str())?,
|
||||
|
|
@ -63,9 +63,9 @@ impl Arrangement {
|
|||
}
|
||||
pub fn scene_add (
|
||||
&mut self, name: Option<&str>, color: Option<ItemColor>
|
||||
) -> Usually<&mut ArrangementScene> {
|
||||
) -> Usually<&mut ArrangerScene> {
|
||||
let name = name.map_or_else(||self.scene_default_name(), |x|x.to_string());
|
||||
self.scenes.push(ArrangementScene {
|
||||
self.scenes.push(ArrangerScene {
|
||||
name: Arc::new(name.into()),
|
||||
clips: vec![None;self.tracks.len()],
|
||||
color: color.unwrap_or_else(||ItemColor::random()),
|
||||
|
|
@ -84,7 +84,7 @@ impl Arrangement {
|
|||
}
|
||||
}
|
||||
|
||||
impl ArrangementScene {
|
||||
impl ArrangerScene {
|
||||
pub fn ppqs (scenes: &[Self], factor: usize) -> Vec<(usize, usize)> {
|
||||
let mut total = 0;
|
||||
if factor == 0 {
|
||||
|
|
@ -113,7 +113,7 @@ impl ArrangementScene {
|
|||
|
||||
/// Returns true if all phrases in the scene are
|
||||
/// currently playing on the given collection of tracks.
|
||||
pub fn is_playing (&self, tracks: &[ArrangementTrack]) -> bool {
|
||||
pub fn is_playing (&self, tracks: &[ArrangerTrack]) -> bool {
|
||||
self.clips.iter().any(|clip|clip.is_some()) && self.clips.iter().enumerate()
|
||||
.all(|(track_index, clip)|match clip {
|
||||
Some(clip) => tracks
|
||||
|
|
@ -153,7 +153,7 @@ impl ArrangementScene {
|
|||
//},
|
||||
//_ => panic!("unexpected in scene '{name:?}': {edn:?}")
|
||||
//});
|
||||
//Ok(ArrangementScene {
|
||||
//Ok(ArrangerScene {
|
||||
//name: Arc::new(name.unwrap_or("").to_string().into()),
|
||||
//color: ItemColor::random(),
|
||||
//clips,
|
||||
|
|
@ -161,7 +161,7 @@ impl ArrangementScene {
|
|||
//}
|
||||
}
|
||||
|
||||
impl ArrangementTrack {
|
||||
impl ArrangerTrack {
|
||||
pub fn longest_name (tracks: &[Self]) -> usize {
|
||||
tracks.iter().map(|s|s.name.read().unwrap().len()).fold(0, usize::max)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue