mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
groovebox: draw sample info
This commit is contained in:
parent
4e2702f69e
commit
e00d870d70
4 changed files with 63 additions and 31 deletions
|
|
@ -3,15 +3,16 @@
|
|||
(info "A sequencer with built-in sampler.")
|
||||
|
||||
(view
|
||||
(bsp/a :view-dialog
|
||||
(bsp/s (fixed/y 1 :view-transport)
|
||||
(bsp/n (fixed/y 1 :view-status)
|
||||
(bsp/w :view-meters-output
|
||||
(bsp/e :view-meters-input
|
||||
(bsp/n (fixed/y 5 :view-sample-viewer)
|
||||
(bsp/w (fixed/x :w-sidebar :view-pool)
|
||||
(bsp/e :view-samples-keys
|
||||
(fill/y :view-editor))))))))))
|
||||
(bsp/a :view-dialog
|
||||
(bsp/s (fixed/y 1 :view-transport)
|
||||
(bsp/n (fixed/y 1 :view-status)
|
||||
(bsp/w :view-meters-output
|
||||
(bsp/e :view-meters-input
|
||||
(bsp/n :view-sample-info
|
||||
(bsp/n (fixed/y 5 :view-sample-viewer)
|
||||
(bsp/w (fixed/x :w-sidebar :view-pool)
|
||||
(bsp/e :view-samples-keys
|
||||
(fill/y :view-editor)))))))))))
|
||||
|
||||
(keys
|
||||
(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<'_> {
|
||||
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<'_> {
|
||||
When::new(self.dialog.is_some(), Bsp::b(
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::*;
|
|||
#[derive(Debug)]
|
||||
pub struct Sampler {
|
||||
/// Name of sampler.
|
||||
pub name: String,
|
||||
pub name: Arc<str>,
|
||||
/// Device color.
|
||||
pub color: ItemTheme,
|
||||
/// Audio input ports. Samples get recorded here.
|
||||
|
|
@ -55,7 +55,7 @@ impl Default for Sampler {
|
|||
input_meters: vec![0.0;2],
|
||||
output_meters: vec![0.0;2],
|
||||
audio_outs: vec![],
|
||||
name: "tek_sampler".to_string(),
|
||||
name: "tek_sampler".into(),
|
||||
mapped: [const { None };128],
|
||||
unmapped: 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())
|
||||
}
|
||||
|
||||
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|{
|
||||
Fill::y(RmsMeter(*value))
|
||||
})))
|
||||
draw_meters(&self.input_meters)
|
||||
}
|
||||
|
||||
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|{
|
||||
Fill::y(RmsMeter(*value))
|
||||
})))
|
||||
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))
|
||||
})))
|
||||
}
|
||||
|
||||
fn draw_list_item (sample: &Option<Arc<RwLock<Sample>>>) -> String {
|
||||
if let Some(sample) = sample {
|
||||
let sample = sample.read().unwrap();
|
||||
format!("{:8} {:3} {:6}-{:6}/{:6}",
|
||||
sample.name,
|
||||
sample.gain,
|
||||
sample.start,
|
||||
sample.end,
|
||||
sample.channels[0].len()
|
||||
)
|
||||
format!("{:8}", sample.name)
|
||||
//format!("{:8} {:3} {:6}-{:6}/{:6}",
|
||||
//sample.name,
|
||||
//sample.gain,
|
||||
//sample.start,
|
||||
//sample.end,
|
||||
//sample.channels[0].len()
|
||||
//)
|
||||
} else {
|
||||
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> {
|
||||
Tui::bold(true, Tui::fg(Tui::g(224), sample
|
||||
.map(|sample|{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue