Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: envelope follower

  1. #1

    envelope follower

    Hello,

    I would like to do an envelope follower. The goal is to get the envelope of an audio signal to modulate filters.

    I can't figure out precisely the way to do it. Here are my idea at the moment :
    - read the audio input and extract positive peaks
    - averaging / filtering
    - inject result to modulate a filter

    I use Teensy 3.6 + audio shield.
    How is it possible to make readings of the audio input ? I know about audio library objects. But how to access directly to audio samples values for your code ?

    I think I need some guidance !
    Emmanuel

  2. #2
    Hello, how about using the Peak object to find the amplitude and using this value (multiplied by some constant) to adjust the cutoff frequency? There is a PeakMeterMono example sketch that samples the input several times a second, you could experiment with using the read() value to adjust the filter.

  3. #3
    Yes, I thought using this object. I wonder if it can be fast enough to detect accurately an envelope. I will try.

  4. #4
    Member
    Join Date
    Feb 2018
    Location
    Corvallis, OR
    Posts
    60
    Have you looked over this explanation of digital envelope detectors: https://www.dsprelated.com/showarticle/938.php

    It seems that you just need access to the signal to do a full-wave rectification followed by an appropriate low-pass filter.

    Now that I think about it, this sounds a lot like a VU meter. Is there a VU Meter object in the Teensy audio library that you could modify for fast response to better catch peaks?

    Oops. I've betrayed my lack of experience with the Teensy Audio Library. It looks like the AudioEffectEnvelope object does what is needed.
    Last edited by mborgerson; 03-27-2020 at 12:27 AM. Reason: Added name of audio library object

  5. #5
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,326
    I haven't used the audio library much... so hopefully I get this correct.

    Envelope effect is a generator not a detector/follower.

    The RMS or peak objects could be used or you can filter the audio directly after taking absolute value.

    There should be an object for this as it's a standard synthesis tool.

    Some soft-synth tools have a lowpass with different filter coefficients for attack and fall so the signal generated could be more responsive matching one or the other... typically faster attack and slower decay to smooth out the fall between oscillations in the wave but still capture the attack effectively.

  6. #6
    Tanks for the thread, that will certainly help me.
    Envelope audio effect is an ADSR envelope "shaper" and won't work as a detector.

    I have some results using the peak detection object. But even with filter, it produces harshness and glitches when I try to modulate waveforms or filters.
    Envelope detection seems easy to do, but getting a musical result is another story...

  7. #7
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,326
    You need a VERY low cutoff as you're effectively trying to get below any fundamental so the corner frequency needs to be 50Hz or lower (and maybe much lower) and that makes the attack pretty unresponsive.

    Paul suggests the state variable filter as being best for a low corner needed by this application: https://forum.pjrc.com/threads/29579...ll=1#post94859

    I'd try the RMS signal and a lowpass set lower and lower until the attack becomes unresponsive and then back off a bit.

    That said.. if the Audio Library is supposed to be a synthesis tool it should have a module for this.

    When researching this be aware that much of the material is for demodulating AM radio signals where the signal is a modulated sinusoidal at very high frequency which means the techniques may not be appropriate for the audio task.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •