AudioGenerator

AudioGenerator[model]

generates one second of audio of a given model.

AudioGenerator[model,t]

generates t seconds of audio.

AudioGenerator[model,t,"type"]

generates audio samples of the specified "type".

Details and Options

  • AudioGenerator can generate different types of audio, including oscillators or noises.
  • Possible settings for model include:
  • fsample an arbitrary function f of time (in seconds)
    procgenerate samples from a random process proc
    tseriesgenerate samples from a TimeSeries tseries
    "model"generate sample from a named function "model"
  • Silence:
  • "Silence"silence (zero) signal
  • Oscillators:
  • {"Sin",freq,phase}sine wave
    {"Triangle",freq,phase}triangle wave
    {"Sawtooth",freq,phase}sawtooth wave
    {"Square",freq,phase}square wave
    {"Pulse",freq,phase,width}rectangular wave using the duty cycle width
    {"Impulse",freq,phase}impulse signal
  • By default, freq=TemplateBox[{440, "Hz", hertz, "Hertz"}, Quantity], phase=TemplateBox[{0, "rad", radians, "Radians"}, Quantity], and width=TemplateBox[{25, "%", percent, "Percent"}, QuantityPostfix] are used.
  • The parameters freq, phase, and width can be a scalar value, a Quantity, an Audio object, a TimeSeries, or a pure function.
  • Noise:
  • "White"constant power spectral density
    "Pink"power spectral density that follows 1/f
    "Brown"power spectral density that follows
    "Blue"power spectral density that follows
    {"Color",α}power spectral density that follows with
    {"White",dist}random noise with values sampled from dist
    "PeriodicRandomNoise"sum of sinusoidal components with constant amplitude and random phase
  • Other:
  • AudioGenerator generates an audio object of "Real32" type. See the reference page for Audio for possible settings of "type".
  • AudioGenerator has the same options as Audio.
  • List of all options

Examples

open allclose all

Basic Examples  (3)

Generate one second of sinusoidal audio:

Generate a signal from an arbitrary function:

Generate two seconds of white noise:

Scope  (17)

Basic Uses  (2)

By default, 1 second of audio is generated:

Specify the duration:

Specify the duration as a time quantity:

Specify the number of samples to generate:

By default, the generated audio is of "Real32" type:

Specify a different data type:

Model Specifications  (15)

Oscillators  (5)

Sinusoidal oscillator at 2000 Hz:

Control the frequency of the sine wave with a function:

Visualize the spectrogram:

Control the frequency of the sine wave with another Audio object:

Visualize a spectrogram of the generated audio:

Control the frequency of the sine wave with a TimeSeries:

Generate different oscillators:

Noise Generators  (5)

Generate white noise:

The values for the white noise can be sampled from a distribution:

Generate different kinds of noises:

The spectra of pink, brown, and blue noises follow a distribution of f-α, with α equal to 1, 2, and , respectively:

The spectrum of "PeriodicRandomNoise" is perfectly flat:

Using Functions  (1)

AudioGenerator supports functions of time:

Using Processes  (2)

Generate audio from a noise process:

Use an audio object generated from a random process to control the amplitude of a sinusoid:

Using TimeSeries  (2)

Generate an audio object from a TimeSeries:

Generate an audio object from an irregular TimeSeries:

Options  (1)

SampleRate  (1)

By default, SampleRate->44100 is used:

Specify a different sample rate:

Applications  (8)

Noise Applications  (2)

Add noise to an audio object:

Use "PeriodicRandomNoise" to test the frequency response of a linear system:

Audio Generation from Temporal Data  (2)

Compare the stock price trends of two companies:

Resample and smooth the data:

Generate audio controlled by the two time series:

Use a list of TimeSeries to control the amplitudes of a list of harmonic sine waves:

Multi-Frequency Generation  (3)

Generate a series of DTMF tones to simulate the dialing of a phone number:

Create a numeric keypad:

Create an auditory illusion:

Generate ramps to control frequencies and amplitudes of the oscillators:

Create frequencies that will control the oscillators. The frequencies are exactly one octave apart from each other and increase exponentially, so that pitch increases linearly:

Create amplitudes that will control the oscillators. Amplitudes go to 0 when the frequencies drop to the minimum value:

Show the relation between frequency and amplitude of one oscillator:

Combine a bank of oscillators using the created frequencies and amplitudes:

Frequency and Amplitude Modulation  (1)

Generation and reconstruction of an AM signal:

Modulate the amplitude with a 22050 Hz sinusoid to shift the content at the high end of the spectrum. The result should be already inaudible for most people:

Demodulate the AM signal by multiplying the result by another sinusoid at 22050 Hz with the same phase:

Possible Issues  (2)

With oscillators, the frequency should be less than or equal to half of the sample rate:

If a TimeSeries is used as an input, it needs to have numeric non-negative time stamps:

The TimeSeries needs to have a single scalar-valued path:

Interactive Examples  (3)

Control frequency and phase of an oscillator:

The spectrum of AudioGenerator[{"Color",α}] follows a distribution of f-α:

Create a complex audio signal using frequency modulation:

Neat Examples  (4)

Sweep the frequency of the modulating signal:

Use the digits of Pi in base 24 to generate a sequence of frequencies for a sinusoidal oscillator:

Create a melody using DiscreteMarkovProcess:

Generate an audio signal using Morse code:

Create a function to translate a message to an audio signal using the dictionary:

Encode a string into an audio signal:

Wolfram Research (2016), AudioGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/AudioGenerator.html.

Text

Wolfram Research (2016), AudioGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/AudioGenerator.html.

CMS

Wolfram Language. 2016. "AudioGenerator." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AudioGenerator.html.

APA

Wolfram Language. (2016). AudioGenerator. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AudioGenerator.html

BibTeX

@misc{reference.wolfram_2024_audiogenerator, author="Wolfram Research", title="{AudioGenerator}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/AudioGenerator.html}", note=[Accessed: 21-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_audiogenerator, organization={Wolfram Research}, title={AudioGenerator}, year={2016}, url={https://reference.wolfram.com/language/ref/AudioGenerator.html}, note=[Accessed: 21-December-2024 ]}