Bee Audio Testing Notes - DynamicDevices/bee-monitor GitHub Wiki

Getting Started

So I want to look at audio analysis. Some folks on Twitter have recommended GNU Octave & Waterfall Plots.

Before I get started I want to try some basic things to get a handle on creating some simle test cases for later.

Firstly I thought it would help to know how to generate an audio file with a sine wave at a certain frequency. Googling around I see I can create a 1kHz sine wave for 5s using FFMPEG like this

ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -c:a pcm_s16le sine_test.wav

I like the OpenSource Audacity audio tool and I am sure it can do lots of things I am unaware of. So I tried loading my sine-wave WAV file into it...

So that looks pretty good. Next I thought I would try plotting the spectrum for this

So that all looks pretty good and I reckon I can move onto the next step

Waterfall Analysis

I was recommendeded to take a look at a script to create a waterfall plot from an audio file.

Details in Github here

So first off I'll clone this repo and see what I can do to generate a plot!

Grab some dependencies and git clone the repo

$ sudo apt-get install parallel mencoder ffmpeg sox libsox-fmt-mp3 mp3info
$ git clone https://github.com/jdesbonnet/audio-to-waterfall-plot-video

Edit the make-waterfall-video.sh file as it hardcodes locations for needed utilities

# Location of tools
MP3INFO=mp3info
SOX=sox
#PARALLEL=/home/joe/Downloads/parallel-20140122/src/parallel 
PARALLEL=parallel
#FFMPEG=/var/tmp/ffmpeg-2.1.3/ffmpeg
FFMEG=ffmpeg
MENCODER=mencoder

Here's the help output

./make-waterfall-video.sh options... <mp3file>

Options:

 -c <credit> : will be displayed at bottom left (default credit to this script)
 -t <title> : will be displayed centered on top (default none)
 -d <seconds> : width of the spectrogram in seconds. Determines scroll speed. (default 1)
 -r <frames-per-second> : Video frame rate (default 30)
 -o <output-file> : name of output mp4 file (default output.mp4)
 -h : display this message and exit
 -v : display version and exit

For more information see this blog post:
http://jdesbonnet.blogspot.ie/2014/02/convert-mp3-to-scrolling-spectrum.html

Or GitHub at https://github.com/jdesbonnet/audio-to-waterfall-plot-video

Now let's run it against our sine wave. First we need to convert to an mp3

ffmpeg -i sine_test.wav -vn -ar 44100 -ac 2 -b:a 192k sine_test.mp3

So that works and gets me an MP4 output which I have uploaded to YouTube here

I'm not entirely sure about what this is showing, particularly at the left at the start?

Bee Noises

Now I am going to try to look at the Bee sounds with the same technique.

So I downloaded one of the live streams of the Bees from YouTube using YouTube Downloader

Then I stripped out the audio with FFMPEG

ffmpeg -i input-video.avi -vn -acodec copy output-audio.aac

That was showing me it was outputting AAC

So then I converted this to MP3 (note the -t to limit the output to the first 60 seconds)

ffmpeg -i output-audio.aac -c:a libmp3lame -ac 2 -b:a 190k -t 60 outputfile.mp3

That gave me Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp, 190 kb/s

So then I ran the script

./make-waterfall-video.sh -t "1Khz Sine Test" ~/Downloads/outputfile.mp3 

Which gave the the nice output video here

Back to Audacity

Loading in the Bee audio and plotting again in Audacity I get the following.

Not entirely sure what it means except that the audio intensity does seem low as I see here and it does seem concentrated down at the low end of the frequency spectrum.

If I take the "size" up this seems to clean up the image above 1KHz which is what I expect as the bees aren't making noises above that frequency (From the manual: "In Spectrum, a larger size gives more accurate frequency resolution (narrow bands), but averages the result over a longer period of time (because more samples are needed for the calculation)")

So then for the purposes of hearing this more easily I used the amplify effect with 20dB to go from a peak amplitude of -30dB to -10dB (I am not sure what this does in terms of the signal quality?)

Plotting the spectrum again shows the same curve but louder so it seems more or less reasonable

Running the Waterfall script again

So I see sox is used to downsample the original input audio to 8kHz to make the output interesting (8/2Khz = 4kHz range). For bees I think the maximum we want is 1kHz so I downsampled to 2kHz which gave this interesting output.

Then I looked at some of the writing on bees and it seems they tend to make noise up to about 550Hz so I downsammpled further.

I also experimented with changing the quantisation and the audio intensity range.

Lots of "waterfall" videos uploaded to the channel here

And one I like here

⚠️ **GitHub.com Fallback** ⚠️