Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %read the audio file x samples, output Fs
- [x,Fs]= audioread('Guitar_notes.wav');
- %take the fourier transform
- xdft = fft(x);
- xdft = xdft(1:length(x)/2+1);
- % create a frequency vector
- freq = 0:Fs/length(x):Fs/2;
- %locs is now in frequency
- [pks,locs] = findpeaks(20*log10(abs(xdft)));
- %finds the peaks within the range of the fundamental frequency of the notes
- indesiredrange = locs > 150 & locs < 500;
- %gets the subsets within range
- pks_subset = pks(indesiredrange);
- locs_subset = locs(indesiredrange);
- figure(1)
- semilogx(freq,20*log10(abs(xdft)))
- hold on
- plot(freq(locs_subset), pks_subset, 'or')
- hold off
- xlabel('f(Hz)');
- title('FFT of signal')
- [pks,locs] = findpeaks(20*log10(abs(xdft)), freq);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement