Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

SoundManager





The sound_manager module header is lapin/sound_manager.h
typedef enum e_bunny_music_track
{
     BST_ALL = -1,
     BST_TRACK_01,
     BST_TRACK_02,
     BST_TRACK_03,
     BST_LAST_TRACK

} t‌_‌b‌u‌n‌n‌y‌_‌m‌u‌s‌i‌c‌_‌t‌r‌a‌c‌k;

Description

     This enumeration helps you to indicate a track to play when you need music.

Symbols

  • BST_ALL:
         All tracks at once.
  • BST_TRACK_01:
         A track.
  • BST_TRACK_02:
         Another track.
  • BST_TRACK_03:
         Yet another track.
  • BST_LAST_TRACK:
         How many tracks there is.



INDEX

typedef enum e_bunny_sound_type
{
     BST_GENERAL = -1,
     BST_MUSIC,
     BST_EFFECT,
     BST_VOICE,
     BST_LAST_SOUND_TYPE,

} t‌_‌b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d‌_‌t‌y‌p‌e;

Description

     This enumeration helps you to categorize sounds in order to share gauge like volume or pitch.

Symbols

  • BST_GENERAL:
         All sounds.
  • BST_MUSIC:
         Musics.
  • BST_EFFECT:
         Sound effects.
  • BST_VOICE:
         Voices.
  • BST_LAST_SOUND_TYPE:
         How many sound types exist.



INDEX

typedef struct s_bunny_sound_manager
{
     const t‌_‌b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d * const current_music[BST_LAST_TRACK];
const double general_volume;
const double volumes[BST_LAST_SOUND_TYPE];
const double general_pitch;
const double pitches[BST_LAST_SOUND_TYPE];

} t‌_‌b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d‌_‌m‌a‌n‌a‌g‌e‌r;

Description

     The sound manager structure role is to collect every sounds and musics to control their volumes and pitches accordingly to a central command - usually a configuration panel in a video game.

Attributes

  • const t‌_‌b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d * const current_music[BST_LAST_TRACK]:
         This field of length BST_LAST_TRACK have space for all tracks. It contains pointers to musics currently being played so it can stop it, replace it and avoid to restart it easily.
  • const double general_volume:
         A value between 0 and 100 which is the general volume. This impact all sounds.
    A normal value is around 50.
  • const double volumes[ST_LAST_SOUND_TYPE:
         Values between 0 and 100 which represent the volume of their category.
    A normal value is around 50.
  • const double general_pitch:
         A value superior to 0 which is the general pitch. This impact all sounds.
    The normal value is 1.
  • const double pitches[ST_LAST_SOUND_TYPE:
         Values superior to 0 which represent the pitch of their category.
    The normal value is 1.


INDEX


Description

     A global sound manager brought by the library itself. This allows you to not make the sound manager follow you everywhere.
You can still create your own sound manager if you need to, but I am not sure about its usefulness.

Default values

  • const t‌_‌b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d * const current_music[BST_LAST_TRACK]:
         Set to NULL.
  • const double general_volume:
         Set to 50.0.
  • const double volumes[ST_LAST_SOUND_TYPE:
         Set to 70.0, 80.0 and 90.0.
  • const double general_pitch:
         A value superior to 0 which is the general pitch. This impact all sounds.
    The normal value is 1.0.
  • const double pitches[ST_LAST_SOUND_TYPE:
         Values superior to 0 which represent the pitch of their category.
    The normal value is 1.0.


INDEX


Description

     This function adds the sent sound into the sound manager and associate it to the precised category.

The sound cannot be added into different category.

A sound added inside the sound manager should not have its volume or pitch set by b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d‌_‌v‌o‌l‌u‌m‌e or b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d‌_‌p‌i‌t‌c‌h but with b‌u‌n‌n‌y‌_‌m‌a‌n‌a‌g‌e‌d‌_‌s‌o‌u‌n‌d‌_‌v‌o‌l‌u‌m‌e or b‌u‌n‌n‌y‌_‌m‌a‌n‌a‌g‌e‌d‌_‌s‌o‌u‌n‌d‌_‌p‌i‌t‌c‌h.

It can be removed with b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d‌_‌m‌a‌n‌a‌g‌e‌r‌_‌r‌e‌m‌o‌v‌e. Note that a sound added inside a unique manager and deleted with b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌s‌o‌u‌n‌d will be automatically removed from its manager. Note it does not handle to be added into several manager, so you should avoid doing it at the same time.

Parameters


Return value

Return true if the sound was inserted or was already inserted. false on error.





INDEX


Description

     This function remove the sent sound from the sent sound manager.

A sound added inside a unique manager and deleted with b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌s‌o‌u‌n‌d will be automatically removed from its manager. Note it does not handle to be added into several manager, so you should avoid doing it at the same time.

Parameters





INDEX


Description

     Play the sent music that must be a registered music in the sent sound manager on the sent track. If it was already being played, it is left as it. If another music was being played on this track, it is stopped before. If no music was being played, the music simply start.

Parameters


Return value

Return true if the music is being played now or was already playing.




INDEX


Description

     Stop the music being played on the sent track.

Parameters




INDEX


Description

     Play the sent sound that must be a registered sound in the sent sound manager.

Parameters


Return value

Return true if the effect was found and played.




INDEX


Description

     Stop the sent sound that must be a registered sound in the sent sound manager.

Parameters




INDEX


Description

     Send the volume of the sent category to the sent level.

Parameters




INDEX


Description

     Send the pitch of the sent category to the sent level.

Parameters




INDEX


Description

     Set the volume of the sent sound to the given value considering the context. The computed value, which takes consideration of the proper volume, the global volume and the category volume will be stored inside the t‌_‌b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d itself.

Parameters


Return value

Return true if the effect was found and set.





INDEX


Description

     Set the pitch of the sent sound to the given value considering the context. The computed value, which takes consideration of the proper pitch, the global pitch and the category pitch will be stored inside the t‌_‌b‌u‌n‌n‌y‌_‌s‌o‌u‌n‌d itself.

Parameters


Return value

Return true if the effect was found and set.





INDEX