marf.Preprocessing.FFTFilter
Class FFTFilter

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

public abstract class FFTFilter
extends Filter

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.37 2007/12/16 21:58:31 mokhov Exp $

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

Field Summary
protected  double[] adFreqResponse
          Frequency response 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
bRemoveNoise, bRemoveSilence, DEFAULT_SILENCE_THRESHOLD, dSilenceThreshold, oSample
 
Fields inherited from class marf.Storage.StorageManager
bDumpOnNotFound, iCurrentDumpMode, oObjectToSerialize, strFilename
 
Fields inherited from interface marf.Preprocessing.IFilter
FILTER_DIMENSIONALITY_1D, FILTER_DIMENSIONALITY_2D, FILTER_DIMENSIONALITY_3D, MARF_INTERFACE_CODE_REVISION
 
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()
          Default constructor for reflective creation of Preprocessing clones.
FFTFilter(IPreprocessing poPreprocessing)
          Pipelined constructor.
FFTFilter(Sample poSample)
          FFTFilter Constructor.
 
Method Summary
 boolean filter(double[][][] padSample, double[][][] padFiltered)
          Applies two-dimensional filtering to every plane of the matrix.
 boolean filter(double[][] padSample, double[][] padFiltered)
          Applies single-dimensional filtering to every row of the matrix.
 boolean filter(double[] padSample, double[] padFiltered)
          Perform a filter by the following algorithm: (1) sample -> window -> FFT -> buffer
(2) buffer * frequency response
(3) buffer -> IFFT -> window -> sample.
abstract  void generateResponseCoefficients()
          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, clone, compress, compress, cropAudio, extractParameters, getSample, normalize, normalize, normalize, removeNoise, removeSilence, removeSilence, setSample
 
Methods inherited from class marf.Storage.StorageManager
dump, dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, dumpXML, enableDumpOnNotFound, equals, getDefaultExtension, getDefaultExtension, getDumpMode, getFilename, getObjectToSerialize, hashCode, restore, restoreBinary, restoreCSV, restoreGzipBinary, restoreHTML, restoreSQL, restoreXML, setDumpMode, setFilename, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, 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 response to be multiplied by the incoming value.

Constructor Detail

FFTFilter

public FFTFilter()
Default constructor for reflective creation of Preprocessing clones. Typically should not be used unless really necessary for the frameworked modules.

Since:
0.3.0.5

FFTFilter

public FFTFilter(IPreprocessing poPreprocessing)
          throws PreprocessingException
Pipelined constructor.

Parameters:
poPreprocessing - the follow-up preprocessing module
Throws:
PreprocessingException
Since:
0.3.0.3

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 overrides the default of Filter to allow a check for the frequency response array validation. NOTE: it alters inner Sample by resetting its data array to the new filtered values.

Specified by:
preprocess in interface IPreprocessing
Overrides:
preprocess in class Filter
Returns:
true if there was something filtered out
Throws:
PreprocessingException - primarily 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.

Parameters:
padPesponse - desired frequency response coefficients

filter

public final boolean filter(double[] padSample,
                            double[] padFiltered)
                     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:
padSample - incoming sample analog data
padFiltered - 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.

filter

public boolean filter(double[][] padSample,
                      double[][] padFiltered)
               throws PreprocessingException
Applies single-dimensional filtering to every row of the matrix.

Parameters:
padSample - original sample to apply filtering to; should not be altered
padFiltered - buffer for filtered data
Returns:
true if filtering was successful and/or there were any changes
Throws:
PreprocessingException - if any error happened during filtering
Since:
0.3.0.6
See Also:
IFilter.filter(double[][], double[][]), filter(double[], double[])

filter

public boolean filter(double[][][] padSample,
                      double[][][] padFiltered)
               throws PreprocessingException
Applies two-dimensional filtering to every plane of the matrix.

Parameters:
padSample - original sample to apply filtering to; should not be altered
padFiltered - buffer for filtered data
Returns:
true if filtering was successful and/or there were any changes
Throws:
PreprocessingException - if any error happened during filtering
Since:
0.3.0.6
See Also:
IFilter.filter(double[][][], double[][][]), filter(double[][], double[][])

generateResponseCoefficients

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

Since:
0.3.0.2

getMARFSourceCodeRevision

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

Returns:
revision string
Since:
0.3.0.2


SourceForge Logo