entagged.audioformats
Class AudioFile

java.lang.Object
  extended byjava.io.File
      extended byentagged.audioformats.AudioFile
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class AudioFile
extends java.io.File

This is the main object manipulated by the user representing an audiofile, its properties and its tag.

The prefered way to obtain an AudioFile is to use the AudioFileIO.read(File) method.

The AudioFile contains every properties associated with the file itself (no meta-data), like the bitrate, the sampling rate, the encoding infos, etc.

To get the meta-data contained in this file you have to get the Tag of this AudioFile

Since:
v0.01
Version:
$Id: AudioFile.html,v 1.2 2005/09/14 19:30:31 kikidonk Exp $
Author:
Raphael Slinckx
See Also:
AudioFileIO, Tag, Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
AudioFile(java.io.File f, EncodingInfo info)
          These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.
AudioFile(java.io.File f, EncodingInfo info, Tag tag)
          These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.
AudioFile(java.lang.String s, EncodingInfo info)
          These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.
AudioFile(java.lang.String s, EncodingInfo info, Tag tag)
          These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.
 
Method Summary
 void commit()
          Write the tag contained in this AudioFile in the actual file on the disk, this is the same as calling the AudioFileIO.write(this) method.
 int getBitrate()
          Returns the bitrate of this AufioFile in kilobytes per second (KB/s).
 int getChannelNumber()
          Returns the number of audio channels contained in this AudioFile, 2 for example means stereo
 java.lang.String getEncodingType()
          Returns the encoding type of this AudioFile, this needs to be precisely specified in the future
 java.lang.String getExtraEncodingInfos()
          Returns the extra encoding infos of this AudioFile, this needs to be precisely specified in the future
 int getLength()
          Returns the length (duration) in seconds (s) of this AudioFile.Example: 241 seconds
 float getPreciseLength()
          Returns the length (duration) in seconds with fractions.
 int getSamplingRate()
          Returns the sampling rate of this AudioFile in Hertz (Hz).
 Tag getTag()
          Returns the tag contained in this AudioFile, the Tag contains any useful meta-data, like artist, album, title, etc.
 boolean isVbr()
          Checks if this file is a VBR (variable bitrate) or a Constant Bitrate one True means VBR, false means CBR This has only meaning with MP3 and MPC files, other formats are always VBR since it offers a better compression ratio (and lossless compression is by nature VBR
 java.lang.String toString()
          Returns a multi-line string with the file path, the encoding informations, and the tag contents.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AudioFile

public AudioFile(java.io.File f,
                 EncodingInfo info)

These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.

Create the AudioFile representing file f, the encodinginfos and containing an empty tag

Parameters:
f - The file of the audiofile
info - the encoding infos over this file

AudioFile

public AudioFile(java.io.File f,
                 EncodingInfo info,
                 Tag tag)

These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.

Create the AudioFile representing file f, the encodinginfos and containing the tag

Parameters:
f - The file of the audiofile
info - the encoding infos over this file
tag - the tag contained in this file

AudioFile

public AudioFile(java.lang.String s,
                 EncodingInfo info)

These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.

Create the AudioFile representing file denoted by pathname s, the encodinginfos and containing an empty tag

Parameters:
s - The pathname of the audiofile
info - the encoding infos over this file

AudioFile

public AudioFile(java.lang.String s,
                 EncodingInfo info,
                 Tag tag)

These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File) method instead !.

Create the AudioFile representing file denoted by pathname s, the encodinginfos and containing the tag

Parameters:
s - The pathname of the audiofile
info - the encoding infos over this file
tag - the tag contained in this file
Method Detail

commit

public void commit()
            throws entagged.audioformats.exceptions.CannotWriteException

Write the tag contained in this AudioFile in the actual file on the disk, this is the same as calling the AudioFileIO.write(this) method.

Throws:
entagged.audioformats.exceptions.CannotWriteException - If the file could not be written/accessed, the extension wasn't recognized, or other IO error occured.
See Also:
AudioFileIO

getBitrate

public int getBitrate()

Returns the bitrate of this AufioFile in kilobytes per second (KB/s). Example: 192 KB/s

Returns:
Returns the bitrate of this AufioFile

getChannelNumber

public int getChannelNumber()

Returns the number of audio channels contained in this AudioFile, 2 for example means stereo

Returns:
Returns the number of audio channels contained in this AudioFile

getEncodingType

public java.lang.String getEncodingType()

Returns the encoding type of this AudioFile, this needs to be precisely specified in the future

Returns:
Returns the encoding type of this AudioFile
TO DO:
This method needs to be fully specified

getExtraEncodingInfos

public java.lang.String getExtraEncodingInfos()

Returns the extra encoding infos of this AudioFile, this needs to be precisely specified in the future

Returns:
Returns the extra encoding infos of this AudioFile
TO DO:
This method needs to be fully specified

getLength

public int getLength()

Returns the length (duration) in seconds (s) of this AudioFile.Example: 241 seconds

Returns:
Returns the length (duration) of this AudioFile

getPreciseLength

public float getPreciseLength()
Returns the length (duration) in seconds with fractions.

Returns:
The duration in seconds.

getSamplingRate

public int getSamplingRate()

Returns the sampling rate of this AudioFile in Hertz (Hz). Example: 44100 Hz for most of the audio files

Returns:
Returns the sampling rate of this AudioFile

getTag

public Tag getTag()

Returns the tag contained in this AudioFile, the Tag contains any useful meta-data, like artist, album, title, etc.

If the file does not contain any tag, a new empty tag is returned

Returns:
Returns the tag contained in this AudioFile, or a new one if file hasn't any tag.

isVbr

public boolean isVbr()

Checks if this file is a VBR (variable bitrate) or a Constant Bitrate one

True means VBR, false means CBR

This has only meaning with MP3 and MPC files, other formats are always VBR since it offers a better compression ratio (and lossless compression is by nature VBR


toString

public java.lang.String toString()

Returns a multi-line string with the file path, the encoding informations, and the tag contents.

Returns:
A multi-line string with the file path, the encoding informations, and the tag contents.
TO DO:
Maybe this can be changed ?