示例#1
0
size_t EffectBassTreble::InstanceProcess(EffectBassTrebleState & data,
                                              float **inBlock,
                                              float **outBlock,
                                              size_t blockLen)
{
   float *ibuf = inBlock[0];
   float *obuf = outBlock[0];

   // Set value to ensure correct rounding
   double oldBass = DB_TO_LINEAR(mBass);
   double oldTreble = DB_TO_LINEAR(mTreble);

   data.gain = DB_TO_LINEAR(mGain);

   // Compute coefficents of the low shelf biquand IIR filter
   if (data.bass != oldBass)
      Coefficents(data.hzBass, data.slope, mBass, data.samplerate, kBass,
                  data.a0Bass, data.a1Bass, data.a2Bass,
                  data.b0Bass, data.b1Bass, data.b2Bass);

   // Compute coefficents of the high shelf biquand IIR filter
   if (data.treble != oldTreble)
      Coefficents(data.hzTreble, data.slope, mTreble, data.samplerate, kTreble,
                  data.a0Treble, data.a1Treble, data.a2Treble,
                  data.b0Treble, data.b1Treble, data.b2Treble);

   for (decltype(blockLen) i = 0; i < blockLen; i++) {
      obuf[i] = DoFilter(data, ibuf[i]) * data.gain;
   }

   return blockLen;
}
示例#2
0
bool EffectBassTreble::NewTrackPass1()
{
   const float slope = 0.4f;   // same slope for both filters
   const double hzBass = 250.0f;
   const double hzTreble = 4000.0f;

   //(re)initialise filter parameters
   xn1Bass=xn2Bass=yn1Bass=yn2Bass=0;
   xn1Treble=xn2Treble=yn1Treble=yn2Treble=0;

   // Compute coefficents of the low shelf biquand IIR filter
   Coefficents(hzBass, slope, dB_bass, bassType,
               a0Bass, a1Bass, a2Bass,
               b0Bass, b1Bass, b2Bass);

   // Compute coefficents of the high shelf biquand IIR filter
   Coefficents(hzTreble, slope, dB_treble, trebleType, 
               a0Treble, a1Treble, a2Treble,
               b0Treble, b1Treble, b2Treble);

   return true;
}