|
HART
0.2.0
High level Audio Regression and Testing
|
Configures and tunes an experiment setup for accurate THD measurement. More...
#include <hart_thd.hpp>
Public Member Functions | |
| ExperimentSetupTuner & | withFrequency (double desiredFrequencyHz) |
| Sets the desired frequency of the input signal. | |
| ExperimentSetupTuner & | withSampleRate (double sampleRateHz) |
| Sample rate of the test case. | |
| ExperimentSetupTuner & | withDuration (double desiredDurationSeconds) |
| Sets desired render time of the test case in seconds. | |
| ExperimentSetupTuner & | withNumFrames (size_t desiredDurationFrames) |
| Sets desired render time of the test case in frames. | |
| ExperimentSetupTuner & | withMaxHarmonic (int desiredMaxHarmonic) |
| Sets desired number of harmonics for the THD measurement. | |
| ExperimentSetup | tune () const |
Call it at the end of the builder chain to produce a hart::THD::ExperimentSetup instance. | |
Configures and tunes an experiment setup for accurate THD measurement.
Intended to be used for hart::thd() metric.
THD measurement requires a pure sine, whose fundamental frequency should fall exactly on an FFT bin. The analysed signal should also contain exactly the same number of frames as the FFT, without zero padding. Otherwise, spectral leakage may appear as harmonic energy and artificially increase the measured THD.
This class takes the desired experiment parameters and tunes them to satisfy these requirements for you. The tune() method:
Examples:
If the desired duration is already expressed in frames, withNumFrames() can be used instead:
The most minimal scenario can look like this:
In that case, the duration and sample rate will be pulled from hart::CLIConfig, and be the same as the defaults in the usual hart::AudioTestBuilder.
Definition at line 161 of file hart_thd.hpp.
|
inline |
Sets the desired frequency of the input signal.
It will be tuned to fall exactly in the centre of an FFT bin.
If omitted, this desired frequency will be assumed to be 1 kHz.
| desiredFrequencyHz | Your desired frequency of a sine wave in the input signal |
Definition at line 170 of file hart_thd.hpp.
|
inline |
Sample rate of the test case.
If omitted, the global default sample rate will be pulled from hart::CLIConfig
| sampleRateHz | Sample rate in Herts |
Definition at line 183 of file hart_thd.hpp.
|
inline |
Sets desired render time of the test case in seconds.
Alternatively, you can set this duration in frames, using withNumFrames(). There's no need to call both seconds and frames setters in one chained builder, use no more than one - either this one, or withNumFrames().
If both seconds and frames setters are omitted, the global default duration will be pulled from hart::CLIConfig.
This value be tuned in a way that resulting rendered audio will have number of frames that is a power of two, so that no FFT zero padding would be required.
| desiredDurationSeconds | Desired render time in seconds |
Definition at line 204 of file hart_thd.hpp.
|
inline |
Sets desired render time of the test case in frames.
Alternatively, you can set this duration in seconds, using withDuration(). There's no need to call both seconds and frames setters in one chained builder, use no more than one - either this one, or withDuration().
If both seconds and frames setters are omitted, the global default duration will be pulled from hart::CLIConfig.
This value be tuned in a way that resulting rendered audio will have number of frames that is a power of two, so that no FFT zero padding would be required.
| desiredDurationFrames | Desired size of rendered audio in frames |
Definition at line 226 of file hart_thd.hpp.
|
inline |
Sets desired number of harmonics for the THD measurement.
This value will be limited in a way it's always under the Nyquist bin in the resulting FFT.
| desiredMaxHarmonic | Desired highest harmonic used for the THD calculation (fundamental is number 1) |
Definition at line 242 of file hart_thd.hpp.
|
inline |
Call it at the end of the builder chain to produce a hart::THD::ExperimentSetup instance.
This will give you a structure with tunes experiment setup values inside.
You're expected to use those values for the test case, namely sine wave frequency and render duration, instead of your desired values used in this builder. The values will be different from the desired ones (except for rare lucky cases), but they'll be optimized for an accurate THD reading, with no FFT spills. You're also expected to pass the same instance of experiment setup to the hart::thd() metric, so that it has all experiment context it needs.
hart::THD::ExperimentSetup instance containing tuned values for the THD measurement experiment. Definition at line 261 of file hart_thd.hpp.