jAudioFeatureExtractor
Class ExtractionThread

java.lang.Object
  extended by java.lang.Thread
      extended by jAudioFeatureExtractor.ExtractionThread
All Implemented Interfaces:
Updater, java.lang.Runnable

public class ExtractionThread
extends java.lang.Thread
implements Updater

This is a thread for executing the DataModel.extractFeatures without tying up the swing dispatch thread.

Author:
Daniel McEnnis

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ExtractionThread(Controller c, OuterFrame of)
          This constructor constructs the thread, partially preparing it for execution
 
Method Summary
 void announceUpdate(int fileDone)
          This is part of the Updater interface.
 void announceUpdate(int fileNumber, int fileDone)
          This is part of the Updater interface.
 boolean hasRun()
          Used to prevent this thread from executing twice.
 void run()
          Execute the thread, suspending the main frame, extracting the features, then enabling the main frame.
 void setFileLength(int window)
          This is part of the Updater interface.
 void setNumberOfFiles(int files)
          This is part of the Updater interface.
 void setup(boolean perFile, boolean perWindow, java.lang.String valuesSavePath, java.lang.String definitionSavePath, int windowSize, double windowOverlap)
          This is the method to finish preparing the thread for execution
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtractionThread

public ExtractionThread(Controller c,
                        OuterFrame of)
This constructor constructs the thread, partially preparing it for execution

Parameters:
c - Near global container for numerous controller and model objects
of - Link to outerframe of the gui. Used to disable the main frame to prevent race conditions in the feature settings.
Method Detail

setup

public void setup(boolean perFile,
                  boolean perWindow,
                  java.lang.String valuesSavePath,
                  java.lang.String definitionSavePath,
                  int windowSize,
                  double windowOverlap)
This is the method to finish preparing the thread for execution

Parameters:
perFile - Should features be extracted over the entire file
perWindow - Should features be extracted on a window by window basis
valuesSavePath - File to save extracted features
definitionSavePath - File to save descriptions of the features extracted
windowSize - Size of the analysis window in samples
windowOverlap - Percent of the window that is duplicated between analysis windows

run

public void run()
Execute the thread, suspending the main frame, extracting the features, then enabling the main frame.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

announceUpdate

public void announceUpdate(int fileNumber,
                           int fileDone)
This is part of the Updater interface. It notifies the gui that a file has been completed.

Specified by:
announceUpdate in interface Updater
Parameters:
fileNumber - How many files are completed.
fileDone - Position in the file (usually 0).

announceUpdate

public void announceUpdate(int fileDone)
This is part of the Updater interface. It notifies the gui of an increase in the amount of the file processed.

Specified by:
announceUpdate in interface Updater
Parameters:
fileDone - Position in file.

setNumberOfFiles

public void setNumberOfFiles(int files)
This is part of the Updater interface. It is used to set the total number of files to be processed.

Specified by:
setNumberOfFiles in interface Updater
Parameters:
files - Number of files to be processed.

setFileLength

public void setFileLength(int window)
This is part of the Updater interface. It is used to notify the gui of the total size of the file (in windows of data).

Specified by:
setFileLength in interface Updater
Parameters:
window - Total number of windows of data to be processed.

hasRun

public boolean hasRun()
Used to prevent this thread from executing twice.

Returns:
whether or not this thread has run before