mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
reenable playhead for playing clip
This commit is contained in:
parent
0f3103a003
commit
b2680914d7
3 changed files with 28 additions and 11 deletions
|
|
@ -4,9 +4,27 @@ impl<E: Engine> Audio for Arranger<E> {
|
||||||
if let Some(ref transport) = self.transport {
|
if let Some(ref transport) = self.transport {
|
||||||
transport.write().unwrap().process(client, scope);
|
transport.write().unwrap().process(client, scope);
|
||||||
}
|
}
|
||||||
for track in self.arrangement.tracks.iter_mut() {
|
let Arrangement { scenes, ref mut tracks, selected, .. } = &mut self.arrangement;
|
||||||
|
for track in tracks.iter_mut() {
|
||||||
track.player.process(client, scope);
|
track.player.process(client, scope);
|
||||||
}
|
}
|
||||||
|
if let ArrangementFocus::Clip(t, s) = selected {
|
||||||
|
if let Some(Some(Some(phrase))) = scenes.get(*s).map(|scene|scene.clips.get(*t)) {
|
||||||
|
if let Some(track) = tracks.get(*t) {
|
||||||
|
if let Some((ref started_at, Some(ref playing))) = track.player.phrase {
|
||||||
|
let phrase = phrase.read().unwrap();
|
||||||
|
if *playing.read().unwrap() == *phrase {
|
||||||
|
let pulse = self.clock.current.pulse.get();
|
||||||
|
let start = started_at.pulse.get();
|
||||||
|
let now = (pulse - start) % phrase.length as f64;
|
||||||
|
self.editor.now.set(now);
|
||||||
|
return Control::Continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.editor.now.set(0.);
|
||||||
Control::Continue
|
Control::Continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ pub struct PhraseEditor<E: Engine> {
|
||||||
/// Notes currently held at output
|
/// Notes currently held at output
|
||||||
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
||||||
/// Current position of global playhead
|
/// Current position of global playhead
|
||||||
pub now: Arc<AtomicUsize>,
|
pub now: Arc<Pulse>,
|
||||||
/// Width of notes area at last render
|
/// Width of notes area at last render
|
||||||
pub width: AtomicUsize,
|
pub width: AtomicUsize,
|
||||||
/// Height of notes area at last render
|
/// Height of notes area at last render
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ impl Content for PhraseEditor<Tui> {
|
||||||
let ScaledAxis {
|
let ScaledAxis {
|
||||||
start: time_start, point: time_point, clamp: time_clamp, scale: time_scale
|
start: time_start, point: time_point, clamp: time_clamp, scale: time_scale
|
||||||
} = *self.time_axis.read().unwrap();
|
} = *self.time_axis.read().unwrap();
|
||||||
let color = Color::Rgb(0,255,0);
|
//let color = Color::Rgb(0,255,0);
|
||||||
let color = phrase.as_ref().map(|p|p.read().unwrap().color.base.rgb).unwrap_or(color);
|
//let color = phrase.as_ref().map(|p|p.read().unwrap().color.base.rgb).unwrap_or(color);
|
||||||
let keys = CustomWidget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{
|
let keys = CustomWidget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{
|
||||||
Ok(if to.area().h() >= 2 {
|
Ok(if to.area().h() >= 2 {
|
||||||
to.buffer_update(to.area().set_w(5), &|cell, x, y|{
|
to.buffer_update(to.area().set_w(5), &|cell, x, y|{
|
||||||
|
|
@ -109,18 +109,18 @@ impl Content for PhraseEditor<Tui> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
let playhead_inactive = Style::default().fg(Color::Rgb(255,255,255)).bg(Color::Rgb(0,0,0));
|
let playhead_inactive = Style::default().fg(Color::Rgb(255,255,255)).bg(Color::Rgb(40,50,30));
|
||||||
let playhead_active = playhead_inactive.clone().yellow().bold().not_dim();
|
let playhead_active = playhead_inactive.clone().yellow().bold().not_dim();
|
||||||
let playhead = CustomWidget::new(
|
let playhead = CustomWidget::new(
|
||||||
|to:[u16;2]|Ok(Some(to.clip_h(1))),
|
|to:[u16;2]|Ok(Some(to.clip_h(1))),
|
||||||
move|to: &mut TuiOutput|{
|
move|to: &mut TuiOutput|{
|
||||||
if let Some(_) = phrase {
|
if let Some(_) = phrase {
|
||||||
let now = self.now.load(Ordering::Relaxed); // TODO FIXME: self.now % phrase.read().unwrap().length;
|
let now = self.now.get() as usize; // TODO FIXME: self.now % phrase.read().unwrap().length;
|
||||||
let time_clamp = time_clamp
|
let time_clamp = time_clamp
|
||||||
.expect("time_axis of sequencer expected to be clamped");
|
.expect("time_axis of sequencer expected to be clamped");
|
||||||
for x in 0..time_clamp/time_scale {
|
for x in 0..(time_clamp/time_scale).saturating_sub(time_start) {
|
||||||
let this_step = (x * time_scale + time_start + 0) * time_scale;
|
let this_step = time_start + (x + 0) * time_scale;
|
||||||
let next_step = (x * time_scale + time_start + 1) * time_scale;
|
let next_step = time_start + (x + 1) * time_scale;
|
||||||
let x = to.area().x() + x as u16;
|
let x = to.area().x() + x as u16;
|
||||||
let active = this_step <= now && now < next_step;
|
let active = this_step <= now && now < next_step;
|
||||||
let character = if active { "|" } else { "·" };
|
let character = if active { "|" } else { "·" };
|
||||||
|
|
@ -136,8 +136,7 @@ impl Content for PhraseEditor<Tui> {
|
||||||
let border = Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color));
|
let border = Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color));
|
||||||
let note_area = lay!(notes, cursor).fill_x();
|
let note_area = lay!(notes, cursor).fill_x();
|
||||||
let piano_roll = row!(keys, note_area).fill_x();
|
let piano_roll = row!(keys, note_area).fill_x();
|
||||||
let content_bg = Color::Rgb(40, 50, 30);
|
let content = piano_roll.bg(Color::Rgb(40, 50, 30)).border(border);
|
||||||
let content = piano_roll.bg(content_bg).border(border);
|
|
||||||
let content = lay!(content, playhead);
|
let content = lay!(content, playhead);
|
||||||
let mut upper_left = String::from("Sequencer");
|
let mut upper_left = String::from("Sequencer");
|
||||||
if let Some(phrase) = phrase {
|
if let Some(phrase) = phrase {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue