[sdiy] Fast envelope follower circuit needed..

Richie Burnett rburnett at richieburnett.co.uk
Thu Mar 28 23:22:02 CET 2013


The Hilbert transform is a classic tool for envelope extraction using DSP. Envelope following is really what electrical engineers would call AM demodulation, and has existed in various forms since the dawn of radio.

Also, FIR filters with cutoff frequencies which are very low compared to the sample rate and result in really long impulse responses (hundreds or thousands of taps) can be used effectively if implemented as polyphase filters. A 2000 tap FIR filter only requires the same amount of DSP grunt as a 20 tap filter if you can drop the sample rate of the output by a factor of 1/10.

The CIC filter is also a very common filter in communications applications where a high frequency signal needs to be demodulated and the envelope is output at a reduced sample rate.

-Richie,



Sent from my Sony Ericsson Xperia ray

cheater cheater <cheater00 at gmail.com> wrote:

>Hi Tom,
>a few comments:
>
>On Thu, Mar 28, 2013 at 7:24 PM, Tom Wiltshire <tom at electricdruid.net> wrote:
>> Hi Dan,
>>
>> On 28 Mar 2013, at 13:55, Dan Snazelle <subjectivity at hotmail.com> wrote:
>>
>>>
>>> Though i work with c//arduino/AVRS not pics, this sounds very appealing! Can anyone recommend a place to learn about writing C code for an envelope follower? How do you do it? Shift signal to 0-5, then......
>>>
>>>
>>> Thanks!!!
>>
>> The first thing after that would be to do the full wave rectification. Either dump the sign bit, if you've got signed data, or invert the data if the highest bit is clear if it's not signed - same thing, different representation.
>
>I strongly advise against doing this. It will create insane amounts of
>aliasing. Do the rectification in analog. In fact full-wave
>rectification is the most difficult thing to do when modelling analog
>circuits digitally. Doing it anywhere near a level acceptable even for
>the non-discriminating musician would require processing power orders
>of magnitude larger than what a lowly pic can offer you. And in analog
>it's just a few junctions.
>
>BTW, you can't really rectify a signal that's unipolar already.. just
>a minor nitpick ;)
>
>> For the smoothing, I can imagine a couple of approaches:
>>
>> 1) Genuine honest-to-goodness digital filtering.
>> There's a ton of stuff about this all over the web. But since we're talking about bottom-end chips, most of it is totally out of reach. We're not going to be running long FIR filters. But we could perhaps use an IIR filter, or a FIR with a very low sample rate, to keep it manageable.
>
>You can't change the sample rate, unless you mean you would downsample
>the signal first. But then you'll have to have steep bandwidth
>limiting filters and a filter for the down-sampling itself, which
>means you do ten times the work you think you're saving by using lower
>sampling rates. If you don't downsample you get aliasing, and then
>you're detecting the envelope very incorrectly. It can only get you
>fairly small speed-ups anyways before it stops being useful at all.
>
>An FIR with a fairly short impulse is fairly easy to manage, and on
>something like a dspic you can do even longer ones. However IIR is the
>usual way to go with envelope detectors if I'm not mistaken.
>
>> 2) Peak detection.
>> This might be a good way to go. Keeping track of what the last couple of samples are would be easy, and would allow us to work out the current slope of the waveform. When the current sample is less than the previous one, the waveform has started heading back down, so we'd hold the peak value.
>> Obviously we can't hold the highest value for ever, so there needs to be some "decay" parameter that allows it to fall. Multiply by 0.99 every sample, perhaps, or remove some small constant. This is good because the algorithm can respond instantly to peaks, but will smoothly and slowly fall for decays, which naturally tend to be longer. As ever, it won't do everything well - the envelope of short percussion hits might get stretched, for example.
>
>Depending on how one would fill in the blanks, you've just described
>either IIR, or FIR, or a thing that results in loads of zipper noise
>and incorrect enveloping. IIR and FIR really are the best approaches
>here.
>
>> There's probably other ways, or combinations of one and the other that would work. The more specific you can be about what inputs you're trying to deal with, the better a job you'll manage to do. If you want to solve the general case, you'll need to make more compromises.
>
>Or add knobs :-)
>
>Cheers,
>D.
>_______________________________________________
>Synth-diy mailing list
>Synth-diy at dropmix.xs4all.nl
>http://dropmix.xs4all.nl/mailman/listinfo/synth-diy


More information about the Synth-diy mailing list