@ -26,8 +26,10 @@
# include <Audio.h>
# include "control_sgtl5000plus.h"
void AudioControlSGTL5000Plus : : init_parametric_eq ( void )
void AudioControlSGTL5000Plus : : init_parametric_eq ( uint8_t n )
{
num_bands = constrain ( n , 1 , 7 ) ;
eqSelect ( PARAMETRIC_EQUALIZER ) ;
eqFilterCount ( num_bands ) ;
@ -95,11 +97,13 @@ void AudioControlSGTL5000Plus::init_parametric_eq(void)
setEQGain ( 7 , 0.0 ) ;
commitFilter ( 7 ) ;
}
_enabled = true ;
}
void AudioControlSGTL5000Plus : : setEQType ( uint8_t band , uint8_t ft )
{
if ( filter_type )
if ( filter_type & & _enabled = = true )
{
band = constrain ( band , 1 , num_bands ) ;
filter_type [ band - 1 ] = ft ;
@ -108,7 +112,7 @@ void AudioControlSGTL5000Plus::setEQType(uint8_t band, uint8_t ft)
void AudioControlSGTL5000Plus : : setEQFc ( uint8_t band , float frq )
{
if ( Fc )
if ( Fc & & _enabled = = true )
{
band = constrain ( band , 1 , num_bands ) ;
Fc [ band - 1 ] = frq ;
@ -117,7 +121,7 @@ void AudioControlSGTL5000Plus::setEQFc(uint8_t band, float frq)
void AudioControlSGTL5000Plus : : setEQQ ( uint8_t band , float q )
{
if ( Q )
if ( Q & & _enabled = = true )
{
band = constrain ( band , 1 , num_bands ) ;
Q [ band - 1 ] = q ;
@ -128,7 +132,7 @@ void AudioControlSGTL5000Plus::setEQQ(uint8_t band, float q)
// Calculate Q: http://www.sengpielaudio.com/calculator-bandwidth.htm
void setEQBandwidth ( uint8_t band , float bw )
{
if ( Q & & Fc )
if ( Q & & Fc & & _enabled = = true )
{
band = constrain ( band , 1 , num_bands ) ;
//Q[band - 1] = ;
@ -138,7 +142,7 @@ void AudioControlSGTL5000Plus::setEQQ(uint8_t band, float q)
void AudioControlSGTL5000Plus : : setEQGain ( uint8_t band , float gain )
{
if ( peakGainDB )
if ( peakGainDB & & _enabled = = true )
{
band = constrain ( band , 1 , num_bands ) ;
peakGainDB [ band - 1 ] = gain ;
@ -149,6 +153,9 @@ void AudioControlSGTL5000Plus::commitFilter(uint8_t band)
{
int filter [ 5 ] = { 0 , 0 , 0 , 0 , 0 } ;
if ( _enabled = = false )
return ;
band = constrain ( band , 1 , num_bands ) ;
calcBiquad ( filter_type [ band - 1 ] , Fc [ band - 1 ] , peakGainDB [ band - 1 ] , Q [ band - 1 ] , 0x80000 , AUDIO_SAMPLE_RATE , filter ) ;
@ -157,15 +164,22 @@ void AudioControlSGTL5000Plus::commitFilter(uint8_t band)
void AudioControlSGTL5000Plus : : show_params ( uint8_t band )
{
Serial . print ( F ( " Band: " ) ) ;
Serial . print ( band , DEC ) ;
Serial . print ( F ( " Type: " ) ) ;
Serial . print ( filter_type [ band - 1 ] , DEC ) ;
Serial . print ( F ( " Fc: " ) ) ;
Serial . print ( Fc [ band - 1 ] , 1 ) ;
Serial . print ( F ( " Q: " ) ) ;
Serial . print ( Q [ band - 1 ] , 1 ) ;
Serial . print ( F ( " peakGainDB: " ) ) ;
Serial . print ( peakGainDB [ band - 1 ] , 1 ) ;
Serial . println ( ) ;
if ( _enabled = = false )
{
Serial . print ( F ( " Parametric-EQ not initialized! " ) ) ;
}
else
{
Serial . print ( F ( " Band: " ) ) ;
Serial . print ( band , DEC ) ;
Serial . print ( F ( " Type: " ) ) ;
Serial . print ( filter_type [ band - 1 ] , DEC ) ;
Serial . print ( F ( " Fc: " ) ) ;
Serial . print ( Fc [ band - 1 ] , 1 ) ;
Serial . print ( F ( " Q: " ) ) ;
Serial . print ( Q [ band - 1 ] , 1 ) ;
Serial . print ( F ( " peakGainDB: " ) ) ;
Serial . print ( peakGainDB [ band - 1 ] , 1 ) ;
Serial . println ( ) ;
}
}