mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-08-07 22:17:07 +02:00
reorganize more
This commit is contained in:
parent
b9e7b9732e
commit
2d64f63741
12 changed files with 117 additions and 145 deletions
|
|
@ -1,7 +1,6 @@
|
|||
use crate::*;
|
||||
use ::std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::*}};
|
||||
use ::atomic_float::AtomicF64;
|
||||
use ::tengri::{draw::*, term::*};
|
||||
|
||||
/// A point in time in all time scales (microsecond, sample, MIDI pulse)
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::*;
|
||||
use ::std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::*}};
|
||||
use ::atomic_float::AtomicF64;
|
||||
use ::tengri::{draw::*, term::*};
|
||||
|
||||
/// Iterator that emits subsequent ticks within a range.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::*;
|
||||
use ::std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::*}};
|
||||
use ::atomic_float::AtomicF64;
|
||||
use ::tengri::{draw::*, term::*};
|
||||
|
||||
/// Temporal resolutions: sample rate, tempo, MIDI pulses per quaver (beat)
|
||||
///
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ impl PianoHorizontal {
|
|||
}
|
||||
}
|
||||
}
|
||||
Ok(xywh)
|
||||
Ok(Some(xywh))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ impl PianoHorizontal {
|
|||
break
|
||||
}
|
||||
}
|
||||
Ok(xywh)
|
||||
Ok(Some(xywh))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ impl PianoHorizontal {
|
|||
to.blit(¬e_pitch_to_name(note), x, screen_y, off_style)
|
||||
};
|
||||
}
|
||||
Ok(xywh)
|
||||
Ok(Some(xywh))
|
||||
})))
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ impl PianoHorizontal {
|
|||
to.blit(&"|", screen_x, y, style);
|
||||
}
|
||||
}
|
||||
Ok(xywh)
|
||||
Ok(Some(xywh))
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,37 +11,33 @@ pub struct Log10Meter(pub f32);
|
|||
#[derive(Debug, Default, Clone)]
|
||||
pub struct RmsMeter(pub f32);
|
||||
|
||||
impl Draw<Tui> for RmsMeter {
|
||||
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
|
||||
let XYWH(x, y, w, h) = to.area().into();
|
||||
let signal = f32::max(0.0, f32::min(100.0, self.0.abs()));
|
||||
let v = (signal * h as f32).ceil() as u16;
|
||||
let y2 = y + h;
|
||||
//to.blit(&format!("\r{v} {} {signal}", self.0), x * 30, y, Some(Style::default()));
|
||||
for y in y..(y + v) {
|
||||
for x in x..(x + w) {
|
||||
to.blit(&"▌", x, y2.saturating_sub(y), Some(Style::default().green()));
|
||||
}
|
||||
impl_draw!(|self: RmsMeter, to: Tui|{
|
||||
let XYWH(x, y, w, h) = to.area().into();
|
||||
let signal = f32::max(0.0, f32::min(100.0, self.0.abs()));
|
||||
let v = (signal * h as f32).ceil() as u16;
|
||||
let y2 = y + h;
|
||||
//to.blit(&format!("\r{v} {} {signal}", self.0), x * 30, y, Some(Style::default()));
|
||||
for y in y..(y + v) {
|
||||
for x in x..(x + w) {
|
||||
to.blit(&"▌", x, y2.saturating_sub(y), Some(Style::default().green()));
|
||||
}
|
||||
Ok(to.area().into())
|
||||
}
|
||||
}
|
||||
Ok(Some(to.area().into()))
|
||||
});
|
||||
|
||||
impl Draw<Tui> for Log10Meter {
|
||||
fn draw(self, to: &mut Tui) -> Usually<XYWH<u16>> {
|
||||
let XYWH(x, y, w, h) = to.area().into();
|
||||
let signal = 100.0 - f32::max(0.0, f32::min(100.0, self.0.abs()));
|
||||
let v = (signal * h as f32 / 100.0).ceil() as u16;
|
||||
let y2 = y + h;
|
||||
//to.blit(&format!("\r{v} {} {signal}", self.0), x * 20, y, None);
|
||||
for y in y..(y + v) {
|
||||
for x in x..(x + w) {
|
||||
to.blit(&"▌", x, y2 - y, Some(Style::default().green()));
|
||||
}
|
||||
impl_draw!(|self: Log10Meter, to: Tui| {
|
||||
let XYWH(x, y, w, h) = to.area().into();
|
||||
let signal = 100.0 - f32::max(0.0, f32::min(100.0, self.0.abs()));
|
||||
let v = (signal * h as f32 / 100.0).ceil() as u16;
|
||||
let y2 = y + h;
|
||||
//to.blit(&format!("\r{v} {} {signal}", self.0), x * 20, y, None);
|
||||
for y in y..(y + v) {
|
||||
for x in x..(x + w) {
|
||||
to.blit(&"▌", x, y2 - y, Some(Style::default().green()));
|
||||
}
|
||||
Ok(to.area().into())
|
||||
}
|
||||
}
|
||||
Ok(Some(to.area().into()))
|
||||
});
|
||||
|
||||
fn draw_meters (meters: &[f32]) -> impl Draw<Tui> + use<'_> {
|
||||
bg(Black, w_exact(2, iter_east_fixed(1, ||meters.iter(), |value, _index|{
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_
|
|||
})
|
||||
.render(area, to.as_mut());
|
||||
}
|
||||
Ok(xywh)
|
||||
Ok(Some(xywh))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use crate::{*, device::sampler::*};
|
|||
pub _search: Option<String>,
|
||||
}
|
||||
|
||||
impl_draw!(|self: SampleAdd, to: Tui|{ todo!() });
|
||||
|
||||
impl SampleAdd {
|
||||
fn exited (&self) -> bool {
|
||||
self.exited
|
||||
|
|
@ -118,9 +120,3 @@ impl SampleAdd {
|
|||
return Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
impl Draw<Tui> for SampleAdd {
|
||||
fn draw (self, _to: &mut Tui) -> Usually<XYWH<u16>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue