dsfml.audio.sound

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, ...)

$(PARA 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. *)

Members

Classes

Sound
class Sound

Regular sound that can be played in the audio environment.

Examples

1 auto buffer = new SoundBuffer();
2 buffer.loadFromFile("sound.wav");
3 
4 auto sound = new Sound();
5 sound.setBuffer(buffer);
6 sound.play();

See Also

$(SOUNDBUFFER_LINK), $(MUSIC_LINK)

Meta