marf.Preprocessing
Class Preprocessing

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

public abstract class Preprocessing
extends StorageManager

Abstract Preprocessing Module.

$Id: Preprocessing.java,v 1.32 2005/06/04 03:54:37 mokhov Exp $

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

Field Summary
protected  marf.Storage.Sample oSample
          Sample reference.
 
Fields inherited from class marf.Storage.StorageManager
iCurrentDumpMode, oObjectToSerialize, strFilename
 
Fields inherited from interface marf.Storage.IStorageManager
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, INTERFACE_CODE_REVISION, sastrExtensionsMap
 
Constructor Summary
protected Preprocessing(marf.Preprocessing.Preprocessing 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 getRevision()
          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.
abstract  boolean preprocess()
          Derivatives must implement this method to do general preprocessing and perhaps calling removeNoise() and removeSilence().
 boolean removeNoise()
          Derivatives should implement this method to remove noise from the sample.
 boolean removeSilence()
          Derivatives should implement this method to remove silence.
 
Methods inherited from class marf.Storage.StorageManager
dump, dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, dumpXML, 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

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.Preprocessing 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
See Also:
preprocess(), MARF, HighFrequencyBoost, HighPassFilter
Method Detail

preprocess

public abstract boolean preprocess()
                            throws PreprocessingException
Derivatives must implement this method to do general preprocessing and perhaps calling removeNoise() and removeSilence().

Returns:
boolean that sample has changed as a result of preprocessing
Throws:
PreprocessingException - if an error occurred while preprocessing
See Also:
removeNoise(), removeSilence()

removeNoise

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

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.

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).

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).

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.

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.

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.

Returns:
Sample object

backSynchronizeObject

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

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

getRevision

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

Returns:
revision string
Since:
0.3.0