mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +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,12 +79,15 @@ FFT::analyze(ARDOUR::Sample *input, WindowingType windowing_type)
|
|||
for (uint32_t i = 1; i < _data_size - 1; ++i) {
|
||||
|
||||
power = (Re * Re) + (Im * Im);
|
||||
phase = atanf(Im / Re);
|
||||
|
||||
if (Re < 0.0 && Im > 0.0) {
|
||||
phase += M_PI;
|
||||
} else if (Re < 0.0 && Im < 0.0) {
|
||||
phase -= M_PI;
|
||||
if (power < 1e-16) {
|
||||
phase = 0;
|
||||
} else {
|
||||
phase = atanf (Im / Re);
|
||||
if (Re < 0.0 && Im > 0.0) {
|
||||
phase += M_PI;
|
||||
} else if (Re < 0.0 && Im < 0.0) {
|
||||
phase -= M_PI;
|
||||
}
|
||||
}
|
||||
|
||||
_power_at_bin[i] += power;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue