wip: fixing some assumptions

This commit is contained in:
🪞👃🪞 2024-08-06 16:43:04 +03:00
parent 5ae99b4ada
commit 2a60808239
11 changed files with 73 additions and 125 deletions

View file

@ -15,14 +15,14 @@ impl Scene {
Self { name, clips, }
}
/// Returns the pulse length of the longest phrase in the scene
pub fn pulses (&self, tracks: &[Track]) -> usize {
pub fn pulses (&self, tracks: &[SequencerTrack]) -> usize {
self.clips.iter().enumerate()
.filter_map(|(i, c)|c.map(|c|tracks[i].phrases.get(c)))
.filter_map(|p|p)
.fold(0, |a, p|a.max(p.read().unwrap().length))
}
/// Returns true if all phrases in the scene are currently playing
pub fn is_playing (&self, tracks: &[Track]) -> bool {
pub fn is_playing (&self, tracks: &[SequencerTrack]) -> bool {
self.clips.iter().enumerate()
.all(|(track_index, phrase_index)|match phrase_index {
Some(i) => tracks[track_index].sequence == Some(*i),
@ -37,7 +37,7 @@ pub fn scene_name_max_len (scenes: &[Scene]) -> usize {
.fold(0, usize::max)
}
pub fn scene_ppqs (tracks: &[Track], scenes: &[Scene]) -> Vec<(usize, usize)> {
pub fn scene_ppqs (tracks: &[SequencerTrack], scenes: &[Scene]) -> Vec<(usize, usize)> {
let mut total = 0;
let mut scenes: Vec<(usize, usize)> = scenes.iter().map(|scene|{
let pulses = scene.pulses(tracks);