Wolfram Language

Computational Audio

Audio Clustering Based on Spectral Features

Use spectral features to find clusters in a list of audio objects.

In[1]:=
Click for copyable input
a = ExampleData[{"Audio", "Drums"}, "Audio"]
Out[1]=

Split the recording where transients happen.

In[2]:=
Click for copyable input
samples = Select[AudioSplit[a, FindPeaks[AudioLocalMeasurements[a, "Novelty"]]["Times"]], Duration@# > Quantity[50, "ms"] &]; samples = Audio[#, Appearance -> "Minimal"] & /@ samples
Out[2]=

Plot the resulting samples in positions defined by their spectral centroid and spectral spread.

In[3]:=
Click for copyable input
ListPlot[Partition[ AudioMeasurements[#, {"SpectralCentroid", "SpectralSpread"}, "List"] & /@ samples, 1], PlotMarkers -> (Audio[#, Appearance -> "Minimal"] & /@ samples), AxesLabel -> {Style["Centroid", Italic], Style["Spread", Italic]}, ImageSize -> Medium]
Out[3]=

Find similar sounds using the "SpectralCentroid" and "SpectralSpread" measurements.

In[4]:=
Click for copyable input
FindClusters[ AudioMeasurements[#, {"SpectralCentroid", "SpectralSpread"}, "List"] & /@ samples -> samples]
Out[4]=

Related Examples

de es fr ja ko pt-br ru zh