IGModAudioChannel:FFT

From Garry's Mod
Jump to: navigation, search
 IGModAudioChannel:FFT( )

Contents

Description

Computes the DFT (discrete Fourier transform) of the sound channel.

The size parameter specifies the number of consecutive audio samples to use as the input to the DFT and is restricted to a power of two. A Hann window is applied to the input data.

The computed DFT has the same number of frequency bins as the number of samples. Only half of this DFT is returned, since the DFT magnitudes are symmetric for real input data. The magnitudes of the DFT (values from 0 to 1) are used to fill the output table, starting at index 1.

Visualization protip: For a size N DFT, bin k (1-indexed) corresponds to a frequency of (k - 1) / N * sampleRate.

Visualization protip: Sound energy is proportional to the square of the magnitudes. Adding magnitudes together makes no sense physically, but adding energies does.

Visualization protip: The human ear works on a logarithmic amplitude scale. You can convert to decibels by taking 20 log10 of frequency magnitudes, or 10 log10 of energy. The decibel values will range from -infinity to 0.

Arguments

table tbl

The table to output the DFT magnitudes (numbers between 0 and 1) into. Indices start from 1.

Arguments

number size

The number of samples to use. See FFT_ Enums

Returns

number

The number of frequency bins that have been filled in the output table.
Personal tools
Navigation