VoltAir
|
An instance of a sound effect. More...
Public Member Functions | |
SoundEffectInstance () | |
Create a SoundEffectInstance referencing nothing. More... | |
SoundEffectInstance (const QSharedPointer< QSoundEffect > &soundEffect) | |
Create a SoundEffectInstance referencing a shared QSoundEffect . More... | |
SoundEffectInstance (SoundEffectInstance &&other) | |
Move-constructs a SoundEffectInstance instance, making it use the same shared QSoundEffect reference that other was using. More... | |
SoundEffectInstance (const SoundEffectInstance &other)=delete | |
Deleted copy constructor. More... | |
SoundEffectInstance & | operator= (SoundEffectInstance &&other) |
Move assigns other to this SoundEffectInstance instance. More... | |
SoundEffectInstance & | operator= (const SoundEffectInstance &other)=delete |
Deleted copy and assign. More... | |
void | reset () |
Releases the reference to the shared QSoundEffect , stopping it if necessary. More... | |
void | reset (SoundEffectInstance &&other) |
Releases the current QSoundEffect reference, replacing it with another from other using a move operation. More... | |
void | swap (SoundEffectInstance &other) |
Swaps QSoundEffect references and parameters with another SoundEffectInstance. More... | |
void | setLooped (bool value) |
Sets property to play looped or as a one-shot sound effect. More... | |
void | setVolume (float value) |
Sets play volume property. More... | |
bool | isPlaying () const |
Returns whether or not this sample is currently playing. More... | |
void | play () |
Starts playing this instance of the sound effect. More... | |
void | stop () |
Stops the sample if it is currently playing. More... | |
An instance of a sound effect.
Separate instances of a sound effect can have different properties (i.e. volume, looped, etc.) but share the same sample data (i.e. the same wave file, etc.). This class also automatically stops looped sound effects when destroyed.
SoundEffectInstance::SoundEffectInstance | ( | ) |
Create a SoundEffectInstance referencing nothing.
|
explicit |
Create a SoundEffectInstance referencing a shared QSoundEffect
.
When this SoundEffectInstance is destroyed, it stops soundEffect
, if the sound is looped, and then releases its reference to soundEffect
.
soundEffect | Shared QSoundEffect to reference |
SoundEffectInstance::SoundEffectInstance | ( | SoundEffectInstance && | other | ) |
Move-constructs a SoundEffectInstance instance, making it use the same shared QSoundEffect
reference that other
was using.
other | SoundEffectInstance to move into this |
|
delete |
Deleted copy constructor.
other | SoundEffectInstance to copy |
bool SoundEffectInstance::isPlaying | ( | ) | const |
Returns whether or not this sample is currently playing.
SoundEffectInstance& SoundEffectInstance::operator= | ( | SoundEffectInstance && | other | ) |
Move assigns other
to this SoundEffectInstance instance.
other | SoundEffectInstance to move into this |
this
|
delete |
Deleted copy and assign.
other | SoundEffectInstance to copy and assign |
this
void SoundEffectInstance::play | ( | ) |
Starts playing this instance of the sound effect.
If the sound effect is already playing, it will relaunch it at the start of the sample. One-shot sounds will play once, and looped samples will loop until this instance is destroyed, or stop() is called.
void SoundEffectInstance::reset | ( | ) |
Releases the reference to the shared QSoundEffect
, stopping it if necessary.
void SoundEffectInstance::reset | ( | SoundEffectInstance && | other | ) |
Releases the current QSoundEffect
reference, replacing it with another from other
using a move operation.
other | SoundEffectInstance whose shared QSoundEffect reference should be moved |
void SoundEffectInstance::setLooped | ( | bool | value | ) |
Sets property to play looped or as a one-shot sound effect.
value | true if the SoundEffectInstance should play looped |
void SoundEffectInstance::setVolume | ( | float | value | ) |
Sets play volume property.
0.0f
is silent, 1.0f
is max volume, and values in between are linear gain factors.
value | Volume level [0.0f, 1.0f] to set for the sound effect |
void SoundEffectInstance::stop | ( | ) |
Stops the sample if it is currently playing.
void SoundEffectInstance::swap | ( | SoundEffectInstance & | other | ) |
Swaps QSoundEffect
references and parameters with another SoundEffectInstance.
other | SoundEffectInstance to swap into this |