sound

struct sound

struct sound

Sound effect

create_sound

struct sound *create_sound(const char *filepath)

Create a new sound effect from an OGG, WAV or MP3 file

Return
a sound effect resource or NULL on error

destroy_sound

void destroy_sound(struct sound *sound)

Cleanup and deallocate a sound effect

Parameters
  • sound -

    sound effect to cleanup and free

load_sound

int load_sound(struct sound *sound, const char *filepath)

Initialize an already allocated sound effect The sound file will be loaded and stored for use in the sound effect.

Parameters
  • sound -

    sound instance to use

  • filepath -

    file path to the sound file in ogg, wav or mp3 format

Return
0 or higher on success or -1 or lower on failure

cleanup_sound

void cleanup_sound(struct sound *sound)

Internally cleanup an initialized sound effect

Parameters
  • sound -

    sound effect to cleanup

play_sound

int play_sound(struct sound *sound, int loops)

Play sound effect Will play an initialized sound effect

Parameters
  • sound -

    sound effect to play

  • loops -

    -1 - infinite, 0 - play once, 1 - twice and so on..

Return
0 or higher means success -1 or lower means failure

stop_sound

void stop_sound(struct sound *sound)

Stop playing a sound

Parameters
  • sound -

    sound effect to stop playing

is_playing

int is_playing(struct sound *sound)

Test if a sound effect is playing

Return
1 if the sound effect is being played or 0 otherwise
Parameters
  • sound -

    sound effect to test