typedef struct s_bunny_sound
{
 
const char _private[
sizeof(
size_t)];
 
const char *
const file;
 
double volume;
 
double pitch;
 
bool loop;
 
double position[3];
 
double attenuation;
 
const bool playing;
 
const bool pause;
}
t_bunny_sound;
Description
  The sound structure is a partially abstract structure that
represents a loaded or a read sound.
It is a base structure for t_buny_effects and
t_bunny_music.
Any structure that could take a
t_bunny_sound can take any structure
based on it.
Attributes
-
const char _private[sizeof(size_t)]:
  Private fields you should edit or your program may crash.
-
const char * const file:
  The field from which the sound or music was extracted.
It is set to empty string ("") if the sound was created
with bunny_new_effect.
-
double volume:
  The volume, between 0 and 100, of the sound.
-
double pitch:
  The pitch, greater than 0 with a normal value that is 1, of the sound.
The pitch is the speed of the sound being played.
-
bool loop:
  true if you need to make this sound being repeated.
-
double position[3]:
  The relative 3D position of the sound. Being relative means
(0, 0, 0) is "on" the program user. Values to set here may vary
a lot depending of the attenuation value. With the default,
a distance from the origin of maximum 5 is a good choice.
-
double attenuation:
  The default sound attenuation. In combination with
the distance, it will decrease the sound volume. By
default, the attenuation is set to 5.
-
const bool playing:
  Is the sound being played?
-
const bool pause:
  Is the sound paused?
INDEX
Attributes
-
t_bunny_sound sound:
  The sound base.
-
const size_t sample_per_second:
  The duration of the music in seconds.
-
const double duration:
  The duration in seconds. Multiplied by sample_per_second
will give you the length of sample.
-
int16_t * const sample:
  A constant address to a writable area of *Ssample_per_second *
duration short signed int. Each case store a value which
compose the wave of the sound effect.
Modifications inside the sound effect will be computed
by calling bunny_compute_effect. If you do not call it before
playing, your modifications will be ignored.
INDEX
Description
  Open a music file and stream it when you play it, from a sound file or
a configuration file.
Delete the music file with
bunny_delete_sound when you do not
need it anymore.
Parameters
-
const char *file:
  The music file to open. Supported files are .wav and .ogg.
This function also support configuration file input. Configuration
file format is described below.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function or subfunctions may be tagged with
"ressource",
"configuration",
"syntax" or
"sound"
labels.
Configuration file format
You can set properties of a t_bunny_sound thanks to a file at runtime.
This allow you to get rid of a lot of configuration and to create space for
any outside editor.
INI format and complete field description
Mandatory field
-
RessourceFile is a single string that contains the address of a sound.
Usage:
RessourceFile="Sound file that will be loaded"
Optionnal fields
-
Volume is the volume of the sound. It should be an integer between 0 and 100.
Volume=42
-
Pitch is the accelleration of the sound. A pitch of 2 will shorter the
sound, but also make it more acute. A pitch of 0.5 will make it longer
and also more low. A single double is neccessary.
Pitch=3
-
Loop indicates if the sound must be play continuously or a single time.
A single integer is required, like 1, true, 0 or false.
Loop=true
-
Position indicates the position of the sound in space.
It is three double.
Position=X,Y,Y
-
Attenuation is how fast the sound decrease when going far away. It is a single
double. that should be between 0 and 10.
Attenuation=10
CSV format
The CSV format does not follow the same architecture as the INI one.
Here is its architecture:
"ressourcefile";"path_to_ressource_file"
"volume";volume
"pitch";pitch
"loop";loop
"position";x;y;z
"attenuation";attenuation
DABSIC format
The DABSIC format follow the same architecture as the INI one.
Here is its architecture:
RessourceFile="Sound file that will be loaded"
Volume=42
Pitch=3
Loop=true
{Position X, Y, Y }
Attenuation=10
XML format
Not documented yet.
LUA format
Not documented yet.
JSON format
Not documented yet.
LISP format
Not documented yet.
YAML format
There is no support for YAML yet.
INDEX
Parameters
-
double duration:
  The duration of the generated sound in seconds.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function or subfunctions may be tagged with
"ressource" or
"sound"
labels.
INDEX
Parameters
-
const char *file:
  The sound file to open. Supported files are .wav and .ogg.
This function also support configuration file input. Configuration
file format is described below.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function or subfunctions may be tagged with
"ressource",
"configuration",
"syntax" or
"sound"
labels.
Configuration file format
You can set properties of a t_bunny_sound thanks to a file at runtime.
This allow you to get rid of a lot of configuration and to create space for
any outside editor.
INI format and complete field description
Mandatory field
-
RessourceFile is a single string that contains the address of a sound.
Usage:
RessourceFile="Sound file that will be loaded"
Optionnal fields
-
Volume is the volume of the sound. It should be an integer between 0 and 100.
Volume=42
-
Pitch is the accelleration of the sound. A pitch of 2 will shorter the
sound, but also make it more acute. A pitch of 0.5 will make it longer
and also more low. A single double is neccessary.
Pitch=3
-
Loop indicates if the sound must be play continuously or a single time.
A single integer is required, like 1, true, 0 or false.
Loop=true
-
Position indicates the position of the sound in space.
It is three double.
Position=X,Y,Y
-
Attenuation is how fast the sound decrease when going far away. It is a single
double. that should be between 0 and 10.
Attenuation=10
CSV format
The CSV format does not follow the same architecture as the INI one.
Here is its architecture:
"ressourcefile";"path_to_ressource_file"
"volume";volume
"pitch";pitch
"loop";loop
"position";x;y;z
"attenuation";attenuation
DABSIC format
The DABSIC format follow the same architecture as the INI one.
Here is its architecture:
RessourceFile="Sound file that will be loaded"
Volume=42
Pitch=3
Loop=true
{Position X, Y, Y }
Attenuation=10
XML format
Not documented yet.
LUA format
Not documented yet.
JSON format
Not documented yet.
LISP format
Not documented yet.
YAML format
There is no support for YAML yet.
INDEX
Description
  Generate the sent sound effect in your sound card after what
you have written into its buffer.
Return value
Returns true on success.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function or subfunctions may be tagged with
"sound"
labels.
INDEX
Description
  Set if the sound loop or not.
INDEX
Description
  Set the sent position to the sent sound.
Parameters
-
t_bunny_sound *sound:
  The sound sound to modify.
-
double x:
  A coordinate to set.
-
double y:
  A coordinate to set.
-
double z:
  A coordinate to set.
INDEX
Description
  Set the sent position to the sent sound.
INDEX
Description
  Play the sent sound.
INDEX
Description
  Pause the sent sound.
INDEX
Description
  Stop the sent sound.
INDEX
Description
  Set the read cursor at the sent position in sound.
INDEX
Description
  Get the current read position of the sent sound.
Return value
Returns the position in seconds in the sound that match the currently being
read part.
INDEX
Description
  Get the duration of the sent sound.
Return value
Returns the length in seconds of the sound.
INDEX
Description
  Return true if the sent sound is being played right now.
Return value
Returns if the sound is being played right now or not.
INDEX
Description
  Delete the sent sound.
INDEX
k
Description
  In the bunny library, some bottom level ressources are shared. This means
that when you load several times the same sound effect, the sound effect
itself is only loaded once and then it is given to multiples holders.
Sometimes, you only base your work on a sound effect but plan to edit
it to create a new one... And editing it would edit all sounds played
by all other holders, so before doing it, you will need to call
bunny_make_effect_unique so your sound effect got duplicated and pulled
out the ressource manager.
In
t_bunny_sound_effect, shared parts are the private side of the mother
structure
t_bunny_sound and the
buffer field.
Return value
Return true if everything went well. false if instead it went wrong.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function or subfunctions may be tagged with
"sound"
labels.
INDEX