Audio Synthesis

The Wolfram Language provides extensive support for the creation, analysis, and manipulation of audio data, fully integrated with the Wolfram Language's powerful mathematical and algorithmic capabilities.

The starting point for audio synthesis is the AudioGenerator function.

AudioGenerator[model]generates one second of audio of a given model
AudioGenerator[model,t]generates t seconds of audio

Audio generation.

Oscillators

The simplest way to generate a signal is to use one of the native oscillator models supported in AudioGenerator.

Generate a sinusoidal signal.
In[1]:=
Click for copyable input
Out[1]=
Generate a sinusoidal signal of a specific frequency.
In[2]:=
Click for copyable input
Out[2]=
Different oscillator models have different harmonic contents.
In[3]:=
Click for copyable input
Out[4]=

All oscillator models accept time-varying parameters for frequency and phase: the input can be a TimeSeries, another Audio object, or even a pure function.

Use an audio signal to control the frequency.
In[5]:=
Click for copyable input
Out[6]=
Use a pure function to control the frequency.
In[7]:=
Click for copyable input
Out[7]=
Use a time series to control the frequency.
In[8]:=
Click for copyable input
Out[9]=

Noise Generators

In addition to oscillators, AudioGenerator allows for the creation of different kinds of noise signals.

Generate one second of pink noise.
In[10]:=
Click for copyable input
Out[10]=
Different types of noise have different spectral contents.
In[11]:=
Click for copyable input
Out[12]=

White noise is characterized by a flat spectrum. By default, sample values are picked from a uniform distribution, but it is possible to change that without affecting the spectrum.

White noise with amplitudes sampled from a normal distribution.
In[13]:=
Click for copyable input
Out[13]=
Plot the histogram and the periodogram of the signal.
In[14]:=
Click for copyable input
Out[14]=
In[15]:=
Click for copyable input
Out[15]=

Using {"Color",α} will generate a "colored" noise signal whose spectrum follows a f-α distribution. "Pink", "Brown", and "Blue" are instances of colored noise, where the α has values of 1, 2, and .

Change the "color" of the noise.
In[16]:=
Click for copyable input
Out[16]=Play Animation

Processes and Time Series

AudioGenerator can be used to generate a signal by sampling a random process.

Generate an audio signal from a discrete-time or continuous-time process.
In[17]:=
Click for copyable input
Out[17]=
In[18]:=
Click for copyable input
Out[18]=

AudioGenerator can also be used to create an Audio object from a TimeSeries.

Create an audio signal starting from a TimeSeries.
In[19]:=
Click for copyable input
Out[21]=

Advanced Synthesis

Subtractive Synthesis

By processing an audio object with one or more frequency-selective filters, it is possible to manipulate its harmonic content and therefore change its timbre. This technique is effective if the starting audio object is harmonically rich.

Filter a sawtooth wave.
In[22]:=
Click for copyable input
Out[22]=
Use two different filters on a square waveform.
In[23]:=
Click for copyable input
Out[23]=Play Animation

Additive Synthesis

In contrast to subtractive synthesis where harmonics are attenuated using filters, additive synthesis is based on the addition of harmonics. The effect is obtained with linear combination of sine waves at different frequencies, where the user has control over the coefficients of the linear combination.

Control the amplitudes of the first 8 harmonics of a 200 Hz fundamental.
In[24]:=
Click for copyable input
Out[24]=Play Animation

Amplitude Modulation

Amplitude modulation (AM) is a common technique to create signals with complex harmonic content.

In AM, two signals are used, called carrier and modulator. The result is computed using carrier(1+μmodulator), where the scaling constant μ is called modulation index.

If the modulator is a sinusoid, for each component of the carrier at a frequency f, a pair of sidebands is created at frequencies f±m, whose amplitude is controlled by the modulation index.

Amplitude modulation of a triangle wave.
In[25]:=
Click for copyable input
Out[28]=
Plot the periodogram of the signal.
In[29]:=
Click for copyable input
Out[29]=

Frequency Modulation

Another popular technique, discovered in the early 1970s, uses frequency modulation (FM).

In the case of FM, the frequency of the carrier signal is controlled by the modulator and the modulation index. As the modulation index increases, sidebands occur above and below the carrier frequency at intervals of the modulating frequency.

Basic frequency modulation.
In[30]:=
Click for copyable input
Out[34]=
Plot the periodogram of the signal.
In[35]:=
Click for copyable input
Out[35]=

The number and intensity of these additional sidebands are related to the modulation index.

Use a higher modulation amount to increase sideband amplitude.
In[36]:=
Click for copyable input
Out[41]=

The position of the sidebands is determined by the ratio between the carrier and modulator frequencies. Changing this ratio, it is possible to obtain both harmonic (typical of pitched instruments) and inharmonic (typical of percussive instruments) spectra.

Create harmonic and inharmonic signals.
In[42]:=
Click for copyable input
Out[46]=

If the modulation index becomes a time-varying argument, it becomes easy to generate signals whose harmonic content evolves with time.

Increase the bandwidth of the signal by incrementing the modulation index.
In[47]:=
Click for copyable input
Out[51]=
Plot the spectrogram of the result.
In[52]:=
Click for copyable input
Out[52]=

The modulating frequency can be a time-varying parameter as well.

Change the position of the sidebands by varying the modulating frequency.
In[53]:=
Click for copyable input
Out[56]=
Plot the spectrogram of the result.
In[57]:=
Click for copyable input
Out[57]=

Related Tutorials