org.qtunes.replaygain
Class Normalizer

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

public class Normalizer
extends java.lang.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(java.io.File file)
          Start an analysis on the specified file, which will add the GainAnalysis to the database when it completes.
 GainAnalysis getGain(java.io.File file)
          Get the GainAnalysis for the specified file.
 void remove(java.io.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(java.io.File file)
          Set the Database file.
 void setDebug(java.io.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(java.io.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 java.io.IOException
Save the Database of analyses to the database file set in setDatabase(java.io.File)

Throws:
java.io.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(java.io.File file)
Set the Database file. The file is assumed to be absolute


remove

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

Throws:
java.io.IOException

enqueue

public void enqueue(java.io.File file)
             throws java.io.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:
java.io.IOException

getGain

public GainAnalysis getGain(java.io.File file)
                     throws java.io.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:
java.io.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 java.lang.InterruptedException
Shutdown the Normalizer. This must be called before the System will exit cleanly.

Throws:
java.lang.InterruptedException