Fixing several PEQ problems.

pull/77/head
Holger Wirtz 3 years ago
parent 33472967be
commit 778b9218c7
  1. 12
      MicroDexed.ino
  2. 7
      UI.hpp
  3. 74
      control_sgtl5000plus.cpp
  4. 43
      control_sgtl5000plus.h

@ -430,12 +430,12 @@ void setup()
#endif #endif
#ifdef SGTL5000_AUDIO_ENHANCE #ifdef SGTL5000_AUDIO_ENHANCE
sgtl5000.audioPostProcessorEnable(); sgtl5000.audioPostProcessorEnable();
sgtl5000.enhanceBassEnable(); //sgtl5000.enhanceBassEnable();
sgtl5000.enhanceBass(1.0, 1.5, 0, 5); // enhanceBass(1.0, 1.0, 1, 2); // Configures the bass enhancement by setting the levels of the original stereo signal and the bass-enhanced mono level which will be mixed together. The high-pass filter may be enabled (0) or bypassed (1). //sgtl5000.enhanceBass(1.0, 1.5, 0, 5); // enhanceBass(1.0, 1.0, 1, 2); // Configures the bass enhancement by setting the levels of the original stereo signal and the bass-enhanced mono level which will be mixed together. The high-pass filter may be enabled (0) or bypassed (1).
sgtl5000.surroundSoundEnable(); //sgtl5000.surroundSoundEnable();
sgtl5000.surroundSound(7, 3); // Configures virtual surround width from 0 (mono) to 7 (widest). select may be set to 1 (disable), 2 (mono input) or 3 (stereo input). //sgtl5000.surroundSound(7, 3); // Configures virtual surround width from 0 (mono) to 7 (widest). select may be set to 1 (disable), 2 (mono input) or 3 (stereo input).
sgtl5000.autoVolumeEnable(); //sgtl5000.autoVolumeEnable();
sgtl5000.autoVolumeControl(1, 1, 1, 0.9, 0.01, 0.05); //sgtl5000.autoVolumeControl(1, 1, 1, 0.9, 0.01, 0.05);
#else #else
sgtl5000.audioProcessorDisable(); sgtl5000.audioProcessorDisable();
sgtl5000.autoVolumeDisable(); sgtl5000.autoVolumeDisable();

@ -7676,6 +7676,7 @@ void UI_func_eq_1(uint8_t param)
} }
lcd_display_meter_float("EQ 50Hz", configuration.fx.eq_1, 0.1, 0.0, EQ_1_MIN, EQ_1_MAX, 1, 1, false, true, true); lcd_display_meter_float("EQ 50Hz", configuration.fx.eq_1, 0.1, 0.0, EQ_1_MIN, EQ_1_MAX, 1, 1, false, true, true);
sgtl5000.setEQFc(1, mapfloat(configuration.fx.eq_1, EQ_1_MIN, EQ_1_MAX, -1.0, 1.0)); sgtl5000.setEQFc(1, mapfloat(configuration.fx.eq_1, EQ_1_MIN, EQ_1_MAX, -1.0, 1.0));
sgtl5000.commitFilter(1);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -7720,6 +7721,7 @@ void UI_func_eq_2(uint8_t param)
} }
lcd_display_meter_float("EQ 120Hz", configuration.fx.eq_2, 0.1, 0.0, EQ_2_MIN, EQ_2_MAX, 1, 1, false, true, true); lcd_display_meter_float("EQ 120Hz", configuration.fx.eq_2, 0.1, 0.0, EQ_2_MIN, EQ_2_MAX, 1, 1, false, true, true);
sgtl5000.setEQFc(2, mapfloat(configuration.fx.eq_2, EQ_2_MIN, EQ_2_MAX, -1.0, 1.0)); sgtl5000.setEQFc(2, mapfloat(configuration.fx.eq_2, EQ_2_MIN, EQ_2_MAX, -1.0, 1.0));
sgtl5000.commitFilter(2);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -7764,6 +7766,7 @@ void UI_func_eq_3(uint8_t param)
} }
lcd_display_meter_float("EQ 220Hz", configuration.fx.eq_3, 0.1, 0.0, EQ_3_MIN, EQ_3_MAX, 1, 1, false, true, true); lcd_display_meter_float("EQ 220Hz", configuration.fx.eq_3, 0.1, 0.0, EQ_3_MIN, EQ_3_MAX, 1, 1, false, true, true);
sgtl5000.setEQFc(3, mapfloat(configuration.fx.eq_3, EQ_3_MIN, EQ_3_MAX, -1.0, 1.0)); sgtl5000.setEQFc(3, mapfloat(configuration.fx.eq_3, EQ_3_MIN, EQ_3_MAX, -1.0, 1.0));
sgtl5000.commitFilter(3);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -7808,6 +7811,7 @@ void UI_func_eq_4(uint8_t param)
} }
lcd_display_meter_float("EQ 1000Hz", configuration.fx.eq_4, 0.1, 0.0, EQ_4_MIN, EQ_4_MAX, 1, 1, false, true, true); lcd_display_meter_float("EQ 1000Hz", configuration.fx.eq_4, 0.1, 0.0, EQ_4_MIN, EQ_4_MAX, 1, 1, false, true, true);
sgtl5000.setEQFc(4, mapfloat(configuration.fx.eq_4, EQ_4_MIN, EQ_4_MAX, -1.0, 1.0)); sgtl5000.setEQFc(4, mapfloat(configuration.fx.eq_4, EQ_4_MIN, EQ_4_MAX, -1.0, 1.0));
sgtl5000.commitFilter(4);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -7852,6 +7856,7 @@ void UI_func_eq_5(uint8_t param)
} }
lcd_display_meter_float("EQ 2000Hz", configuration.fx.eq_5, 0.1, 0.0, EQ_5_MIN, EQ_5_MAX, 1, 1, false, true, true); lcd_display_meter_float("EQ 2000Hz", configuration.fx.eq_5, 0.1, 0.0, EQ_5_MIN, EQ_5_MAX, 1, 1, false, true, true);
sgtl5000.setEQFc(5, mapfloat(configuration.fx.eq_5, EQ_5_MIN, EQ_5_MAX, -1.0, 1.0)); sgtl5000.setEQFc(5, mapfloat(configuration.fx.eq_5, EQ_5_MIN, EQ_5_MAX, -1.0, 1.0));
sgtl5000.commitFilter(5);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -7896,6 +7901,7 @@ void UI_func_eq_6(uint8_t param)
} }
lcd_display_meter_float("EQ 7000Hz", configuration.fx.eq_6, 0.1, 0.0, EQ_6_MIN, EQ_6_MAX, 1, 1, false, true, true); lcd_display_meter_float("EQ 7000Hz", configuration.fx.eq_6, 0.1, 0.0, EQ_6_MIN, EQ_6_MAX, 1, 1, false, true, true);
sgtl5000.setEQFc(6, mapfloat(configuration.fx.eq_6, EQ_6_MIN, EQ_6_MAX, -1.0, 1.0)); sgtl5000.setEQFc(6, mapfloat(configuration.fx.eq_6, EQ_6_MIN, EQ_6_MAX, -1.0, 1.0));
sgtl5000.commitFilter(6);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
@ -7940,6 +7946,7 @@ void UI_func_eq_7(uint8_t param)
} }
lcd_display_meter_float("EQ 10000Hz", configuration.fx.eq_7, 0.1, 0.0, EQ_7_MIN, EQ_7_MAX, 1, 1, false, true, true); lcd_display_meter_float("EQ 10000Hz", configuration.fx.eq_7, 0.1, 0.0, EQ_7_MIN, EQ_7_MAX, 1, 1, false, true, true);
sgtl5000.setEQFc(7, mapfloat(configuration.fx.eq_7, EQ_7_MIN, EQ_7_MAX, -1.0, 1.0)); sgtl5000.setEQFc(7, mapfloat(configuration.fx.eq_7, EQ_7_MIN, EQ_7_MAX, -1.0, 1.0));
sgtl5000.commitFilter(7);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********

@ -36,57 +36,63 @@ void AudioControlSGTL5000Plus::init_parametric_eq(void)
Q = new float[num_bands]; Q = new float[num_bands];
peakGainDB = new float[num_bands]; peakGainDB = new float[num_bands];
setEQType(1, GRAPHIC_EQ_TYPE_0); setEQType(1, EQ_TYPE_0);
setEQFc(1, GRAPHIC_EQ_CENTER_FRQ_0); setEQFc(1, EQ_CENTER_FRQ_0);
setEQQ(1, GRAPHIC_EQ_Q_0); setEQQ(1, EQ_Q_0);
setEQGain(1, 0.0); setEQGain(1, 0.0);
if (num_bands > 1) if (num_bands > 1)
{ {
setEQType(2, GRAPHIC_EQ_TYPE_1); setEQType(2, EQ_TYPE_1);
setEQFc(2, GRAPHIC_EQ_CENTER_FRQ_1); setEQFc(2, EQ_CENTER_FRQ_1);
setEQQ(2, GRAPHIC_EQ_Q_1); setEQQ(2, EQ_Q_1);
setEQGain(2, 0.0); setEQGain(2, 0.0);
commitFilter(7);
} }
if (num_bands > 2) if (num_bands > 2)
{ {
setEQType(3, GRAPHIC_EQ_TYPE_2); setEQType(3, EQ_TYPE_2);
setEQFc(3, GRAPHIC_EQ_CENTER_FRQ_2); setEQFc(3, EQ_CENTER_FRQ_2);
setEQQ(3, GRAPHIC_EQ_Q_2); setEQQ(3, EQ_Q_2);
setEQGain(3, 0.0); setEQGain(3, 0.0);
commitFilter(7);
} }
if (num_bands > 3) if (num_bands > 3)
{ {
setEQType(4, GRAPHIC_EQ_TYPE_3); setEQType(4, EQ_TYPE_3);
setEQFc(4, GRAPHIC_EQ_CENTER_FRQ_3); setEQFc(4, EQ_CENTER_FRQ_3);
setEQQ(4, GRAPHIC_EQ_Q_3); setEQQ(4, EQ_Q_3);
setEQGain(4, 0.0); setEQGain(4, 0.0);
commitFilter(7);
} }
if (num_bands > 4) if (num_bands > 4)
{ {
setEQType(5, GRAPHIC_EQ_TYPE_4); setEQType(5, EQ_TYPE_4);
setEQFc(5, GRAPHIC_EQ_CENTER_FRQ_4); setEQFc(5, EQ_CENTER_FRQ_4);
setEQQ(5, GRAPHIC_EQ_Q_4); setEQQ(5, EQ_Q_4);
setEQGain(5, 0.0); setEQGain(5, 0.0);
commitFilter(7);
} }
if (num_bands > 5) if (num_bands > 5)
{ {
setEQType(6, GRAPHIC_EQ_TYPE_5); setEQType(6, EQ_TYPE_5);
setEQFc(6, GRAPHIC_EQ_CENTER_FRQ_5); setEQFc(6, EQ_CENTER_FRQ_5);
setEQQ(6, GRAPHIC_EQ_Q_5); setEQQ(6, EQ_Q_5);
setEQGain(6, 0.0); setEQGain(6, 0.0);
commitFilter(7);
} }
if (num_bands > 6) if (num_bands > 6)
{ {
setEQType(7, GRAPHIC_EQ_TYPE_6); setEQType(7, EQ_TYPE_6);
setEQFc(7, GRAPHIC_EQ_CENTER_FRQ_6); setEQFc(7, EQ_CENTER_FRQ_6);
setEQQ(7, GRAPHIC_EQ_Q_6); setEQQ(7, EQ_Q_6);
setEQGain(7, 0.0); setEQGain(7, 0.0);
commitFilter(7);
} }
} }
@ -94,12 +100,8 @@ void AudioControlSGTL5000Plus::setEQType(uint8_t band, uint8_t ft)
{ {
if (filter_type) if (filter_type)
{ {
int filter[5];
band = constrain(band, 1, num_bands); band = constrain(band, 1, num_bands);
filter_type[band - 1] = ft; filter_type[band - 1] = ft;
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter);
//eqFilter(band, filter);
} }
} }
@ -107,12 +109,8 @@ void AudioControlSGTL5000Plus::setEQFc(uint8_t band, float frq)
{ {
if (Fc) if (Fc)
{ {
int filter[5];
band = constrain(band, 1, num_bands); band = constrain(band, 1, num_bands);
Fc[band - 1] = frq; Fc[band - 1] = frq;
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter);
//eqFilter(band, filter);
} }
} }
@ -120,12 +118,8 @@ void AudioControlSGTL5000Plus::setEQQ(uint8_t band, float q)
{ {
if (Q) if (Q)
{ {
int filter[5];
band = constrain(band, 1, num_bands); band = constrain(band, 1, num_bands);
Q[band - 1] = q; Q[band - 1] = q;
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter);
//eqFilter(band, filter);
} }
} }
@ -133,11 +127,17 @@ void AudioControlSGTL5000Plus::setEQGain(uint8_t band, float gain)
{ {
if (peakGainDB) if (peakGainDB)
{ {
int filter[5];
band = constrain(band, 1, num_bands); band = constrain(band, 1, num_bands);
peakGainDB[band - 1] = gain; peakGainDB[band - 1] = gain;
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter);
//eqFilter(band, filter);
} }
} }
void AudioControlSGTL5000Plus::commitFilter(uint8_t band)
{
int filter[5] = {0, 0, 0, 0, 0};
band = constrain(band, 1, num_bands);
calcBiquad(filter_type[band - 1], Fc[band - 1], peakGainDB[band - 1], Q[band - 1], 524288, AUDIO_SAMPLE_RATE, filter);
eqFilter(band, filter);
}

