mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
more stats in transport
This commit is contained in:
parent
ba56c1909d
commit
7e02a46beb
3 changed files with 42 additions and 26 deletions
|
|
@ -10,20 +10,20 @@ mod arranger_h;
|
|||
|
||||
/// Root view for standalone `tek_arranger`
|
||||
pub struct ArrangerTui {
|
||||
jack: Arc<RwLock<JackClient>>,
|
||||
pub clock: ClockModel,
|
||||
pub phrases: PoolModel,
|
||||
pub tracks: Vec<ArrangerTrack>,
|
||||
pub scenes: Vec<ArrangerScene>,
|
||||
pub splits: [u16;2],
|
||||
pub selected: ArrangerSelection,
|
||||
pub mode: ArrangerMode,
|
||||
pub color: ItemPalette,
|
||||
pub size: Measure<Tui>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub editor: MidiEditorModel,
|
||||
pub perf: PerfModel,
|
||||
jack: Arc<RwLock<JackClient>>,
|
||||
pub clock: ClockModel,
|
||||
pub phrases: PoolModel,
|
||||
pub tracks: Vec<ArrangerTrack>,
|
||||
pub scenes: Vec<ArrangerScene>,
|
||||
pub splits: [u16;2],
|
||||
pub selected: ArrangerSelection,
|
||||
pub mode: ArrangerMode,
|
||||
pub color: ItemPalette,
|
||||
pub size: Measure<Tui>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub editor: MidiEditorModel,
|
||||
pub perf: PerfModel,
|
||||
}
|
||||
impl ArrangerTui {
|
||||
pub fn selected (&self) -> ArrangerSelection {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ pub struct PerfModel {
|
|||
period: AtomicF64,
|
||||
}
|
||||
|
||||
pub trait HasPerf {
|
||||
fn perf (&self) -> &PerfModel;
|
||||
}
|
||||
|
||||
impl Default for PerfModel {
|
||||
fn default () -> Self {
|
||||
Self {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ pub struct TransportView {
|
|||
color: ItemPalette,
|
||||
focused: bool,
|
||||
sr: String,
|
||||
chunk: String,
|
||||
latency: String,
|
||||
bpm: String,
|
||||
ppq: String,
|
||||
beat: String,
|
||||
|
|
@ -46,17 +48,22 @@ pub struct TransportView {
|
|||
}
|
||||
impl<T: HasClock> From<(&T, Option<ItemPalette>, bool)> for TransportView {
|
||||
fn from ((state, color, focused): (&T, Option<ItemPalette>, bool)) -> Self {
|
||||
let clock = state.clock();
|
||||
let sr = format!("{:.1}k", clock.timebase.sr.get() / 1000.0);
|
||||
let bpm = format!("{:.3}", clock.timebase.bpm.get());
|
||||
let ppq = format!("{:.0}", clock.timebase.ppq.get());
|
||||
let color = color.unwrap_or(ItemPalette::from(TuiTheme::g(32)));
|
||||
let clock = state.clock();
|
||||
let rate = clock.timebase.sr.get();
|
||||
let chunk = clock.chunk.load(Relaxed);
|
||||
let latency = chunk as f64 / rate * 1000.;
|
||||
let sr = format!("{:.1}k", rate / 1000.0);
|
||||
let bpm = format!("{:.3}", clock.timebase.bpm.get());
|
||||
let ppq = format!("{:.0}", clock.timebase.ppq.get());
|
||||
let chunk = format!("{chunk}");
|
||||
let latency = format!("{latency}");
|
||||
let color = color.unwrap_or(ItemPalette::from(TuiTheme::g(32)));
|
||||
if let Some(started) = clock.started.read().unwrap().as_ref() {
|
||||
let current_sample = (clock.global.sample.get() - started.sample.get())/1000.;
|
||||
let current_usec = clock.global.usec.get() - started.usec.get();
|
||||
let current_second = current_usec/1000000.;
|
||||
Self {
|
||||
color, focused, sr, bpm, ppq,
|
||||
color, focused, sr, bpm, ppq, chunk, latency,
|
||||
started: true,
|
||||
global_sample: format!("{:.0}k", started.sample.get()/1000.),
|
||||
global_second: format!("{:.1}s", started.usec.get()/1000.),
|
||||
|
|
@ -68,7 +75,7 @@ impl<T: HasClock> From<(&T, Option<ItemPalette>, bool)> for TransportView {
|
|||
}
|
||||
} else {
|
||||
Self {
|
||||
color, focused, sr, bpm, ppq,
|
||||
color, focused, sr, bpm, ppq, chunk, latency,
|
||||
started: false,
|
||||
global_sample: format!("{:.0}k", clock.global.sample.get()/1000.),
|
||||
global_second: format!("{:.1}s", clock.global.usec.get()/1000000.),
|
||||
|
|
@ -91,13 +98,18 @@ render!(<Tui>|self: TransportView|{
|
|||
Tui::bg(color.base.rgb, Fill::w(row!([
|
||||
//PlayPause(self.started), " ",
|
||||
col!([
|
||||
Field(" Beat", self.beat.as_str(), &color),
|
||||
Field(" BPM", self.bpm.as_str(), &color),
|
||||
Field(" Beat", self.beat.as_str(), &color),
|
||||
Field(" BPM", self.bpm.as_str(), &color),
|
||||
]),
|
||||
" ",
|
||||
col!([
|
||||
Field("Time", format!("{:.1}s", self.current_second).as_str(), &color),
|
||||
Field("Smpl", format!("{:.1}k", self.current_sample).as_str(), &color),
|
||||
Field(" Time", format!("{:.1}s", self.current_second).as_str(), &color),
|
||||
//Field(" Smpl", format!("{:.1}k", self.current_sample).as_str(), &color),
|
||||
Field(" Rate", format!("{}", self.sr).as_str(), &color),
|
||||
//Field(" CPU%", format!("{:.1}ms", self.perf).as_str(), &color),
|
||||
]),
|
||||
col!([
|
||||
Field(" Chunk", format!("{}", self.chunk).as_str(), &color),
|
||||
Field(" Lag", format!("{:.3}ms", self.latency).as_str(), &color),
|
||||
]),
|
||||
])))
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue