4

I'm trying to figure out how to use Mathematica to identify a note from a song. The short .mp3 file found here or here contains a bass-note that I'd like to identify. I can find it through experimentation with a piano, but I'd like to identify mathematically.

I know little about signal processing. I tried implementing a process shown in Plotting Fourier spectrum versus frequency of a signal, but 1) I don't understand signal processing and 2) the result has a lot of noise as the bass note is surrounded by lots of other sound.

How can I use Mathematica to analyze a short audio clip and identify dominant notes?

GregH
  • 1,909
  • 12
  • 25
  • Well, unless you have a clear peak in the Fourier near lower frequencies, you probably can't without clearing up the audio. Do you have a plot of the spectrum? – Feyre Jun 23 '16 at 18:47
  • AudioReverb may work as you wish – partida Jun 15 '17 at 07:49

1 Answers1

6

In order to facilitate an answer (sound - D Cord):

Import["D_vbr.mp3", "Elements"]
Fs = Import["D_vbr.mp3", "SampleRate"]

data = Import["D_vbr.mp3", "Data"];
{nChannel, nSamples} = Dimensions[data]

Py = Fourier[data[[1, All]]];
nUniquePts = Ceiling[(nSamples + 1)/2];
Py = Py[[Range[1, nUniquePts]]];
Py = 2 (Abs[Py]/nSamples)^2;
Py[[1]] = Py[[1]]/2;
f = (Range[0, nUniquePts - 1] Fs)/nSamples;

spectrum = Transpose[{f, Py}];

ListLogLogPlot[Transpose[{f, Py}], Joined -> True, PlotRange -> All, 
 PlotLabel -> "Power Spectrum of mp3 file", 
 AxesLabel -> {"Freq. Hz", "power"}, ImageSize -> 400]

thres = 5*^-10;
peakValue = FindPeaks[spectrum[[All, 2]], 0, 0, thres]
peakFreq = Part[spectrum[[All, 1]], peakValue[[All, 1]]] // N

enter image description here

Your MP3 file looks like this:

enter image description here

{348.359, 467.031, 700.547, 932.148} Hz

Young
  • 7,495
  • 1
  • 20
  • 45