Feat: UI/UX and ducking compressor
Some checks failed
Deploy Website / deploy (push) Failing after 4m52s
Some checks failed
Deploy Website / deploy (push) Failing after 4m52s
This commit is contained in:
@@ -482,6 +482,15 @@ fn render_tile(
|
||||
}
|
||||
}
|
||||
|
||||
fn viz_gain(data: &[f32], config: &crate::state::audio::AudioConfig) -> f32 {
|
||||
if config.normalize_viz {
|
||||
let peak = data.iter().fold(0.0_f32, |m, s| m.max(s.abs()));
|
||||
if peak > 0.0001 { 1.0 / peak } else { 1.0 }
|
||||
} else {
|
||||
config.gain_boost
|
||||
}
|
||||
}
|
||||
|
||||
fn render_scope(frame: &mut Frame, app: &App, area: Rect, orientation: Orientation) {
|
||||
let theme = theme::get();
|
||||
let block = Block::default()
|
||||
@@ -490,9 +499,11 @@ fn render_scope(frame: &mut Frame, app: &App, area: Rect, orientation: Orientati
|
||||
let inner = block.inner(area);
|
||||
frame.render_widget(block, area);
|
||||
|
||||
let gain = viz_gain(&app.metrics.scope, &app.audio.config);
|
||||
let scope = Scope::new(&app.metrics.scope)
|
||||
.orientation(orientation)
|
||||
.color(theme.meter.low);
|
||||
.color(theme.meter.low)
|
||||
.gain(gain);
|
||||
frame.render_widget(scope, inner);
|
||||
}
|
||||
|
||||
@@ -504,7 +515,13 @@ fn render_spectrum(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let inner = block.inner(area);
|
||||
frame.render_widget(block, area);
|
||||
|
||||
let spectrum = Spectrum::new(&app.metrics.spectrum);
|
||||
let gain = if app.audio.config.normalize_viz {
|
||||
viz_gain(&app.metrics.spectrum, &app.audio.config)
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
let spectrum = Spectrum::new(&app.metrics.spectrum)
|
||||
.gain(gain);
|
||||
frame.render_widget(spectrum, inner);
|
||||
}
|
||||
|
||||
@@ -516,8 +533,16 @@ fn render_lissajous(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let inner = block.inner(area);
|
||||
frame.render_widget(block, area);
|
||||
|
||||
let peak = app.metrics.scope.iter().chain(app.metrics.scope_right.iter())
|
||||
.fold(0.0_f32, |m, s| m.max(s.abs()));
|
||||
let gain = if app.audio.config.normalize_viz {
|
||||
if peak > 0.0001 { 1.0 / peak } else { 1.0 }
|
||||
} else {
|
||||
app.audio.config.gain_boost
|
||||
};
|
||||
let lissajous = Lissajous::new(&app.metrics.scope, &app.metrics.scope_right)
|
||||
.color(theme.meter.low);
|
||||
.color(theme.meter.low)
|
||||
.gain(gain);
|
||||
frame.render_widget(lissajous, inner);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user