Class SpeexAudioFileReader


  • public class SpeexAudioFileReader
    extends javax.sound.sampled.spi.AudioFileReader
    Provider for Speex audio file reading services. This implementation can parse the format information from Speex audio file, and can produce audio input streams from files of this type.
    Version:
    $Revision: 1.2 $
    Author:
    Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int OGG_HEADERSIZE  
      static java.lang.String OGGID
      The String that identifies the beginning of an Ogg packet.
      static int SEGOFFSET  
      static int SPEEX_HEADERSIZE
      The size of the Speex header.
      static java.lang.String SPEEXID
      The String that identifies the beginning of the Speex header.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.File file)
      Obtains the audio file format of the File provided.
      javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.InputStream stream)
      Obtains an audio input stream from the input stream provided.
      protected javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.InputStream stream, int medialength)
      Return the AudioFileFormat from the given InputStream.
      protected javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.InputStream bitStream, java.io.ByteArrayOutputStream baos, int mediaLength)
      Return the AudioFileFormat from the given InputStream.
      javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.net.URL url)
      Obtains an audio input stream from the URL provided.
      javax.sound.sampled.AudioInputStream getAudioInputStream​(java.io.File file)
      Obtains an audio input stream from the File provided.
      javax.sound.sampled.AudioInputStream getAudioInputStream​(java.io.InputStream stream)
      Obtains an audio input stream from the input stream provided.
      protected javax.sound.sampled.AudioInputStream getAudioInputStream​(java.io.InputStream inputStream, int medialength)
      Obtains an audio input stream from the input stream provided.
      javax.sound.sampled.AudioInputStream getAudioInputStream​(java.net.URL url)
      Obtains an audio input stream from the URL provided.
      private static int readInt​(byte[] data, int offset)
      Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SPEEX_HEADERSIZE

        public static final int SPEEX_HEADERSIZE
        The size of the Speex header.
        See Also:
        Constant Field Values
      • OGGID

        public static final java.lang.String OGGID
        The String that identifies the beginning of an Ogg packet.
        See Also:
        Constant Field Values
      • SPEEXID

        public static final java.lang.String SPEEXID
        The String that identifies the beginning of the Speex header.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SpeexAudioFileReader

        public SpeexAudioFileReader()
    • Method Detail

      • getAudioFileFormat

        public javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.File file)
                                                               throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                      java.io.IOException
        Obtains the audio file format of the File provided. The File must point to valid audio file data.
        Specified by:
        getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
        Parameters:
        file - the File from which file format information should be extracted.
        Returns:
        an AudioFileFormat object describing the audio file format.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioFileFormat

        public javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.net.URL url)
                                                               throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                      java.io.IOException
        Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.
        Specified by:
        getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
        Parameters:
        url - the URL for which the AudioInputStream should be constructed.
        Returns:
        an AudioInputStream object based on the audio file data pointed to by the URL.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioFileFormat

        public javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.InputStream stream)
                                                               throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                      java.io.IOException
        Obtains an audio input stream from the input stream provided.
        Specified by:
        getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
        Parameters:
        stream - the input stream from which the AudioInputStream should be constructed.
        Returns:
        an AudioInputStream object based on the audio file data contained in the input stream.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioFileFormat

        protected javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.InputStream stream,
                                                                         int medialength)
                                                                  throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                         java.io.IOException
        Return the AudioFileFormat from the given InputStream.
        Parameters:
        stream - the input stream from which the AudioInputStream should be constructed.
        medialength -
        Returns:
        an AudioInputStream object based on the audio file data contained in the input stream.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioFileFormat

        protected javax.sound.sampled.AudioFileFormat getAudioFileFormat​(java.io.InputStream bitStream,
                                                                         java.io.ByteArrayOutputStream baos,
                                                                         int mediaLength)
                                                                  throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                         java.io.IOException
        Return the AudioFileFormat from the given InputStream. Implementation.
        Parameters:
        bitStream -
        baos -
        mediaLength -
        Returns:
        an AudioInputStream object based on the audio file data contained in the input stream.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioInputStream

        public javax.sound.sampled.AudioInputStream getAudioInputStream​(java.io.File file)
                                                                 throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                        java.io.IOException
        Obtains an audio input stream from the File provided. The File must point to valid audio file data.
        Specified by:
        getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
        Parameters:
        file - the File for which the AudioInputStream should be constructed.
        Returns:
        an AudioInputStream object based on the audio file data pointed to by the File.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioInputStream

        public javax.sound.sampled.AudioInputStream getAudioInputStream​(java.net.URL url)
                                                                 throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                        java.io.IOException
        Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.
        Specified by:
        getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
        Parameters:
        url - the URL for which the AudioInputStream should be constructed.
        Returns:
        an AudioInputStream object based on the audio file data pointed to by the URL.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioInputStream

        public javax.sound.sampled.AudioInputStream getAudioInputStream​(java.io.InputStream stream)
                                                                 throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                        java.io.IOException
        Obtains an audio input stream from the input stream provided. The stream must point to valid audio file data.
        Specified by:
        getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
        Parameters:
        stream - the input stream from which the AudioInputStream should be constructed.
        Returns:
        an AudioInputStream object based on the audio file data contained in the input stream.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • getAudioInputStream

        protected javax.sound.sampled.AudioInputStream getAudioInputStream​(java.io.InputStream inputStream,
                                                                           int medialength)
                                                                    throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                           java.io.IOException
        Obtains an audio input stream from the input stream provided. The stream must point to valid audio file data.
        Parameters:
        inputStream - the input stream from which the AudioInputStream should be constructed.
        medialength -
        Returns:
        an AudioInputStream object based on the audio file data contained in the input stream.
        Throws:
        javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
        java.io.IOException - if an I/O exception occurs.
      • readInt

        private static int readInt​(byte[] data,
                                   int offset)
        Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).
        Parameters:
        data - the data to read.
        offset - the offset from which to start reading.
        Returns:
        the integer value of the reassembled bytes.