Harmonic Distortion - loudifier/chirplab GitHub Wiki
Harmonic Distortion Measurement
The Chirplab Harmonic Distortion measurement uses an extension of the "Farina method", deriving a raw impulse response from a logchirp, applying windows to the impulse response to isolate harmonic distortion products, and measuring the total distortion level of the harmonics
Measurement Parameters
start_harmonic
The lowest harmonic to measure. The output THD will include the total energy for all harmonics from start_harmonic
to stop_harmonic
stop_harmonic
The highest harmonic to measure. The output THD will include the total energy for all harmonics from start_harmonic
to stop_harmonic
Note: the harmonic windowing parameters are not exposed in the GUI. You can experiment with different values by editing the project file directly and reloading the project
window_start
Starting time of the harmonic window, expressed as a proportion of the time from the center of the current harmonic impulse to the center of the next harmonic impulse
fade_in
The start of the harmonic window consists of the first half of a Hann window of width 2*fade_in
, where fade_in is the proportion of the time from the center of the current harmonic impulse to the center of the next harmonic impulse. If fade_in
is 0, the start of the harmonic window will have a rectangular shape with every sample from window_start
to the center of the harmonic impulse equal to 1.0. If fade_in
is equal to window_start
, the start of the harmonic window will be the first half of a Hann window of width 2*window_start
window_end
Ending time of the harmonic window, expressed as a proportion of the time from the center of the current harmonic impulse to the center of the previous harmonic impulse. If the second harmonic is being analyzed, the previous harmonic impulse time is the fundamental impulse response at t=0.
fade_out
The end of the harmonic window consists of the second half of a Hann window of width 2*fade_out
, where fade_out is the proportion of the time from the center of the current harmonic impulse to the center of the previous harmonic impulse. If fade_out
is 0, the end of the harmonic window will have a rectangular shape with every sample from the center of the harmonic impulse to window_end
equal to 1.0. If fade_out
is equal to window_end
, the end of the harmonic window will be 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:
- 'dB': Decibel level of the harmonic distortion relative to the fundamental frequency response. The fundamental frequency response is calculated using the Frequency Response measurement with default parameter values and the same output frequency points as the Harmonic Distortion measurement
- '%': Level of the harmonic distortion relative to the fundamental frequency response, expressed as a percentage. If the harmonic distortion level is greater than the fundamental frequency response level, the percentage can exceed 100%
- '% (IEC method)': The harmonic distortion level divided by the sum of the harmonic distortion and the fundamental frequency response, expressed as a percentage. As distortion level increases and fundamental response falls the percentage will approach but never exceed 100%
- 'dBFS' or 'FS': Absolute Full Scale digital level not referenced to the fundamental or total signal 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': Absolute acoustic Sound Pressure Level not referenced to the fundamental or total signal 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': Absolute electrical Voltage not referenced to the fundamental or total signal level, 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
or the analysis sample rate Nyquist frequency divided by the lowest harmonic analyzed, whichever is lower
spacing
- 'linear': Output points are spaced evenly for
num_points
betweenmin_freq
andmax_freq
- 'log': Output points are spaced proportionally for
num_points
betweenmin_freq
andmax_freq
- 'octave': Output points are spaced proportionally between
min_freq
andmax_freq
. The total number of frequency point isnum_points
multiplied by the number of octaves betweenmin_freq
andmax_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 harmonic distortion measurement starts by using a modified process to calculate the raw impulse response. Instead of using the chirp stimulus as the reference signal, a chirp is generated with the same start time, start frequency, and sweep rate, but extending up to the Nyquist frequency. This allows harmonic distortion products to be accurately measured at frequencies higher than the chirp stop_freq
The raw impulse response is calculated by dividing the response spectrum by the spectrum of the Nyquist chirp. Due to the unique properties of using a logchirp stimulus, harmonic distortion appears as impulse responses preceeding the fundamental impulse response at
Th = -chirp_length (Log(H) / Log(stop_freq/start_freq))
Where H is the harmonic number
To calculate the total harmonic distortion, each harmonic from start_harmonic
to start_harmonic
is first windowed out of the raw impulse response
Then the spectrum of each harmonic is calulated and normalized to the fundamental by dividing the harmonic spectrum frequency axis by the harmonic number
The total harmonic distortion is the power sum of the harmonic spectrums at each frequency point
Once the total harmonic distortion is calculated, it is interpolated along the specified output frequencies. If a relative output unit is specified (dB or percentage), the fundamental frequency response is calculated at each of the output points using the same method as the default parameters of a Frequency Response measurement and the THD ratio is calculated relative to the fundamental response