# Extract the Beat Frequency of a Sound

Create sounds of various frequencies and beat frequencies.

 In[1]:= Xtrainingset = MapThread[ Play[Sin[#1*t] + Sin[(#1 + #2)*t], {t, 0, 1}] -> #2 &, {RandomReal[{1500, 1800}, 70], RandomReal[50, 70]}];

Train a predictor that predicts the beat frequency of a sound.

 In[2]:= Xp = Predict[trainingset]
 Out[2]=

Predict the beat frequencies of some test examples.

 In[3]:= Xtestset = {Sound[ SampledSoundFunction[ CompiledFunction[{10, 10., 5444}, { Blank[Integer]}, {{2, 0, 0}, {3, 0, 5}}, {{-0.007330290496228353, {3, 0, 7}}, {{ 1500.0071924545466`, 12.514222800735638`}, {3, 1, 0}}, { 0.000125, {3, 0, 1}}, { 0.5027712654104036, {3, 0, 8}}, {-1, {2, 0, 2}}, { 1, {2, 0, 1}}, {0., {3, 0, 0}}}, {0, 3, 9, 0, 1}, {{10, 0, 2}, {16, 1, 2, 3}, {13, 0, 3, 2}, {38, 0, 0, 1, 0, 3}, {16, 3, 2, 4}, {40, 1, 3, 0, 4, 3, 0, 5}, {38, 0, 0, 2, 0, 4}, {13, 3, 4, 6}, {16, 6, 2, 6}, {40, 1, 3, 0, 6, 3, 0, 4}, {13, 5, 4, 5}, {13, 5, 7, 5}, {16, 5, 8, 5}, {1}}, Function[{Play`Time2493}, Block[{Compile`\$2409}, Block[{t = 0. + 0.000125 Play`Time2493}, Compile`\$2409 = First[{1500.0071924545466`, 12.514222800735638`}]; (( Sin[Compile`\$2409 t] + Sin[( Compile`\$2409 + Last[{1500.0071924545466`, 12.514222800735638`}]) t]) - 0.007330290496228353) 0.5027712654104036]]], Evaluate], 8000, 8000]] -> 12.51, Sound[ SampledSoundFunction[ CompiledFunction[{10, 10., 5444}, { Blank[Integer]}, {{2, 0, 0}, {3, 0, 5}}, {{{1586.703939924514, 30.083992984347987`}, {3, 1, 0}}, { 0.000125, {3, 0, 1}}, {-1, {2, 0, 2}}, { 1, {2, 0, 1}}, {-0.0070196741195687196`, {3, 0, 7}}, { 0., {3, 0, 0}}, {0.5020364580937144, {3, 0, 8}}}, {0, 3, 9, 0, 1}, {{10, 0, 2}, {16, 1, 2, 3}, {13, 0, 3, 2}, {38, 0, 0, 1, 0, 3}, {16, 3, 2, 4}, {40, 1, 3, 0, 4, 3, 0, 5}, {38, 0, 0, 2, 0, 4}, {13, 3, 4, 6}, {16, 6, 2, 6}, {40, 1, 3, 0, 6, 3, 0, 4}, {13, 5, 4, 5}, {13, 5, 7, 5}, {16, 5, 8, 5}, {1}}, Function[{Play`Time2491}, Block[{Compile`\$2407}, Block[{t = 0. + 0.000125 Play`Time2491}, Compile`\$2407 = First[{1586.703939924514, 30.083992984347987`}]; (( Sin[Compile`\$2407 t] + Sin[( Compile`\$2407 + Last[{1586.703939924514, 30.083992984347987`}]) t]) - 0.0070196741195687196`) 0.5020364580937144]]], Evaluate], 8000, 8000]] -> 30.08};
 In[4]:= Xp[testset[[All, 1]]]
 Out[4]=

## Mathematica + Mathematica Online

Questions? Comments? Contact a Wolfram expert »