@ -28,33 +28,33 @@
#include <Arduino.h> #include <Arduino.h>
#include <Audio.h> #include <Audio.h>
#define GRAPHIC_EQ_TYPE_0 FILTER_HIPASS #define EQ_TYPE_0 FILTER_PARAEQ
#define GRAPHIC_EQ_CENTER_FRQ_0 50.0 #define EQ_CENTER_FRQ_0 50.0
#define GRAPHIC_EQ_Q_0 6.0 #define EQ_Q_0 1.0
#define GRAPHIC_EQ_TYPE_1 FILTER_BANDPASS #define EQ_TYPE_1 FILTER_PARAEQ
#define GRAPHIC_EQ_CENTER_FRQ_1 120.0 #define EQ_CENTER_FRQ_1 120.0
#define GRAPHIC_EQ_Q_1 6.0 #define EQ_Q_1 1.0
#define GRAPHIC_EQ_TYPE_2 FILTER_BANDPASS #define EQ_TYPE_2 FILTER_PARAEQ
#define GRAPHIC_EQ_CENTER_FRQ_2 220.0 #define EQ_CENTER_FRQ_2 220.0
#define GRAPHIC_EQ_Q_2 6.0 #define EQ_Q_2 1.0
#define GRAPHIC_EQ_TYPE_3 FILTER_BANDPASS #define EQ_TYPE_3 FILTER_PARAEQ
#define GRAPHIC_EQ_CENTER_FRQ_3 1000.0 #define EQ_CENTER_FRQ_3 1000.0
#define GRAPHIC_EQ_Q_3 6.0 #define EQ_Q_3 1.0
#define GRAPHIC_EQ_TYPE_4 FILTER_BANDPASS #define EQ_TYPE_4 FILTER_PARAEQ
#define GRAPHIC_EQ_CENTER_FRQ_4 2000.0 #define EQ_CENTER_FRQ_4 2000.0
#define GRAPHIC_EQ_Q_4 6.0 #define EQ_Q_4 1.0
#define GRAPHIC_EQ_TYPE_5 FILTER_BANDPASS #define EQ_TYPE_5 FILTER_PARAEQ
#define GRAPHIC_EQ_CENTER_FRQ_5 7000.0 #define EQ_CENTER_FRQ_5 7000.0
#define GRAPHIC_EQ_Q_5 2.0 #define EQ_Q_5 1.0
#define GRAPHIC_EQ_TYPE_6 FILTER_LOPASS #define EQ_TYPE_6 FILTER_PARAEQ
#define GRAPHIC_EQ_CENTER_FRQ_6 10000.0 #define EQ_CENTER_FRQ_6 10000.0
#define GRAPHIC_EQ_Q_6 6.0 #define EQ_Q_6 1.0
class AudioControlSGTL5000Plus : public AudioControlSGTL5000 class AudioControlSGTL5000Plus : public AudioControlSGTL5000
{ {
@ -67,6 +67,7 @@ class AudioControlSGTL5000Plus : public AudioControlSGTL5000
void setEQFc(uint8_t band, float frq); void setEQFc(uint8_t band, float frq);
void setEQQ(uint8_t band, float q); void setEQQ(uint8_t band, float q);
void setEQGain(uint8_t band, float gain); void setEQGain(uint8_t band, float gain);
void commitFilter(uint8_t band);
private: private:
void init_parametric_eq(void); void init_parametric_eq(void);

Loading…
Cancel
Save