public int doFilter ( final float [ ] ringBuffer , final int start , final int length , final int useBands ) { final float internalPreAmp = 1f / useBands ; final float rest = 1.0f - internalPreAmp ; final int end = start + length ; int index = start ; while ( index < end ) { for ( int c = 0 ; c < channels ; c ++ ) { final int sampleIndex = ( index ++ ) % sampleBufferSize ; float sample = 0 ; // Run the difference equation final float preAmpedSample = ringBuffer [ sampleIndex ] * preAmp * internalPreAmp ; for ( int f = 0 ; f < useBands ; f ++ ) { IIRFilterBase filter = filters [ f ] ; sample += filter . performFilterCalculation ( preAmpedSample , c , iIndex , jIndex , kIndex ) * filter . amplitudeAdj ; } sample += ( ringBuffer [ sampleIndex ] * rest ) ; ringBuffer [ sampleIndex ] = ( sample > 1.0f ) ? 1.0f : ( ( sample < - 1.0f ) ? - 1.0f : sample ) ; } // Do indices maintenance iIndex = ( iIndex + 1 ) % IIRFilterBase . HISTORYSIZE ; jIndex = ( jIndex + 1 ) % IIRFilterBase . HISTORYSIZE ; kIndex = ( kIndex + 1 ) % IIRFilterBase . HISTORYSIZE ; } return length ; }
This will perform the filter on the samples