Audio processing to figure out RPM of motor

In [1]:
[d, sam] = audioread("tablefan.wav",'native');
N = size(d);
t = (0:1:N-1)'.*1.0/sam;
plot(t, d); xlabel("Time"); ylabel("Audio signal near fan");
In [2]:
dk = fft(d);
dk = dk(1:floor(N/2));
#plot(real(dk));
xk = sam/N(1):sam/N(1):sam/2;
loglog(xk, abs(dk));
hold on;

pkg load signal;

[peaks idx]= findpeaks(abs(dk),"MinPeakHeight",1e7,"MinPeakDistance",200);

loglog(xk(idx), abs(dk(idx)), 'xr')
hold off;
In [3]:
disp(xk(idx))
    25.843    51.587    77.579   103.423   128.919   154.663   180.407   231.944
In [4]:
[d, sam] = audioread("benchgrinder.wav","native");
N = size(d);
t = (0:1:N-1)'.*1.0/sam;
#plot(t, d); xlabel("Time"); ylabel("Audio signal near bench grinder");
dk = fft(d);
dk = dk(1:floor(N/2));
xk = sam/N(1):sam/N(1):sam/2;
loglog(xk, abs(dk));
hold on;
[peaks idx]= findpeaks(abs(dk),"MinPeakHeight",1e7,"MinPeakDistance",200);

loglog(xk(idx), abs(dk(idx)), 'xr')
In [5]:
xk(idx)
ans =

 Columns 1 through 7:

     49.936     99.710    149.807    199.420    249.275    299.050    348.985

 Columns 8 through 14:

    649.162   1009.745   1048.164   1215.448   1253.947   1459.971   4212.709