The harder you work,
           the
luckier you seem to be.  

Spectral Analysis with gnu Octave

After reading the file into memory, the application steps piecewise through the audio file in units of time determined by the constant ‘tdelta’.  Specifically, the number of samples in a sampleSet, denoted ‘nn’, is equal to the sample rate at which the file was recorded multiplied by the constant ‘tdelta’.

             To each sampleSet’s channel, a Hamming filter is applied in the time domain by multiplication (not convolution), which has the practical effect of attenuating “end effects” (and the formal effect of yielding finite bounds for the FFT). 

             Next, the complex Fast Fourier Transform is calculated, from which the real Discrete Fourier Transform is extracted.  For this application we are only interested in the magnitude of the basis functions (not their phase), so they are calculated during the DFT extraction.  (The complex values are converted from rectangular to polar form while discarding phase angles.)

             Finally, depending on the values of dAudio, dAnalysis, and dAnalyzer, the corresponding display functions may be called. 

             dispAudio() is a very simple function which employs gnuPlot to display the unmodified PCM data for a sampleSet (figure 1).

3  of  4

 

www.MichaelDWelch.net                                                                                   MichaelDWelch@(no-spam)acm.org

www.linkedIn.com/in/MichaelDWelch                                                                 303-920-9749      remove (no-spam)

nn = sampleRate * tdelta;

hamm = hamming(nn);
hamm(:,2) = hamm(:);
data2 = data .* hamm;

ffdata = fft(data2);
yf1 = abs(ffdata(1:nn/2, 1));
yf2 = abs(ffdata(1:nn/2, 2));