libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Attributes | List of all members
donut::audio::SoundOptions Struct Reference

Configuration options for a Sound. More...

#include <donut/audio/Sound.hpp>

Public Attributes

SoundAttenuationModel attenuationModel = SoundAttenuationModel::INVERSE_DISTANCE
 Which distance attenuation/falloff model to use for 3D positional audio when playing this sound. More...
 
float volume = 1.0f
 The default volume of instances of this sound, which is used if no volume override is specified when the sound is played. More...
 
float minDistance = 1.0f
 The minimum distance of the range where the distance between the sound instance and listener changes the sound attenuation/falloff for this sound. More...
 
float maxDistance = std::numeric_limits<float>::max()
 The maximum distance of the range where the distance between the sound instance and listener changes sound attenuation/falloff for this sound. More...
 
float rolloffFactor = 1.0f
 The rolloff factor to use in the attenuation/falloff calculation for this sound. More...
 
float dopplerFactor = 1.0f
 Strength of the doppler effect for this sound. More...
 
bool useDistanceDelay = false
 Simulate the delay due to the speed of sound between the sound being played and the sound being heard. More...
 
bool listenerRelative = false
 Don't take the listener's sound stage position into account when playing this sound. More...
 
bool looping = false
 Play this sound on repeat instead of just playing it once. More...
 
bool singleInstance = false
 Override any instances of this sound that are already playing when a new instance is played. More...
 

Detailed Description

Configuration options for a Sound.

Examples
example_game.cpp.

Member Data Documentation

◆ attenuationModel

SoundAttenuationModel donut::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.
Examples
example_game.cpp.

◆ volume

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

The 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 donut::audio::SoundOptions::minDistance = 1.0f

The 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 donut::audio::SoundOptions::maxDistance = std::numeric_limits<float>::max()

The 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 donut::audio::SoundOptions::rolloffFactor = 1.0f

The 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.

Note
A value greater than or equal to 1 is usually recommended.
Warning
When using the default attenuation model, this value must be greater than 0.

◆ dopplerFactor

float donut::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 donut::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 donut::audio::SoundOptions::listenerRelative = false

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

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 donut::audio::SoundOptions::looping = false

Play this sound on repeat instead of just playing it once.

◆ singleInstance

bool donut::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.


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