Detecting occurences of a sound

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-chorus-pheenys-track. I’ve marked the positions of the thumps.

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

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
Picture 1.png

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

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.

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

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.

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)

(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.

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.

If you have any “geek” in you, you’ll love it :smiley:

Spot on.

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

Because it creates a square wave? My spectrogram isn’t as clean as yours, what parameters have you set for it?

Yes, you’ve got it.

I tend to change these quite frequently when analysing stuff… give me a moment and I’ll post a screenshot…

spectrum-prefs.png

Thanks for that. I’d chosen Hamming by mistake, instead of Hanning. It makes quite a difference.

I change them a lot too. I wonder if the developers would consider adding an option to save/load the spectrogram parameters.

You mean like “favourites” for the spectrogram page?
What do you have in mind?

I was thinking of something like the Save/Manage Curves button in Eq. Then I could save and name some settings, and load the one I need by looking at the names I’ve given them. I probably only need two or three, but it might help users get going with spectrograms by providing some predefined ones so they don’t have to guess what all those mysterious settings are.

A preview while fiddling with the settings would be nice too.

Is this just for FFT window size and type?

You mean a visual preview? I’m not sure how well that would work - there may be no audio track.

A patch exists (tied in with quite complex algorithm changes if I recall) that lets you change window size in the Tracks Menu, where the item in the Tracks Menu enabled a shortcut to cycle through the window sizes. I think that was it, but the details may be wrong. Would you like to vote for something like that, to include an item for window type too?


Gale

No. I experiment with all the settings, and I’m never confident I’ve got them back how they were when I’m done. I could, of course, just stick a bit of paper on the wall with some favourite settings written on it instead of bothering developers.



You mean a visual preview? I’m not sure how well that would work - there may be no audio track.

It’s a little tedious to get into Preferences (I know about ^P), change a setting, save the preferences to see how it looks, over and over. If there was a button on that Preferences form to regenerate the current spectrogram(s), if any, without leaving the form, that would save a lot of button pressing and clicking.

A patch exists (tied in with quite complex algorithm changes if I recall) that lets you change window size in the Tracks Menu, where the item in the Tracks Menu enabled a shortcut to cycle through the window sizes. I think that was it, but the details may be wrong. Would you like to vote for something like that, to include an item for window type too?

Window type isn’t something I change that often, but I often experiment with gain, etc, too, so I’d want to see them all. I suppose having access to shortcut keys would make it really quick, but I think cycling through, rather than choosing what you want, could be frustrating. I think I like my preview button idea better. Do you know of a thread for that suggestion?

Now that I’ve tried the spectrogram idea on the long track, I’ve found that the recalculation times for panning are a little slow with high window size values. (It’s slow on the one minute track too, but there was no need to pan.) Splitting the stereo track and working on just one side helps a lot. Can anyone suggest other ways to speed it up?

I’m experimenting with Sonic Visualiser, which is much faster for panning. I think it achieves this by caching the graphics for the whole spectrogram, but that means it takes ages to change a spectrogram value. I think it might be best to stick with Audacity unless I want to learn a whole new set of shortcut keys and how to import labels into Audacity.

Or you could do the digital equivalent and store the groups of settings commented out in audacity.cfg. Before you launch Audacity, uncomment the set you want to use.

[quote=“pshute”]
A preview while fiddling with the settings would be nice too.
[/quote]

You mean a visual preview? I’m not sure how well that would work - there may be no audio track.

It’s a little tedious to get into Preferences (I know about ^P), change a setting, save the preferences to see how it looks, over and over. If there was a button on that Preferences form to regenerate the current spectrogram(s), if any, without leaving the form, that would save a lot of button pressing and clicking.

A patch exists (tied in with quite complex algorithm changes if I recall) that lets you change window size in the Tracks Menu, where the item in the Tracks Menu enabled a shortcut to cycle through the window sizes. I think that was it, but the details may be wrong. Would you like to vote for something like that, to include an item for window type too?

Window type isn’t something I change that often, but I often experiment with gain, etc, too, so I’d want to see them all. I suppose having access to shortcut keys would make it really quick, but I think cycling through, rather than choosing what you want, could be frustrating. I think I like my preview button idea better. Do you know of a thread for that suggestion?

No-one has suggested it before to my knowledge, but now I know what you want I’ll add your vote for it and for the settings save and reload.

But with you and Steve apparently changing Spectrogram settings frequently, it makes me wonder if Preferences are the best place. For example instead of the Preferences pane, there could be View > Adjust Spectrograms, which opened a dialogue box with the same dialogue that is in Preferences now. If that menu item was greyed unless there was an audio track in Spectrogram or Pitch view, then it might make more sense for changing the settings to update the window before closing the dialogue.


Gale