Package nzilbb.media.wav
Class TruncatingAudioInputStream
- java.lang.Object
-
- java.io.InputStream
-
- javax.sound.sampled.AudioInputStream
-
- nzilbb.media.wav.TruncatingAudioInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class TruncatingAudioInputStream extends AudioInputStream
Input stream that truncates another input stream - i.e. read operations only return data between the given start time and end time.- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Constructor Summary
Constructors Constructor Description TruncatingAudioInputStream(AudioInputStream audioInputStream, double dStart, double dEnd)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()doublegetEndSeconds()EndSeconds accessorlonggetFrameLength()Obtains the length of the audio data contained in the file, expressed in sample frames.AudioInputStreamgetInputStream()InputStream accessordoublegetStartSeconds()StartSeconds accessorvoidmark(int nReadLimit)booleanmarkSupported()intread()intread(byte[] abData, int nOffset, int nLength)voidreset()TruncatingAudioInputStreamsetEndSeconds(double dNewEndSeconds)EndSeconds mutatorTruncatingAudioInputStreamsetInputStream(AudioInputStream isNewInputStream)InputStream mutatorTruncatingAudioInputStreamsetStartSeconds(double dNewStartSeconds)StartSeconds mutatorlongskip(long lLength)-
Methods inherited from class javax.sound.sampled.AudioInputStream
getFormat, read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
TruncatingAudioInputStream
public TruncatingAudioInputStream(AudioInputStream audioInputStream, double dStart, double dEnd) throws IOException
Constructor- Throws:
IOException
-
-
Method Detail
-
getInputStream
public AudioInputStream getInputStream()
InputStream accessor- Returns:
- The input stream that this is to truncate
-
setInputStream
public TruncatingAudioInputStream setInputStream(AudioInputStream isNewInputStream)
InputStream mutator- Parameters:
isNewInputStream- The input stream that this is to truncate
-
getStartSeconds
public double getStartSeconds()
StartSeconds accessor- Returns:
- Start time in seconds
-
setStartSeconds
public TruncatingAudioInputStream setStartSeconds(double dNewStartSeconds) throws IOException
StartSeconds mutator- Parameters:
dNewStartSeconds- Start time in seconds- Throws:
IOException
-
getEndSeconds
public double getEndSeconds()
EndSeconds accessor- Returns:
- End time in seconds Can be 0 to indicate the end of the stream.
-
setEndSeconds
public TruncatingAudioInputStream setEndSeconds(double dNewEndSeconds)
EndSeconds mutator- Parameters:
dNewEndSeconds- End time in seconds. Can be 0 to indicate the end of the stream.
-
read
public int read() throws IOException- Overrides:
readin classAudioInputStream- Throws:
IOException
-
read
public int read(byte[] abData, int nOffset, int nLength) 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 IOException- Overrides:
skipin classAudioInputStream- Throws:
IOException
-
available
public int available() throws IOException- Overrides:
availablein classAudioInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAudioInputStream- Throws:
IOException
-
mark
public void mark(int nReadLimit)
- Overrides:
markin classAudioInputStream
-
reset
public void reset() throws IOException- Overrides:
resetin classAudioInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classAudioInputStream
-
-