Sound


Object Hierarchy:

Object hierarchy for Sound

Description:

[ Compact ]
[ CCode ( cprefix = "sfSound_" , free_function = "sfSound_destroy" ) ]
public class Sound

Regular sound that can be played in the audio environment.

sf.Sound is the class to use to play sounds.

It provides:

Control (play, pause, stop) Ability to modify output parameters in real-time (pitch, volume, ...) 3D spatial features (position, attenuation, ...). sf.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 sf.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 sf.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.

Usage example:

var buffer = new SoundBuffer.FromFile("sound.wav");

var sound = new Sound();
sound.setBuffer(buffer);
sound.play();

See also:

sf.SoundBuffer, sf.Music


Namespace: sf
Package: sfml

Content:

Creation methods:

Methods: