#include <sdlwavfile.h>
Collaboration diagram for WAVFile:

Public Member Functions | |
| WAVFile (const std::string &file, int volume=SDL_MIX_MAXVOLUME) | |
| Constructor will load the wav file from disk into sound and initialise the data members. | |
| ~WAVFile () | |
| Destructor will free the memory used by the sound buffer. | |
| void | setVolume (int newVol=SDL_MIX_MAXVOLUME) |
| Change the volume. | |
| void | play (bool repeat=false) |
| Commence playing this WAV file on the audio stream. | |
| void | open () |
| Open a connection to the audio device - only one WAVFile can be connected at once (the most recent connection will preempt any others). | |
| void | stop () |
| Stop playing this WAVFile and close all connections to the audio device. | |
| void | pause () |
| Pause the playing of all WAVFile s (so that they may subsequently be resumed() d. | |
| void | resume () |
| Restart the playing of the WAVFile currently connected to the audio device. | |
Protected Member Functions | |
| void | fill (Uint8 *stream, int len) |
| SDL will [indirectly] call this to fill its audio buffer, and this function will then fill it. | |
| void | lock () |
| Increment the synchronised function call depth, locking if it is the first. | |
| void | unlock () |
| Decrement the synchronised function call depth, unlocking if it is the last. | |
Protected Attributes | |
| SDL_AudioSpec | spec |
| SDL Specification for the WAV. | |
| Uint8 * | sound |
| The (entire) WAV file, buffered. | |
| Uint32 | slen |
| The length of the WAV file buffer. | |
| int | spos |
| The current pointer offset in sound. | |
| bool | once |
| if false, the playing will repeat/loop | |
| bool | nomore |
| if true, the next fill() will call stop() | |
| int | vol |
| The current volume in [0, SDL_MIX_MAXVOLUME]. | |
| int | locks |
| The number of locks (synchronised fn call depth). | |
Private Member Functions | |
| WAVFile (const WAVFile &) | |
| No copying. | |
Friends | |
| void | fillerup (void *, Uint8 *, int) |
| Callback for when the SDL Audio device needs more data. | |
Any number of WAVFile s may be created, for any number (or the same) WAV files. However, only one can be playing at once (this is a limitation of SDL). When another file starts playing - playback of the other WAV will be stopped. To resume, it must be play() ed again.
Definition at line 34 of file sdlwavfile.h.
|
|
No copying.
|
|
||||||||||||
|
Constructor will load the wav file from disk into sound and initialise the data members.
Definition at line 47 of file sdlwavfile.cc. References SDL_AudioSpec::callback, fillerup(), lock(), SDL_LoadWAV, setVolume(), slen, sound, spec, unlock(), and SDL_AudioSpec::userdata. |
Here is the call graph for this function:

|
|
Destructor will free the memory used by the sound buffer.
Definition at line 106 of file sdlwavfile.cc. References lock(), SDL_FreeWAV(), sound, and unlock(). |
Here is the call graph for this function:

|
||||||||||||
|
SDL will [indirectly] call this to fill its audio buffer, and this function will then fill it.
Definition at line 76 of file sdlwavfile.cc. References nomore, once, SDL_MixAudio(), slen, sound, spos, stop(), and vol. |
Here is the call graph for this function:

|
|
Increment the synchronised function call depth, locking if it is the first.
Definition at line 63 of file sdlwavfile.cc. References locks, and SDL_LockAudio(). Referenced by open(), pause(), play(), resume(), stop(), WAVFile(), and ~WAVFile(). |
Here is the call graph for this function:

|
|
Open a connection to the audio device - only one WAVFile can be connected at once (the most recent connection will preempt any others). This can be used to resume a file, if it was interrupted by playing another wav, otherwise just play() works.
Definition at line 124 of file sdlwavfile.cc. References lock(), SDL_OpenAudio(), spec, stop(), and unlock(). Referenced by play(). |
Here is the call graph for this function:

|
|
Pause the playing of all WAVFile s (so that they may subsequently be resumed() d.
Definition at line 142 of file sdlwavfile.cc. References lock(), SDL_PauseAudio(), and unlock(). |
Here is the call graph for this function:

|
|
Commence playing this WAV file on the audio stream.
Definition at line 116 of file sdlwavfile.cc. |
Here is the call graph for this function:

|
|
Restart the playing of the WAVFile currently connected to the audio device.
Definition at line 148 of file sdlwavfile.cc. References lock(), SDL_PauseAudio(), and unlock(). Referenced by play(). |
Here is the call graph for this function:

|
|
Change the volume.
Definition at line 112 of file sdlwavfile.cc. References SDL_MIX_MAXVOLUME, and vol. Referenced by WAVFile(). |
|
|
Stop playing this WAVFile and close all connections to the audio device.
Definition at line 134 of file sdlwavfile.cc. References lock(), nomore, SDL_CloseAudio(), spos, and unlock(). |
Here is the call graph for this function:

|
|
Decrement the synchronised function call depth, unlocking if it is the last.
Definition at line 69 of file sdlwavfile.cc. References locks, and SDL_UnlockAudio(). Referenced by open(), pause(), play(), resume(), stop(), WAVFile(), and ~WAVFile(). |
Here is the call graph for this function:

|
||||||||||||||||
|
Callback for when the SDL Audio device needs more data. This is called by SDL automatically. Definition at line 43 of file sdlwavfile.cc. |
|
|
The number of locks (synchronised fn call depth).
Definition at line 46 of file sdlwavfile.h. |
|
|
if true, the next fill() will call stop()
Definition at line 44 of file sdlwavfile.h. |
|
|
if false, the playing will repeat/loop
Definition at line 43 of file sdlwavfile.h. |
|
|
The length of the WAV file buffer.
Definition at line 41 of file sdlwavfile.h. |
|
|
The (entire) WAV file, buffered.
Definition at line 40 of file sdlwavfile.h. Referenced by fill(), WAVFile(), and ~WAVFile(). |
|
|
SDL Specification for the WAV.
Definition at line 39 of file sdlwavfile.h. |
|
|
The current pointer offset in sound.
Definition at line 42 of file sdlwavfile.h. |
|
|
The current volume in [0, SDL_MIX_MAXVOLUME].
Definition at line 45 of file sdlwavfile.h. Referenced by fill(), and setVolume(). |
1.3.4