Fix audio blowups in \headphoneListener
This MR fixes audio blowups when using \headphoneListener
at a sample rate other than 44.1kHz.
The LPF
cutoff frequency calculation was using a mixture of SampleRate.ir
and the value 44100
. It was therefore possible under certain aziDeg
and nfIndex
combinations to end up with negative cutoff frequencies. Explosions ensued!
Firstly, I made the cutoff freq calculation based on the value 22050 (aka nyquist at 44.1kHz aka the limit of human hearing). I believe this is the code's original basic intent.
Second, I make significant formatting improvements. Some of these (moving the vars around) were necessary to allow the line:
nfIndex = nfIndex.clip(0.0, 1.0);
I believe it's absolutely necessary to clip nfIndex
to 0.0 - 1.0
given how it is used.
The rest of the formatting was to remove the strange whitespacing and inconsistent indentation.