libgdx API

com.badlogic.gdx.audio.io
Interface Decoder

All Superinterfaces:
Disposable
All Known Implementing Classes:
Mpg123Decoder, VorbisDecoder

public interface Decoder
extends Disposable

Interface for audio decoders that return successive amplitude frames. When a decoder is no longer used it has to be disposed.

Author:
badlogicgames@gmail.com

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.
 

Method Detail

readSamples

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.

Parameters:
samples - The number of read samples.

skipSamples

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.

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.

getNumChannels

int getNumChannels()
Returns:
the number of channels

getRate

int getRate()
Returns:
the sampling rate in herz, e.g. 44100

getLength

float getLength()
Returns:
the length of the file in seconds

dispose

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

Specified by:
dispose in interface Disposable

libgdx API

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