/** * Calculate first order shelving filter. Filter is not directly usable by the * filter_process() function. * @param cutoff shelf midpoint frequency. See eq_pk_coefs for format. * @param A decibel value multiplied by ten, describing gain/attenuation of * shelf. Max value is 24 dB. * @param low true for low-shelf filter, false for high-shelf filter. * @param c pointer to coefficient storage. Coefficients are s4.27 format. */ void filter_shelf_coefs(unsigned long cutoff, long A, bool low, int32_t *c) { long sin, cos; int32_t b0, b1, a0, a1; /* s3.28 */ const long g = get_replaygain_int(A*5) << 4; /* 10^(db/40), s3.28 */ sin = fp_sincos(cutoff/2, &cos); if (low) { const int32_t sin_div_g = fp_div(sin, g, 25); const int32_t sin_g = FRACMUL(sin, g); cos >>= 3; b0 = sin_g + cos; /* 0.25 .. 4.10 */ b1 = sin_g - cos; /* -1 .. 3.98 */ a0 = sin_div_g + cos; /* 0.25 .. 4.10 */ a1 = sin_div_g - cos; /* -1 .. 3.98 */ } else {
static void init_tables(void) { int i; int pfrac; unsigned long phase; long sin; phase = pfrac = 0; for (i = 0; i < TABLE_SIZE; i++) { sin = fp_sincos(phase, NULL); xtable[i] = RADIUS_X + sin / DIV_X; ytable[i] = RADIUS_Y + sin / DIV_Y; phase += PHASE_STEP; pfrac += PHASE_FRAC; if (pfrac >= TABLE_SIZE) { pfrac -= TABLE_SIZE; phase++; } } }
static void init_clock(void) { int i; int pfrac; unsigned long phase; long sin, cos; phase = pfrac = 0; for (i = 0; i < 60; i++) { sin = fp_sincos(phase, &cos); xminute[i] = LCD_WIDTH/2 + sin / DIV_MX; yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY; xhour[i] = LCD_WIDTH/2 + sin / DIV_HX; yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY; phase += CLOCK_STEP; pfrac += CLOCK_FRAC; if (pfrac >= 60) { pfrac -= 60; phase++; } } }