Class OggInputStream
java.lang.Object
de.pottgames.tuningfork.decoder.OggInputStream
- All Implemented Interfaces:
AudioStream, Closeable, AutoCloseable
An input stream to read Ogg Vorbis.
-
Constructor Summary
ConstructorsConstructorDescriptionOggInputStream(com.badlogic.gdx.files.FileHandle file, OggInputStream previousStream) Initializes aOggInputStreamfrom aFileHandleand an optionalOggInputStreamfor buffer reusage, the old stream shouldn't be used afterward.OggInputStream(InputStream stream) Initializes aOggInputStreamfrom anInputStream. -
Method Summary
Modifier and TypeMethodDescriptionbooleanatEnd()voidclose()intReturns the number of bits per sample, also known as the sample depth.intReturns the number of audio channels.floatReturns the duration in seconds or -1 if this information is not available.intGet the number of bytes on the streamReturns the output data format of this AudioStream.intReturns the sample rate.booleanisClosed()Returns true if the AudioStream is closed.intread()intread(byte[] b) Reads bytes from the stream until the given array is full or the stream ends.intread(byte[] b, int off, int len) reset()Resets the audio stream as if it was re-opened.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AudioStream
getBlockAlign, getBlockSize
-
Constructor Details
-
OggInputStream
Initializes aOggInputStreamfrom aFileHandleand an optionalOggInputStreamfor buffer reusage, the old stream shouldn't be used afterward.- Parameters:
file- the file handlepreviousStream- may be null
-
OggInputStream
Initializes aOggInputStreamfrom anInputStream. This stream does not support the reset and getDuration function. UseOggInputStream(FileHandle, OggInputStream)instead to get the full functionality.- Parameters:
stream- the input stream
-
-
Method Details
-
reset
Description copied from interface:AudioStreamResets the audio stream as if it was re-opened. Implementations are free to close themselves and provide a new AudioStream. The AudioStream returned by this function will be used, regardless of whether it is a new instance or the old one.- Specified by:
resetin interfaceAudioStream- Returns:
- an AudioStream
-
getDuration
public float getDuration()Description copied from interface:AudioStreamReturns the duration in seconds or -1 if this information is not available.- Specified by:
getDurationin interfaceAudioStream- Returns:
- duration in seconds or -1 if the information is not available
-
getLength
public int getLength()Get the number of bytes on the stream- Returns:
- The number of the bytes on the stream
-
getChannels
public int getChannels()Description copied from interface:AudioStreamReturns the number of audio channels.- Specified by:
getChannelsin interfaceAudioStream- Returns:
- number of channels
-
getSampleRate
public int getSampleRate()Description copied from interface:AudioStreamReturns the sample rate.- Specified by:
getSampleRatein interfaceAudioStream- Returns:
- the sample rate
-
getBitsPerSample
public int getBitsPerSample()Description copied from interface:AudioStreamReturns the number of bits per sample, also known as the sample depth.- Specified by:
getBitsPerSamplein interfaceAudioStream- Returns:
- the number of bits per sample
-
read
public int read() -
atEnd
public boolean atEnd() -
read
public int read(byte[] b, int off, int len) -
read
public int read(byte[] b) Description copied from interface:AudioStreamReads bytes from the stream until the given array is full or the stream ends. Returns the number of bytes that were actually read.- Specified by:
readin interfaceAudioStream- Parameters:
b- the byte array to store the bytes in- Returns:
- number of bytes read or -1 if there are no bytes left
-
getPcmDataType
Description copied from interface:AudioStreamReturns the output data format of this AudioStream.- Specified by:
getPcmDataTypein interfaceAudioStream- Returns:
- the pcm data type
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isClosed
public boolean isClosed()Description copied from interface:AudioStreamReturns true if the AudioStream is closed.- Specified by:
isClosedin interfaceAudioStream- Returns:
- true if closed, false if open
-