pub fn tick(&mut self) {
        self.state.current_samples += 1.0;
        let current_samples = self.state.current_samples;
        let maybe_stage_config = match self.stage {
            EnvelopeStage::Idle => None,
            EnvelopeStage::Attack => {
                self.state.current_volume =
                    self.calculate_volume(self.config.attack_level, self.config.attack.samples);
                Some(&self.config.attack)
            }
            EnvelopeStage::Decay => {
                self.state.current_volume =
                    self.calculate_volume(self.config.sustain, self.config.decay.samples);
                Some(&self.config.decay)
            }
            EnvelopeStage::Sustain => {
                self.state.current_volume = self.config.sustain;
                None
            }
            EnvelopeStage::Release => {
                self.state.current_volume = self.calculate_volume(0.0, self.config.release.samples);
                Some(&self.config.release)
            }
        };

        if let Some(stage_config) = maybe_stage_config {
            if current_samples >= stage_config.samples {
                self.next_stage();
            }
        }
    }
/// Update the envelope, pushing its state forwards by 1 sample
Update the envelope, pushing its state forwards by 1 sample
Update the envelope pushing its state forwards by 1 sample
pub fn tick(&mut self) {
        self.state.current_samples += 1.0;
        let current_samples = self.state.current_samples;
        let maybe_stage_config = match self.stage {
            EnvelopeStage::Idle => None,
            EnvelopeStage::Attack => {
                self.state.current_volume =
                    self.calculate_volume(self.config.attack_level, self.config.attack.samples);
                Some(&self.config.attack)
            }
            EnvelopeStage::Decay => {
                self.state.current_volume =
                    self.calculate_volume(self.config.sustain, self.config.decay.samples);
                Some(&self.config.decay)
            }
            EnvelopeStage::Sustain => {
                self.state.current_volume = self.config.sustain;
                None
            }
            EnvelopeStage::Release => {
                self.state.current_volume = self.calculate_volume(0.0, self.config.release.samples);
                Some(&self.config.release)
            }
        };
        if let Some(stage_config) = maybe_stage_config {
            if current_samples >= stage_config.samples {
                self.next_stage();
            }
        }
    }
pub fn tick ( & mut self ) { self . state . current_samples += 1.0 ; let current_samples = self . state . current_samples ; let maybe_stage_config = match self . stage { EnvelopeStage :: Idle => None , EnvelopeStage :: Attack => { self . state . current_volume = self . calculate_volume ( self . config . attack_level , self . config . attack . samples ) ; Some ( & self . config . attack ) } EnvelopeStage :: Decay => { self . state . current_volume = self . calculate_volume ( self . config . sustain , self . config . decay . samples ) ; Some ( & self . config . decay ) } EnvelopeStage :: Sustain => { self . state . current_volume = self . config . sustain ; None } EnvelopeStage :: Release => { self . state . current_volume = self . calculate_volume ( 0.0 , self . config . release . samples ) ; Some ( & self . config . release ) } } ; if let Some ( stage_config ) = maybe_stage_config { if current_samples >= stage_config . samples { self . next_stage ( ) ; } } }
Update the envelope, pushing its state forwards by 1 sample
Update the envelope pushing its state forwards by 1 sample
&mut self
&mut self