|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
AudioCallBack | Consumes handles to audio files and controls how they are mixed and played. |
Class Summary | |
AudioData | Wrapper around the native buffer containing the chuncks of audio data read from audio files. |
AudioPlay | Wrapper around the sound to be played. |
SDLAudio | SDLAudio is the primary binding for the SDL Audio subsystem. |
SDLAudioCvt | |
SDLAudioSpec | Format of the SDL audio stream. |
Java bindings for SDL audio subsystem.
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
First of all, it is important to understand the difference between the audio stream going to the audio device and the data stream read from audio files.
SDL abstractions | River Analogy |
Playing an audio stream on an audio device. Controlling the stream of bytes pumped into the audio device is the job of SDLAudio. There is ONE stream per audio device. |
Audio Stream = A river of flowing water. Audio Device = a cave that the river flows into. Playing the stream is letting the river flow into the cave. |
Playing (Mixing) files into this stream. Playing audio files involves extracting chuncks of audio data and converting time to an appropriate format. These converted data chuncks then need to be mixed into the current audio stream. This job is supervised by the callback. |
Sound files = several individual boats placed on
the flowing river (audio stream).
The river will eventually carry them to the cave. AudioPlayBack = a third party supervisor. The river traffic controller that stands by and make sure the boats sail or stop/dock as needed. Playing files is setting the boats afloat on the river current. |
AudioCallBack
,
AudioPlay
,
SDLAudio
,
sdl.test.TestAudio
|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |