<commit_before>use envelope_detector::{Frame, Mode, EnvelopeDetector, Peak, Rms};
use time::Ms;

/// A peak `Detector` type.
pub use envelope_detector::PeakEnvelopeDetector;


/// Envelope **Detector** types that may be used by the **Compressor**.
pub trait Detector<F>
    where F: Frame,
{
    /// The detection **Mode** used by the **Detector**.
    type Mode: Mode<F>;
    /// Mutably borrow the **MultiChannelEnvelopeDetector**.
    fn detector(&mut self) -> &mut EnvelopeDetector<F, Self::Mode>;
}


/// An RMS envelope detector with a window adjustable in milliseconds.
#[derive(Clone)]
pub struct RmsEnvelopeDetector<F>
    where F: Frame,
{
    /// The multi-channel RMS envelope detector.
    pub rms: EnvelopeDetector<F, Rms<F>>,
    /// The duration of the RMS window used by the detector.
    pub window_ms: Ms,
}


impl<F> Detector<F> for PeakEnvelopeDetector<F>
    where F: Frame,
{
    type Mode = Peak;
    fn detector(&mut self) -> &mut Self {
        self
    }
}

impl<F> Detector<F> for RmsEnvelopeDetector<F>
    where F: Frame,
{
    type Mode = Rms<F>;
    fn detector(&mut self) -> &mut EnvelopeDetector<F, Self::Mode> {
        &mut self.rms
    }
}
<commit_msg>Add manual Debug implementation for RmsEnvelopeDetector.<commit_after>use envelope_detector::{Frame, Mode, EnvelopeDetector, Peak, Rms};
use std;
use time::Ms;

/// A peak `Detector` type.
pub use envelope_detector::PeakEnvelopeDetector;


/// Envelope **Detector** types that may be used by the **Compressor**.
pub trait Detector<F>
    where F: Frame,
{
    /// The detection **Mode** used by the **Detector**.
    type Mode: Mode<F>;
    /// Mutably borrow the **MultiChannelEnvelopeDetector**.
    fn detector(&mut self) -> &mut EnvelopeDetector<F, Self::Mode>;
}


/// An RMS envelope detector with a window adjustable in milliseconds.
#[derive(Clone)]
pub struct RmsEnvelopeDetector<F>
    where F: Frame,
{
    /// The multi-channel RMS envelope detector.
    pub rms: EnvelopeDetector<F, Rms<F>>,
    /// The duration of the RMS window used by the detector.
    pub window_ms: Ms,
}

impl<F> std::fmt::Debug for RmsEnvelopeDetector<F>
    where F: Frame + std::fmt::Debug,
          F::Float: std::fmt::Debug,
{
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        write!(f, "RmsEnvelopeDetector {{ rms: {:?}, window_ms: {:?} }}", &self.rms, &self.window_ms)
    }
}


impl<F> Detector<F> for PeakEnvelopeDetector<F>
    where F: Frame,
{
    type Mode = Peak;
    fn detector(&mut self) -> &mut Self {
        self
    }
}

impl<F> Detector<F> for RmsEnvelopeDetector<F>
    where F: Frame,
{
    type Mode = Rms<F>;
    fn detector(&mut self) -> &mut EnvelopeDetector<F, Self::Mode> {
        &mut self.rms
    }
}

{'fraction_non_alphanumeric': 0.14441615132775554, 'fraction_numerical': 0.0, 'mean_word_length': 3.365079365079365, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '865667', 'n_tokens_mistral': 938, 'n_tokens_neox': 925, 'n_words': 278}