Sound

Regular sound that can be played in the audio environment. Sound is the class used to play sounds.

It provides: - Control (play, pause, stop) - Ability to modify output parameters in real-time (pitch, volume, ...) - 3D spatial features (position, attenuation, ...).

Sound is perfect for playing short sounds that can fit in memory and require no latency, like foot steps or gun shots. For longer sounds, like background musics or long speeches, rather see Music (which is based on streaming).

In order to work, a sound must be given a buffer of audio data to play. Audio data (samples) is stored in SoundBuffer, and attached to a sound with the setBuffer() function. The buffer object attached to a sound must remain alive as long as the sound uses it. Note that multiple sounds can use the same sound buffer at the same time.

Constructors

this
this()
Undocumented in source.
this
this(const(SoundBuffer) buffer)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

pause
void pause()

Pause the sound.

play
void play()

Start or resume playing the sound.

setBuffer
void setBuffer(const(SoundBuffer) buffer)
Undocumented in source. Be warned that the author may not have intended to support it.
stop
void stop()

Stop playing the sound.

Properties

attenuation
float attenuation [@property setter]

The attenuation factor of the sound.

attenuation
float attenuation [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
isLooping
bool isLooping [@property setter]

Whether or not the sound should loop after reaching the end.

isLooping
bool isLooping [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
minDistance
float minDistance [@property setter]

The minimum distance of the sound.

minDistance
float minDistance [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
pitch
float pitch [@property setter]

The pitch of the sound.

pitch
float pitch [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
playingOffset
Duration playingOffset [@property setter]

Change the current playing position (from the beginning) of the sound.

playingOffset
Duration playingOffset [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
position
Vector3f position [@property setter]

The 3D position of the sound in the audio scene.

position
Vector3f position [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
relativeToListener
bool relativeToListener [@property setter]

Make the sound's position relative to the listener (true) or absolute (false).

relativeToListener
bool relativeToListener [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
status
Status status [@property getter]

Get the current status of the sound (stopped, paused, playing).

volume
float volume [@property setter]

The volume of the sound.

volume
float volume [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

sfPtr
sfSound* sfPtr;
Undocumented in source.

Inherited Members

From SoundSource

Status
enum Status

Enumeration of the sound source states.

pitch
float pitch [@property setter]

The pitch of the sound.

pitch
float pitch [@property getter]
Undocumented in source.
volume
float volume [@property setter]

The volume of the sound.

volume
float volume [@property getter]
Undocumented in source.
position
Vector3f position [@property setter]

The 3D position of the sound in the audio scene.

position
Vector3f position [@property getter]
Undocumented in source.
relativeToListener
bool relativeToListener [@property setter]

Make the sound's position relative to the listener (true) or absolute (false).

relativeToListener
bool relativeToListener [@property getter]
Undocumented in source.
minDistance
float minDistance [@property setter]

The minimum distance of the sound.

minDistance
float minDistance [@property getter]
Undocumented in source.
attenuation
float attenuation [@property setter]

The attenuation factor of the sound.

attenuation
float attenuation [@property getter]
Undocumented in source.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan