mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
performance meter
This commit is contained in:
parent
a509db7215
commit
398f676ae3
12 changed files with 123 additions and 32 deletions
|
|
@ -23,6 +23,7 @@ pub struct SequencerTui {
|
|||
pub note_buf: Vec<u8>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub focus: FocusState<AppFocus<SequencerFocus>>,
|
||||
pub perf: PerfModel,
|
||||
}
|
||||
|
||||
/// Root view for standalone `tek_arranger`
|
||||
|
|
|
|||
|
|
@ -11,15 +11,13 @@ impl<T: TransportControl> Command<T> for TransportCommand {
|
|||
use TransportCommand::{Focus, Clock};
|
||||
use FocusCommand::{Next, Prev};
|
||||
use ClockCommand::{SetBpm, SetQuant, SetSync};
|
||||
Ok(Some(match self {
|
||||
Focus(Next) => { todo!() }
|
||||
Focus(Prev) => { todo!() },
|
||||
Focus(_) => { unimplemented!() },
|
||||
Clock(SetBpm(bpm)) => Clock(SetBpm(state.bpm().set(bpm))),
|
||||
Clock(SetQuant(quant)) => Clock(SetQuant(state.quant().set(quant))),
|
||||
Clock(SetSync(sync)) => Clock(SetSync(state.sync().set(sync))),
|
||||
Ok(match self {
|
||||
Focus(cmd) => cmd.execute(state)?.map(Focus),
|
||||
Clock(SetBpm(bpm)) => Some(Clock(SetBpm(state.bpm().set(bpm)))),
|
||||
Clock(SetQuant(quant)) => Some(Clock(SetQuant(state.quant().set(quant)))),
|
||||
Clock(SetSync(sync)) => Some(Clock(SetSync(state.sync().set(sync)))),
|
||||
_ => return Ok(None)
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,18 @@ impl<'a, T: TransportViewState> Content for TransportView<'a, T> {
|
|||
impl Content for SequencerTui {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
col!(
|
||||
widget(&TransportView(self)),
|
||||
Split::right(20,
|
||||
widget(&PhrasesView(self)),
|
||||
widget(&PhraseView(self)),
|
||||
).min_y(20)
|
||||
lay!(
|
||||
col!(
|
||||
widget(&TransportView(self)),
|
||||
Split::right(20,
|
||||
widget(&PhrasesView(self)),
|
||||
widget(&PhraseView(self)),
|
||||
).min_y(20)
|
||||
),
|
||||
self.perf.percentage()
|
||||
.map(|cpu|format!("{cpu:.03}%"))
|
||||
.fg(Color::Rgb(255,128,0))
|
||||
.align_sw(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,20 @@
|
|||
use crate::*;
|
||||
|
||||
pub trait TransportControl: ClockApi {
|
||||
pub trait TransportControl: ClockApi + FocusGrid + HasEnter {
|
||||
fn transport_focused (&self) -> Option<TransportFocus>;
|
||||
}
|
||||
|
||||
pub trait SequencerControl: TransportControl {}
|
||||
|
||||
pub trait ArrangerControl: TransportControl {
|
||||
fn selected (&self) -> ArrangerSelection;
|
||||
fn selected_mut (&mut self) -> &mut ArrangerSelection;
|
||||
fn activate (&mut self);
|
||||
fn selected_phrase (&self) -> Option<Arc<RwLock<Phrase>>>;
|
||||
fn toggle_loop (&mut self);
|
||||
fn randomize_color (&mut self);
|
||||
}
|
||||
|
||||
impl TransportControl for TransportTui {
|
||||
fn transport_focused (&self) -> Option<TransportFocus> {
|
||||
if let AppFocus::Content(focus) = self.focus.inner() {
|
||||
|
|
@ -34,19 +45,8 @@ impl TransportControl for ArrangerTui {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait SequencerControl: TransportControl {}
|
||||
|
||||
impl SequencerControl for SequencerTui {}
|
||||
|
||||
pub trait ArrangerControl: TransportControl {
|
||||
fn selected (&self) -> ArrangerSelection;
|
||||
fn selected_mut (&mut self) -> &mut ArrangerSelection;
|
||||
fn activate (&mut self);
|
||||
fn selected_phrase (&self) -> Option<Arc<RwLock<Phrase>>>;
|
||||
fn toggle_loop (&mut self);
|
||||
fn randomize_color (&mut self);
|
||||
}
|
||||
|
||||
impl ArrangerControl for ArrangerTui {
|
||||
fn selected (&self) -> ArrangerSelection {
|
||||
self.selected
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
|
|||
midi_buf: vec![vec![];65536],
|
||||
note_buf: vec![],
|
||||
clock,
|
||||
focus: FocusState::Entered(AppFocus::Content(SequencerFocus::Transport(TransportFocus::Bpm)))
|
||||
focus: FocusState::Entered(AppFocus::Content(SequencerFocus::Transport(TransportFocus::Bpm))),
|
||||
perf: PerfModel::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ impl Audio for TransportTui {
|
|||
|
||||
impl Audio for SequencerTui {
|
||||
fn process (&mut self, client: &Client, scope: &ProcessScope) -> Control {
|
||||
let t0 = self.perf.get_t0();
|
||||
if ClockAudio(self).process(client, scope) == Control::Quit {
|
||||
return Control::Quit
|
||||
}
|
||||
|
|
@ -18,6 +19,7 @@ impl Audio for SequencerTui {
|
|||
).process(client, scope) == Control::Quit {
|
||||
return Control::Quit
|
||||
}
|
||||
self.perf.update(t0, scope);
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ pub struct PhrasePlayerModel {
|
|||
/// Send all notes off
|
||||
pub(crate) reset: bool, // TODO?: after Some(nframes)
|
||||
/// Record from MIDI ports to current sequence.
|
||||
pub(crate) midi_ins: Vec<Port<MidiIn>>,
|
||||
pub midi_ins: Vec<Port<MidiIn>>,
|
||||
/// Play from current sequence to MIDI ports
|
||||
pub(crate) midi_outs: Vec<Port<MidiOut>>,
|
||||
pub midi_outs: Vec<Port<MidiOut>>,
|
||||
/// Notes currently held at input
|
||||
pub(crate) notes_in: Arc<RwLock<[bool; 128]>>,
|
||||
/// Notes currently held at output
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue