Class WavRiffHandler

  • All Implemented Interfaces:
    RiffHandler

    public class WavRiffHandler
    extends java.lang.Object
    implements RiffHandler
    Implementation of RiffHandler specialising in Wav support. Extracts data from chunk/list types:
    • "INFO": artist, title, product, track number, date created, genre, comments, copyright, software, duration
    • "fmt ": format, channels, samples/second, bytes/second, block alignment, bits/sample
    • "data": duration
    Sources: http://www.neurophys.wisc.edu/auditory/riff-format.txt http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html http://wiki.audacityteam.org/wiki/WAV
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addError​(java.lang.String message)
      Registers an error message for consumption after extraction.
      void processChunk​(java.lang.String fourCC, byte[] payload)
      Perform whatever processing is necessary for the type of chunk with its payload.
      boolean shouldAcceptChunk​(java.lang.String fourCC)
      Gets whether this handler is interested in the specific chunk type.
      boolean shouldAcceptList​(java.lang.String fourCC)
      Gets whether this handler is interested in the specific list type.
      boolean shouldAcceptRiffIdentifier​(java.lang.String identifier)
      Gets whether the specified RIFF identifier is of interest to this handler.
      • Methods inherited from class java.lang.Object

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

      • _currentList

        private java.lang.String _currentList
    • Constructor Detail

      • WavRiffHandler

        public WavRiffHandler​(Metadata metadata)
    • Method Detail

      • shouldAcceptRiffIdentifier

        public boolean shouldAcceptRiffIdentifier​(java.lang.String identifier)
        Description copied from interface: RiffHandler
        Gets whether the specified RIFF identifier is of interest to this handler. Returning false causes processing to stop after reading only the first twelve bytes of data.
        Specified by:
        shouldAcceptRiffIdentifier in interface RiffHandler
        Parameters:
        identifier - The four character code identifying the type of RIFF data
        Returns:
        true if processing should continue, otherwise false
      • shouldAcceptChunk

        public boolean shouldAcceptChunk​(java.lang.String fourCC)
        Description copied from interface: RiffHandler
        Gets whether this handler is interested in the specific chunk type. Returns true if the data should be copied into an array and passed to RiffHandler.processChunk(String, byte[]), or false to avoid the copy and skip to the next chunk in the file, if any.
        Specified by:
        shouldAcceptChunk in interface RiffHandler
        Parameters:
        fourCC - the four character code of this chunk
        Returns:
        true if RiffHandler.processChunk(String, byte[]) should be called, otherwise false
      • shouldAcceptList

        public boolean shouldAcceptList​(java.lang.String fourCC)
        Description copied from interface: RiffHandler
        Gets whether this handler is interested in the specific list type. Returns true if the chunks should continue being processed, or false to avoid any unknown chunks within the list.
        Specified by:
        shouldAcceptList in interface RiffHandler
        Parameters:
        fourCC - the four character code of this chunk
        Returns:
        true if RiffHandler.processChunk(String, byte[]) should be called, otherwise false
      • processChunk

        public void processChunk​(java.lang.String fourCC,
                                 byte[] payload)
        Description copied from interface: RiffHandler
        Perform whatever processing is necessary for the type of chunk with its payload. This is only called if a previous call to RiffHandler.shouldAcceptChunk(String) with the same fourCC returned true.
        Specified by:
        processChunk in interface RiffHandler
        Parameters:
        fourCC - the four character code of the chunk
        payload - they payload of the chunk as a byte array
      • addError

        public void addError​(java.lang.String message)
        Description copied from interface: RiffHandler
        Registers an error message for consumption after extraction.
        Specified by:
        addError in interface RiffHandler
        Parameters:
        message - the error message