mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
more updates to space and transport
This commit is contained in:
parent
9fa858f226
commit
304ce35cbb
6 changed files with 139 additions and 140 deletions
|
|
@ -18,10 +18,13 @@ from_jack!(|jack|TransportTui Self {
|
|||
cursor: (0, 0),
|
||||
focus: TransportFocus::PlayPause
|
||||
});
|
||||
has_clock!(|self:TransportTui|&self.clock);
|
||||
audio!(|self:TransportTui,client,scope|ClockAudio(self).process(client, scope));
|
||||
handle!(<Tui>|self:TransportTui,from|TransportCommand::execute_with_state(self, from));
|
||||
render!(<Tui>|self: TransportTui|TransportView::from((self, None, true)));
|
||||
has_clock!(|self: TransportTui|&self.clock);
|
||||
audio!(|self: TransportTui, client, scope|ClockAudio(self).process(client, scope));
|
||||
handle!(<Tui>|self: TransportTui, from|TransportCommand::execute_with_state(self, from));
|
||||
render!(<Tui>|self: TransportTui|row!([
|
||||
Fixed::wh(5, 3, PlayPause(false)),
|
||||
Fixed::h(3, TransportView::new(self, None, true))
|
||||
]));
|
||||
impl std::fmt::Debug for TransportTui {
|
||||
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||
f.debug_struct("TransportTui")
|
||||
|
|
@ -46,8 +49,8 @@ pub struct TransportView {
|
|||
current_sample: f64,
|
||||
current_second: f64,
|
||||
}
|
||||
impl<T: HasClock> From<(&T, Option<ItemPalette>, bool)> for TransportView {
|
||||
fn from ((state, color, focused): (&T, Option<ItemPalette>, bool)) -> Self {
|
||||
impl TransportView {
|
||||
pub fn new (state: &impl HasClock, color: Option<ItemPalette>, focused: bool) -> Self {
|
||||
let clock = state.clock();
|
||||
let rate = clock.timebase.sr.get();
|
||||
let chunk = clock.chunk.load(Relaxed);
|
||||
|
|
@ -58,61 +61,56 @@ impl<T: HasClock> From<(&T, Option<ItemPalette>, bool)> for TransportView {
|
|||
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 (
|
||||
global_sample, global_second, current_sample, current_second, beat
|
||||
) = 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, chunk, latency,
|
||||
started: true,
|
||||
global_sample: format!("{:.0}k", started.sample.get()/1000.),
|
||||
global_second: format!("{:.1}s", started.usec.get()/1000.),
|
||||
current_sample,
|
||||
current_second,
|
||||
beat: clock.timebase.format_beats_0(
|
||||
clock.timebase.usecs_to_pulse(current_usec)
|
||||
),
|
||||
}
|
||||
let global_sample = format!("{:.0}k", started.sample.get()/1000.);
|
||||
let global_second = format!("{:.1}s", started.usec.get()/1000.);
|
||||
let beat = clock.timebase.format_beats_1(clock.timebase.usecs_to_pulse(current_usec));
|
||||
(global_sample, global_second, current_sample, current_second, beat)
|
||||
} else {
|
||||
Self {
|
||||
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.),
|
||||
current_sample: 0.0,
|
||||
current_second: 0.0,
|
||||
beat: format!("000.0.00")
|
||||
}
|
||||
let global_sample = format!("{:.0}k", clock.global.sample.get()/1000.);
|
||||
let global_second = format!("{:.1}s", clock.global.usec.get()/1000000.);
|
||||
let current_sample = 0.0;
|
||||
let current_second = 0.0;
|
||||
let beat = format!("000.0.00");
|
||||
(global_sample, global_second, current_sample, current_second, beat)
|
||||
};
|
||||
Self {
|
||||
color, focused, sr, bpm, ppq, chunk, latency, started: false,
|
||||
global_sample, global_second, current_sample, current_second, beat
|
||||
}
|
||||
}
|
||||
}
|
||||
render!(<Tui>|self: TransportView|{
|
||||
let color = self.color;
|
||||
struct Field<'a>(&'a str, &'a str, &'a ItemPalette);
|
||||
render!(<Tui>|self: Field<'a>|row!([
|
||||
Tui::fg_bg(self.2.lightest.rgb, self.2.base.rgb, Tui::bold(true, self.0)),
|
||||
Tui::fg_bg(self.2.base.rgb, self.2.darkest.rgb, "▌"),
|
||||
Tui::fg_bg(self.2.lightest.rgb, self.2.darkest.rgb, format!("{:>10}", self.1)),
|
||||
Tui::fg_bg(self.2.darkest.rgb, self.2.base.rgb, "▌"),
|
||||
]));
|
||||
Tui::bg(color.base.rgb, Fill::w(row!([
|
||||
Fixed::h(3, Tui::bg(color.base.rgb, Fill::w(row!([
|
||||
//PlayPause(self.started), " ",
|
||||
col!([
|
||||
Field(" Beat", self.beat.as_str(), &color),
|
||||
Field(" Time", format!("{:.1}s", self.current_second).as_str(), &color),
|
||||
TransportField(" Beat", self.beat.as_str(), &color),
|
||||
TransportField(" Time", format!("{:.1}s", self.current_second).as_str(), &color),
|
||||
TransportField(" BPM", self.bpm.as_str(), &color),
|
||||
]),
|
||||
col!([
|
||||
TransportField(" Rate", format!("{}", self.sr).as_str(), &color),
|
||||
TransportField(" Chunk", format!("{}", self.chunk).as_str(), &color),
|
||||
TransportField(" Lag", format!("{:.3}ms", self.latency).as_str(), &color),
|
||||
]),
|
||||
col!([
|
||||
Field(" BPM", self.bpm.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),
|
||||
]),
|
||||
])))
|
||||
]))))
|
||||
});
|
||||
struct TransportField<'a>(&'a str, &'a str, &'a ItemPalette);
|
||||
render!(<Tui>|self: TransportField<'a>|row!([
|
||||
Tui::fg_bg(self.2.lightest.rgb, self.2.base.rgb, Tui::bold(true, self.0)),
|
||||
Tui::fg_bg(self.2.base.rgb, self.2.darkest.rgb, "▌"),
|
||||
Tui::fg_bg(self.2.lightest.rgb, self.2.darkest.rgb, format!("{:>10}", self.1)),
|
||||
Tui::fg_bg(self.2.darkest.rgb, self.2.base.rgb, "▌"),
|
||||
]));
|
||||
pub struct PlayPause(pub bool);
|
||||
render!(<Tui>|self: PlayPause|Tui::bg(
|
||||
if self.0{Color::Rgb(0,128,0)}else{Color::Rgb(128,64,0)},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue