GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::audio::SoundOptions Struct Reference

Configuration options for a Sound. More...

#include <GREM/audio/Sound.hpp>

Public Member Functions

constexpr bool operator== (const SoundOptions &other) const =default
 Compare these options to another set of options for equality.

Public Attributes

SoundAttenuationModel attenuationModel = SoundAttenuationModel::INVERSE_DISTANCE
 Which distance attenuation/falloff model to use for 3D positional audio when playing this sound.
float volume = 1.0f
 Default volume of instances of this sound, which is used if no volume override is specified when the sound is played.
float minDistance = 1.0f
 Minimum distance of the range where the distance between the sound instance and listener changes the sound attenuation/falloff for this sound.
float maxDistance = Limits<float>::MAX
 Maximum distance of the range where the distance between the sound instance and listener changes sound attenuation/falloff for this sound.
float rolloffFactor = 1.0f
 Rolloff factor to use in the attenuation/falloff calculation for this sound.
float dopplerFactor = 1.0f
 Strength of the doppler effect for this sound.
bool useDistanceDelay = false
 Simulate the delay due to the speed of sound between the sound being played and the sound being heard.
bool listenerRelative = false
 Don't take the listener's sound stage position into account when playing this sound in 3D.
bool looping = false
 Default to playing instances of this sound on repeat instead of just playing them once.
bool singleInstance = false
 Override any instances of this sound that are already playing when a new instance is played.
bool streamed = false
 Stream in the contents of the sound file gradually as the sound plays instead of loading the whole file at once.

Detailed Description

Configuration options for a Sound.

Member Function Documentation

◆ operator==()

bool grem::audio::SoundOptions::operator== ( const SoundOptions & other) const
nodiscardconstexprdefault

Compare these options to another set of options for equality.

Parameters
otherthe options to compare these to.
Returns
true if the options are equal, false otherwise.

Member Data Documentation

◆ attenuationModel

SoundAttenuationModel grem::audio::SoundOptions::attenuationModel = SoundAttenuationModel::INVERSE_DISTANCE

Which distance attenuation/falloff model to use for 3D positional audio when playing this sound.

See SoundAttenuationModel for the different alternatives.

Remarks
The recommended model for most applications is SoundAttenuationModel::INVERSE_DISTANCE.

◆ volume

float grem::audio::SoundOptions::volume = 1.0f

Default volume of instances of this sound, which is used if no volume override is specified when the sound is played.

When used, the amplitude of the playing sound is multiplied by this gain value, meaning that a value of 1 represents no change, i.e. 100% of the original volume of the loaded sound file.

◆ minDistance

float grem::audio::SoundOptions::minDistance = 1.0f

Minimum distance of the range where the distance between the sound instance and listener changes the sound attenuation/falloff for this sound.

See SoundAttenuationModel for the effect this parameter has when using the different attenuation models, as well as the restrictions on its value for well-defined results.

Warning
When using the default attenuation model, this value must be greater than 0, and must also be less than or equal to maxDistance.

◆ maxDistance

float grem::audio::SoundOptions::maxDistance = Limits<float>::MAX

Maximum distance of the range where the distance between the sound instance and listener changes sound attenuation/falloff for this sound.

Beyond this range, the distance between sound instance and listener stops having an effect on the volume.

See SoundAttenuationModel for the effect this parameter has when using the different attenuation models, as well as the restrictions on its value for well-defined results.

Warning
When using the default attenuation model, this value must be greater than or equal to minDistance.

◆ rolloffFactor

float grem::audio::SoundOptions::rolloffFactor = 1.0f

Rolloff factor to use in the attenuation/falloff calculation for this sound.

In general, a larger rolloff factor causes the sound volume to drop more steeply with the distance between the sound instance and listener.

See SoundAttenuationModel for the effect this parameter has when using the different attenuation models, as well as the restrictions on its value for well-defined results.

Warning
When using the default attenuation model, this value must be greater than 0.

◆ dopplerFactor

float grem::audio::SoundOptions::dopplerFactor = 1.0f

Strength of the doppler effect for this sound.

The doppler effect depends on the velocity of the sound instance and the listener as well as the speed of sound that is set in the SoundStage. When both velocities are 0, there is no doppler effect, and in that case this parameter makes no difference to the sound.

◆ useDistanceDelay

bool grem::audio::SoundOptions::useDistanceDelay = false

Simulate the delay due to the speed of sound between the sound being played and the sound being heard.

When enabled, the delay depends on the distance between the sound instance and the listener as well as the sound speed set in the SoundStage.

◆ listenerRelative

bool grem::audio::SoundOptions::listenerRelative = false

Don't take the listener's sound stage position into account when playing this sound in 3D.

When enabled, the position of the sound instance is treated as being relative to the listener, as if the listener's position is (0, 0, 0).

◆ looping

bool grem::audio::SoundOptions::looping = false

Default to playing instances of this sound on repeat instead of just playing them once.

◆ singleInstance

bool grem::audio::SoundOptions::singleInstance = false

Override any instances of this sound that are already playing when a new instance is played.

Useful for making sure a certain sound effect never overlaps with itself when played multiple times.

◆ streamed

bool grem::audio::SoundOptions::streamed = false

Stream in the contents of the sound file gradually as the sound plays instead of loading the whole file at once.

Note
This option has no effect when constructing a sound from a raw array of samples.

The documentation for this struct was generated from the following file: