Table of Contents

Class VUMeterFFTEventArgs

Namespace
VisioForge.Core.Types
Assembly
VisioForge.Core.dll

Provides data for events that report Fast Fourier Transform (FFT) results for audio frequency analysis.

public class VUMeterFFTEventArgs : EventArgs

Inheritance

Inherited Members

Examples

// Subscribe to FFT events for spectrum analysis
audioProcessor.OnFFTData += (sender, e) =>
{
    // Calculate magnitude spectrum
    double[] magnitudes = new double[e.Result.Length / 2];

    for (int i = 0; i < magnitudes.Length; i++)
    {
        // Calculate magnitude from complex number
        double real = e.Result[i].X;
        double imaginary = e.Result[i].Y;
        magnitudes[i] = Math.Sqrt(real * real + imaginary * imaginary);

        // Convert to decibels
        double db = 20 * Math.Log10(magnitudes[i]);
    }

    // Update spectrum display
    UpdateSpectrumVisualizer(magnitudes);
};

Remarks

This event argument contains FFT data that represents the frequency spectrum of audio signals. The FFT transforms time-domain audio samples into frequency-domain data, allowing analysis of which frequencies are present in the audio and their relative amplitudes.

Common uses include: - Spectrum analyzers and frequency visualizers - Audio equalization and filtering analysis - Beat detection and rhythm analysis - Pitch detection and harmonic analysis - Real-time audio effects based on frequency content

The FFT result is an array of complex numbers where: - The magnitude represents the amplitude of each frequency component - The phase represents the phase shift of each frequency component - Each index corresponds to a specific frequency bin

The frequency represented by each bin can be calculated as: frequency = (binIndex * sampleRate) / fftSize

Constructors

VUMeterFFTEventArgs(Complex[])

Initializes a new instance of the VisioForge.Core.Types.VUMeterFFTEventArgs class with the specified FFT results.

public VUMeterFFTEventArgs(Complex[] result)

Parameters

result Complex[]

An array of NAudio.Dsp.Complex numbers representing the FFT output. Must not be null. The array length should typically be a power of 2 (e.g., 512, 1024, 2048, 4096) for optimal FFT performance.

Remarks

The FFT size determines the frequency resolution: - Larger FFT sizes provide better frequency resolution but poorer time resolution - Smaller FFT sizes provide better time resolution but poorer frequency resolution

Common FFT sizes: - 512: Fast response, suitable for real-time visualization - 1024: Good balance between frequency and time resolution - 2048: Better frequency resolution for detailed analysis - 4096 or higher: High frequency resolution for precision applications

Exceptions

ArgumentNullException

Thrown when result is null.

Properties

Result

Gets the array of complex numbers representing the Fast Fourier Transform (FFT) result.

public Complex[] Result { get; }

Property Value

Complex[]

Remarks

For real audio signals, only the first N/2 + 1 bins are unique (where N is the FFT size), as the remaining bins are complex conjugates of the first half.

To calculate the frequency of a specific bin:

double binFrequency = (binIndex * sampleRate) / fftSize;

To calculate the magnitude (amplitude) of a frequency component:

double magnitude = Math.Sqrt(Result[i].X * Result[i].X + Result[i].Y * Result[i].Y);

To calculate the phase angle of a frequency component:

double phase = Math.Atan2(Result[i].Y, Result[i].X);

See Also