Package nzilbb.media.wav
Class SingleChannelAudioInputStream
- java.lang.Object
-
- java.io.InputStream
-
- javax.sound.sampled.AudioInputStream
-
- nzilbb.media.wav.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 Summary
Constructors Constructor Description SingleChannelAudioInputStream(AudioInputStream audioInputStream, int channel)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns the maximum number of bytes that can be read (or skipped over) from this audio input stream without blocking.voidclose()Closes this audio input stream and releases any system resources associated with the stream.intgetChannel()Getter forchannel: Which channel to pass through, e.g. 0 for left, 1 for right.longgetFrameLength()Obtains the length of the audio data contained in the file, expressed in sample frames.AudioInputStreamgetInputStream()InputStream accessorvoidmark(int nReadLimit)Marks the current position in this audio input stream.booleanmarkSupported()Tests whether this audio input stream supports the mark and reset methods.intread()intread(byte[] data, int offset, int length)voidreset()Repositions this audio input stream to the position it had at the time its mark method was last invoked.SingleChannelAudioInputStreamsetChannel(int newChannel)Setter forchannel: Which channel to pass through, e.g. 0 for left, 1 for right.SingleChannelAudioInputStreamsetInputStream(AudioInputStream newInputStream)InputStream mutatorlongskip(long lLength)Skips over and discards a specified number of bytes from this audio input stream.-
Methods inherited from class javax.sound.sampled.AudioInputStream
getFormat, read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
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
-
setInputStream
public SingleChannelAudioInputStream setInputStream(AudioInputStream newInputStream)
InputStream mutator- Parameters:
newInputStream- The input stream that this is to truncate
-
getChannel
public int getChannel()
Getter forchannel: 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 forchannel: 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.
-
read
public int read() throws IOException- Overrides:
readin classAudioInputStream- Throws:
IOException
-
read
public int read(byte[] data, int offset, int length) throws IOException- Overrides:
readin classAudioInputStream- Throws:
IOException
-
getFrameLength
public long getFrameLength()
Obtains the length of the audio data contained in the file, expressed in sample frames.- Overrides:
getFrameLengthin classAudioInputStream- Returns:
- the number of sample frames of audio data in the file
-
skip
public long skip(long lLength) throws IOExceptionSkips over and discards a specified number of bytes from this audio input stream.- Overrides:
skipin classAudioInputStream- Throws:
IOException
-
available
public int available() throws IOExceptionReturns the maximum number of bytes that can be read (or skipped over) from this audio input stream without blocking.- Overrides:
availablein classAudioInputStream- Throws:
IOException
-
close
public void close() throws IOExceptionCloses this audio input stream and releases any system resources associated with the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAudioInputStream- Throws:
IOException
-
mark
public void mark(int nReadLimit)
Marks the current position in this audio input stream.- Overrides:
markin classAudioInputStream
-
reset
public void reset() throws IOExceptionRepositions this audio input stream to the position it had at the time its mark method was last invoked.- Overrides:
resetin classAudioInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()
Tests whether this audio input stream supports the mark and reset methods.- Overrides:
markSupportedin classAudioInputStream
-
-