Music

Streamed music played from an audio file.

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 Music has almost the same features as the SoundBuffer / Sound 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.

Constructors

this
this()
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

getDuration
Duration getDuration()

Get the total duration of the music.

onGetData
bool onGetData(const(short)[] samples)

Request a new chunk of audio samples from the stream source.

onSeek
void onSeek(Duration timeOffset)

Change the current playing position in the stream source.

openFromFile
bool openFromFile(string filename)

Open a music from an audio file.

openFromMemory
bool openFromMemory(const(void)[] data)

Open a music from an audio file in memory.

openFromStream
bool openFromStream(InputStream stream)

Open a music from an audio file in memory.

Inherited Members

From SoundStream

sfPtr
sfSoundStream* sfPtr;
Undocumented in source.
~this
~this()
Undocumented in source.
initialize
void initialize(uint channelCount, uint sampleRate)
Undocumented in source. Be warned that the author may not have intended to support it.
pitch
float pitch [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
pitch
float pitch [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
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.
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.
isLooping
bool isLooping [@property setter]

Whether or not the stream 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.
playingOffset
Duration playingOffset [@property setter]

The current playing position (from the beginning) of the stream.

playingOffset
Duration playingOffset [@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.
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.
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.
channelCount
uint channelCount [@property getter]

The number of channels of the stream.

sampleRate
uint sampleRate [@property getter]

The stream sample rate of the stream

status
Status status [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
play
void play()
Undocumented in source. Be warned that the author may not have intended to support it.
pause
void pause()
Undocumented in source. Be warned that the author may not have intended to support it.
stop
void stop()
Undocumented in source. Be warned that the author may not have intended to support it.
onGetData
bool onGetData(const(short)[] samples)
Undocumented in source.
onSeek
void onSeek(Duration timeOffset)
Undocumented in source.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan