Detecting occurences of a sound

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
pshute
Posts: 181
Joined: Sat Feb 18, 2012 9:39 am
Operating System: Please select

Detecting occurences of a sound

Post by pshute » Thu Nov 08, 2012 9:20 pm

I've got a 2 hour nature recording, and at random intervals all through it I can hear a soft thump, which might be a distant gun shot. I'd like to find them all so I can use the longest uninterrupted section. I can only hear them if I listen carefully with headphones with no background noise, so they're easy to miss, and I'm wondering if there's an automatic way to detect them.

I was able to make them more obvious by running a low pass filter at about 200Hz, but it still very tedious to listen to. I can see them better on a spectrogram once I've done this, but it gives me lots of false positives because it's hard to see their length and abruptness.

There's a one minute downloadable sample here: http://soundcloud.com/petershute/dawn-c ... enys-track. I've marked the positions of the thumps.

I'd also appreciate any opinions about what the noises might be.

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

Re: Detecting occurences of a sound

Post by kozikowski » Thu Nov 08, 2012 10:05 pm

It does sound like gunshots.

Apply a low pass filter of 120Hz at 24dB per octave. Select that one sharp spike in the middle and delete it.

Effect > Amplify > OK.

That should give you the display in the picture. All those spikes are booms.

Koz
Attachments
Picture 1.png
Picture 1.png (35.65 KiB) Viewed 933 times

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

Re: Detecting occurences of a sound

Post by kozikowski » Thu Nov 08, 2012 10:14 pm

Of course you could just go around them by applying a high pass filter around 100Hz - 12dB. If you had trouble hearing them before, they should almost vanish if you do that. Juggle the values a bit.

This is the kind of thing we minimize by applying the filter at the time of recording -- particularly if we're shooting human voices.

Koz

pshute
Posts: 181
Joined: Sat Feb 18, 2012 9:39 am
Operating System: Please select

Re: Detecting occurences of a sound

Post by pshute » Thu Nov 08, 2012 11:25 pm

kozikowski wrote:It does sound like gunshots.

Apply a low pass filter of 120Hz at 24dB per octave. Select that one sharp spike in the middle and delete it.

Effect > Amplify > OK.

That should give you the display in the picture. All those spikes are booms.

Koz
I don't have it in front of me to try it, but I'll give that a go tonight. You've just filtered at a lower frequency than I did, and perhaps made them more obvious. However, there are other sounds in other parts of the recording that also make big spikes like that when I use a low pass filter, e.g. the sound of birds fluttering near the microphone. The difference is that the gunshots, or whatever they are, start more abruptly. Is it possible that there's some way to highlight abrupt sounds in that frequency range? If not then I have to check them all.

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

Re: Detecting occurences of a sound

Post by kozikowski » Thu Nov 08, 2012 11:42 pm

Yes, if you have very low frequency thumping from something in the show, that's the end of automated tools and easy solutions. Somebody would have to write code to do that, and then there will only be one customer.

Koz

pshute
Posts: 181
Joined: Sat Feb 18, 2012 9:39 am
Operating System: Please select

Re: Detecting occurences of a sound

Post by pshute » Fri Nov 09, 2012 1:25 am

I just found a better way. I adjusted the spectrogram parameters to make them more visible. I left everything at the default settings except:
size = 32768
max freq= 200

Now I can see them easily without even fiddling with low pass filters. I've only tried it on the one minute sample, so hopefully the high size value won't make it too slow to be usable on the long track. 8192 seems much faster, and is still usable.

I've also reassigned ctrl+Q to "Paste Text To New Label" (which I never knew existed before), and now I can mark them all quickly. An automated method would have been nice, but this is a million times better than I had before. Thanks for your help.

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

Re: Detecting occurences of a sound

Post by steve » Fri Nov 09, 2012 1:39 am

Try running this code in the "Nyquist Prompt" effect on a duplicate copy of the track. (make a duplicate copy of the track by selecting the entire track, then press Ctrl+D)

Code: Select all

(clip (mult 10 (highpass8 (lowpass8 s 100) 10)) 0.8)
You will see peaks where there are "booms".

You will then need to "look" and "listen" to those sections that show up as "booms".
When you have looked at a few you will probably be able to identify the gunshots from what they look like. For example this is the obvious one zoomed in at 23 seconds:
firsttrack000.png
firsttrack000.png (18.71 KiB) Viewed 925 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

pshute
Posts: 181
Joined: Sat Feb 18, 2012 9:39 am
Operating System: Please select

Re: Detecting occurences of a sound

Post by pshute » Fri Nov 09, 2012 1:54 am

steve wrote:Try running this code in the "Nyquist Prompt" effect on a duplicate copy of the track. (make a duplicate copy of the track by selecting the entire track, then press Ctrl+D)

Code: Select all

(clip (mult 10 (highpass8 (lowpass8 s 100) 10)) 0.8)
You will see peaks where there are "booms".

You will then need to "look" and "listen" to those sections that show up as "booms".
When you have looked at a few you will probably be able to identify the gunshots from what they look like. For example this is the obvious one zoomed in at 23 seconds:
firsttrack000.png
Thanks, I've never used the nyquist prompt before. I'm guessing that filters everything outside the 10-100Hz range then amplifies the result? What does "clip" do?

I think my spectrogram method highlights them better with less fiddling around, but thanks for the intro to nyquist programming.

pshute
Posts: 181
Joined: Sat Feb 18, 2012 9:39 am
Operating System: Please select

Re: Detecting occurences of a sound

Post by pshute » Fri Nov 09, 2012 2:01 am

I wonder if it's possible to write nyquist code to detect sets of points where they are, say, 1/100 of a second apart and rising by more than a certain value, and insert a label at that point. That might find all the abrupt sounds. It probably needs the high frequencies removed first, using the code you provided. I think I'll give the spectrogram method a go tonight, it might be all I need, and then fiddle with this if I find time.

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

Re: Detecting occurences of a sound

Post by steve » Fri Nov 09, 2012 2:11 am

pshute wrote:Thanks, I've never used the nyquist prompt before.
If you have any "geek" in you, you'll love it :D
pshute wrote: I'm guessing that filters everything outside the 10-100Hz range then amplifies the result?
Spot on.
pshute wrote:What does "clip" do?
It "clips" (truncates) the amplitude to a maximum of 0.8 (linear track scale).
This does 2 things:
1) It helps to prevent blowing your speakers or ear drums when there is a "boom"
2) It helps to make the booms show up terrifically on "spectrogram" track view because it "clips" the peaks, creating a surge right across the audio spectrum which shows up as a vertical line:
firsttrack002.png
firsttrack002.png (38.16 KiB) Viewed 925 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply