AudioSpectrumOutput

class NatML.Devices.Outputs.AudioClipOutput : AudioOutput

The AudioSpectrumOutput computes the spectral distribution of audio buffers using the Fast Fourier Transform.

Creating the Output

/// <summary>
/// Create an audio spectrum output.
/// </summary>
/// <param name="sampleCount">Audio sample count.</param>
/// <param name="channel">Audio channel index on which to perform spectrum transformation.</param>
AudioSpectrumOutput (int sampleCount = 1024, int channel = 0);

The AudioSpectrumOutput is created with the expected sampleCount in a given FFT window. The channel parameter can be used to select the channel index on which to perform the spectrum transformation.

The sampleCount is always rounded to the closest power of two.

Updating with New Buffers

/// <summary>
/// Update the output with a new audio buffer.
/// </summary>
/// <param name="audioBuffer">Audio buffer.</param>
void Update (AudioBuffer audioBuffer);

Refer to the Updating with New Buffers section of the AudioOutput class for more information.

Accessing the Autospectrum

/// <summary>
/// Spectrum magnitude.
/// </summary>
float[] spectrum { get; }

The spectrum array contains the autospectrum (i.e. the spectrum magnitude) at each frequency bin.

The length of the spectrum is always half of the sample count provided in the constructor.

Disposing the Output

/// <summary>
/// Dispose the audio output and release resources.
/// </summary>
void Dispose ();

Refer to the Disposing the Output section of the AudioOutput class for more information.

Last updated