Package be.tarsos.dsp.io.jvm
Class JVMAudioInputStream
java.lang.Object
be.tarsos.dsp.io.jvm.JVMAudioInputStream
- All Implemented Interfaces:
TarsosDSPAudioInputStream
public class JVMAudioInputStream extends java.lang.Object implements TarsosDSPAudioInputStream
Encapsulates an
AudioInputStream
to make it work with the core TarsosDSP library.- Author:
- Joren Six
-
Constructor Summary
Constructors Constructor Description JVMAudioInputStream(javax.sound.sampled.AudioInputStream stream)
-
Method Summary
Modifier and Type Method Description void
close()
Closes this audio input stream and releases any system resources associated with the stream.TarsosDSPAudioFormat
getFormat()
long
getFrameLength()
int
read(byte[] b, int off, int len)
Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.long
skip(long bytesToSkip)
Skip a number of bytes before reading the remaining bytes.static javax.sound.sampled.AudioFormat
toAudioFormat(TarsosDSPAudioFormat format)
Converts aTarsosDSPAudioFormat
to aAudioFormat
.static TarsosDSPAudioFormat
toTarsosDSPFormat(javax.sound.sampled.AudioFormat format)
Converts aAudioFormat
to aTarsosDSPAudioFormat
.
-
Constructor Details
-
JVMAudioInputStream
public JVMAudioInputStream(javax.sound.sampled.AudioInputStream stream)
-
-
Method Details
-
skip
public long skip(long bytesToSkip) throws java.io.IOExceptionDescription copied from interface:TarsosDSPAudioInputStream
Skip a number of bytes before reading the remaining bytes.- Specified by:
skip
in interfaceTarsosDSPAudioInputStream
- Parameters:
bytesToSkip
- The number of bytes to skip.- Returns:
- The number of bytes skipped.
- Throws:
java.io.IOException
- If the underlying if an input or output error occurs #see read
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionDescription copied from interface:TarsosDSPAudioInputStream
Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.This method will always read an integral number of frames. If
len
does not specify an integral number of frames, a maximum oflen - (len % frameSize)
bytes will be read.- Specified by:
read
in interfaceTarsosDSPAudioInputStream
- Parameters:
b
- the buffer into which the data is readoff
- the offset, from the beginning of arrayb
, at which the data will be writtenlen
- the maximum number of bytes to read- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
- Throws:
java.io.IOException
- if an input or output error occurs- See Also:
TarsosDSPAudioInputStream.skip(long)
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:TarsosDSPAudioInputStream
Closes this audio input stream and releases any system resources associated with the stream.- Specified by:
close
in interfaceTarsosDSPAudioInputStream
- Throws:
java.io.IOException
- if an input or output error occurs
-
getFrameLength
public long getFrameLength()- Specified by:
getFrameLength
in interfaceTarsosDSPAudioInputStream
-
getFormat
- Specified by:
getFormat
in interfaceTarsosDSPAudioInputStream
- Returns:
- The format of the underlying audio
-
toTarsosDSPFormat
Converts aAudioFormat
to aTarsosDSPAudioFormat
.- Parameters:
format
- TheAudioFormat
- Returns:
- A
TarsosDSPAudioFormat
-
toAudioFormat
Converts aTarsosDSPAudioFormat
to aAudioFormat
.- Parameters:
format
- TheTarsosDSPAudioFormat
- Returns:
- A
AudioFormat
-