#include <lib_snd.h>
A class for playing sounds.
- Note
- Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
Normally one want to use the BaseSound class for the actual sound, as in this example:
return false;
if (!sound) return false;
if (!sound->
Load(fn))
return false;
if (!playsound) return false;
playsound->
Scrub(0, sndinfo.GetLength().Get());
{
}
◆ GePlaySnd()
◆ ~GePlaySnd()
◆ Alloc()
Allocates a GePlaySnd instance. Destroy the allocated GePlaySnd instance with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Returns
- The allocated GePlaySnd instance, or nullptr if the allocation failed.
◆ Free()
Destructs GePlaySnd instances allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Parameters
-
[in,out] | data | The GePlaySnd instance to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards. |
◆ Open() [1/2]
The audio data referenced by the BaseSound will be kept in memory until Close() is called.
- Parameters
-
[in] | snd | The sound to use for playback. The caller owns the pointed sound. |
- Returns
- true if successful, otherwise false.
◆ Open() [2/2]
Opens an audio device with multiple BaseSounds that will be mixed. The audio data referenced by the BaseSounds will be kept in memory until Close() is called.
- Parameters
-
[in] | stream_cnt | The number of sounds to be mixed. |
[in] | streams | The array with the sounds. |
[in] | start_offsets | The array with start time offsets in seconds (this is the audible sound data when StartAt(0) is called). |
[in] | max_length | The maximum length of the audio data in seconds (relative to StartAt(0) ). |
- Returns
- true if successful, otherwise false.
◆ Close()
Closes the audio device.
- Note
- If the sounds used for Open() have been deleted in the meantime, their audio data will be released.
◆ StartAt()
Starts audio output.
- Parameters
-
[in] | start | The position relative to the start of the audio data in seconds. |
◆ Scrub()
- Parameters
-
[in] | start | The position relative to the start of the audio data in seconds. |
[in] | duration | The scrub duration in seconds after which the audio device will be stopped. |
◆ Stop()
◆ IsPlaying()
Checks if the audio device is running
- Returns
- true if if audio is playing, otherwise false.
◆ GetPositionEstimate()
Float64 GetPositionEstimate |
( |
void |
| ) |
|
Gets an estimate audio position.
- Returns
- The currently audible position in seconds.
◆ SetScale()
Sets the playback time scale.
- Parameters
-
[in] | scale | The playback scale value: 1.0 means real time, 2.0 means twice as fast, 0.5 means half the speed, 0.0 is invalid. |
◆ GetScale()
Gets the current playback time scale.
- Returns
- The playback scale value: 1.0 means real time, 2.0 means twice as fast, 0.5 means half the speed, 0.0 is invalid.