exa04 / cyma

Visualizers for nih-plug UIs made using VIZIA.
https://exa04.github.io/cyma/book
Mozilla Public License 2.0
35 stars 1 forks source link

Peak Buffer decay #50

Closed exa04 closed 7 months ago

exa04 commented 7 months ago

Implements decay for the peak buffer.

Changes the peak buffer's enqueueing behavior; It now behaves like a peak meter, by immediately snapping to values greater than its previous value, but decaying in amplitude if the current value is less than the previous one.

Changes:

Breaking Change

The parameter list for PeakBuffer::new() has now changed:

- fn new(size: usize, sample_rate: f32, duration: f32)
+ fn new(size: usize, duration:    f32, decay:    f32)

As an example, this is how you could adapt to this new parameter list if you have a PeakBuffer that you initialize inside your plug-in's default() function.

impl Default for DemoPlugin {
    fn default() -> Self {
        Self {
-           peak_buffer: Arc::new(Mutex::new(PeakBuffer::new(800, 44100.0, 10.0)))
+           peak_buffer: Arc::new(Mutex::new(PeakBuffer::new(800, 10.0, 0.)))
        }
    }
}