marf.Preprocessing.FFTFilter
Class FFTFilter

java.lang.Object
  |
  +--marf.Preprocessing.Preprocessing
        |
        +--marf.Preprocessing.FFTFilter.FFTFilter
All Implemented Interfaces:
StorageManager
Direct Known Subclasses:
BandpassFilter, HighFrequencyBoost, HighPassFilter, LowPassFilter

public abstract class FFTFilter
extends Preprocessing

FFTFilter class

Implements filtering using FFT algorithm

Derivatives must set frequency response based on the type of filter they are.

Author:
Stephen Sinclair

Field Summary
protected  double[] freqResponse
          Frequency repsonse to be multiplied by the incoming value
 
Fields inherited from class marf.Preprocessing.Preprocessing
oSample
 
Constructor Summary
FFTFilter(Sample poSample)
          FFTFilter Constructor
 
Method Summary
 boolean filter(double[] sample, double[] filtered)
          Perform a filter by the following algorithm: sample -> window -> FFT -> buffer buffer * frequency response buffer -> IFFT -> window -> sample Window used is square root of Hamming window, because the sum at half-window overlap is a constant, which avoids amplitude distortion from noise.
 boolean preprocess()
          FFTFilter implementation of preprocess()
 void setFrequencyResponse(double[] response)
          Sets frequency response.
 
Methods inherited from class marf.Preprocessing.Preprocessing
cropAudio, dump, getSample, normalize, removeNoise, removeSilence, restore
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

freqResponse

protected double[] freqResponse
Frequency repsonse to be multiplied by the incoming value
Constructor Detail

FFTFilter

public FFTFilter(Sample poSample)
FFTFilter Constructor
Parameters:
poSample - incoming sample
Method Detail

preprocess

public boolean preprocess()
                   throws PreprocessingException
FFTFilter implementation of preprocess()

It does call removeNoise() and removeSilence() if they were explicitly requested by an app before applying filtering.

Overrides:
preprocess in class Preprocessing
Returns:
true if there was something filtered out
Throws:
PreprocessingException -  

setFrequencyResponse

public final void setFrequencyResponse(double[] response)
Sets frequency response. Derivatives must call this method in their constructors.
Parameters:
response - desired frequency response
Throws:
PreprocessingException -  

filter

public final boolean filter(double[] sample,
                            double[] filtered)
                     throws PreprocessingException
Perform a filter by the following algorithm: sample -> window -> FFT -> buffer buffer * frequency response buffer -> IFFT -> window -> sample Window used is square root of Hamming window, because the sum at half-window overlap is a constant, which avoids amplitude distortion from noise. Also, start sampling at -responseSize/2, in order to avoid amplitude distortion of the first half of the first window. "filtered" must be at least as long as "sample"
Parameters:
sample - incoming sample analog data
filtered - will contain data after the filter was applied
Returns:
true if some filtering actually happened
Throws:
PreprocessingException -