- #1
blue_raver22
- 2,250
- 0
I need help in extracting the fundamental frequency from a recorded wav file. The input is an A-chord from the guitar sampled at 44100 Hz using mono.
my source code is as follows. The variable framed is components of the signal required to be processed. So if the waveform of chord A starts at time 1.2 seconds and starts to dissipate at 3.4 seconds, framed would be the signal components from 1.2 until approximately 2.5 seconds.
y = fft(framed);
m = abs(y); % absolute value to eliminate the imaginary components
blocksize = 8000;
% Avoid taking the log of 0.
index = find(m == 0);
xfft(index) = 1e-17;
mag = 20*log(m); % take the magnitude of the fft in dB
mag = mag(1:floor(blocksize/2));
f = (0:length(mag)-1)*Fs/blocksize;
f = f(:);
% Now create a frequency vector for the x-axis and plot the magnitude and phase.
%f = (0:length(framed)-1)'*100/length(framed);
figure;plot(f,mag),
ylabel('Abs. Magnitude'), grid on
xlabel('Frequency [Hertz]')
[ymax,maxindex]= max(mag); % takes the max values
maxindex
ymax
When running this program, the desired output waveform does not show the frequency of chord A (440 Hz) but rather something else. Please help me! Our thesis doesn't seem to be progressing anymore because of this minor but irritable problem. If anyone can please help me on this. Thanks!
miguel.mcervantes@gmail.com
or
blue_raver19@yahoo.com
my source code is as follows. The variable framed is components of the signal required to be processed. So if the waveform of chord A starts at time 1.2 seconds and starts to dissipate at 3.4 seconds, framed would be the signal components from 1.2 until approximately 2.5 seconds.
y = fft(framed);
m = abs(y); % absolute value to eliminate the imaginary components
blocksize = 8000;
% Avoid taking the log of 0.
index = find(m == 0);
xfft(index) = 1e-17;
mag = 20*log(m); % take the magnitude of the fft in dB
mag = mag(1:floor(blocksize/2));
f = (0:length(mag)-1)*Fs/blocksize;
f = f(:);
% Now create a frequency vector for the x-axis and plot the magnitude and phase.
%f = (0:length(framed)-1)'*100/length(framed);
figure;plot(f,mag),
ylabel('Abs. Magnitude'), grid on
xlabel('Frequency [Hertz]')
[ymax,maxindex]= max(mag); % takes the max values
maxindex
ymax
When running this program, the desired output waveform does not show the frequency of chord A (440 Hz) but rather something else. Please help me! Our thesis doesn't seem to be progressing anymore because of this minor but irritable problem. If anyone can please help me on this. Thanks!
miguel.mcervantes@gmail.com
or
blue_raver19@yahoo.com