com.groovemanager.sampled.providers
Class WavFileReader

java.lang.Object
  extended by javax.sound.sampled.spi.AudioFileReader
      extended by com.groovemanager.sampled.providers.WavFileReader

public class WavFileReader
extends javax.sound.sampled.spi.AudioFileReader

A simple WavFileReader implementation for support of additional headers

Author:
Manu Robledo

Field Summary
protected static java.lang.String[] supportedChunks
          supported chunk IDs of additional chunks
 
Constructor Summary
WavFileReader()
           
 
Method Summary
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File file)
           
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream)
           
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.net.URL url)
           
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
           
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream stream)
           
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.net.URL url)
           
protected static java.util.Map processChunk(java.io.InputStream stream, java.lang.String chunkName, int length)
          Process a chunk and get the properties known out of it, if any
protected static javax.sound.sampled.AudioFormat readFormatHeader(java.io.InputStream in)
          Get the AudioFormat out of the given InputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supportedChunks

protected static java.lang.String[] supportedChunks
supported chunk IDs of additional chunks

Constructor Detail

WavFileReader

public WavFileReader()
Method Detail

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File file)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
Specified by:
getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
Specified by:
getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioFileFormat(java.io.InputStream)

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.net.URL url)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
Specified by:
getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Specified by:
getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioInputStream(java.io.File)

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream stream)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Specified by:
getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.net.URL url)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Specified by:
getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioInputStream(java.net.URL)

processChunk

protected static java.util.Map processChunk(java.io.InputStream stream,
                                            java.lang.String chunkName,
                                            int length)
                                     throws java.io.IOException
Process a chunk and get the properties known out of it, if any

Parameters:
stream - The InputStream to read from
chunkName - The chunk ID
length - The chunk length
Returns:
A Map of properties found in the given chunk
Throws:
java.io.IOException - If an I/O Error occured during reading

readFormatHeader

protected static javax.sound.sampled.AudioFormat readFormatHeader(java.io.InputStream in)
                                                           throws java.io.IOException,
                                                                  javax.sound.sampled.UnsupportedAudioFileException
Get the AudioFormat out of the given InputStream

Parameters:
in - The InputStream to read from. The next 16 bytes should be the data of the fmt-chunk
Returns:
The AudioFormat of the file
Throws:
java.io.IOException - If an I/O Error occurs during reading
javax.sound.sampled.UnsupportedAudioFileException - If the format is invalid