* @return an APEAudioFileFormat object describing the MAC audio file format
* @throws UnsupportedAudioFileException - if the File does not point to valid MAC audio file
* @throws IOException - if an I/O exception occurs
*/
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
IAPEDecompress decoder = null;
davaguine.jmac.tools.File io = new RandomAccessFile(file, "r");
try {
decoder = IAPEDecompress.CreateIAPEDecompress(io);
} catch (JMACException e) {
throw new UnsupportedAudioFileException("Unsupported audio file");
} catch (EOFException e) {
throw new UnsupportedAudioFileException("Unsupported audio file");
} finally {
io.close();
}
Map fileProperties = new HashMap();
Map formatProperties = new HashMap();
APEPropertiesHelper.readProperties(decoder, fileProperties, formatProperties);
AudioFormat format = new APEAudioFormat(APEEncoding.APE, decoder.getApeInfoSampleRate(),
decoder.getApeInfoBitsPerSample(),
decoder.getApeInfoChannels(),
AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, false, formatProperties);
return new APEAudioFileFormat(APEAudioFileFormatType.APE, format, AudioSystem.NOT_SPECIFIED, (int) file.length(), fileProperties);
}