# Detecting a low frequency cue in audio recording

I am hoping to find a linux program or library for a language like perl or python (open to any solution though) to detect low frequency cues in an audio recording.

Ideally I would end up with a printout of timestamps in HH:MM:SS format that correspond to where the cues occur.

Here is visual example of the audio cue:

The cue appears to be unique waveform and there is no other sounds at this frequency through out the recording. The frequency is so low that it is in audible. Based on this I assume it must be possible to detect the cues.

• what you want is a fourier transform library that allows you to output the frequency, then all you do is scan through for that frequency occurring. I'd suggest googling for either fourier transform, or frequency identification – Rory Alsop Mar 31 '17 at 16:13
• @audionuma do you know how id initiate a migration? – BryanK Mar 31 '17 at 17:20
• flagging might raise a moderator's attention. I wil do it now. – audionuma Mar 31 '17 at 20:45
• libsndfile and fftw will do the trick. – Mark Apr 1 '17 at 11:49

You can solve this problem with a simple time based low pass filter, no need for an FFT:

• Calculate the minimum integration time you want by dividing your sampling rate by the frequency you want to detect. For a 10Hz at 44100Hz, it would be 4410 samples, so let's take 4500 samples.

• Then apply a low pass filter to this group of samples (choosing the right frequency cut), you will isolate the frequencies you want. I do not really know how to use them, but it should look something like this:

$$y(n) = x{(n)}+x(n-1) + ...$$

• Calculate the relative power of your filtrated group of samples in dBFS (Full Scale) based on this formula:

$$p_{RMS} = \sqrt{\frac{ x_1^2 + x_2^2 + \ldots}n }$$ $$dbFS = 20\log_{10}\frac{ p_{RMS}}{p_{max}}$$ 'n' behind the number of samples and 'pmax' the maximum value of a sample.

If the level you get is superior to a specific threshold of your choice (not to low, because your audio certainly have a tiny low frequency component), then there is a cue, otherwise there isn't.

As for the timestamp aspect, you can increase a variable each time you get into this low frequency detection loop, and calculate the time passed using the sampling rate. Then write an array containing the input/output time of each successful detection.

Not sure if the minimum integration time is really necessary though.

• I did end up using a lowpass filter so I will accept this answer. My final solution was slightly different though. After applying a lowpass I used ffmpeg to do a silence detection. Every timestamp where there was a silence end or start was my cue. I would like to ask if you know of good sources for learning the math you posted - its way over my head. I will post my solution soon, maybe you will have some ideas for improvements. – BryanK Apr 4 '17 at 10:57
• The website dsprelated.com is pretty useful to me, it contains a freebook section with serious information, while staying accessible to the beginners (which I still am). The EBU R128 Loudness Recommendation should be interesting to look at. There probably is an expensive academic book about it. And getting in touch with audio developers (working on DAWs like Ardour, Reaper, Audacity ...) could also be a good idea. – Victor Deleau Apr 4 '17 at 15:57