org.qtunes.replaygain
Class Normalizer

java.lang.Object
  extended by org.qtunes.replaygain.Normalizer

public class Normalizer
extends Object

A class which manages the ReplayGain normalization on a number of files. It stores the GainAnalysis to a database, queues new analyses to ensure they're not all run at once or repeated if we've already analysed a file.


Constructor Summary
Normalizer()
           
 
Method Summary
 void enqueue(File file)
          Start an analysis on the specified file, which will add the GainAnalysis to the database when it completes.
 GainAnalysis getGain(File file)
          Get the GainAnalysis for the specified file.
 void remove(File file)
          Remove the previously calculated analysus for file from the database
 void saveDatabase()
          Save the Database of analyses to the database file set in setDatabase(java.io.File)
 void setAutoSave(int seconds)
          Set how many seconds apart the database should be automatically saved
 void setDatabase(File file)
          Set the Database file.
 void setDebug(PrintStream out, boolean debug)
          Set the output stream for info/debug
 void shutdown()
          Shutdown the Normalizer.
 boolean waitForCompletion()
          Wait untli all pending tasks are completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Normalizer

public Normalizer()
Method Detail

setDebug

public void setDebug(PrintStream out,
                     boolean debug)
Set the output stream for info/debug

Parameters:
out - the PrintStream to write debug to
debug - whether to write debug or not

saveDatabase

public void saveDatabase()
                  throws IOException
Save the Database of analyses to the database file set in setDatabase(java.io.File)

Throws:
IOException

setAutoSave

public void setAutoSave(int seconds)
Set how many seconds apart the database should be automatically saved

Parameters:
seconds - the number of seconds between saves, or 0 to never save.

setDatabase

public void setDatabase(File file)
Set the Database file. The file is assumed to be absolute


remove

public void remove(File file)
            throws IOException
Remove the previously calculated analysus for file from the database

Throws:
IOException

enqueue

public void enqueue(File file)
             throws IOException
Start an analysis on the specified file, which will add the GainAnalysis to the database when it completes. If the file already exists in the database it's entry will be overwritten. If the file is a directory it's contents will be enqueued instead.

Throws:
IOException

getGain

public GainAnalysis getGain(File file)
                     throws IOException
Get the GainAnalysis for the specified file. If it doesn't yet exists, it will be run immediately (no queueing) and returned. If it can't be determined due to failure, return null.

Throws:
IOException

waitForCompletion

public boolean waitForCompletion()
Wait untli all pending tasks are completed.

Returns:
true if they're all done, false if we were interrupted or more were queued

shutdown

public void shutdown()
              throws InterruptedException
Shutdown the Normalizer. This must be called before the System will exit cleanly.

Throws:
InterruptedException