voice-filter 0.1.0

Live voice filter for PipeWire: a virtual microphone that removes background noise with DeepFilterNet3 and enhances the voice
use ::std::sync::atomic::{AtomicU32, Ordering};

/// An `f32` shared lock-free between threads, e.g. a setting the control interface changes and
/// the audio path reads.
#[derive(Debug)]
pub struct AtomicF32(AtomicU32);

impl AtomicF32 {
    pub fn new(value: f32) -> Self {
        Self(AtomicU32::new(value.to_bits()))
    }

    pub fn load(&self) -> f32 {
        f32::from_bits(self.0.load(Ordering::Relaxed))
    }

    pub fn store(&self, value: f32) {
        self.0.store(value.to_bits(), Ordering::Relaxed);
    }
}

impl Default for AtomicF32 {
    fn default() -> Self {
        Self::new(0.)
    }
}