[sdiy] Fast envelope follower circuit needed..
subjectivity at hotmail.com
Thu Mar 28 23:02:20 CET 2013
On Mar 28, 2013, at 2: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......
> 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. Half-wave rectification just makes the signal more "lumpy" and isn't significantly easier digitally anyway.
> 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.
> 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.
> 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.
> Years ago I did quite a bit of work on autowah circuits, and the envelope followers for those can get quite specific since you know that the signal is coming from a guitar, and therefore what the lowest note and highest note you have to deal with are. But then your funky stomp box doesn't sound so great when your keys player puts his fender rhodes through it - you can't win, or you can't win all the time, anyway. Have you done an autowah for Snazzy FX? Maybe you've found the same thing.
Thanks for the great reply!!
I will have to investigate with the AVR.
Yes a few Snazzy Fx products have analog followers in them.
Depending on your input, a follower can be perfect for one source but not another.
I worked very hard on the follower circuit in the Wow and Flutter euro module which is coming out this week.
The original Wow and Flutter was for guitar, the module is for synth, so I had to re-work everything.
More information about the Synth-diy