mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
create input/output per track
This commit is contained in:
parent
b1ff549514
commit
bc9be689a8
7 changed files with 93 additions and 84 deletions
|
|
@ -153,12 +153,21 @@ impl<E: Engine> Arranger<E> {
|
|||
}
|
||||
Ok(Some(true))
|
||||
}
|
||||
pub fn next_color (&self) -> ItemColor {
|
||||
if let ArrangementFocus::Clip(track, scene) = self.arrangement.selected {
|
||||
let track_color = self.arrangement.tracks[track].color;
|
||||
let scene_color = self.arrangement.scenes[scene].color;
|
||||
track_color.mix(scene_color, 0.5).mix(ItemColor::random(), 0.25)
|
||||
} else {
|
||||
panic!("could not compute next color")
|
||||
}
|
||||
}
|
||||
/// Focus the editor with the current phrase
|
||||
pub fn show_phrase (&mut self) { self.editor.show(self.arrangement.phrase().as_ref()); }
|
||||
/// Focus the editor with the current phrase
|
||||
pub fn edit_phrase (&mut self) {
|
||||
if self.arrangement.phrase().is_none() {
|
||||
self.phrases.write().unwrap().append_new(None, None);
|
||||
if self.arrangement.selected.is_clip() && self.arrangement.phrase().is_none() {
|
||||
self.phrases.write().unwrap().append_new(None, Some(self.next_color().into()));
|
||||
self.arrangement.phrase_put();
|
||||
}
|
||||
self.show_phrase();
|
||||
|
|
@ -415,7 +424,7 @@ impl<E: Engine> Arrangement<E> {
|
|||
|name| ArrangementTrack::new(
|
||||
&self.jack, &self.clock, name, color
|
||||
),
|
||||
));
|
||||
)?);
|
||||
let index = self.tracks.len() - 1;
|
||||
Ok(&mut self.tracks[index])
|
||||
}
|
||||
|
|
@ -456,7 +465,9 @@ impl<E: Engine> Arrangement<E> {
|
|||
pub fn scene_prev (&mut self) {
|
||||
self.selected.scene_prev()
|
||||
}
|
||||
pub fn scene_add (&mut self, name: Option<&str>, color: Option<ItemColor>) -> Usually<&mut Scene> {
|
||||
pub fn scene_add (
|
||||
&mut self, name: Option<&str>, color: Option<ItemColor>
|
||||
) -> Usually<&mut Scene> {
|
||||
let clips = vec![None;self.tracks.len()];
|
||||
let name = name.map(|x|x.to_string()).unwrap_or_else(||self.scene_default_name());
|
||||
self.scenes.push(Scene::new(name, clips, color));
|
||||
|
|
@ -488,11 +499,9 @@ impl<E: Engine> Arrangement<E> {
|
|||
let scene_index = self.selected.scene();
|
||||
track_index
|
||||
.and_then(|index|self.tracks.get_mut(index).map(|track|(index, track)))
|
||||
.map(|(track_index, _)|{
|
||||
scene_index
|
||||
.and_then(|index|self.scenes.get_mut(index))
|
||||
.map(|scene|scene.clips[track_index] = None);
|
||||
});
|
||||
.map(|(track_index, _)|scene_index
|
||||
.and_then(|index|self.scenes.get_mut(index))
|
||||
.map(|scene|scene.clips[track_index] = None));
|
||||
}
|
||||
pub fn phrase_put (&mut self) {
|
||||
if let ArrangementFocus::Clip(track, scene) = self.selected {
|
||||
|
|
@ -542,13 +551,13 @@ impl ArrangementTrack {
|
|||
clock: &Arc<TransportTime>,
|
||||
name: &str,
|
||||
color: Option<ItemColor>
|
||||
) -> Self {
|
||||
Self {
|
||||
) -> Usually<Self> {
|
||||
Ok(Self {
|
||||
name: Arc::new(RwLock::new(name.into())),
|
||||
width: name.len() + 2,
|
||||
color: color.unwrap_or_else(ItemColor::random),
|
||||
player: PhrasePlayer::new(&jack, clock),
|
||||
}
|
||||
player: PhrasePlayer::new(&jack, clock, name)?,
|
||||
})
|
||||
}
|
||||
pub fn longest_name (tracks: &[Self]) -> usize {
|
||||
tracks.iter().map(|s|s.name.read().unwrap().len()).fold(0, usize::max)
|
||||
|
|
@ -583,35 +592,35 @@ impl ArrangementFocus {
|
|||
}
|
||||
})
|
||||
}
|
||||
pub fn is_mix (&self) -> bool { match self { Self::Mix => true, _ => false } }
|
||||
pub fn is_track (&self) -> bool { match self { Self::Track(_) => true, _ => false } }
|
||||
pub fn is_scene (&self) -> bool { match self { Self::Scene(_) => true, _ => false } }
|
||||
pub fn is_mix (&self) -> bool { match self { Self::Mix => true, _ => false } }
|
||||
pub fn is_track (&self) -> bool { match self { Self::Track(_) => true, _ => false } }
|
||||
pub fn is_scene (&self) -> bool { match self { Self::Scene(_) => true, _ => false } }
|
||||
pub fn is_clip (&self) -> bool { match self { Self::Clip(_, _) => true, _ => false } }
|
||||
pub fn track (&self) -> Option<usize> {
|
||||
match self { Self::Clip(t, _) => Some(*t), Self::Track(t) => Some(*t), _ => None }
|
||||
}
|
||||
pub fn track_next (&mut self, last_track: usize) {
|
||||
*self = match self {
|
||||
Self::Mix => Self::Track(0),
|
||||
Self::Track(t) => Self::Track(last_track.min(*t + 1)),
|
||||
Self::Scene(s) => Self::Clip(0, *s),
|
||||
Self::Clip(t, s) => Self::Clip(last_track.min(*t + 1), *s),
|
||||
Self::Mix =>
|
||||
Self::Track(0),
|
||||
Self::Track(t) =>
|
||||
Self::Track(last_track.min(*t + 1)),
|
||||
Self::Scene(s) =>
|
||||
Self::Clip(0, *s),
|
||||
Self::Clip(t, s) =>
|
||||
Self::Clip(last_track.min(*t + 1), *s),
|
||||
}
|
||||
}
|
||||
pub fn track_prev (&mut self) {
|
||||
*self = match self {
|
||||
Self::Mix => Self::Mix,
|
||||
Self::Scene(s) => Self::Scene(*s),
|
||||
Self::Track(t) => if *t == 0 {
|
||||
Self::Mix
|
||||
} else {
|
||||
Self::Track(*t - 1)
|
||||
},
|
||||
Self::Clip(t, s) => if *t == 0 {
|
||||
Self::Scene(*s)
|
||||
} else {
|
||||
Self::Clip(t.saturating_sub(1), *s)
|
||||
}
|
||||
Self::Mix =>
|
||||
Self::Mix,
|
||||
Self::Scene(s) =>
|
||||
Self::Scene(*s),
|
||||
Self::Track(t) =>
|
||||
if *t == 0 { Self::Mix } else { Self::Track(*t - 1) },
|
||||
Self::Clip(t, s) =>
|
||||
if *t == 0 { Self::Scene(*s) } else { Self::Clip(t.saturating_sub(1), *s) }
|
||||
}
|
||||
}
|
||||
pub fn scene (&self) -> Option<usize> {
|
||||
|
|
@ -619,26 +628,26 @@ impl ArrangementFocus {
|
|||
}
|
||||
pub fn scene_next (&mut self, last_scene: usize) {
|
||||
*self = match self {
|
||||
Self::Mix => Self::Scene(0),
|
||||
Self::Track(t) => Self::Clip(*t, 0),
|
||||
Self::Scene(s) => Self::Scene(last_scene.min(*s + 1)),
|
||||
Self::Clip(t, s) => Self::Clip(*t, last_scene.min(*s + 1)),
|
||||
Self::Mix =>
|
||||
Self::Scene(0),
|
||||
Self::Track(t) =>
|
||||
Self::Clip(*t, 0),
|
||||
Self::Scene(s) =>
|
||||
Self::Scene(last_scene.min(*s + 1)),
|
||||
Self::Clip(t, s) =>
|
||||
Self::Clip(*t, last_scene.min(*s + 1)),
|
||||
}
|
||||
}
|
||||
pub fn scene_prev (&mut self) {
|
||||
*self = match self {
|
||||
Self::Mix => Self::Mix,
|
||||
Self::Track(t) => Self::Track(*t),
|
||||
Self::Scene(s) => if *s == 0 {
|
||||
Self::Mix
|
||||
} else {
|
||||
Self::Scene(*s - 1)
|
||||
},
|
||||
Self::Clip(t, s) => if *s == 0 {
|
||||
Self::Track(*t)
|
||||
} else {
|
||||
Self::Clip(*t, s.saturating_sub(1))
|
||||
}
|
||||
Self::Mix =>
|
||||
Self::Mix,
|
||||
Self::Track(t) =>
|
||||
Self::Track(*t),
|
||||
Self::Scene(s) =>
|
||||
if *s == 0 { Self::Mix } else { Self::Scene(*s - 1) },
|
||||
Self::Clip(t, s) =>
|
||||
if *s == 0 { Self::Track(*t) } else { Self::Clip(*t, s.saturating_sub(1)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue