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 int
available()
void
close()
double
getEndSeconds()
EndSeconds accessorlong
getFrameLength()
Obtains the length of the audio data contained in the file, expressed in sample frames.AudioInputStream
getInputStream()
InputStream accessordouble
getStartSeconds()
StartSeconds accessorvoid
mark(int nReadLimit)
boolean
markSupported()
int
read()
int
read(byte[] abData, int nOffset, int nLength)
void
reset()
TruncatingAudioInputStream
setEndSeconds(double dNewEndSeconds)
EndSeconds mutatorTruncatingAudioInputStream
setInputStream(AudioInputStream isNewInputStream)
InputStream mutatorTruncatingAudioInputStream
setStartSeconds(double dNewStartSeconds)
StartSeconds mutatorlong
skip(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:
read
in classAudioInputStream
- Throws:
IOException
-
read
public int read(byte[] abData, int nOffset, int nLength) throws IOException
- Overrides:
read
in classAudioInputStream
- Throws:
IOException
-
getFrameLength
public long getFrameLength()
Obtains the length of the audio data contained in the file, expressed in sample frames.- Overrides:
getFrameLength
in classAudioInputStream
- Returns:
- the number of sample frames of audio data in the file
-
skip
public long skip(long lLength) throws IOException
- Overrides:
skip
in classAudioInputStream
- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
available
in classAudioInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classAudioInputStream
- Throws:
IOException
-
mark
public void mark(int nReadLimit)
- Overrides:
mark
in classAudioInputStream
-
reset
public void reset() throws IOException
- Overrides:
reset
in classAudioInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classAudioInputStream
-
-