I have imported an audio file of a musical triad (three notes) and then taken its fourier transform to find the fundamental frequencies of the chord. From this transform, I would like to automatically select the three highest peaks in magnitude and determine where they fall on the x (frequency) axis.
My initial thought was to utilize maxk, but this obviously chooses the three highest points overall, even if they are on the same "peak".
Ultimately, I would like the return to be a vector (or array) with the three most prominent frequencies (and their magnitude, if it's an array).
[x,Fs] = audioread('eqt-CMajor.wav');
T = 1/Fs;
L = length(x);
t = (0:L-1)*T;
xMono = sum(x, 2) / size(x, 2);
Y = fft(xMono);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
[M, Hz] = maxk(f,3,'ComparisonMethod','abs')