Least-squares fit of a single sinusoid at a known frequency. More...
#include <audio_spectrum.hpp>
Public Attributes | |
| double | cycles_per_sample = 0.0 |
| The frequency fitted (f / sample_rate). | |
| double | sin_gain = 0.0 |
| Coefficient of sin(2π·f·n). | |
| double | cos_gain = 0.0 |
| Coefficient of cos(2π·f·n). | |
| double | amplitude = 0.0 |
| hypot(sin_gain, cos_gain). | |
| double | fitted_energy = 0.0 |
| Σ of the fitted tone squared. | |
| double | residual_energy = 0.0 |
| Σ of (samples − fitted) squared. | |
Least-squares fit of a single sinusoid at a known frequency.
The fit spans both sin and cos, so the tone's PHASE is solved for, not assumed — amplitude is phase-independent and residual is unaffected by where the caller's segment happens to start.
| double pulp::test::audio::ToneFit::amplitude = 0.0 |
hypot(sin_gain, cos_gain).
| double pulp::test::audio::ToneFit::cos_gain = 0.0 |
Coefficient of cos(2π·f·n).
| double pulp::test::audio::ToneFit::cycles_per_sample = 0.0 |
The frequency fitted (f / sample_rate).
| double pulp::test::audio::ToneFit::fitted_energy = 0.0 |
Σ of the fitted tone squared.
| double pulp::test::audio::ToneFit::residual_energy = 0.0 |
Σ of (samples − fitted) squared.
| double pulp::test::audio::ToneFit::sin_gain = 0.0 |
Coefficient of sin(2π·f·n).