com.tuneology.avm
Class AudioConverter

java.lang.Object
  |
  +--com.tuneology.avm.AudioConverter

public class AudioConverter
extends java.lang.Object

Utilities for converting audio files to different types.

Conversion to the same format can be done to resample.

Here's what is currently supported:

From:
To:  |   WAV   MP3   OGG   WMA   AIFF  AU    AAC   FLAC
WAV       1     2     4     -     1     1     5     6
MP3       1     1    4/1    -     1     1    5/1   6/1
OGG       3    2/3    3     -     3     3    5/3   6/3
WMA       -     -     -     -     -     -     -     -
AIFF     6/6    2   4/6/6   -    6/6  1/6/6   5     6
AU        -     2     -     -     -     -     5     -
AAC       -     -     -     -     -     -     -     -
FLAC      6    2/6   4/6    -     6    1/6   5/6    -

1 = lame
2 = madplay
3 = oggenc
4 = oggdec
5 = faad
6 = flac

Version:
$Id: AudioConverter.java,v 1.16 2003/07/10 19:52:12 xnarf Exp $
Author:
Fran Taylor

Method Summary
static java.io.File convertFile(java.io.File dir, java.io.File src, FormatPrefs prefs, TocEntry finfo, ProgressListener pm, boolean isTemp, java.io.File tempDir)
          Converts a file from one format to another
static java.lang.Process convertStream(FormatPrefs iprefs, FormatPrefs oprefs, TocEntry finfo)
           
static void createSubdirs(java.lang.String path)
          Creates any necessary subdirectories for the path.
static java.lang.String fileTypeName(int n)
           
static int getFileFormat(java.io.File f)
          Returns the file type.
static java.lang.String getMadplayCmd()
           
static java.lang.String getVersions()
          Returns a string containing the versions of all the format conversion programs.
static java.io.File makeLocalCopy(java.io.File dir, java.io.File f, ProgressListener pm, boolean isTemp)
          Given a file, creates a new object representing a local version of the file, and copies the file from the remote store to the local file system.
static void setFaadCmd(java.lang.String cmd)
           
static void setFlacCmd(java.lang.String cmd)
           
static void setLameCmd(java.lang.String cmd)
           
static void setMadplayCmd(java.lang.String cmd)
           
static void setOggdecCmd(java.lang.String cmd)
           
static void setOggencCmd(java.lang.String cmd)
           
static long spaceRequired(TocEntry finfo, FormatPrefs prefs)
          returns the number of bytes of space required to store the specified file according to the specified preferences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getVersions

public static java.lang.String getVersions()
Returns a string containing the versions of all the format conversion programs.
Returns:
a string containing the versions of all the format conversion programs.

makeLocalCopy

public static java.io.File makeLocalCopy(java.io.File dir,
                                         java.io.File f,
                                         ProgressListener pm,
                                         boolean isTemp)
                                  throws java.io.IOException
Given a file, creates a new object representing a local version of the file, and copies the file from the remote store to the local file system.
Parameters:
dir - The directory in which to write the file.
f - The souce file.
pm - The GUI status indicator.
isTemp - If true, marks the file as tempoary (to be deleted on exit)
Throws:
java.io.IOException -  

getFileFormat

public static int getFileFormat(java.io.File f)
Returns the file type.
Parameters:
f - the file in question.
Returns:
the file type, or -1 if not known.

spaceRequired

public static long spaceRequired(TocEntry finfo,
                                 FormatPrefs prefs)
                          throws java.lang.Exception
returns the number of bytes of space required to store the specified file according to the specified preferences.
Parameters:
finfo -  
prefs -  
Returns:
the number of bytes required to store the data
Throws:
java.io.IOException - if the format parameters are invalid

convertStream

public static java.lang.Process convertStream(FormatPrefs iprefs,
                                              FormatPrefs oprefs,
                                              TocEntry finfo)
                                       throws java.io.IOException
Throws:
java.io.IOException -  

convertFile

public static java.io.File convertFile(java.io.File dir,
                                       java.io.File src,
                                       FormatPrefs prefs,
                                       TocEntry finfo,
                                       ProgressListener pm,
                                       boolean isTemp,
                                       java.io.File tempDir)
                                throws java.lang.Exception
Converts a file from one format to another
Parameters:
dir - The destination directory.
src - The source file.
prefs - The preferences for the destination file.
finfo - Meta-information to be written to the destination file.
pm - Callback for status updates.
isTemp - True if the destination file is a temp file.
tempDir - directory in which to write temp files, if needed.
Returns:
The created file.
Throws:
java.lang.Exception -  

createSubdirs

public static void createSubdirs(java.lang.String path)
                          throws java.io.IOException
Creates any necessary subdirectories for the path.
Parameters:
path - the path.
Throws:
java.io.IOException - if directories cannot be created.

getMadplayCmd

public static java.lang.String getMadplayCmd()

setMadplayCmd

public static void setMadplayCmd(java.lang.String cmd)
                          throws java.lang.Exception
Throws:
java.lang.Exception -  

setOggdecCmd

public static void setOggdecCmd(java.lang.String cmd)
                         throws java.lang.Exception
Throws:
java.lang.Exception -  

setOggencCmd

public static void setOggencCmd(java.lang.String cmd)
                         throws java.lang.Exception
Throws:
java.lang.Exception -  

setLameCmd

public static void setLameCmd(java.lang.String cmd)
                       throws java.lang.Exception
Throws:
java.lang.Exception -  

setFaadCmd

public static void setFaadCmd(java.lang.String cmd)
                       throws java.lang.Exception
Throws:
java.lang.Exception -  

setFlacCmd

public static void setFlacCmd(java.lang.String cmd)
                       throws java.lang.Exception
Throws:
java.lang.Exception -  

fileTypeName

public static java.lang.String fileTypeName(int n)
                                     throws java.util.NoSuchElementException