Programming Reference:WavePlayer Class: Difference between revisions
| Line 46: | Line 46: | ||
==See also== | ==See also== | ||
[[Programming Reference:TextToSpeech Class]], [[Programming Reference:MidiPlayer Class]] | |||
[[Category:Framework API]][[Category:Development]] | [[Category:Framework API]][[Category:Development]] | ||
Revision as of 10:24, 16 June 2008
Synopsis
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.
Properties
For each property, there is a getter method carrying the plain property name. Writable properties have an additional setter method prefixed with "Set".
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 ... 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 Error ErrorState (r)
The result of the preceding operation, represented by one of the members of the Error enumerated type.
Enumerations
enum Error
- 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.
Methods
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>.
Play()
Start playback. This method does nothing if the File property has not been specified.
Stop()
Stops playback, and resets the playback position to the beginning. This method does nothing when no audio is being played.
Remarks
Copying or assigning WavePlayer instances may require re-loading audio data into memory; consequently, manipulations to STL containers that contain WavePlayer objects are not advisable in time-critical situations. Typically, one would set up such containers at initialization time, and use use WavePlayer::Play() to play back from contained objects when appropriate.
See also
Programming Reference:TextToSpeech Class, Programming Reference:MidiPlayer Class