Skip to content

Frequency estimation in audio files using STFT and parabolic interpolation.

Notifications You must be signed in to change notification settings

JorenSix/stft_freq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STFT_FREQ – Frequency estimation using STFT
-————————-

STFT_FREQ is a C application for frequency estimation in audio files. It calculates a Short Time Forier Transform (STFT) and picks the most promenten bin within a frequency region of interest. It subsequently refines the frequency estimation using parabolic interpolation. It prints out the estimated frequency together with the magnitude of the frequency FFT bin.

Why STFT_FREQ?

Most speech or music frequency estimators need relatively large FFT windows to allow precise frequency estimation. The assumption for speech and music is that frequency changes relatively slowly. For birdsong this assumption might not hold. In the example below a fast change is shown.

Finch birdsong analysis

STFT_FREQ requirements

To use stft_freq ffmpeg and ruby need to be installed on your system. While the core of stft_freq is in pure c, a Ruby script provides an easy to use interface to its capabilities. The Ruby script converts audio (with ffmpeg), parses command line arguments and reports results in a readable format.

To install ffmpeg and ruby on a Debian like system:

apt-get install ffmpeg ruby

On macOS ruby is available by default and ffmpeg can be installed with homebrew

brew install ffmpeg 

Compilation and installation of stft_freq

To compile use toffolwing commands. By default the makefile uses gcc set to the C11 standard. It should be possible to use other compilers compliant with the C11 standard as well. So either make sure gcc is installed correctly or modify the Makefile for your compiler of choice. Compilation and installation:

make
make install

STFT_FREQ Usage

After a successfull installation of stft_freq on your path calling the program should be as simple as

stft_freq audio.mp3

To import the results in Sonic Visualizer save the result to a csv file. Import out.csv into sonic visualiser with the first column the time in seconds and the second column the value. It might be of interest to filter out the fft bins with a low magnitude.

stft_freq audio.mp3 > out.csv

The c application can be used directly as well with correctly converted RAW files:

	stft_freq audio_sr block_size step_size min_freq max_freq audio_file.raw

Further Reading

The parabolic interpolation and windowing function is described here:

Gasior, M., and J. L. Gonzalez. Improving FFT frequency measurement resolution by parabolic and gaussian interpolation. No. AB-Note-2004-021. CERN-AB-Note-2004-021, 2004.

Credits

Parts of the code are reused from Olaf .

STFTF_freq by Joren Six at IPEM, Ghent University.

About

Frequency estimation in audio files using STFT and parabolic interpolation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published