Total harmonic distortion result.
More...
#include <audio_spectrum.hpp>
Total harmonic distortion result.
Determinism contract (echoed into the artifact):
- stimulus: a steady sine at fundamental_hz; for a trustworthy reading the tone MUST be bin-coherent — fundamental_hz = k * sample_rate /
fft_length for integer k — so the fundamental and all harmonics land on exact bins. coherent records whether that held; a non-coherent reading is advisory only.
- window/length: rectangular over an fft_length segment after analysis_offset when coherent (no leakage); non_coherent_window (default hann) otherwise. The chosen window is recorded in window.
- THD = sqrt(Σ harmonic²) / fundamental (ratio); THD+N = sqrt(total energy − fundamental²) / fundamental, i.e. everything that is not the fundamental bin (harmonics + noise + leakage).
- both ratios cancel absolute FFT scale, so they are backend-stable.
◆ thd_db()
| double pulp::test::audio::ThdResult::thd_db |
( |
| ) |
const |
20·log10(thd), kSilenceFloorDb at zero.
◆ thd_percent()
| double pulp::test::audio::ThdResult::thd_percent |
( |
| ) |
const |
|
inline |
◆ thd_plus_n_db()
| double pulp::test::audio::ThdResult::thd_plus_n_db |
( |
| ) |
const |
◆ analysis_offset
| int pulp::test::audio::ThdResult::analysis_offset = 0 |
◆ analyzer
| std::string pulp::test::audio::ThdResult::analyzer = "thd" |
◆ bin_hz
| double pulp::test::audio::ThdResult::bin_hz = 0.0 |
◆ coherent
| bool pulp::test::audio::ThdResult::coherent = false |
True when the tone is bin-coherent (see above).
◆ fft_length
| int pulp::test::audio::ThdResult::fft_length = 0 |
◆ fundamental_hz
| double pulp::test::audio::ThdResult::fundamental_hz = 0.0 |
◆ harmonics
| std::vector<Harmonic> pulp::test::audio::ThdResult::harmonics |
[0] = fundamental, then 2nd, 3rd, ...
◆ num_harmonics
| int pulp::test::audio::ThdResult::num_harmonics = 0 |
Harmonics summed (beyond the fundamental).
◆ sample_rate
| double pulp::test::audio::ThdResult::sample_rate = 0.0 |
◆ thd
| double pulp::test::audio::ThdResult::thd = 0.0 |
Ratio (Σ harmonics / fundamental).
◆ thd_plus_n
| double pulp::test::audio::ThdResult::thd_plus_n = 0.0 |
Ratio (all non-fundamental / fundamental).
◆ window
The documentation for this struct was generated from the following file:
- /home/runner/work/pulp/pulp/tools/audio/analysis/include/pulp/audio/analysis/audio_spectrum.hpp