Friday, June 22, 2018

fft - Dividing Audio signals into Barks Bands


I want to apply the following steps in matlab


1) Read the audio data


2) Apply window function on that data


3) Apply fft on the result of window function


4) Make power spectrum of fft


5) divide power spectrum in Barks bands


[y,Fs,bits] = wavread('file1.wav');
Nsamps = length(y);

ham= hamming(Nsamps);
ham_fft = abs(fft(ham));
ham_fft = ham_fft(1:Nsamps/2); %Discard Half of Points
plot(f, ham_fft)
xlim([0 1000])
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('FFT of Hamming Window of a an audio');

I am not getting the correct waveform , want to draw the spectrum and then Divide into barks bands .




Answer





  • Read the audio data


    [y,Fs,bits] = wavread('file1.wav');


  • Apply window function on that data


    ham=hamming(Nsamps);
    windowed = y .* ham;



  • Apply fft on the result of window function


    ham_fft = fft(windowed);
    ham_fft = ham_fft(1:Nsamps/2); %Discard Half of Points


  • Make power spectrum of fft


    PowSpec = abs(fft(ham_fft)).^2;



  • divide power spectrum in Barks bands




So here maybe start interesting things, based in wikipedia the 24 Critical Barks Bands in Hertz is:


20,100,200,300,400,510,630,770,920,1080,1270,1480,1720,2000,2320,2700,3150,3700,4400,5300 6400,7700,9500,12000,15500

Now to split the power spectrum in Barks bands you need to do something like:


BandBarks = [20 100 200 300 400 510 630 770 920 1080 1270 1480 1720 2000 2320 2700 3150 3700 4400 5300 6400 7700 9500 12000 15500];



for l = 1:length(BandBarks)-1
CurrentBand = [BandBarks(l):BandBarks(l+1)];
PowSpec(CurrentBand,:) %% here is the power spectrum for each Barks bands
end

OK by your commented error seems that your audios are in stereo, convert to mono, or get just one channel!


my example above assumes that each BIN number is the equivalent frequency (course this is nothing common was just an example), to find what bin is your frequency you need calculate:


$$ BandBarks * (\frac{Fs}{length(FFT)})$$


So based in this equation:



Bins = zeros(length(BandBarks),1);
for j = 1:length(BandBarks)

Bins(j)=round(BandBarks(j)/(Fs/length(FFT)))

end

Now here how to plot individually each Bark band:


for l = 1:length(Bins)-1 
CurrentBand = [Bins(l):Bins(l+1)];

figure(l);
plot(PowSpec(CurrentBand,:));
end

I think I can not be clearer than that


No comments:

Post a Comment

periodic trends - Comparing radii in lithium, beryllium, magnesium, aluminium and sodium ions

Apparently the of last four, $\ce{Mg^2+}$ is closest in radius to $\ce{Li+}$. Is this true, and if so, why would a whole larger shell ($\ce{...