Programming Reference:WavePlayer Class
- 1 Location
- 2 Synopsis
- 3 Properties
- 4 Enumerations
- 5 Methods
- 6 Remarks
- 7 See also
The WavePlayer class is a wrapper for audio output from audio data recorded in PCM format (Windows WAV files). In order to minimize playback delay, an audio file is loaded into memory prior to playback. WavePlayer objects may be stored in STL containers.
string File (rw)
Path to an audio file to be played back. The SetFile method loads audio data into memory. The path may be absolute, or relative to the current executable.
float Volume (rw)
Playback volume in the range 0.0 to 1.0.
float Pan (rw)
Panning position in the range -1.0 (leftmost) to +1.0 (rightmost).
float PlayingPos (r)
Playback position from start, in milliseconds. Zero if not playing.
bool IsPlaying (r)
True during playback, false otherwise.
enum WavePlayer::Error ErrorState (r)
The result of the preceding operation, represented by one of the members of the Error enumerated type.
- No Error
- File Opening Error
- the File property was set to a non-existent file, or a file that could not be loaded as an audio file.
- Feature not supported
- a feature provided by one of the properties (such as panning) is not supported by the current implementation.
- Invalid Parameters
- a property is out of range.
- Inititalization Error
- there was an error when initializing an underlying library (such as DirectX Audio under Windows).
- Generic Error
- an error occurred that does not fit into any of the remaining categories.
Default Constructor, Copy Constructors, Assignment Operator, Destructor
These provide the full set of methods required to use WavePlayer as a data type in STL containers, such as std::vector<WavePlayer>.
Start playback. This method does nothing if the File property has not been specified.
Stops playback, and resets the playback position to the beginning. This method does nothing when no audio is being played.
Copying or assigning WavePlayer instances may require re-loading audio data into memory. Write operations to STL containers may imply copying of a contained object, followed by destruction of the original object after copying. Consequently, manipulations to STL containers that contain WavePlayer objects are not advisable during playback from one or more of its contained objects, or in time-critical situations. Typically, one would set up such containers at initialization time, and perform only read operations on containers during playback.