DSPRelated.com
Forums

Looking for an automated method for plotting the amplitude envelope of an audio signal

Started by maxplanck October 18, 2007
I'm trying to plot the amplitude envelope of an audio signal, with perfect
accuracy. (the algorithm for perfect accuracy would be to take the
absolute value of the audio signal, then plot a point at the location of
each local maxima, then connect adjacent points with a line)

In Reaktor I've tried to use the envelope follower macro, but even after
tweaking the settings it doesn't seem to plot the signal's amplitude
envelope with enough accuracy (it's very close, but i'm looking for
perfect accuracy).

Can anyone recommend software that can do this?

Whatever method i end up using must be able to output the amplitude
envelope as a text file or as copy-and-pastable data so i can import it
into Reaktor.

Thanks, any help is much appreciated


On Oct 18, 9:37 am, "maxplanck" <erik.bo...@comcast.net> wrote:
> I'm trying to plot the amplitude envelope of an audio signal, with perfect > accuracy. (the algorithm for perfect accuracy would be to take the > absolute value of the audio signal, then plot a point at the location of > each local maxima, then connect adjacent points with a line) > > In Reaktor I've tried to use the envelope follower macro, but even after > tweaking the settings it doesn't seem to plot the signal's amplitude > envelope with enough accuracy (it's very close, but i'm looking for > perfect accuracy). > > Can anyone recommend software that can do this? > > Whatever method i end up using must be able to output the amplitude > envelope as a text file or as copy-and-pastable data so i can import it > into Reaktor. > > Thanks, any help is much appreciated
Consider the "algorithm" using a Hilbret transform and multiplication described in Rick Lyon's book: http://www.amazon.com/Understanding-Digital-Signal-Processing-2nd/dp/0131089897 or look up AM detector or envelope detector and hilbert transform Consider also that "local maximum" implies some kind of low pass filter and makes this method fundamentally imperfect. This is the same exact issue I had as a kid playing with AM radios. The 1/2 wave rectifier envelope detector can never be perfect becasue it needs a low pass filter. If the slope of the envelope exceeds the rate that can pass through the low pass filter you get what was called "diagonal clipping" basically slew rate limiting. My understanding is the hilbert tranform / multiply method neatly overcomes this inherent limitation and can be used to make "in principle" a perfect envelope detector. Mark
Mark wrote:
> On Oct 18, 9:37 am, "maxplanck" <erik.bo...@comcast.net> wrote: >> I'm trying to plot the amplitude envelope of an audio signal, with perfect >> accuracy. (the algorithm for perfect accuracy would be to take the >> absolute value of the audio signal, then plot a point at the location of >> each local maxima, then connect adjacent points with a line) >> >> In Reaktor I've tried to use the envelope follower macro, but even after >> tweaking the settings it doesn't seem to plot the signal's amplitude >> envelope with enough accuracy (it's very close, but i'm looking for >> perfect accuracy). >> >> Can anyone recommend software that can do this? >> >> Whatever method i end up using must be able to output the amplitude >> envelope as a text file or as copy-and-pastable data so i can import it >> into Reaktor. >> >> Thanks, any help is much appreciated > > Consider the "algorithm" using a Hilbret transform and multiplication > described in Rick Lyon's book: > > http://www.amazon.com/Understanding-Digital-Signal-Processing-2nd/dp/0131089897 > > or look up AM detector or envelope detector and hilbert transform > > Consider also that "local maximum" implies some kind of low pass > filter and makes this method fundamentally imperfect. > > This is the same exact issue I had as a kid playing with AM radios. > The 1/2 wave rectifier envelope detector can never be perfect becasue > it needs a low pass filter. If the slope of the envelope exceeds the > rate that can pass through the low pass filter you get what was > called "diagonal clipping" basically slew rate limiting. > > My understanding is the hilbert tranform / multiply method neatly > overcomes this inherent limitation and can be used to make "in > principle" a perfect envelope detector.
Other imperfection come about for even more fundamental reasons. The waveform consists of samples, and there may not be a sample at the exact maximum. Even if each maximum were precisely located, the straight line segments that connect them will actually cross the curve. I have usually found that when somebody asks for perfection rather than a defines level of quality, the problem hasn't been thought through. I used to mitigate diagonal clipping when warranted by using a full-wave detector. This allows doubling the cutoff frequency of the low-pass filter. Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
On Oct 18, 9:37 am, "maxplanck" <erik.bo...@comcast.net> wrote:
> I'm trying to plot the amplitude envelope of an audio signal, with perfect > accuracy. (the algorithm for perfect accuracy would be to take the > absolute value of the audio signal, then plot a point at the location of > each local maxima, then connect adjacent points with a line)
sorry, Max, but that is not even a good spec, let alone one of "perfect accuracy". the connect with straight line ain't so good, but you have to think about your "local maxima" a bit (for waveforms that are complicated). r b-j
I can write a lowpass signal as A(t)sin(2 pi fcenter+phi(t))

