mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
groovebox: draw sample info
This commit is contained in:
parent
4e2702f69e
commit
e00d870d70
4 changed files with 63 additions and 31 deletions
|
|
@ -8,10 +8,11 @@
|
||||||
(bsp/n (fixed/y 1 :view-status)
|
(bsp/n (fixed/y 1 :view-status)
|
||||||
(bsp/w :view-meters-output
|
(bsp/w :view-meters-output
|
||||||
(bsp/e :view-meters-input
|
(bsp/e :view-meters-input
|
||||||
|
(bsp/n :view-sample-info
|
||||||
(bsp/n (fixed/y 5 :view-sample-viewer)
|
(bsp/n (fixed/y 5 :view-sample-viewer)
|
||||||
(bsp/w (fixed/x :w-sidebar :view-pool)
|
(bsp/w (fixed/x :w-sidebar :view-pool)
|
||||||
(bsp/e :view-samples-keys
|
(bsp/e :view-samples-keys
|
||||||
(fill/y :view-editor))))))))))
|
(fill/y :view-editor)))))))))))
|
||||||
|
|
||||||
(keys
|
(keys
|
||||||
(layer-if :focus-pool-import "./keys_pool_file.edn")
|
(layer-if :focus-pool-import "./keys_pool_file.edn")
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,15 @@ impl App {
|
||||||
pub fn view_sample_viewer (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_sample_viewer (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
self.sampler().map(|s|s.view_sample(self.editor().unwrap().get_note_pos()))
|
self.sampler().map(|s|s.view_sample(self.editor().unwrap().get_note_pos()))
|
||||||
}
|
}
|
||||||
|
pub fn view_sample_info (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
self.sampler().map(|s|s.view_sample_info(self.editor().unwrap().get_note_pos()))
|
||||||
|
}
|
||||||
|
pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
self.sampler().map(|s|s.view_meters_input())
|
||||||
|
}
|
||||||
|
pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
self.sampler().map(|s|s.view_meters_output())
|
||||||
|
}
|
||||||
pub fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
When::new(self.dialog.is_some(), Bsp::b(
|
When::new(self.dialog.is_some(), Bsp::b(
|
||||||
Fill::xy(Tui::fg_bg(Rgb(64,64,64), Rgb(32,32,32), "")),
|
Fill::xy(Tui::fg_bg(Rgb(64,64,64), Rgb(32,32,32), "")),
|
||||||
|
|
@ -56,12 +65,6 @@ impl App {
|
||||||
)))
|
)))
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
|
||||||
self.sampler().map(|s|s.view_meters_input())
|
|
||||||
}
|
|
||||||
pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
|
||||||
self.sampler().map(|s|s.view_meters_output())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::*;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Sampler {
|
pub struct Sampler {
|
||||||
/// Name of sampler.
|
/// Name of sampler.
|
||||||
pub name: String,
|
pub name: Arc<str>,
|
||||||
/// Device color.
|
/// Device color.
|
||||||
pub color: ItemTheme,
|
pub color: ItemTheme,
|
||||||
/// Audio input ports. Samples get recorded here.
|
/// Audio input ports. Samples get recorded here.
|
||||||
|
|
@ -55,7 +55,7 @@ impl Default for Sampler {
|
||||||
input_meters: vec![0.0;2],
|
input_meters: vec![0.0;2],
|
||||||
output_meters: vec![0.0;2],
|
output_meters: vec![0.0;2],
|
||||||
audio_outs: vec![],
|
audio_outs: vec![],
|
||||||
name: "tek_sampler".to_string(),
|
name: "tek_sampler".into(),
|
||||||
mapped: [const { None };128],
|
mapped: [const { None };128],
|
||||||
unmapped: vec![],
|
unmapped: vec![],
|
||||||
voices: Arc::new(RwLock::new(vec![])),
|
voices: Arc::new(RwLock::new(vec![])),
|
||||||
|
|
|
||||||
|
|
@ -100,33 +100,46 @@ impl Sampler {
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn status (&self, index: usize) -> impl Content<TuiOut> {
|
pub fn view_sample_info (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
Fill::x(Fixed::y(1, draw_info(if let Some((_, sample)) = &self.recording {
|
||||||
|
Some(sample)
|
||||||
|
} else if let Some(sample) = &self.mapped[note_pt] {
|
||||||
|
Some(sample)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn view_status (&self, index: usize) -> impl Content<TuiOut> {
|
||||||
draw_status(self.mapped[index].as_ref())
|
draw_status(self.mapped[index].as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
Tui::bg(Black, Fixed::x(2, Map::east(1, ||self.input_meters.iter(), |value, _index|{
|
draw_meters(&self.input_meters)
|
||||||
Fill::y(RmsMeter(*value))
|
|
||||||
})))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
Tui::bg(Black, Fixed::x(2, Map::east(1, ||self.output_meters.iter(), |value, _index|{
|
draw_meters(&self.output_meters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_meters (meters: &[f32]) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
Tui::bg(Black, Fixed::x(2, Map::east(1, ||meters.iter(), |value, _index|{
|
||||||
Fill::y(RmsMeter(*value))
|
Fill::y(RmsMeter(*value))
|
||||||
})))
|
})))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_list_item (sample: &Option<Arc<RwLock<Sample>>>) -> String {
|
fn draw_list_item (sample: &Option<Arc<RwLock<Sample>>>) -> String {
|
||||||
if let Some(sample) = sample {
|
if let Some(sample) = sample {
|
||||||
let sample = sample.read().unwrap();
|
let sample = sample.read().unwrap();
|
||||||
format!("{:8} {:3} {:6}-{:6}/{:6}",
|
format!("{:8}", sample.name)
|
||||||
sample.name,
|
//format!("{:8} {:3} {:6}-{:6}/{:6}",
|
||||||
sample.gain,
|
//sample.name,
|
||||||
sample.start,
|
//sample.gain,
|
||||||
sample.end,
|
//sample.start,
|
||||||
sample.channels[0].len()
|
//sample.end,
|
||||||
)
|
//sample.channels[0].len()
|
||||||
|
//)
|
||||||
} else {
|
} else {
|
||||||
String::from("........")
|
String::from("........")
|
||||||
}
|
}
|
||||||
|
|
@ -187,6 +200,21 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
When(sample.is_some(), Thunk::new(move||{
|
||||||
|
let sample = sample.unwrap().read().unwrap();
|
||||||
|
let theme = ItemTheme::G[96];
|
||||||
|
row!(
|
||||||
|
FieldH(theme, "Name", format!("{:<10}", sample.name.clone())),
|
||||||
|
FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())),
|
||||||
|
FieldH(theme, "Start", format!("{:<8}", sample.start)),
|
||||||
|
FieldH(theme, "End", format!("{:<8}", sample.end)),
|
||||||
|
FieldH(theme, "Transpose", " 0 "),
|
||||||
|
FieldH(theme, "Gain", format!("{}", sample.gain)),
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> {
|
fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> {
|
||||||
Tui::bold(true, Tui::fg(Tui::g(224), sample
|
Tui::bold(true, Tui::fg(Tui::g(224), sample
|
||||||
.map(|sample|{
|
.map(|sample|{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue