Skip to content

Module: music

Synopsis

#include <core/music.h>

This module provide support for playing music. In contrast to sounds only one music can be played at a time.

Enums

music_flags

Optional music flags that can be OR'ed in functions which use them.

Enumerator Description
MUSIC_NONE No flags.
MUSIC_LOOP Loop the music.

Structs

music

This structure has no public editable fields but is still publicly exposed to allow stack allocation.

Functions

music_open

Open a music file from path and store the result into mus. Returns false on errors, in this case mus remains uninitialized and must not be used.

bool
music_open(struct music *mus, const char *path)

music_openmem

Open a music from the memory buffer of size buffersz and store the result into mus. Returns false on errors, in this case mus remains uninitialized and must not be used.

Note

The argument buffer must stay valid until the font is no longer used.

bool
music_openmem(struct music *mus, const void *buffer, size_t buffersz)

music_ok

Returns true if the music mus is properly initialized.

bool
music_ok(const struct music *mus)

music_play

Start playing the given music mus.

The argument flags can control the playback options and if fadein is greater than 0 it will fade in during the number of specified milliseconds.

This function will resume the playback since the beginning and will stop the current music. If the music playing is currently fading out the playback will not start until it has finished.

bool
music_play(struct music *mus, enum music_flags flags, unsigned int fadein)

music_playing

Returns true if a music is playing.

bool
music_playing(void)

music_pause

Pause the music playback immediately.

void
music_pause(void)

music_resume

Resume the music playback immediately.

void
music_resume(void)

music_stop

Stop the music playback, applying an optional fadeout delay expressed in milliseconds.

void
music_stop(unsigned int fadeout)

music_finish

Close the music mus, if it is playing it is immediately stopped.

void
music_finish(struct music *mus)