How to stem plot frequencies of an audio file?

6 views (last 30 days)
Jim Sun
Jim Sun on 29 Nov 2015
Edited: Jim Sun on 29 Nov 2015
I've been trying to audio read a file and then to plot the frequency on the y axis but I've had no luck. This is what I'm getting
But I need to get this
Here's my code
[data,Fs]=audioread('mysn.wav');
sound(data,Fs); % see what it sounds like */
N=length(data)
n=0:N-1;
x=transpose(data);
X=fft(x);
X_mag=abs(X);
z=max(X_mag);
N_2 = (N/2);
gh=find(X_mag(1:N_2)>10543)
gk=gh.*(Fs/N)
stem(gk)
  2 Comments
Geoff Hayes
Geoff Hayes on 29 Nov 2015
Jim - in the second figure, there are twelve distinct chords whereas in your figure there appears to be twelve sets of chords where each set may contain duplicated ones. What happens if you try to plot the unique chords as
stem(unique(gk));
How does your figure look then?
Jim Sun
Jim Sun on 29 Nov 2015
Edited: Jim Sun on 29 Nov 2015
This still gives me the same stem plot. Here's the audio file
The values are actually not duplicate as they have a very minor difference. I'm trying to find the frequency of each key pressed. in this case I pressed 12 keys and created that wave file, but apparently there's a leakage that causes multiple frequencies to be plotted that are very close to each other.

Sign in to comment.

Answers (0)

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!