mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
watch it do: display sample waveform during recording
This commit is contained in:
parent
080c4131b7
commit
1859f378ea
2 changed files with 8 additions and 10 deletions
|
|
@ -77,7 +77,7 @@ render!(<Tui>|self:GrooveboxTui|{
|
|||
PhraseSelector::next_phrase(&self.player),
|
||||
]))),
|
||||
row!([
|
||||
Tui::split_n(false, 5,
|
||||
Tui::split_n(false, 9,
|
||||
col!([
|
||||
row!(|add|{
|
||||
if let Some(sample) = &self.sampler.mapped[note_pt] {
|
||||
|
|
@ -88,7 +88,7 @@ render!(<Tui>|self:GrooveboxTui|{
|
|||
}),
|
||||
lay!([
|
||||
Outer(Style::default().fg(TuiTheme::g(128))),
|
||||
Fill::w(Fixed::h(4, if let Some((_, sample)) = &self.sampler.recording {
|
||||
Fill::w(Fixed::h(8, if let Some((_, sample)) = &self.sampler.recording {
|
||||
SampleViewer(Some(sample.clone()))
|
||||
} else if let Some(sample) = &self.sampler.mapped[note_pt] {
|
||||
SampleViewer(Some(sample.clone()))
|
||||
|
|
|
|||
|
|
@ -18,18 +18,16 @@ render!(<Tui>|self: SampleViewer|render(|to|{
|
|||
let step = length / width as f64;
|
||||
let mut t = start;
|
||||
while t < end {
|
||||
points.push((t as f64, 0.));
|
||||
points.push((t as f64, 1.));
|
||||
points.push((t as f64, 0.5));
|
||||
points.push((t as f64, 0.25));
|
||||
points.push((t as f64, 0.125));
|
||||
points.push((t as f64, 0.0625));
|
||||
points.push((t as f64, 0.03125));
|
||||
let chunk = &sample.channels[0][t as usize..((t + step) as usize).min(sample.end)];
|
||||
let total: f32 = chunk.iter().map(|x|x.abs()).sum();
|
||||
let count = chunk.len() as f32;
|
||||
let meter = 10. * (total / count).log10();
|
||||
points.push((t as f64, meter as f64));
|
||||
t += step;
|
||||
}
|
||||
(
|
||||
[sample.start as f64, sample.end as f64],
|
||||
[0., 1.],
|
||||
[-40., 0.],
|
||||
points.as_slice()
|
||||
)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue