Class SingleChannelAudioInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class SingleChannelAudioInputStream
    extends AudioInputStream
    Input stream that extracts a single selected channel from another input stream - i.e. read operations only return data for one stream (e.g. left channel only of a stereo recording).
    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • SingleChannelAudioInputStream

        public SingleChannelAudioInputStream​(AudioInputStream audioInputStream,
                                             int channel)
                                      throws IOException
        Constructor.
        Parameters:
        channel - Which channel to pass through, e.g. 0 for left, 1 for right.
        Throws:
        IOException
    • Method Detail

      • getInputStream

        public AudioInputStream getInputStream()
        InputStream accessor
        Returns:
        The input stream that this is to truncate
      • getChannel

        public int getChannel()
        Getter for channel: Which channel to pass through, e.g. 0 for left, 1 for right.
        Returns:
        Which channel to pass through, e.g. 0 for left, 1 for right.
      • setChannel

        public SingleChannelAudioInputStream setChannel​(int newChannel)
        Setter for channel: Which channel to pass through, e.g. 0 for left, 1 for right.
        Parameters:
        newChannel - Which channel to pass through, e.g. 0 for left, 1 for right.
      • getFrameLength

        public long getFrameLength()
        Obtains the length of the audio data contained in the file, expressed in sample frames.
        Overrides:
        getFrameLength in class AudioInputStream
        Returns:
        the number of sample frames of audio data in the file
      • available

        public int available()
                      throws IOException
        Returns the maximum number of bytes that can be read (or skipped over) from this audio input stream without blocking.
        Overrides:
        available in class AudioInputStream
        Throws:
        IOException
      • mark

        public void mark​(int nReadLimit)
        Marks the current position in this audio input stream.
        Overrides:
        mark in class AudioInputStream
      • reset

        public void reset()
                   throws IOException
        Repositions this audio input stream to the position it had at the time its mark method was last invoked.
        Overrides:
        reset in class AudioInputStream
        Throws:
        IOException
      • markSupported

        public boolean markSupported()
        Tests whether this audio input stream supports the mark and reset methods.
        Overrides:
        markSupported in class AudioInputStream