Frequency Response - loudifier/chirplab GitHub Wiki

Frequency Response Measurement

"Frequency response is the single most important aspect of the performance of any audio device. If it is wrong, nothing else matters." -Floyd Toole

The Chirplab Frequency Response measurement uses the "Farina method", deriving a raw impulse response from a logchirp, applying a window to the impulse response to discard the vast majority of the noise and distortion present in the response, and transforming back to the frequency domain to produce the frequency response of just the fundamental frequency.

Measurement Parameters

window_mode

  • 'raw': Do not apply any windowing to the impulse response. The output frequency response will be contaminated by distortion artifacts and will be more succeptible to noise.
  • 'windowed': Manually specify the shape of the impulse response window
  • 'adaptive': Automatically calculate a window for each output frequency point, which tends to reject more noise and reverberation at mid and high frequencies and produces a smoother output that preserves peaks and notches that could be obscured when post-processing the output with a moving average smoothing step. The window time parameters are ignored and the window for each output point will be based on the wavelength, L, of the output frequency, such that window_start=L, fade_in=L, window_end=2*L, and fade_out=L. Much slower than using a fixed window, but still reasonably fast for a moderate output resolution.

window_start

The total time in milliseconds before the t=0 point of the impulse response to start the impulse response window

fade_in

The time in milliseconds at the beginning of the impulse response window to be constructed with the first half of a Hann window of width 2*fade_in. If fade_in is 0, the start of the impulse response window will have a rectangular shape, with all points equal to 1.0. If fade_in is equal to window_start the entire impulse response window from -window_start to t=0 will consist of the first half of a Hann window of width 2*window_start.

window_end

The total time in milliseconds after the t=0 point of the impulse response to end the impulse response window.

fade_out

the time in milliseconds at the end of the impulse response window to be constructed with the second half of a Hann window of width 2*fade_out. If fade_out is 0, the end of the impulse response window will have a rectangular shape, with all points equal to 1.0. If fade_out is equal to window_end the entire impulse response window from t=0 to window_end will consist of the second half of a Hann window of width 2*window_end

Output Parameters

unit

Output points are specified in this measurement unit. Options are:

  • 'dBFS' or 'FS': Full Scale digital level, using the "sine wave peak" definition of full scale. A measured level of 1.0FS or 0dBFS corresponds to a sine wave that peaks at a digital level of 1.0, even though a sine wave of that level would have an RMS level of 0.707FS or -3dBFS
  • 'Pa' or 'dBSPL': Acoustic Sound Pressure Level in Pascals or decibels converted from digital measurement using the project's FS_per_Pa calibration parameter. dBSPL level is defined as the dB level relative to 20uPa, so 20uPa = 0dBSPL and 1Pa = 94dBSPL.
  • 'V' or 'dBV': Electrical Voltage converted from digital measurement using the project's FS_per_V calibration parameter

min_freq

The lowest output frequency point in Hz

min_auto

If True the min_freq parameter is ignored and the lowest output frequency point is set to the chirp start_freq

max_freq

The highest output frequency point in Hz

max_auto

If True the max_freq parameter is ignored and the highest output frequency point is set to the chirp stop_freq

spacing

  • 'linear': Output points are spaced evenly for num_points between min_freq and max_freq
  • 'log': Output points are spaced proportionally for num_points between min_freq and max_freq
  • 'octave': Output points are spaced proportionally between min_freq and max_freq. The total number of frequency point is num_points multiplied by the number of octaves between min_freq and max_freq rounded to the nearest whole number (total number of points = round(num_points * Log2(max_freq/min_freq)) )

num_points

If spacing is 'linear' or 'log', the total number of output frequency points between min_freq and max_freq. If spacing is 'octave', the number of points per octave used to calculate the total number of output frequency points between min_freq and max_freq

round_points

If True the array of output frequency points will be rounded to the nearest whole Hz. In cases where low frequiencies are rounded to the same whole Hz, duplicate points will be removed, resulting in fewer total output points than specified by num_points

Measurement Calculation

The frequency response measurement starts by calculating the raw complex transfer function, the spectrum of the response signal divided by the spectrum of the stimulus chirp signal

signals to spectrums

If window_mode is 'raw', the transfer function is used directly with no additional processing, by interpolating the magnitude of the transfer function at the specified output points

raw output

If window_mode is 'windowed' or 'adaptive', the raw transfer function is transformed to the equivalent time-domain form, an impulse response

spectrums to impulse response

A window will be generated based on the window_mode settings. In 'windowed' mode the windowing parameters are used directly, and in 'adaptive' mode the window parameters will be calculated and a new window will be generated for each output frequency point

impulse response window

Applying the window to the impulse response removes the harmonic distortion, most of the noise, and much of the reverberation from the response. Transforming the windowed impulse response back into the frequency domain yields a much smoother curve that corresponds to the system's fundamental frequency response

windowed response

Measurements using the 'windowed' window_mode apply a window to the impulse response determined by the window_start, fade_in, window_end, and fade_out parameters, transform to the frequency domain, and perform the same output point interpolation with the windowed transfer function that 'raw' measurements perform with the non-windowed transfer function.

Measurements using the 'adaptive' window_mode calculate the window parameters for each output frequency point based on the wavelength, L, of the output frequency point, such that:

  • window_start= L
  • fade_in= L
  • window_end= 2 * L
  • -fade_out= L

The entire windowed transfer function is calculated for each output point and the output is interpolated at the output point frequency.