spectrum
This commit is contained in:
@@ -5,7 +5,7 @@ use ratatui::Frame;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::engine::SequencerSnapshot;
|
||||
use crate::widgets::{Orientation, Scope, VuMeter};
|
||||
use crate::widgets::{Orientation, Scope, Spectrum, VuMeter};
|
||||
|
||||
pub fn render(frame: &mut Frame, app: &mut App, snapshot: &SequencerSnapshot, area: Rect) {
|
||||
let [left_area, _spacer, vu_area] = Layout::horizontal([
|
||||
@@ -15,13 +15,31 @@ pub fn render(frame: &mut Frame, app: &mut App, snapshot: &SequencerSnapshot, ar
|
||||
])
|
||||
.areas(area);
|
||||
|
||||
let [scope_area, sequencer_area] = Layout::vertical([
|
||||
Constraint::Length(14),
|
||||
let show_scope = app.audio.config.show_scope;
|
||||
let show_spectrum = app.audio.config.show_spectrum;
|
||||
let viz_height = if show_scope || show_spectrum { 14 } else { 0 };
|
||||
|
||||
let [viz_area, sequencer_area] = Layout::vertical([
|
||||
Constraint::Length(viz_height),
|
||||
Constraint::Fill(1),
|
||||
])
|
||||
.areas(left_area);
|
||||
|
||||
render_scope(frame, app, scope_area);
|
||||
if show_scope && show_spectrum {
|
||||
let [scope_area, _, spectrum_area] = Layout::horizontal([
|
||||
Constraint::Percentage(50),
|
||||
Constraint::Length(2),
|
||||
Constraint::Percentage(50),
|
||||
])
|
||||
.areas(viz_area);
|
||||
render_scope(frame, app, scope_area);
|
||||
render_spectrum(frame, app, spectrum_area);
|
||||
} else if show_scope {
|
||||
render_scope(frame, app, viz_area);
|
||||
} else if show_spectrum {
|
||||
render_spectrum(frame, app, viz_area);
|
||||
}
|
||||
|
||||
render_sequencer(frame, app, snapshot, sequencer_area);
|
||||
render_vu_meter(frame, app, vu_area);
|
||||
}
|
||||
@@ -166,6 +184,12 @@ fn render_scope(frame: &mut Frame, app: &App, area: Rect) {
|
||||
frame.render_widget(scope, area);
|
||||
}
|
||||
|
||||
fn render_spectrum(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let area = Rect { height: area.height.saturating_sub(1), ..area };
|
||||
let spectrum = Spectrum::new(&app.metrics.spectrum);
|
||||
frame.render_widget(spectrum, area);
|
||||
}
|
||||
|
||||
fn render_vu_meter(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let vu = VuMeter::new(app.metrics.peak_left, app.metrics.peak_right);
|
||||
frame.render_widget(vu, area);
|
||||
|
||||
Reference in New Issue
Block a user