Class AudioFrame

  • All Implemented Interfaces:
    MP3Frame

    public class AudioFrame
    extends java.lang.Object
    implements MP3Frame
    An Audio Frame in an MP3 file. These come after the ID3v2 tags in the file. Currently, only the header is processed, not the raw audio data.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int LAYER_1
      Constant for audio layer 1.
      static int LAYER_2
      Constant for audio layer 2.
      static int LAYER_3
      Constant for audio layer 3.
      static int MPEG_V1
      Constant for the MPEG version 1.
      static int MPEG_V2
      Constant for the MPEG version 2.
      static int MPEG_V2_5
      Constant for the MPEG version 2.5.
    • Constructor Summary

      Constructors 
      Constructor Description
      AudioFrame​(int mpegVersion, int layer, int bitRate, int sampleRate, int channels, int length, float duration)
      Creates a new instance of AudioFrame and initializes all properties.
      AudioFrame​(int h1, int h2, int h3, int h4, java.io.InputStream in)
      Deprecated.
      Use the constructor which is passed all values directly.
      AudioFrame​(java.io.InputStream stream, org.xml.sax.ContentHandler handler)
      Deprecated.
      Use the constructor which is passed all values directly.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getBitRate()
      Get the bit rate in bit per second.
      int getChannels()
      Get the number of channels (1=mono, 2=stereo)
      float getDuration()
      Returns the duration in milliseconds.
      int getLayer()
      Get the audio layer code.
      int getLength()
      Returns the frame length in bytes.
      int getSampleRate()
      Get the sampling rate, in Hz
      java.lang.String getVersion()  
      int getVersionCode()
      Get the version code.
      static boolean isAudioHeader​(int h1, int h2, int h3, int h4)
      Does this appear to be a 4 byte audio frame header?
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AudioFrame

        @Deprecated
        public AudioFrame​(java.io.InputStream stream,
                          org.xml.sax.ContentHandler handler)
                   throws java.io.IOException,
                          org.xml.sax.SAXException,
                          TikaException
        Deprecated.
        Use the constructor which is passed all values directly.
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
        TikaException
      • AudioFrame

        @Deprecated
        public AudioFrame​(int h1,
                          int h2,
                          int h3,
                          int h4,
                          java.io.InputStream in)
                   throws java.io.IOException
        Deprecated.
        Use the constructor which is passed all values directly.
        Throws:
        java.io.IOException
      • AudioFrame

        public AudioFrame​(int mpegVersion,
                          int layer,
                          int bitRate,
                          int sampleRate,
                          int channels,
                          int length,
                          float duration)
        Creates a new instance of AudioFrame and initializes all properties.
        Parameters:
        mpegVersion - the code for the MPEG version
        layer - the code for the layer
        bitRate - the bit rate (in bps)
        sampleRate - the sample rate (in samples per second)
        channels - the number of channels
        length - the frame length (in bytes)
        duration - the duration of this frame (in milliseconds)
    • Method Detail

      • getVersion

        public java.lang.String getVersion()
      • getSampleRate

        public int getSampleRate()
        Get the sampling rate, in Hz
      • getChannels

        public int getChannels()
        Get the number of channels (1=mono, 2=stereo)
      • getVersionCode

        public int getVersionCode()
        Get the version code.
        Returns:
        the version code (one of the MPEG constants)
      • getLayer

        public int getLayer()
        Get the audio layer code.
        Returns:
        the audio layer (one of the LAYER constants)
      • getBitRate

        public int getBitRate()
        Get the bit rate in bit per second.
        Returns:
        the bit rate
      • getLength

        public int getLength()
        Returns the frame length in bytes.
        Returns:
        the frame length
      • getDuration

        public float getDuration()
        Returns the duration in milliseconds.
        Returns:
        the duration
      • isAudioHeader

        public static boolean isAudioHeader​(int h1,
                                            int h2,
                                            int h3,
                                            int h4)
        Does this appear to be a 4 byte audio frame header?