diff options
Diffstat (limited to 'apps/dsp.c')
-rw-r--r-- | apps/dsp.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index 6e6f702a30..1f477d3f70 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -589,27 +589,24 @@ static void apply_crossfeed(int32_t* src[], int count) | |||
589 | } | 589 | } |
590 | #endif | 590 | #endif |
591 | 591 | ||
592 | #define EQ_CUTOFF_USER2REAL(x) (0xffffffff / NATIVE_FREQUENCY * (x)) | ||
593 | #define EQ_Q_USER2REAL(x) (((x) << 16) / 10) | ||
594 | #define EQ_GAIN_USER2REAL(x) (((x) << 16) / 10) | ||
595 | |||
596 | /* Synchronize the EQ filters with the global settings */ | 592 | /* Synchronize the EQ filters with the global settings */ |
597 | void dsp_eq_update_data(bool enabled, int band) | 593 | void dsp_eq_update_data(bool enabled, int band) |
598 | { | 594 | { |
599 | int *setting; | 595 | const int *setting; |
600 | int gain, cutoff, q; | 596 | long gain; |
597 | unsigned long cutoff, q; | ||
601 | 598 | ||
602 | dsp->eq_enabled = enabled; | 599 | dsp->eq_enabled = enabled; |
603 | 600 | ||
604 | /* Adjust setting pointer to the band we actually want to change */ | 601 | /* Adjust setting pointer to the band we actually want to change */ |
605 | setting = &global_settings.eq_band0_cutoff + (band * 3); | 602 | setting = &global_settings.eq_band0_cutoff + (band * 3); |
606 | 603 | ||
607 | cutoff = *setting++; | 604 | /* Convert user settings to format required by coef generator functions */ |
608 | q = *setting++; | 605 | cutoff = 0xffffffff / NATIVE_FREQUENCY * (*setting++); |
609 | gain = *setting++; | 606 | q = ((*setting++) << 16) / 10; /* 16.16 */ |
610 | 607 | gain = ((*setting++) << 16) / 10; /* s15.16 */ | |
611 | DEBUGF("cutoff %d, q %d, gain %d\n", cutoff, q, gain); | ||
612 | 608 | ||
609 | /* The coef functions assume the EMAC unit is in fractional mode */ | ||
613 | #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) | 610 | #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) |
614 | /* set emac unit for dsp processing, and save old macsr, we're running in | 611 | /* set emac unit for dsp processing, and save old macsr, we're running in |
615 | codec thread context at this point, so can't clobber it */ | 612 | codec thread context at this point, so can't clobber it */ |
@@ -617,18 +614,16 @@ void dsp_eq_update_data(bool enabled, int band) | |||
617 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND); | 614 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND); |
618 | #endif | 615 | #endif |
619 | 616 | ||
617 | /* Assume a band is disabled if the gain is zero */ | ||
620 | if (gain == 0) { | 618 | if (gain == 0) { |
621 | eq_data.enabled[band] = 0; | 619 | eq_data.enabled[band] = 0; |
622 | } else { | 620 | } else { |
623 | if (band == 0) | 621 | if (band == 0) |
624 | eq_ls_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q), | 622 | eq_ls_coefs(cutoff, q, gain, eq_data.filters[band].coefs); |
625 | EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs); | ||
626 | else if (band == 4) | 623 | else if (band == 4) |
627 | eq_hs_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q), | 624 | eq_hs_coefs(cutoff, q, gain, eq_data.filters[band].coefs); |
628 | EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs); | ||
629 | else | 625 | else |
630 | eq_pk_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q), | 626 | eq_pk_coefs(cutoff, q, gain, eq_data.filters[band].coefs); |
631 | EQ_GAIN_USER2REAL(gain), eq_data.filters[band].coefs); | ||
632 | 627 | ||
633 | eq_data.enabled[band] = 1; | 628 | eq_data.enabled[band] = 1; |
634 | } | 629 | } |