Sound Processing in Matlab: I

In summary, the conversation discusses the need for help in extracting the fundamental frequency from a recorded wav file, specifically an A-chord from a guitar sampled at 44100 Hz using mono. The source code provided is used to process the signal components of the chord, but the desired output waveform does not show the correct frequency. Various methods and approaches are discussed, including using a frequency vector and teaching the program to recognize a series of harmonics. However, the problem is deemed more complex and may require a different approach such as using a wavelet transformation or solving a coherence problem.
  • #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
 
Physics news on Phys.org
  • #2
Help!

Or an alternative method would be a simpler way in extracting the fundamental frequency from a sound file... my syntax doesn't seem to give me the desired results...
 
  • #3
:cry:

You can't dilucidate the fundamental frequency by selecting the peak frequency as you are doing.
Moreover when you have a chord with several fundamental frequency mixed

(you have not a self coherent signal)
but a signal composed by three fundamental (temperated and therefore
non congruent) frequencies

good luck , I am afraid that the process you wish to program is somewhat more complex.
 
  • #4
we were able to display the right frequencies already. but now its just a matter of determining the right chord after recognizing the many harmonics present in one chord... do u think i can teach the program to recognize a series of harmonics that would yield the right chord? Like the D chord has D3, A3, D4, F#4,A4, D5 and F#5... if i teach the program to learn this progression it could possibly detect the correct chord... is this a good approach or does it involve a bit more than simpy looking for a chord's harmonics?
thanks!
 
  • #5
The temperated grid in which you try to locate the armonics of the notes that make up the chord are too coarse to reflect the armonc composition of the notes (due to the fact that armonics are growing lineary and temperated notes are growing logaritmically)
I think the problem you are trying to solve are quite more complex and you'd better do trying some autoscalar logaritmic transformation as wavelet o something similar.
Anyway, you could use (linear) Fourier transform but then you'd need to solve a difficult coherence problem ( that is extracting the Maximun Common Divisor of all the significant frecuencies in the signal) but this is more easy to say that to solve because if you have some noise in each frequency, you'll end up saying that the fundamental frecuency is the lower in the system; that ist the inverse of the duration of the sample.
 

1. What is sound processing in Matlab?

Sound processing in Matlab refers to the use of the Matlab programming language and software to manipulate and analyze sound data. This can include tasks such as filtering, noise reduction, and signal analysis.

2. How does Matlab handle sound data?

Matlab handles sound data as a one-dimensional array of values representing the amplitude of the sound signal at different time points. The sampling rate (number of samples per second) and bit depth (number of bits used to represent each sample) can also be specified for more precise manipulation.

3. What are some common sound processing functions in Matlab?

Some common sound processing functions in Matlab include audioread and audiowrite for reading and writing sound files, soundsc for playing sound data, and fft for performing a Fast Fourier Transform for frequency analysis.

4. Can Matlab be used for real-time sound processing?

Yes, Matlab can be used for real-time sound processing by utilizing the audiorecorder and audioplayer functions to record and play sound data in real-time. Additionally, the sound function can be used to play sound data as it is being generated.

5. Are there any built-in tools for visualizing sound data in Matlab?

Yes, Matlab has built-in tools for visualizing sound data, such as the spectrogram function for plotting the frequency content of a sound signal over time, and the plot function for plotting the amplitude over time.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
16
Views
13K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
Back
Top