|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sdl.audio.SDLAudio
SDLAudio is the primary binding for the SDL Audio subsystem. This class manages all the audio played by SDL. It is responsible for
Step 1. Instantiation and CallBack registration
SDLAudio audio = new SDLAudio(); audio.registerAudioCallBack(aCallback);
Step 2. Opening the audio device
Next the user will define the type of audio to be played on the audio
device, and open the device.
SDLAudioSpec spec = new SDLAudioSpec( 44100,(short)SDLAudio.AUDIO_S16, (byte)2,(byte)0,(short)4096,0); audio.setDesiredAudioSpec(spec); audio.openDevice();
Step 3. Optional initialization stuff
Now we will do some initialization stuff if we want. Here, the callback is
loading and audio file.
// code in AudioCallBack object's (aCallBack) initialization part AudioPlay playable1 = audio.loadAndConvertSDLAudio("song1.wav");
Step 4. Start ("unpause") the audio playblack
Once the extra initialization stuff is finished,
we allow the callback to play the audio stream by "un-pausing" the audio
(ie. starting the audio).
The audio won't actually start playing until the user calls
pauseAudio(false), allowing him to perform other audio
initialization as needed before his callback function is run.
After the user is done using the sound output, he should close it
with the closeAudio() method.
audio.pauseAudio(false); //start Sound
At this point the user may choose to sleep and allow the AudioCallBack thread to play the streams
AudioCallBack
,
AudioPlay
Field Summary | |
static int |
AUDIO_S16
|
static int |
AUDIO_S16LSB
|
static int |
AUDIO_S16MSB
|
static int |
AUDIO_S8
|
static int |
AUDIO_U16
|
static int |
AUDIO_U16LSB
|
static int |
AUDIO_U16MSB
|
static int |
AUDIO_U8
|
Constructor Summary | |
SDLAudio()
|
Method Summary | |
void |
audioCallBack(int handle,
int length)
|
void |
closeDevice()
|
SDLAudioSpec |
getObtainedAudioSpec()
|
AudioPlay |
loadAndConvertSDLAudio(java.lang.String fileName)
Encapsulates the functionality of the native methods SDL_LoadWAV and SDL_ConvertAudio. |
void |
openDevice()
|
void |
pauseAudio(boolean b)
Starts and stops the audio playback done by the AudioCallbacks. |
boolean |
registerAudioCallBack(AudioCallBack e)
|
static void |
SDLMixAudio(int handleAudio,
int handleBuffer,
int offset,
int length,
int volume)
|
void |
setDesiredAudioSpec(SDLAudioSpec spec)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int AUDIO_U8
public static final int AUDIO_S8
public static final int AUDIO_U16LSB
public static final int AUDIO_S16LSB
public static final int AUDIO_U16MSB
public static final int AUDIO_S16MSB
public static final int AUDIO_U16
public static final int AUDIO_S16
Constructor Detail |
public SDLAudio()
Method Detail |
public void openDevice()
public void setDesiredAudioSpec(SDLAudioSpec spec)
public SDLAudioSpec getObtainedAudioSpec()
public void pauseAudio(boolean b)
public void closeDevice()
public AudioPlay loadAndConvertSDLAudio(java.lang.String fileName)
public boolean registerAudioCallBack(AudioCallBack e)
public void audioCallBack(int handle, int length)
public static void SDLMixAudio(int handleAudio, int handleBuffer, int offset, int length, int volume)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |