[Stk] small improvement to Filter::phaseDelay()
Andreas Sumerauer
ansum at soundbytes.de
Mon May 30 14:51:39 PDT 2016
Hello,
I have been recently looking at the filter class and found a small
improvement to the Filter::phaseDelay() function. I hope you like it.
This:
inline StkFloat Filter :: phaseDelay( StkFloat frequency )
{
(...)
StkFloat real = 0.0, imag = 0.0;
for ( unsigned int i=0; i<b_.size(); i++ ) {
(...)
real = 0.0, imag = 0.0;
for ( unsigned int i=0; i<a_.size(); i++ ) {
(...)
}
can be replaced by:
inline StkFloat Filter :: phaseDelay( StkFloat frequency )
{
(...)
StkFloat real = b[0], imag = 0.0;
for ( unsigned int i=1; i<b_.size(); i++ ) {
(...)
real = 0.0, imag = a[0];
for ( unsigned int i=1; i<a_.size(); i++ ) {
(...)
}
It saves a bit of CPU bandwidth by utilizing the trigonometric
identities cos(0) = 1 and sin(0) = 0.
best regards
Andreas Sumerauer
More information about the Stk
mailing list