forked from len0rd/rockbox
Slightly clearer code in dsp_eq_update_data.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9231 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c76904be53
commit
fac50d12bf
1 changed files with 12 additions and 17 deletions
29
apps/dsp.c
29
apps/dsp.c
|
|
@ -589,27 +589,24 @@ static void apply_crossfeed(int32_t* src[], int count)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EQ_CUTOFF_USER2REAL(x) (0xffffffff / NATIVE_FREQUENCY * (x))
|
|
||||||
#define EQ_Q_USER2REAL(x) (((x) << 16) / 10)
|
|
||||||
#define EQ_GAIN_USER2REAL(x) (((x) << 16) / 10)
|
|
||||||
|
|
||||||
/* Synchronize the EQ filters with the global settings */
|
/* Synchronize the EQ filters with the global settings */
|
||||||
void dsp_eq_update_data(bool enabled, int band)
|
void dsp_eq_update_data(bool enabled, int band)
|
||||||
{
|
{
|
||||||
int *setting;
|
const int *setting;
|
||||||
int gain, cutoff, q;
|
long gain;
|
||||||
|
unsigned long cutoff, q;
|
||||||
|
|
||||||
dsp->eq_enabled = enabled;
|
dsp->eq_enabled = enabled;
|
||||||
|
|
||||||
/* Adjust setting pointer to the band we actually want to change */
|
/* Adjust setting pointer to the band we actually want to change */
|
||||||
setting = &global_settings.eq_band0_cutoff + (band * 3);
|
setting = &global_settings.eq_band0_cutoff + (band * 3);
|
||||||
|
|
||||||
cutoff = *setting++;
|
/* Convert user settings to format required by coef generator functions */
|
||||||
q = *setting++;
|
cutoff = 0xffffffff / NATIVE_FREQUENCY * (*setting++);
|
||||||
gain = *setting++;
|
q = ((*setting++) << 16) / 10; /* 16.16 */
|
||||||
|
gain = ((*setting++) << 16) / 10; /* s15.16 */
|
||||||
DEBUGF("cutoff %d, q %d, gain %d\n", cutoff, q, gain);
|
|
||||||
|
|
||||||
|
/* The coef functions assume the EMAC unit is in fractional mode */
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
/* set emac unit for dsp processing, and save old macsr, we're running in
|
/* set emac unit for dsp processing, and save old macsr, we're running in
|
||||||
codec thread context at this point, so can't clobber it */
|
codec thread context at this point, so can't clobber it */
|
||||||
|
|
@ -617,18 +614,16 @@ void dsp_eq_update_data(bool enabled, int band)
|
||||||
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND);
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Assume a band is disabled if the gain is zero */
|
||||||
if (gain == 0) {
|
if (gain == 0) {
|
||||||
eq_data.enabled[band] = 0;
|
eq_data.enabled[band] = 0;
|
||||||
} else {
|
} else {
|
||||||
if (band == 0)
|
if (band == 0)
|
||||||
eq_ls_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
|
eq_ls_coefs(cutoff, q, gain, eq_data.filters[band].coefs);
|
||||||
EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs);
|
|
||||||
else if (band == 4)
|
else if (band == 4)
|
||||||
eq_hs_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
|
eq_hs_coefs(cutoff, q, gain, eq_data.filters[band].coefs);
|
||||||
EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs);
|
|
||||||
else
|
else
|
||||||
eq_pk_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
|
eq_pk_coefs(cutoff, q, gain, eq_data.filters[band].coefs);
|
||||||
EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs);
|
|
||||||
|
|
||||||
eq_data.enabled[band] = 1;
|
eq_data.enabled[band] = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue