libgdx API

com.badlogic.gdx.audio.io
Class VorbisDecoder

java.lang.Object
  extended by com.badlogic.gdx.audio.io.VorbisDecoder
All Implemented Interfaces:
Decoder, Disposable

public class VorbisDecoder
extends java.lang.Object
implements Decoder

A Decoder implementation that decodes OGG Vorbis files using tremor

Author:
mzechner

Constructor Summary
VorbisDecoder(java.lang.String filename)
          Opens the given file for ogg decoding.
 
Method Summary
 void dispose()
          Disposes the decoder and frees all associated resources
 float getLength()
          
 int getNumChannels()
          
 int getRate()
          
 int readSamples(java.nio.ShortBuffer samples)
          Reads in samples.capacity() samples in 16-bit signed PCM format from the decoder.
 int skipSamples(int numSamples)
          Skips numSamples samples.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VorbisDecoder

public VorbisDecoder(java.lang.String filename)
Opens the given file for ogg decoding. Throws an IllegalArugmentException in case the file could not be opened.

Parameters:
filename - the filename
Method Detail

dispose

public void dispose()
Disposes the decoder and frees all associated resources

Specified by:
dispose in interface Decoder
Specified by:
dispose in interface Disposable

getLength

public float getLength()

Specified by:
getLength in interface Decoder
Returns:
the length of the file in seconds

getNumChannels

public int getNumChannels()

Specified by:
getNumChannels in interface Decoder
Returns:
the number of channels

getRate

public int getRate()

Specified by:
getRate in interface Decoder
Returns:
the sampling rate in herz, e.g. 44100

readSamples

public int readSamples(java.nio.ShortBuffer samples)
Reads in samples.capacity() samples in 16-bit signed PCM format from the decoder. Returns the actual number read in. If this number is smaller than the capacity of the buffer then the end of stream has been reached. The provided ShortBuffer must be a direct buffer.

Specified by:
readSamples in interface Decoder
Parameters:
samples - The number of read samples.

skipSamples

public int skipSamples(int numSamples)
Skips numSamples samples. If the decoded file is in stereo the left and right channel samples are counted as 2 samples.

Specified by:
skipSamples in interface Decoder
Parameters:
numSamples - the number of samples to skip
Returns:
the number of samples actually skipped. If this is < numSamples then the end of the file has been reached.

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)