spectrum
This commit is contained in:
@@ -47,7 +47,7 @@ fn render_audio_section(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let [devices_area, _, settings_area, _, samples_area] = Layout::vertical([
|
||||
Constraint::Length(4),
|
||||
Constraint::Length(1),
|
||||
Constraint::Length(6),
|
||||
Constraint::Length(8),
|
||||
Constraint::Length(1),
|
||||
Constraint::Min(3),
|
||||
])
|
||||
@@ -112,8 +112,12 @@ fn render_settings(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let buffer_focused = app.audio.focus == AudioFocus::BufferSize;
|
||||
let fps_focused = app.audio.focus == AudioFocus::RefreshRate;
|
||||
let highlight_focused = app.audio.focus == AudioFocus::RuntimeHighlight;
|
||||
let scope_focused = app.audio.focus == AudioFocus::ShowScope;
|
||||
let spectrum_focused = app.audio.focus == AudioFocus::ShowSpectrum;
|
||||
|
||||
let highlight_text = if app.ui.runtime_highlight { "On" } else { "Off" };
|
||||
let scope_text = if app.audio.config.show_scope { "On" } else { "Off" };
|
||||
let spectrum_text = if app.audio.config.show_spectrum { "On" } else { "Off" };
|
||||
|
||||
let rows = vec![
|
||||
Row::new(vec![
|
||||
@@ -147,6 +151,14 @@ fn render_settings(frame: &mut Frame, app: &App, area: Rect) {
|
||||
Span::styled("Highlight", label_style),
|
||||
render_selector(highlight_text, highlight_focused, highlight, normal),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Span::styled("Scope", label_style),
|
||||
render_selector(scope_text, scope_focused, highlight, normal),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Span::styled("Spectrum", label_style),
|
||||
render_selector(spectrum_text, spectrum_focused, highlight, normal),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Span::styled("Rate", label_style),
|
||||
Span::styled(
|
||||
|
||||
@@ -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