show buffer size and latency

This commit is contained in:
🪞👃🪞 2024-11-27 01:30:40 +01:00
parent 763063f4ed
commit 51889d4b43
5 changed files with 33 additions and 14 deletions

View file

@ -30,7 +30,7 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for ArrangerTui {
fn try_from (jack: &Arc<RwLock<JackClient>>) -> Usually<Self> {
Ok(Self {
jack: jack.clone(),
clock: ClockModel::from(&Arc::new(jack.read().unwrap().transport())),
clock: ClockModel::from(jack),
phrases: PhraseListModel::default(),
editor: PhraseEditorModel::default(),
selected: ArrangerSelection::Clip(0, 0),

View file

@ -20,7 +20,7 @@ pub struct SequencerTui {
impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
type Error = Box<dyn std::error::Error>;
fn try_from (jack: &Arc<RwLock<JackClient>>) -> Usually<Self> {
let clock = ClockModel::from(&Arc::new(jack.read().unwrap().transport()));
let clock = ClockModel::from(jack);
Ok(Self {
jack: jack.clone(),
phrases: PhraseListModel::default(),
@ -111,7 +111,7 @@ impl_focus!(SequencerTui SequencerFocus [
pub struct SequencerStatusBar {
pub(crate) cpu: Option<String>,
pub(crate) size: String,
pub(crate) sr: String,
pub(crate) res: String,
pub(crate) mode: &'static str,
pub(crate) help: &'static [(&'static str, &'static str, &'static str)]
}
@ -130,10 +130,13 @@ impl From<&SequencerTui> for SequencerStatusBar {
fn from (state: &SequencerTui) -> Self {
use SequencerFocus::*;
use TransportFocus::*;
let samples = state.clock.chunk.load(Ordering::Relaxed);
let rate = state.clock.current.timebase.sr.get() as f64;
let buffer = samples as f64 / rate;
Self {
cpu: state.perf.percentage().map(|cpu|format!(" {cpu:.01}% ")),
size: format!(" {}x{} ", state.size.w(), state.size.h()),
sr: format!(" {}Hz ", state.clock.current.timebase.sr.get()),
cpu: state.perf.percentage().map(|cpu|format!("{cpu:.01}%")),
size: format!("{}x{}│", state.size.w(), state.size.h()),
res: format!("│{}s│{:.1}kHz│{:.1}ms│", samples, rate / 1000., buffer * 1000.),
mode: match state.focused() {
Transport(focus) => match focus {
PlayPause => " PLAY/PAUSE ",

View file

@ -25,7 +25,7 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for TransportTui {
fn try_from (jack: &Arc<RwLock<JackClient>>) -> Usually<Self> {
Ok(Self {
jack: jack.clone(),
clock: ClockModel::from(&Arc::new(jack.read().unwrap().transport())),
clock: ClockModel::from(jack),
size: Measure::new(),
cursor: (0, 0),
focus: FocusState::Entered(TransportFocus::PlayPause)

View file

@ -34,7 +34,7 @@ impl Content for SequencerStatusBar {
widget(&self.mode).bg(orange).fg(black).bold(true),
row!(
widget(&self.cpu).fg(orange),
widget(&self.sr).fg(orange),
widget(&self.res).fg(orange),
widget(&self.size).fg(orange),
).align_se().fill_x()
)