/* * ******************************************************************** ** * Copyright notice ** * ** ** * (c) 2003 Entagged Developpement Team ** * http://www.sourceforge.net/projects/entagged ** * ** ** * All rights reserved ** * ** ** * This script is part of the Entagged project. The Entagged ** * project is free software; you can redistribute it and/or modify ** * it under the terms of the GNU General Public License as published by ** * the Free Software Foundation; either version 2 of the License, or ** * (at your option) any later version. ** * ** ** * The GNU General Public License can be found at ** * http://www.gnu.org/copyleft/gpl.html. ** * ** ** * This copyright notice MUST APPEAR in all copies of the file! ** * ******************************************************************** */ package entagged.audioformats; import entagged.audioformats.exceptions.*; import entagged.audioformats.generic.GenericTag; import java.io.*; /** *
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
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
* *@param s The pathname of the audiofile *@param info the encoding infos over this file *@param tag the tag contained in this file */ public AudioFile(String s, EncodingInfo info, Tag tag) { super(s); this.info = info; this.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 an empty tag
* *@param s The pathname of the audiofile *@param info the encoding infos over this file */ public AudioFile(String s, EncodingInfo info) { super(s); this.info = info; this.tag = new GenericTag(); } /** *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
* *@param f The file of the audiofile *@param info the encoding infos over this file *@param tag the tag contained in this file */ public AudioFile(File f, EncodingInfo info, Tag tag) { super(f.getAbsolutePath()); this.info = info; this.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 an empty tag
* *@param f The file of the audiofile *@param info the encoding infos over this file */ public AudioFile(File f, EncodingInfo info) { super(f.getAbsolutePath()); this.info = info; this.tag = new GenericTag(); } /** *Returns the bitrate of this AufioFile in kilobytes per second (KB/s). Example: 192 KB/s
* *@return Returns the bitrate of this AufioFile */ public int getBitrate() { return info.getBitrate(); } /** *Returns the number of audio channels contained in this AudioFile, 2 for example means stereo
* *@return Returns the number of audio channels contained in this AudioFile */ public int getChannelNumber() { return info.getChannelNumber(); } /** *Returns the encoding type of this AudioFile, this needs to be precisely specified in the future
* *@return Returns the encoding type of this AudioFile *@todo This method needs to be fully specified */ public String getEncodingType() { return info.getEncodingType(); } /** *Returns the extra encoding infos of this AudioFile, this needs to be precisely specified in the future
* *@return Returns the extra encoding infos of this AudioFile *@todo This method needs to be fully specified */ public String getExtraEncodingInfos() { return info.getExtraEncodingInfos(); } /** *Returns the sampling rate of this AudioFile in Hertz (Hz). Example: 44100 Hz for most of the audio files
* *@return Returns the sampling rate of this AudioFile */ public int getSamplingRate() { return info.getSamplingRate(); } /** *Returns the length (duration) in seconds (s) of this AudioFile.Example: 241 seconds
* *@return Returns the length (duration) of this AudioFile */ public int getLength() { return info.getLength(); } /** *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
* *@return Returns the tag contained in this AudioFile, or a new one if file hasn't any tag. */ public Tag getTag() { return (tag == null) ? new GenericTag() : tag; } /* *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
*/ public boolean isVbr() { return info.isVbr(); } /** *Returns a multi-line string with the file path, the encoding informations, and the tag contents.
* *@return A multi-line string with the file path, the encoding informations, and the tag contents. *@todo Maybe this can be changed ? */ public String toString() { return "AudioFile "+getAbsolutePath()+" --------\n"+info.toString()+"\n"+ ( (tag == null) ? "" : tag.toString())+"\n-------------------"; } }