Skip to content

Commit a36bbde

Browse files
committed
less magic numbers
1 parent bbee05d commit a36bbde

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/rvoice/fluid_iir_filter.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
extern "C" void fluid_iir_filter_init_table(fluid_iir_sincos_t *sincos_table, fluid_real_t sample_rate)
3131
{
3232
const IIR_COEFF_T period = (IIR_COEFF_T)(2.0 * M_PI / sample_rate);
33-
for(int fres_cents = 1500, i=0; fres_cents <= 13500; fres_cents += CENTS_STEP, i++)
33+
for(int fres_cents = FRES_MIN, i=0; fres_cents <= FRES_MAX; fres_cents += CENTS_STEP, i++)
3434
{
3535
fluid_real_t fres = fluid_ct2hz(fres_cents);
3636
IIR_COEFF_T omega = period * fres;
3737
IIR_COEFF_T sin_coeff = std::sin(omega);
3838
IIR_COEFF_T cos_coeff = std::cos(omega);
39-
// i == (fres_cents - 1500) / CENTS_STEP;
39+
// i == (fres_cents - FRES_MIN) / CENTS_STEP;
4040
sincos_table[i].sin = sin_coeff;
4141
sincos_table[i].cos = cos_coeff;
4242
}
@@ -62,7 +62,7 @@ static inline void fluid_iir_filter_calculate_coefficients(R fres,
6262
* into account for both significant frequency relocation and for
6363
* bandwidth readjustment'. */
6464

65-
unsigned tab_idx = (fres - 1500) / CENTS_STEP;
65+
unsigned tab_idx = (fres - FRES_MIN) / CENTS_STEP;
6666
R sin_coeff = sincos_table[tab_idx].sin;
6767
R cos_coeff = sincos_table[tab_idx].cos;
6868
R alpha_coeff = sin_coeff / (2.0f * q);

src/rvoice/fluid_iir_filter.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ struct _fluid_iir_filter_t
8787
enum
8888
{
8989
CENTS_STEP = 1 /* cents */,
90-
SINCOS_TAB_SIZE = ((13500 /* upper fc in cents */ - 1500 /* lower fc in cents */) / CENTS_STEP)
90+
FRES_MIN = 1500 /* cents */,
91+
FRES_MAX = 13500 /* cents */,
92+
SINCOS_TAB_SIZE = ((FRES_MAX /* upper fc in cents */ - FRES_MIN /* lower fc in cents */) / CENTS_STEP)
9193
+
92-
1 /* add one because asking for 13500 cents must yield a valid coefficient */,
94+
1 /* add one because asking for FRES_MAX cents must yield a valid coefficient */,
9395
};
9496

9597

0 commit comments

Comments
 (0)