Audio Processing

The Wolfram Language provides built-in support for both programmatic and interactive audio processing, fully integrated with other powerful mathematical and algorithmic capabilities. You can process audio objects by applying linear and nonlinear filters, add effects, and analyze them using audio-specific functions or by exploiting the extensive integration with the rest of the Wolfram Language.

Filtering

Audio signals can be used as input to many signal processing functions.

LowpassFilter[audio,ωc]apply a lowpass filter with a cutoff frequency ωc to audio
HighpassFilter[audio,ωc]apply a highpass filter with a cutoff frequency ωc to audio
WienerFilter[audio,r]apply Wiener filter with a range of r samples to audio
MeanFilter[audio,r]apply mean filter with a range of r samples to audio
TotalVariationFilter[audio]apply total variation filter to audio
GaussianFilter[audio, r]apply Gaussian filter with a range of r samples to audio

Some of the filters that can be directly applied to audio objects.

Many of the filtering functions present in the Wolfram Language can be immediately used on audio objects. In many cases, it is possible to specify the cutoff frequency as a frequency Quantity.

FIR filters applied to an audio object.
In[65]:=
Click for copyable input
Out[65]=
In[66]:=
Click for copyable input
Out[66]=
In[67]:=
Click for copyable input
Out[67]=
In[68]:=
Click for copyable input
Out[68]=
Plot the periodogram of the original and processed signals.
In[69]:=
Click for copyable input
Out[69]=
Use WienerFilter to denoise a recording.
In[70]:=
Click for copyable input
Out[70]=
In[71]:=
Click for copyable input
Out[71]=
In[72]:=
Click for copyable input
Out[72]=

Discrete-time transfer function models can be used to filter an audio object using RecurrenceFilter.

RecurrenceFilter[tf,audio]uses a discrete-time filter defined by the TransferFunctionModel tf
BiquadraticFilterModel[{"type",spec}]creates a biquadratic filter of a given {"type",spec}
ButterworthFilterModel[{"type",spec}]creates a Butterworth filter of a given {"type",spec}
TransferFunctionModel[m,s]represents the model of the transfer-function matrix m with complex variable s
ToDiscreteTimeModel[lsys,τ]gives the discrete-time approximation, with sampling period τ, of the continuous-time systems models lsys

Some of the available filter models and additional utilities.

The simplest way to use one of the analog (continuous-time) filter models is to discretize the transfer function using ToDiscreteTimeModel and apply the result to an audio object using RecurrenceFilter.

Apply a resonant biquadratic filter to an audio object.
In[74]:=
Click for copyable input
Out[74]=
In[75]:=
Click for copyable input
Out[75]=
In[76]:=
Click for copyable input
In[77]:=
Click for copyable input
Out[77]=

A discrete transfer function can be created using TransferFunctionModel and applied to an audio object with RecurrenceFilter.

Define a comb filter using TransferFunctionModel and apply it to an audio object.
In[78]:=
Click for copyable input
In[79]:=
Click for copyable input
Out[79]=
In[80]:=
Click for copyable input
Out[80]=

Effects and Manipulation

An audio object can be modified and manipulated using built-in or user-defined functions.

AudioTimeStretch[audio,r]apply time stretching by the specified factor r to audio
AudioPitchShift[audio,r]apply pitch shifting by the specified factor r to audio
AudioReverb[audio]apply a reverberation effect to audio
AudioDelay[audio,delay]apply a delay effect with delay time delay to audio
AudioChannelMix[audio,desttype]mix the channel of audio to the specified desttype

Some common audio effects.

Use pitch shifting and time stretching to independently modify pitch and duration of an audio signal.

Slow down an audio object.
In[81]:=
Click for copyable input
Out[81]=
In[82]:=
Click for copyable input
Out[82]=
Shift the pitch of an audio object up.
In[83]:=
Click for copyable input
Out[83]=

Delay and reverberation effects can be used to immerse a recording in a virtual environment or to produce special effects.

Apply a delay or reverb effect.
In[84]:=
Click for copyable input
Out[84]=
In[85]:=
Click for copyable input
Out[85]=
Perform KarplusStrong synthesis by adding a short delay with a high feedback value to a burst of noise. This will simulate the sound of a vibrating string.
In[86]:=
Click for copyable input
Out[88]=

Downmixing and upmixing to an arbitrary number of channels can be achieved using AudioChannelMix.

Downmix and upmix a multichannel audio object.
In[89]:=
Click for copyable input
Out[89]=
In[90]:=
Click for copyable input
Out[90]=
In[91]:=
Click for copyable input
Out[91]=

It is possible to alter a recording by taking advantage of performing arithmetic operations on the Audio object. All Wolfram Language operators and functions with attributes NumericFunction or Listable are overloaded to work with audio objects.

Apply a smooth distortion to an audio object using the Tanh function.
In[92]:=
Click for copyable input
Out[92]=
In[93]:=
Click for copyable input
Out[93]=
Use the ChebyshevT function to obtain a "waveshaper" effect.
In[94]:=
Click for copyable input
Out[94]=
Multiply an audio object with a sine wave to get a "ring modulator" effect.
In[120]:=
Click for copyable input
Out[120]=

Analysis

Properties can be computed on a recording both on a global and a local scale.

AudioMeasurements[audio,"prop"]compute the property "prop" for the entire audio

Some of the functionality to compute global measurements.

Both time domain and frequency domain properties can be measured with AudioMeasurements. The properties are computed on the average sample values over the channels of the audio object.

Compute time domain properties of a recording.
In[96]:=
Click for copyable input
Out[96]=
Compute frequency domain properties of a recording.
In[97]:=
Click for copyable input
Out[97]=

Compute other measurements by directly applying built-in statistical functions.

Compute moment and entropy of an audio object.
In[98]:=
Click for copyable input
In[99]:=
Click for copyable input
Out[99]=
In[100]:=
Click for copyable input
Out[100]=

Unlike AudioMeasurements, overloaded functions are applied to the flattened version of the data. If the input is a multichannel audio object, the sample values from all channels will be flattened in a single array.

Compute statistical properties of a recording.
In[101]:=
Click for copyable input
Out[101]=

In addition to global properties of audio objects, it is also possible to compute measurements locally.

AudioLocalMeasurements[audio,"prop"]compute the property "prop" locally for partitions of audio
AudioIntervals[audio,crit]find the intervals of audio for which the criterion crit is satisfied

Some of the functionality to compute local measurements..

In AudioLocalMeasurements, properties are computed locally: the signal is partitioned according to the PartitionGranularity specification, and the requested property is computed on each partition. The result is returned as a TimeSeries whose timestamps correspond to the center time of each partition.

Compute the RMS amplitude on 40 ms partitions with an offset of 1 ms.
In[122]:=
Click for copyable input
Out[123]=

The result of AudioLocalMeasurements or AudioMeasurements can be used as an input for other functionality in the Wolfram Language.

Use the "SpectralCentroid" and "SpectralSpread" measurements to find clusters of similar audio objects in a list.
In[125]:=
Click for copyable input
Out[127]=
In[128]:=
Click for copyable input
Out[128]=
Use the MFCC measurement as a feature to compute the distance between various elements of the ExampleData["Audio"] collection.
In[111]:=
Click for copyable input
In[113]:=
Click for copyable input
In[114]:=
Click for copyable input
Out[114]=

Using AudioIntervals allows you to extract intervals on which a user-defined criterion is satisfied.

Locate the non-voiced sections of a recording.
In[115]:=
Click for copyable input
Out[116]=
In[117]:=
Click for copyable input
Out[117]=
Translate this page: