mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Transfer Fn: skip phase calculation for silence and small signal levels
This fixes some division by zero as well as rounding issues for signals < -160dBFS, resulting in garbage being displayed..
This commit is contained in:
parent
dba3ff5236
commit
69194df4d9
1 changed files with 9 additions and 6 deletions
|
|
@ -79,13 +79,16 @@ FFT::analyze(ARDOUR::Sample *input, WindowingType windowing_type)
|
||||||
for (uint32_t i = 1; i < _data_size - 1; ++i) {
|
for (uint32_t i = 1; i < _data_size - 1; ++i) {
|
||||||
|
|
||||||
power = (Re * Re) + (Im * Im);
|
power = (Re * Re) + (Im * Im);
|
||||||
phase = atanf(Im / Re);
|
if (power < 1e-16) {
|
||||||
|
phase = 0;
|
||||||
|
} else {
|
||||||
|
phase = atanf (Im / Re);
|
||||||
if (Re < 0.0 && Im > 0.0) {
|
if (Re < 0.0 && Im > 0.0) {
|
||||||
phase += M_PI;
|
phase += M_PI;
|
||||||
} else if (Re < 0.0 && Im < 0.0) {
|
} else if (Re < 0.0 && Im < 0.0) {
|
||||||
phase -= M_PI;
|
phase -= M_PI;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_power_at_bin[i] += power;
|
_power_at_bin[i] += power;
|
||||||
_phase_at_bin[i] += phase;
|
_phase_at_bin[i] += phase;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue