Monday, March 1, 2010

Using Spectrograms To Get Even More Out of Your Audio Recordings

Last year I began paying a lot of attention to the various audio recordings of potential sasquatch vocalizations that are available on the internet. And while I have a fairly practiced ear when it comes to audio analysis, I had a sneaking suspicion there is more to these recordings than normally meets the ear. So I set about finding tools that could help me take a closer listen to, and look at, some of these recordings.

The first thing I learned was some new tricks from an old friend, Audacity. I found that with some judicious post processing, as described in this post, I could clean up a lot of noisy recordings and uncover previously obscured or inaudible sounds. The second thing I found was that your ears work better when your eyes are involved. So to "visualize" the sounds captured in an audio recording I looked into spectrograms, and found a free, open source application with audio analysis at its core. Sonic Visualiser (http://www.sonicvisualiser.org/ ) is one of a collection of audio applications capable of generating spectrograms, but in terms of capability and configurability, it's very hard to beat. And the the price is certainly nothing to sneeze at.

The thing that makes Sonic Visualiser so appealing to me, its capability, also created a learning curve that took me a few weeks to work through. But the value of this type of tool, even for the simple act or reviewing your audio recordings, is so immense that I found it well worth the effort. And because I believe this tool can fundamentally change the way you will look at your field recordings, I'm willing to write this direct "how-to" to help you get up and productive with this software as quickly as possible.

Why do this? Because listening to hours of field recordings on the off chance that something catches your ear has become a pitiful activity. Your time is better spent examining the sounds you've captured, and this tool will help you find the sounds you would never have known were there. With spectrograms you'll not only be able to scroll through hours of "visual" audio in much less time than it takes to play it, you'll actually begin to recognize patterns that tell you what kind of sound you've captured, before you even listen to it. So enough hyperbole, let's get to it...

Begin by downloading Sonic Visualiser from the download page at the link above and installing it on your computer. You don't need anything super powerful to run this, but a computer bought within the last couple of years will give you the most satisfactory graphics performance (this is a visual application after all). Older computers will work as well, but with diminishing performance as age increases (hmmm, sounds familiar).

Once Sonic Visualser (SV for short) is installed, you'll want to start it and then open your first audio file. Choose something short for these exercises, just till you get the hang of things. Go to the File menu and select the "Import Audio File" option. In the resulting window navigate to the file you wish to listen to, select it, and click Open.

The file will open in SV's default view, the well known spectrum image. This adds little value to our exercise so click the 'X' in the upper left corner to close that spectrum window. Your audio file will remain loaded, but we're going to view it in a different form, as a spectrogram.

On the keyboard hit the "G" key, which is a short cut to the "Pane>Add Spectrogram" menu item. This will open a spectrogram view of your audio file.

First thing to do is notice the panel on the right of your screen, that's where you'll make all the tweaks to your spectrogram (the configurability I referred to above).

Start by clicking on the tab labeled #2, that will overlay a time grid on your spectrogram. Use the "up" arrow on your key board to zoom in on your file. I normally zoom in until I can see the individual seconds of the file. This zoom will give you good fidelity on the signals that are visible in your spectrogram.

But notice how difficult it is to distinguish the colors of this "default" lime green spectrogram. We can improve this by clicking on tab #3 and from there selecting the drop down menu next to the "Colour" option. You'll see a number of "themes" in the drop down, and eventually you should play with them all and find your favorite. But for now, let's choose my favorite, "Fruit Salad". I know the result is garish at best, but we can make one more tweak to improve that. Just below Colour, select the drop down menu next to "Scale" and choose the dBV^2 settting. This will give you an image with the quiet areas of your recording painted in blue, and the louder portions of your recording painted in increasingly warmer colors (red being the loudest).

Now look at the left hand edge of the spectrogram window. You'll see a range of numbers, high at the top, low at the bottom. These are the frequencies, represented in Hertz, that were captured by the audio recorder that made your recording. From my experience, we'll find most of the sounds we're interested in below 2500 Hertz. So to focus in on that area look in the lower right corner of the spectrogram and note the two short, vertical columns stacked on top of the horizontal bar. (If this is not readily obvious, click the Z key on your keyboard repeatedly. This will toggle the columns on and off. You want them on.) Once you've spotted them, use your mouse to double click the left column. This pops up a window where you can specify the range to view. I leave the first number at its default (the lowest frequency), and change second number to 2500. Click OK and the image will zoom in. 2500 Hertz will be the top number on the left hand edge of the spectrogram.

This is a good spot to give your file it first playback. Easiest way to do that is hit the space bar to start playback (and hit it again to stop). You can also use the buttons on the top menu bar, which should look familiar to you.

As the file plays, watch the vertical bar move left to right across the spectrogram. As it crosses over the "hottest" colors in your file, you'll hear the sound that the color represents. The bright red colors are obvious, and probably easily heard through your computer speakers. But notice all those "warm colors", the oranges and yellows. Those are sounds too. If you pay attention as the vertical bar scrolls over them, they may pop out and become more audible. This is the coordination of eye and ear working together. The eye focuses your attention and the ear picks up the sounds. The more files you listen to, the tighter this eye-ear coordination becomes.

In this spectrogram of a 2009 audio recording from the BFRO expedition to the Olympic Peninsula, vocals audible to the unaided ear are the brightest colors on the chart. But fainter, inaudible wood knocks and vocals also become visually discernible, and subsequently audible, once the ear knows where to listen. These fainter signals might easily have gone unnoticed in a typical audio file review. (click image for larger view)

If you focus on a specific blob of color, notice it's relative vertical position. If it's closer to the top of the image, its a higher pitch sound that your ear should listen for. Conversely, colors at the lower edge are low frequency sounds. This is important to remember because often you'll have overlapping sounds, some high and some low, but a spectrogram can clue you in to their existence (where one might normally obscure the other fainter sound). Eventually, once you can see that two or more sounds exist at one point in time, you'll be able to filter out the louder sound and hear the fainter sound in the background. (Doing this without a visual queue can take a lot of focus thought. This is where spectrograms really start to shine).

That's it, you have the basics down and from here you can do all kinds of experimentation. But before you do, you should save your settings before going farther (or closing the file). That's because SV doesn't automatically keep your settings for you. Every new file you open will have to go through these set up steps (a real hassle if you want to listen to the same file more than once, and who doesn't?). So go to the File menu and select "Save Session As". Enter a file name in the resulting window and click save (try to save this new ".sv" session file in the same directory as the audio file, for convenience's sake).

A couple other things worth touching upon before we go, though.

First, use the left and right arrow keys on your keyboard to scroll forward and backward in your audio file. Hitting the left arrow is a quick way to repeat a sound that you want to "loop".

Second, hitting the "T" key on your keyboard will add a new tab to the panel on the right. When that tab is on top you can click on the spectrogram and enter text labels to next to the sounds you hear. This is a great way of noting neat sounds that you want to come back to, or to highlight for other people who use SV. You can also export all those notes as text, with their time location in the file, and share them in an email.

Third, hitting the "X" key will make the panel on the right disappear, giving you a wider spectrogram to view.

Fourth, everything's better with headphones. If you really want to hear what's going on in your audio recordings, you'll absolutely need a decent set of closed, over the ear head phones (Sennheiser has two or three models from $25 up to $100 or so). Some in-ear head phones might work too, if you can deal with the discomfort.

Finally, to get a real feel for how useful spectrograms are for rapid review of large audio files, load up a big file (preferably something that has been post processed as described in the post above) and scroll through it with the arrow keys. When you see a bright blob on your screen stop, and play through it. When you see a faint blob stop and listen to that, too. That's where the real surprises begin to appear, in the faint signals that your ears normally would have never noticed.

Good luck.

3 comments:

  1. Something that isn't immediately apparent with SV is that you can export only the sound that you have found to a wav file. To to this you hit the select button on the tool bar (the one that looks like a mouse cursor) and then highlight the section of audio you are interested in by dragging the cursor from well left of the sound, to well right of the sound. You then select Export Audio File from the File menu. SV will then prompt you for a location and name for the file. Once you have named the file and selected the location and pressed save a splash window will come up asking you whether you want to export the selected region only or the whole audio file. Highlight the selected region radio button and press OK.

    Thanks for putting this together Monongahela. It has been very helpful.

    ReplyDelete
  2. Thanks for that added note Boolywooger. I haven't really used that feature much but it would certainly be helpful when trying to isolate specific sounds.

    ReplyDelete
  3. Both Mono's tutorial and Booly's comment.. have helped me use this program successfully, and get the most out of my recorded audio files, and have also been able to help another researcher, do the same.
    Thanks for taking the time to do this, and share it with all of us.

    ReplyDelete