Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
sound_chef.h File Reference

A wrapper library for miniaudio that emulates functionality of FMOD. More...

#include "sound_chef_common.h"
#include "sound_chef_dsp.h"
Include dependency graph for sound_chef.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

sc_result SC_API sc_system_create (sc_system **outSystem)
 Creates a new System object.
 
sc_result SC_API sc_system_release (sc_system *system)
 Releases the system memory.
 
sc_result SC_API sc_system_log_init (sc_system *system, ma_log_callback_proc logCallback)
 Sets up logging.
 
sc_result SC_API sc_system_init (sc_system *system)
 Initialises the system.
 
sc_result SC_API sc_system_close (sc_system *system)
 Closes the system.
 
sc_result SC_API sc_system_create_sound (sc_system *system, const char *fileName, sc_sound_mode mode, sc_sound **sound)
 
sc_result SC_API sc_system_play_sound (sc_system *system, sc_sound *sound, sc_sound_instance **instance, sc_node_group *parent, sc_bool paused)
 Plays a sound and returns the playing instance.
 
sc_result SC_API sc_system_create_node_group (sc_system *system, sc_node_group **nodeGroup)
 Creates a new Node Group.
 
sc_result SC_API sc_system_create_dsp (sc_system *system, const sc_dsp_config *config, sc_dsp **dsp)
 Creates a new DSP based on the config.
 
sc_result SC_API sc_sound_release (sc_sound *sound)
 
sc_result SC_API sc_sound_instance_is_playing (sc_sound_instance *instance, sc_bool *isPlaying)
 
sc_result SC_API sc_sound_instance_release (sc_sound_instance *instance)
 
sc_dsp_config SC_API sc_dsp_config_init (sc_dsp_type type)
 Returns a valid sc_dsp_config object for the DSP type.
 
sc_result SC_API sc_dsp_get_parameter_float (sc_dsp *dsp, int index, float *value)
 
sc_result SC_API sc_dsp_set_parameter_float (sc_dsp *dsp, int index, float value)
 
sc_result SC_API sc_dsp_release (sc_dsp *dsp)
 
sc_result SC_API sc_node_group_set_volume (sc_node_group *nodeGroup, float volume)
 
sc_result SC_API sc_node_group_get_volume (sc_node_group *nodeGroup, float *volume)
 
sc_result SC_API sc_node_group_set_parent (sc_node_group *nodeGroup, sc_node_group *parent)
 
sc_result SC_API sc_node_group_add_dsp (sc_node_group *nodeGroup, sc_dsp *dsp, sc_dsp_index index)
 
sc_result SC_API sc_node_group_remove_dsp (sc_node_group *nodeGroup, sc_dsp *dsp)
 
sc_result SC_API sc_node_group_release (sc_node_group *nodeGroup)
 

Detailed Description

A wrapper library for miniaudio that emulates functionality of FMOD.

The low level engine powering Sound Bakery.

Function Documentation

◆ sc_dsp_config_init()

sc_dsp_config SC_API sc_dsp_config_init ( sc_dsp_type  type)

Returns a valid sc_dsp_config object for the DSP type.

Warning
Will not return a valid config if the type == SC_DSP_TYPE_UNKOWN.

FUNCTIONS

◆ sc_system_close()

sc_result SC_API sc_system_close ( sc_system system)

Closes the system.

Disconnects the system from the user's audio device and stops all sounds.

◆ sc_system_create()

sc_result SC_API sc_system_create ( sc_system **  outSystem)

Creates a new System object.

See also
sc_system_init sc_system_release

◆ sc_system_create_dsp()

sc_result SC_API sc_system_create_dsp ( sc_system system,
const sc_dsp_config config,
sc_dsp **  dsp 
)

Creates a new DSP based on the config.

Warning
The config parameter must have its vtable pointer set. Using sc_dsp_config_init will ensure the vtable is correct for built in types. However, users must fill it themselves for custom DSP types.

Example:

sc_dsp* dsp = NULL;
sc_dsp_config lpfConfig = sc_dsp_config_init(SC_DSP_TYPE_LOWPASS);
sc_system_create_dsp(system, &lpfConfig, &dsp);
sc_dsp_config SC_API sc_dsp_config_init(sc_dsp_type type)
Returns a valid sc_dsp_config object for the DSP type.
Definition sound_chef_dsp.c:192
sc_result SC_API sc_system_create_dsp(sc_system *system, const sc_dsp_config *config, sc_dsp **dsp)
Creates a new DSP based on the config.
Definition sound_chef.c:412
Definition sound_chef_common.h:140
ma_node with an additional enum descriptor.
Definition sound_chef_common.h:152
See also
sc_dsp_config_init

◆ sc_system_create_node_group()

sc_result SC_API sc_system_create_node_group ( sc_system system,
sc_node_group **  nodeGroup 
)

Creates a new Node Group.

Creates a new Node Group with a SC_DSP_TYPE_FADER by default (for handling volume, pitch etc.). Connects to the endpoint by default.

Todo:
Check for memory allocation failure

◆ sc_system_init()

sc_result SC_API sc_system_init ( sc_system system)

Initialises the system.

Initializes the ma_engine and therefore the ma_device. This makes the system connect to the user's audio device and is then ready for playing sounds.

◆ sc_system_log_init()

sc_result SC_API sc_system_log_init ( sc_system system,
ma_log_callback_proc  logCallback 
)

Sets up logging.

Must be called before sc_system_init.

◆ sc_system_play_sound()

sc_result SC_API sc_system_play_sound ( sc_system system,
sc_sound sound,
sc_sound_instance **  instance,
sc_node_group parent,
sc_bool  paused 
)

Plays a sound and returns the playing instance.

Internally, the function copies the passed in sound to the instance. This doesn't copy the internal audio data but rather the runtime parameters like play position etc. This gives us a new ma_sound we can attach into the node graph.

Parameters
systemsystem object
soundto copy to the instance
instanceof the new sound for playing
parentoptional parameter. Outputs to the master node group by default
pausedwhether this sound is paused upon creation or played instantly
Returns

◆ sc_system_release()

sc_result SC_API sc_system_release ( sc_system system)

Releases the system memory.

See also
sc_system_close sc_system_create