dsfml.audio.music

Musics are sounds that are streamed rather than completely loaded in memory.

This is especially useful for compressed musics that usually take hundreds of MB when they are uncompressed: by streaming it instead of loading it entirely, you avoid saturating the memory and have almost no loading delay.

Apart from that, a $(U Music) has almost the same features as the $(SOUNDBUFFER_LINK)/$(SOUND_LINK) pair: you can play/pause/stop it, request its parameters (channels, sample rate), change the way it is played (pitch, volume, 3D position, ...), etc.

As a sound stream, a music is played in its own thread in order not to block the rest of the program. This means that you can leave the music alone after calling play(), it will manage itself very well.

Members

Classes

Music
class Music

Streamed music played from an audio file.

Examples

1 // Declare a new music
2 auto music = new Music();
3 
4 // Open it from an audio file
5 if (!music.openFromFile("music.ogg"))
6 {
7    // error...
8 }
9 
10 // change its 3D position
11 music.position = Vector3f(0, 1, 10);
12 
13 // increase the pitch
14 music.pitch = 2;
15 
16 // reduce the volume
17 music.volume = 50;
18 
19 // make it loop
20 music.loop = true;
21 
22 // Play it
23 music.play();

See Also

$(SOUND_LINK), $(SOUNDSTREAM_LINK)

Meta