Feat: UI/UX and ducking compressor
This commit is contained in:
@@ -13,6 +13,7 @@ pub struct Lissajous<'a> {
|
||||
left: &'a [f32],
|
||||
right: &'a [f32],
|
||||
color: Option<Color>,
|
||||
gain: f32,
|
||||
}
|
||||
|
||||
impl<'a> Lissajous<'a> {
|
||||
@@ -21,6 +22,7 @@ impl<'a> Lissajous<'a> {
|
||||
left,
|
||||
right,
|
||||
color: None,
|
||||
gain: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +30,11 @@ impl<'a> Lissajous<'a> {
|
||||
self.color = Some(c);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn gain(mut self, g: f32) -> Self {
|
||||
self.gain = g;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Lissajous<'_> {
|
||||
@@ -43,14 +50,6 @@ impl Widget for Lissajous<'_> {
|
||||
let fine_height = height * 4;
|
||||
let len = self.left.len().min(self.right.len());
|
||||
|
||||
let peak = self
|
||||
.left
|
||||
.iter()
|
||||
.chain(self.right.iter())
|
||||
.map(|s| s.abs())
|
||||
.fold(0.0f32, f32::max);
|
||||
let gain = if peak > 0.001 { 1.0 / peak } else { 1.0 };
|
||||
|
||||
PATTERNS.with(|p| {
|
||||
let mut patterns = p.borrow_mut();
|
||||
let size = width * height;
|
||||
@@ -58,8 +57,8 @@ impl Widget for Lissajous<'_> {
|
||||
patterns.resize(size, 0);
|
||||
|
||||
for i in 0..len {
|
||||
let l = (self.left[i] * gain).clamp(-1.0, 1.0);
|
||||
let r = (self.right[i] * gain).clamp(-1.0, 1.0);
|
||||
let l = (self.left[i] * self.gain).clamp(-1.0, 1.0);
|
||||
let r = (self.right[i] * self.gain).clamp(-1.0, 1.0);
|
||||
|
||||
// X = right channel, Y = left channel (inverted so up = positive)
|
||||
let fine_x = ((r + 1.0) * 0.5 * (fine_width - 1) as f32).round() as usize;
|
||||
|
||||
Reference in New Issue
Block a user