com.jme3.audio
Class AudioData

java.lang.Object
  extended by com.jme3.util.NativeObject
      extended by com.jme3.audio.AudioData
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AndroidAudioData, AudioBuffer, AudioStream

public abstract class AudioData
extends NativeObject

AudioData is an abstract representation of audio data. There are two ways to handle audio data, short audio files are to be stored entirely in memory, while long audio files (music) are streamed from the hard drive as they are played.


Nested Class Summary
static class AudioData.DataType
           
 
Field Summary
protected  int bitsPerSample
           
protected  int channels
           
protected  int sampleRate
           
 
Fields inherited from class com.jme3.util.NativeObject
handleRef, id, type, updateNeeded
 
Constructor Summary
  AudioData()
           
protected AudioData(int id)
           
 
Method Summary
 int getBitsPerSample()
           
 int getChannels()
           
abstract  AudioData.DataType getDataType()
           
abstract  float getDuration()
           
 int getSampleRate()
           
 void setupFormat(int channels, int bitsPerSample, int sampleRate)
          Setup the format of the audio data.
 
Methods inherited from class com.jme3.util.NativeObject
clearUpdateNeeded, clone, createDestructableClone, deleteObject, getId, isUpdateNeeded, resetObject, setId, setUpdateNeeded, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sampleRate

protected int sampleRate

channels

protected int channels

bitsPerSample

protected int bitsPerSample
Constructor Detail

AudioData

public AudioData()

AudioData

protected AudioData(int id)
Method Detail

getDataType

public abstract AudioData.DataType getDataType()
Returns:
The data type, either Buffer or Stream.

getDuration

public abstract float getDuration()
Returns:
the duration in seconds of the audio clip.

getBitsPerSample

public int getBitsPerSample()
Returns:
Bits per single sample from a channel.

getChannels

public int getChannels()
Returns:
Number of channels. 1 for mono, 2 for stereo, etc.

getSampleRate

public int getSampleRate()
Returns:
The sample rate, or how many samples per second.

setupFormat

public void setupFormat(int channels,
                        int bitsPerSample,
                        int sampleRate)
Setup the format of the audio data.

Parameters:
channels - # of channels, 1 = mono, 2 = stereo
bitsPerSample - Bits per sample, e.g 8 bits, 16 bits.
sampleRate - Sample rate, 44100, 22050, etc.