Richard Owlett wrote:> PS I subscribe to "Give a man a fish, he eats for a day. Teach him to > fish ...".... he'll undercut you and drive you out of business. Steve
Looking for an automated method for plotting the amplitude envelope of an audio signal
Started by ●October 18, 2007
Reply by ●October 25, 20072007-10-25
Reply by ●October 26, 20072007-10-26
Steve Underwood wrote:> Richard Owlett wrote: > >> PS I subscribe to "Give a man a fish, he eats for a day. Teach him to >> fish ..." > > > ..... he'll undercut you and drive you out of business. > > SteveBut why was I handing out fish in first place? If he is successful enough to undercut me, he has likely had to hire and *TEACH* assistant fishers. Therefore feeding many instead of just one. MORAL: Answer newbie questions with leading questions/hints.
Reply by ●October 26, 20072007-10-26
Richard Owlett wrote:> maxplanck wrote: > >>> Richard Owlett wrote: >>> >>>> maxplanck wrote: >>>> [snip] >>>> >>>>> Do you know of any software that can do this? I understand the >>>>> algorithm, >>>>> but I don't have knowledge of a computer programming language by which >> >> >> to >> >>>>> implement it. >>>> >>>> >>>> >>>> Have you looked at Scilab ( http://www.scilab.org/ ) yet? >>>> I may have to dare you to try it ;) >>> >>> >>> Guess I will have to dare you into getting your programming feet wet ;) >>> >>> Have just done envelope detection in 20 lines of Scilab. >>> [ *INCLUDING* generating and proving test case] >>> >>> Most advanced programing concept used was a loop. >> >> >> >> >> Richard, would you mind sharing your code? > > > *WHEN* you've tried ;) > > I'll give a hint by listing the Help headings for ALL keywords I used: > > abs brackets colon comments comparison diff end equal > for matrices parenthesis plot2d plus semicolon sin star > > PS I subscribe to "Give a man a fish, he eats for a day. Teach him to > fish ..." > >You now have a moving target. I've reduced the total simulation to 10 lines of Scilab code.
Reply by ●October 26, 20072007-10-26
To plot the amplitude envelope you should demodulate the signal to baseband. To do this with a single-valued signal you have to use a Hilbert Transform, then demodulate by multiplying by the carrier frequency. MATLAB provides tools to do this, so do some other DSP packages. If you want to do it yourself, then look up 'analytic signal' and 'acausal filter' which are the tools you can use. Chris ============== Chris Bore www.bores.com On Oct 18, 2:37 pm, "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
Reply by ●October 26, 20072007-10-26
Chris Bore wrote:> To plot the amplitude envelope you should demodulate the signal to > baseband. > > To do this with a single-valued signal you have to use a Hilbert > Transform, then demodulate by multiplying by the carrier frequency. > MATLAB provides tools to do this, so do some other DSP packages."must" ???????????? Why not following Scilab code: slope_signal=diff(signal); // simple minded 1st derivative // will pass thru 0 at local min/max tt = find( (slope_signal(1:$-1).*slope_signal(2:$))<= 0 ); envelope=abs(signal(tt)); OP had said: > >>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) >>
Reply by ●October 26, 20072007-10-26
>Chris Bore wrote: >> To plot the amplitude envelope you should demodulate the signal to >> baseband. >> >> To do this with a single-valued signal you have to use a Hilbert >> Transform, then demodulate by multiplying by the carrier frequency. >> MATLAB provides tools to do this, so do some other DSP packages. > >"must" ???????????? > >Why not following Scilab code: > >slope_signal=diff(signal); // simple minded 1st derivative > // will pass thru 0 at local min/max >tt = find( (slope_signal(1:$-1).*slope_signal(2:$))<= 0 ); >envelope=abs(signal(tt)); > >OP had said: > > > >>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 locationof> >>each local maxima, then connect adjacent points with a line)Richard, what's the "$" mean in scilab code? (i've been able to find everything else in the great list of terms you posted earlier, thanks a lot)
Reply by ●October 26, 20072007-10-26
maxplanck wrote:>>Chris Bore wrote: >> >>>To plot the amplitude envelope you should demodulate the signal to >>>baseband. >>> >>>To do this with a single-valued signal you have to use a Hilbert >>>Transform, then demodulate by multiplying by the carrier frequency. >>>MATLAB provides tools to do this, so do some other DSP packages. >> >>"must" ???????????? >> >>Why not following Scilab code: >> >>slope_signal=diff(signal); // simple minded 1st derivative >> // will pass thru 0 at local min/max >>tt = find( (slope_signal(1:$-1).*slope_signal(2:$))<= 0 ); >>envelope=abs(signal(tt)); >> >>OP had said: >> >>>>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) > > > Richard, what's the "$" mean in scilab code? > (i've been able to find everything else in the great list of terms you > posted earlier, thanks a lot)$ is the maximum value of that index of a matrix.
Reply by ●October 28, 20072007-10-28
>>>slope_signal=diff(signal); // simple minded 1st derivative >>> // will pass thru 0 at local min/max >>>tt = find( (slope_signal(1:$-1).*slope_signal(2:$))<= 0 ); >>>envelope=abs(signal(tt));OK, this works great. To check the results, I did: plot(tt, envelope); and it looks perfect. I'm a bit stumped though on how to output the plot data into a text file. If i can't output the plot data, then i'd have to plot the points (tt, envelope) then draw lines between adjacent points, at a 44100 hz sample rate (since the original signal was recorded at this sample rate). How can i do this? Thanks for all the help, i'm almost there! =D
Reply by ●October 31, 20072007-10-31
Richard Owlett wrote:>Why not following Scilab code: > >slope_signal=diff(signal); // simple minded 1st derivative > // will pass thru 0 at local min/max >tt = find( (slope_signal(1:$-1).*slope_signal(2:$))<= 0 ); >envelope=abs(signal(tt));This works great, here is the code that i'm using: stacksize(99999999); signal=fscanfMat('/H1.txt'); slope_signal=diff(signal); tt = find( (slope_signal(1:$-1).*slope_signal(2:$))<= 0 ); envelope=abs(signal(tt)); plot (tt, envelope); However, i'm stumped on the final step here: I need to export the plot data. (so that i can import it into Reaktor and use it as audio data. Reaktor can import .txt and .wav files.) I've spent a lot of time searching through the scilab help file and online, looking at many commands hoping to find the one(s) i need. Can someone pls give me some guidance here?
Reply by ●October 31, 20072007-10-31
maxplanck wrote: ..> This works great, here is the code that i'm using: > > stacksize(99999999); > signal=fscanfMat('/H1.txt'); > slope_signal=diff(signal); > tt = find( (slope_signal(1:$-1).*slope_signal(2:$))<= 0 ); > envelope=abs(signal(tt)); > plot (tt, envelope); > > However, i'm stumped on the final step here: I need to export the plot > data. (so that i can import it into Reaktor and use it as audio data. > Reaktor can import .txt and .wav files.) > > I've spent a lot of time searching through the scilab help file and > online, looking at many commands hoping to find the one(s) i need. > > Can someone pls give me some guidance here?wavwrite? It is described at the bottom of this page: http://www.lumanmagnum.net/physics/sci_wav.html Richard Dobson