marf.Preprocessing
Class Preprocessing

java.lang.Object
  |
  +--marf.Storage.StorageManager
        |
        +--marf.Preprocessing.Preprocessing
All Implemented Interfaces:
IPreprocessing, IStorageManager, java.io.Serializable
Direct Known Subclasses:
Dummy, Endpoint, FFTFilter

public abstract class Preprocessing
extends StorageManager
implements IPreprocessing

Abstract Preprocessing Module.

$Id: Preprocessing.java,v 1.35 2005/08/05 22:19:54 mokhov Exp $

Since:
0.0.1
Version:
$Revision: 1.35 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  marf.Storage.Sample oSample
          Sample reference.
 
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
protected Preprocessing(marf.Preprocessing.IPreprocessing poPreprocessing)
          Allows chaining of preprocessing modules.
protected Preprocessing(marf.Storage.Sample poSample)
          Main Preprocessing constructor that performs normalization as a part of construction process.
 
Method Summary
 void backSynchronizeObject()
          Implementaion of back-synchronization of Sample loaded object.
 boolean cropAudio(double pdStartingFrequency, double pdEndFrequency)
          Derivatives implement this method to crop arbitrary part of the audio sample.
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 marf.Storage.Sample getSample()
          Returns enclosed sample.
 boolean normalize()
          Normalization of entire incoming samples by amplitude.
 boolean normalize(int piIndexFrom)
          Normalization of incoming samples by amplitude starting from certain index.
 boolean normalize(int piIndexFrom, int piIndexTo)
          Normalization of incoming samples by amplitude between specified indexes.
 boolean removeNoise()
          Derivatives should implement this method to remove noise from the sample.
 boolean removeSilence()
          Derivatives should implement this method to remove silence.
 void setSample(marf.Storage.Sample poSample)
          Allows setting a sample object reference.
 
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
 
Methods inherited from interface marf.Preprocessing.IPreprocessing
preprocess
 

Field Detail

oSample

protected marf.Storage.Sample oSample
Sample reference.

Constructor Detail

Preprocessing

protected Preprocessing(marf.Storage.Sample poSample)
                 throws PreprocessingException
Main Preprocessing constructor that performs normalization as a part of construction process.

Parameters:
poSample - loaded sample by a concrete implementation of SampleLoader
Throws:
PreprocessingException - if normalize() fails
See Also:
normalize()

Preprocessing

protected Preprocessing(marf.Preprocessing.IPreprocessing poPreprocessing)
                 throws PreprocessingException
Allows chaining of preprocessing modules. Makes it possible to apply several preprocessing modules on the same incoming sample, in the form of new FooBarBaz(new HighFrequencyBoost(new HighPassFilter(poSample))). Notice, it calls preprocess() for all inner preprocessing, but not the outer. The outer is supposed to be called by either MARF or an application as a part of defined API.

Parameters:
poPreprocessing - follow up preprocessing module
Throws:
PreprocessingException - if underlying preprocess() fails or the parameter is null.
Since:
0.3.0.3
See Also:
IPreprocessing.preprocess(), MARF, HighFrequencyBoost, HighPassFilter
Method Detail

removeNoise

public boolean removeNoise()
                    throws PreprocessingException
Derivatives should implement this method to remove noise from the sample.

Specified by:
removeNoise in interface IPreprocessing
Returns:
boolean that sample has changed (noise removed)
Throws:
NotImplementedException
PreprocessingException - declared but never thrown

removeSilence

public boolean removeSilence()
                      throws PreprocessingException
Derivatives should implement this method to remove silence.

Specified by:
removeSilence in interface IPreprocessing
Returns:
boolean that sample has changed (silence removed)
Throws:
NotImplementedException
PreprocessingException - declared but never thrown

normalize

public final boolean normalize()
                        throws PreprocessingException
Normalization of entire incoming samples by amplitude. Equivalent to normalize(0).

Specified by:
normalize in interface IPreprocessing
Returns:
true if the sample has been successfully normalized; false otherwise
Throws:
PreprocessingException - if internal sample reference is null
See Also:
normalize(int)

normalize

public final boolean normalize(int piIndexFrom)
                        throws PreprocessingException
Normalization of incoming samples by amplitude starting from certain index. Useful in case where only the last portion of a sample needs to be normalized, like in HighFrequencyBoost. Equivalent to normalize(piIndexFrom, sample array length - 1).

Specified by:
normalize in interface IPreprocessing
Parameters:
piIndexFrom - sample array index to start normalization from
Returns:
true if the sample has been successfully normalized; false otherwise
Throws:
PreprocessingException - if internal sample reference is null
Since:
0.3.0
See Also:
normalize(int, int), HighFrequencyBoost

normalize

public final boolean normalize(int piIndexFrom,
                               int piIndexTo)
                        throws PreprocessingException
Normalization of incoming samples by amplitude between specified indexes. Useful in case where only a portion of a sample needs to be normalized.

Specified by:
normalize in interface IPreprocessing
Parameters:
piIndexFrom - sample array index to start normalization from
piIndexTo - sample array index to end normalization at
Returns:
true if the sample has been successfully normalized; false otherwise
Throws:
PreprocessingException - if internal sample reference is null or one or both indexes are out of range
Since:
0.3.0

cropAudio

public boolean cropAudio(double pdStartingFrequency,
                         double pdEndFrequency)
                  throws PreprocessingException
Derivatives implement this method to crop arbitrary part of the audio sample.

Specified by:
cropAudio in interface IPreprocessing
Parameters:
pdStartingFrequency - double Frequency to start to crop from
pdEndFrequency - double Frequency to crop the sample to
Returns:
boolean true - cropped, false - not
Throws:
NotImplementedException
PreprocessingException - declared, but is never thrown

getSample

public final marf.Storage.Sample getSample()
Returns enclosed sample.

Specified by:
getSample in interface IPreprocessing
Returns:
Sample object

setSample

public void setSample(marf.Storage.Sample poSample)
Allows setting a sample object reference.

Specified by:
setSample in interface IPreprocessing
Parameters:
poSample - new sample object
Since:
0.3.0.4

backSynchronizeObject

public void backSynchronizeObject()
Implementaion of back-synchronization of Sample loaded object.

Overrides:
backSynchronizeObject in class StorageManager
Since:
0.3.0.2
See Also:
StorageManager.restore()

getMARFSourceCodeRevision

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

Returns:
revision string
Since:
0.3.0.2