A(t) and phi(t) are amplitude and phase of the signal. A(t) is even valid
during zero crossings!

This is the "ideal" solution in a communications sense (since I can
reconstruct the signal without loss of information). But I this approach
is inconvenient for several reasons, you may be looking for an
approximation.

The catch is that an ideal lowpass filter has infinitely long memory.

-mn 
On Oct 18, 9:10 am, Jerry Avins <j...@ieee.org> wrote:
> > On Oct 18, 9:37 am, "maxplanck" <erik.bo...@comcast.net> wrote: > >> I'm trying to plot the amplitude envelope of an audio signal, with perfect > >> accuracy. (the algorithm for perfect accuracy would be to take the > >> absolute value of the audio signal, then plot a point at the location of > >> each local maxima, then connect adjacent points with a line) > > >> In Reaktor I've tried to use the envelope follower macro, but even after > >> tweaking the settings it doesn't seem to plot the signal's amplitude > >> envelope with enough accuracy (it's very close, but i'm looking for > >> perfect accuracy). > > >> Can anyone recommend software that can do this? > > >> Whatever method i end up using must be able to output the amplitude > >> envelope as a text file or as copy-and-pastable data so i can import it > >> into Reaktor. > > >> Thanks, any help is much appreciated
...
> The > waveform consists of samples, and there may not be a sample at the exact > maximum.
If the signal was perfectly bandlimted and one had infinitely long set of infinite precision samples, one could still interpolate the maxima using waveform reconstruction. With a finite set of samples or fixed precision samples, however, the reconstruction and thus the interpolation will be imperfect.
> Even if each maximum were precisely located, the straight line > segments that connect them will actually cross the curve.
And thus be incorrect, much less perfect, since the amplitude of the curve may actually be greater then that of the line segments (unless the slopes are all zero). An envelope consisting of straight line segments may also have an infinite first derivative, which is doesn't seem possible for audio produced by any natural source.
> I have usually > found that when somebody asks for perfection rather than a defines level > of quality, the problem hasn't been thought through.
Or a gross misunderstanding of how far perfection usually is from anything that can be done with finite resources. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
Thanks a lot for your responses guys, I really appreciate it.

Can you recommend any software that can compute the amplitude envelope
using any of the better algorithms that you described?

And/or can you recommend any software that can perform a crude amplitude
envelope approximation using the method that I described?


Right now I'm doing some experiments where the most accurate amplitude
envelope computation would be very useful.  I'm trying to avoid getting
bogged down by having to learn complicated amplitude envelope calculation
methods... I just want to find software to perform the calculation as well
as possible.  

I understand that it's often important to understand the computational
algorithms that are being used in order to know what degree of accuracy
the results will have, but for the moment I don't need to do this... my
ears will tell me if the computational method is accurate enough.

Thanks again
-Max
Hello Max,
>And/or can you recommend any software that can perform a crude amplitude >envelope approximation using the method that I described?
Try averaging the maximum standard deviation: This will locate the maximum over a set range 0 < t < n Max(x,t): y=0. for i=0,i<t,i++ : { y=max(y,x(i)). } return y. Mean(x,t): y=Max(x,t)/t+1. return y. for j=0,j<n,j++ : { # if interval = 1 : Mean Function = max (t(0),t(1))/2. envelope{j}=Avg(x,1). Plot(j,envelope{j}). } This brute forces the average of the maximum over time. Look up Euler for starters, or Range-Kutta approximation for something computationally less expensive.
Have not run it but this looks better

Max(x,t,interval):
y=0.
for i=t,i<t+interval,i++ : {
y=max(y,x(i)).
}
return y.

Mean(x,t,interval):
y=Max(x,t,interval)/interval.
return y.

interval=1
for j=1,j<n,j++ : {
# if interval = 1 : Mean Function = max (t(1),t(2))/2.
envelope{j}=Mean(x,j,interval).
Plot(j,envelope{j}).
}


Thanks a lot for this.

I understand the logic, but I only program in Reaktor and Max/MSP so I
don't have knowledge of a computer language by which to implement this
program.  I took a class in C++ in college, but that was 8 years ago.

If I have to I'll learn a computer programming language and implement this
program that way, but I very much want to avoid getting bogged down by
this. 

Is there any software out there that can do this or a more
accurate/computationally expensive amplitude envelope calculation, to save
me from having to learn a programming language?

Thanks again