How can I get the attack time of an audio signal?

Effects, Recipes, Interfacing with other software, etc.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
ruski313
Posts: 6
Joined: Mon Dec 17, 2018 8:45 pm
Operating System: macOS 10.15 Catalina or later

How can I get the attack time of an audio signal?

Post by ruski313 » Mon Dec 17, 2018 8:53 pm

Hi there,

Hope somebody can show me how to get the attack time of an audio signal (a single note performed by only one instrument). I attach an example of the audio signal.

Thanks in advance!
Attachments
0dn_cnt.wav
(44.51 KiB) Downloaded 16 times

steve
Site Admin
Posts: 81651
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How can I get the attack time of an audio signal?

Post by steve » Mon Dec 17, 2018 9:11 pm

Easiest to see if you "Normalize" the track first.

Select the "attack" (rising) section, then read the length from the Selection Toolbar.

As you can see in this screenshot, the attack starts at around 7 ms from the start of the track and has a duration of around 36 ms.

attack.png
attack.png (38.44 KiB) Viewed 368 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

ruski313
Posts: 6
Joined: Mon Dec 17, 2018 8:45 pm
Operating System: macOS 10.15 Catalina or later

Re: How can I get the attack time of an audio signal?

Post by ruski313 » Tue Dec 18, 2018 10:03 am

Hi Steve,

Thanks so much for your advice. In this case, it is very clear. Just wondering if there is an analysis method that helps to accurately measure the envelope or I should try with matlab, r, etc?

Thank you!

ruski313
Posts: 6
Joined: Mon Dec 17, 2018 8:45 pm
Operating System: macOS 10.15 Catalina or later

Re: How can I get the attack time of an audio signal?

Post by ruski313 » Tue Dec 18, 2018 10:28 am

Hi Steve,

What I mean is that I can't see clearly that the attack time starts at 7ms. Should I try to run a piece of code instead maybe?

Thanks a lot,

steve
Site Admin
Posts: 81651
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How can I get the attack time of an audio signal?

Post by steve » Tue Dec 18, 2018 10:40 am

If you were to use MATLAB or similar, you would need to devise an algorithm to determine the start and end of the attack phase. In the "0dn_cnt.wav" example, the attack phase is easy to see, but to define an algorithm is very much more complex.

We can see it your example that the "natural" start of the attack is a little earlier than the start of the waveform. By eye we can extrapolate the slope of the attack to infer a start time of 7 ms. Similarly, we see the initial (curved) slope has a noticeable bend (at the end of the selection), which is the obvious end of the attack phase, even though this is not the maximum level of the sound.

Your algorithm would need to:
1) Find the slope of the attack (following peaks)
2) Extrapolate the slope back to where it intersects the "silence" line.
3) Determine a point where the slope has reduced in steepness enough to be NOT the attack phase
4) Allow for curves in the attack (curved in either direction)

You then need to implement the algorithm as code, test and debug it.
Is it worth the effort?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Trebor
Posts: 9962
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: How can I get the attack time of an audio signal?

Post by Trebor » Tue Dec 18, 2018 2:00 pm

There are free "transient shaper" plugins where you can vary the attack by ear ...

transient shaper plugin.gif
transient shaper plugin.gif (644.62 KiB) Viewed 349 times

kozikowski
Forum Staff
Posts: 69384
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: How can I get the attack time of an audio signal?

Post by kozikowski » Tue Dec 18, 2018 3:35 pm

We should consider the view, too. Waveform view only sees sound down to about -25dB to -30dB before it becomes undetermined (invisible). You can easily hear into the -60s or lower. DB view displays the whole thing, but you stop being able to see wave details enough to give meaningful numbers.

Why are we doing this? It's not unusual for people to try to do surgical analysis on sound that resists surgical analysis.

Audacity is a production editor and does things because they sound good.

Koz

steve
Site Admin
Posts: 81651
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How can I get the attack time of an audio signal?

Post by steve » Tue Dec 18, 2018 5:47 pm

kozikowski wrote:
Tue Dec 18, 2018 3:35 pm
Waveform view only sees sound down to about -25dB to -30dB before it becomes undetermined (invisible).
Unless you zoom in vertically

tracks000.png
tracks000.png (19.79 KiB) Viewed 337 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply