marf.Preprocessing.FFTFilter
Class FFTFilter

java.lang.Object
  extended by marf.Storage.StorageManager
      extended by marf.Preprocessing.Preprocessing
          extended by marf.Preprocessing.FFTFilter.FFTFilter
All Implemented Interfaces:
java.io.Serializable, IPreprocessing, IStorageManager
Direct Known Subclasses:
BandpassFilter, HighFrequencyBoost, HighPassFilter, LowPassFilter

public abstract class FFTFilter
extends Preprocessing

FFTFilter class implements filtering using the FFT algorithm.

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

$Id: FFTFilter.java,v 1.22 2005/06/16 19:58:47 mokhov Exp $

Since:
0.0.1
Version:
$Revision: 1.22 $
Author:
Stephen Sinclair, Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  double[] adFreqResponse
          Frequency repsonse to be multiplied by the incoming value.
static int DEFAULT_FREQUENCY_RESPONSE_SIZE
          Default size of the frequency response vector, 128.
 
Fields inherited from class marf.Preprocessing.Preprocessing
oSample
 
Fields inherited from class marf.Storage.StorageManager
bDumpOnNotFound, iCurrentDumpMode, oObjectToSerialize, strFilename
 
Fields inherited from interface marf.Preprocessing.IPreprocessing
MARF_INTERFACE_CODE_REVISION
 
Fields inherited from interface marf.Storage.IStorageManager
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, MARF_INTERFACE_CODE_REVISION, STORAGE_FILE_EXTENSIONS
 
Constructor Summary
FFTFilter(Preprocessing poPreprocessing)
          Pipelined constructor.
FFTFilter(Sample poSample)
          FFTFilter Constructor.
 
Method Summary
 boolean filter(double[] sample, double[] filtered)
          Perform a filter by the following algorithm: (1) sample -> window -> FFT -> buffer
(2) buffer * frequency response
(3) buffer -> IFFT -> window -> sample.
abstract  void genereateResponseCoefficients()
          Creates frequency response coefficients and sets applies them to the frequency response vector.
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 boolean preprocess()
          FFTFilter implementation of preprocess().
 void setFrequencyResponse(double[] padPesponse)
          Sets frequency response.
 
Methods inherited from class marf.Preprocessing.Preprocessing
backSynchronizeObject, cropAudio, getSample, normalize, normalize, normalize, removeNoise, removeSilence
 
Methods inherited from class marf.Storage.StorageManager
dump, dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, dumpXML, enableDumpOnNotFound, getDefaultExtension, getDefaultExtension, getDumpMode, getFilename, restore, restoreBinary, restoreCSV, restoreGzipBinary, restoreHTML, restoreSQL, restoreXML, setDumpMode, setFilename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FREQUENCY_RESPONSE_SIZE

public static final transient int DEFAULT_FREQUENCY_RESPONSE_SIZE
Default size of the frequency response vector, 128.

See Also:
Constant Field Values

adFreqResponse

protected transient double[] adFreqResponse
Frequency repsonse to be multiplied by the incoming value.

Constructor Detail

FFTFilter

public FFTFilter(Preprocessing poPreprocessing)
          throws PreprocessingException
Pipelined constructor.

Parameters:
poPreprocessing - followup preprocessing module
Throws:
PreprocessingException
Since:
0.3.0

FFTFilter

public FFTFilter(Sample poSample)
          throws PreprocessingException
FFTFilter Constructor.

Parameters:
poSample - incoming sample
Throws:
PreprocessingException
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.

NOTE: it alters inner Sample by resetting its data array to the new filtered values.

Returns:
true if there was something filtered out
Throws:
PreprocessingException - if the frequency response is null
See Also:
IPreprocessing.removeNoise(), IPreprocessing.removeSilence()

setFrequencyResponse

public final void setFrequencyResponse(double[] padPesponse)
Sets frequency response. Derivatives must call this method before any preprocessing occurs. TODO: use marf.util.Arrays.copy()

Parameters:
padPesponse - desired frequency response coefficients

filter

public final boolean filter(double[] sample,
                            double[] filtered)
                     throws PreprocessingException
Perform a filter by the following algorithm: (1) sample -> window -> FFT -> buffer
(2) buffer * frequency response
(3) 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.

Parameters:
sample - incoming sample analog data
filtered - will contain data after the filter was applied. "filtered" must be at least as long as "sample".
Returns:
true if some filtering actually happened
Throws:
PreprocessingException - if the filtered and sample data arrays are not of the same size, the frequency response was not set, or there was an underlying FeatureExctractionException while executing the underlying FFT algorithm.

genereateResponseCoefficients

public abstract void genereateResponseCoefficients()
Creates frequency response coefficients and sets applies them to the frequency response vector. Must be overridden by individual filters.

Since:
0.3.0

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Returns source code revision information.

Returns:
revision string
Since:
0.3.0