Class MP3SequenceOverlay

  • All Implemented Interfaces:
    AudioOverlay
    Direct Known Subclasses:
    MP3ShuffleOverlay

    public class MP3SequenceOverlay
    extends java.lang.Object
    implements AudioOverlay
    This class returns the data bytes of an MP3 file in order.
    Author:
    Richard Rudek
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int currentPosition
      The current data bytes position according to the dataByteOrder
      protected java.util.List<java.lang.Integer> dataByteOrder
      The (modified) order of data bytes
      protected byte[] mp3Bytes
      The byte array containing the mp3 file
    • Constructor Summary

      Constructors 
      Constructor Description
      MP3SequenceOverlay​(byte[] bytes, long seed)
      Adds a sequence overlay to a given byte array containing an MP3 file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Returns the number of bytes that are available to modify and have not been returned by next().
      protected void createOverlay​(long seed)
      A hook method that is responsible for creating the dataByteOrder.
      byte[] getBytes()
      Returns the byte array this object holds.
      byte next()
      Returns the next modifiable byte.
      void setByte​(byte value)
      Sets the current byte to the given value.
      • Methods inherited from class java.lang.Object

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

      • mp3Bytes

        protected byte[] mp3Bytes
        The byte array containing the mp3 file
      • dataByteOrder

        protected java.util.List<java.lang.Integer> dataByteOrder
        The (modified) order of data bytes
      • currentPosition

        protected int currentPosition
        The current data bytes position according to the dataByteOrder
    • Constructor Detail

      • MP3SequenceOverlay

        public MP3SequenceOverlay​(byte[] bytes,
                                  long seed)
                           throws AudioNotFoundException
        Adds a sequence overlay to a given byte array containing an MP3 file. This overlay retrieves only the data bytes of the MP3 file and returns them in order.
        Parameters:
        bytes - byte array containing an MP3 file
        seed - would normally be used to influence the overlay (e.g. shuffling). Obviously, this cannot be used in the a sequence overlay.
        Throws:
        AudioNotFoundException - if the given byte array is null or does not contain an MP3 file
    • Method Detail

      • createOverlay

        protected void createOverlay​(long seed)
        A hook method that is responsible for creating the dataByteOrder.
        Parameters:
        seed - the seed that influences the dataByteOrder
      • next

        public byte next()
                  throws java.util.NoSuchElementException
        Description copied from interface: AudioOverlay
        Returns the next modifiable byte.
        Specified by:
        next in interface AudioOverlay
        Returns:
        byte - the next modifiable byte
        Throws:
        java.util.NoSuchElementException - if there are no more modifiable bytes
      • available

        public int available()
        Description copied from interface: AudioOverlay
        Returns the number of bytes that are available to modify and have not been returned by next().
        Specified by:
        available in interface AudioOverlay
        Returns:
        number of available bytes
      • setByte

        public void setByte​(byte value)
                     throws java.util.NoSuchElementException
        Description copied from interface: AudioOverlay
        Sets the current byte to the given value.
        Specified by:
        setByte in interface AudioOverlay
        Parameters:
        value - the value to set the current byte to
        Throws:
        java.util.NoSuchElementException - if setByte() is called before the first call to next(), or if setByte() is called after a call to next() produced a NoSuchElementException
      • getBytes

        public byte[] getBytes()
        Description copied from interface: AudioOverlay
        Returns the byte array this object holds.
        Specified by:
        getBytes in interface AudioOverlay
        Returns:
        byte array held by this object