-
Notifications
You must be signed in to change notification settings - Fork 3
darnit_sound.h
A handle to a loaded sound resource. This would be either streamed from disk, or preloaded and rendrered to raw pcm data before playback, which is chosen when the resource is loaded. The latter option is recommended for sound effects where latency matters. Please note that there's a limited, hardcoded amount of playback channels. In the current version (v.0.2 beta,) this is set to 16.
- DARNIT_SOUND *d_sound_tracked_load(const char *fname, DARNIT_AUDIO_MODE mode, DARNIT_AUDIO_CHANNELS channels);
- DARNIT_SOUND *d_sound_streamed_load(const char *fname, DARNIT_AUDIO_MODE mode, DARNIT_AUDIO_CHANNELS channels);
- DARNIT_SOUND *d_sound_unload(DARNIT_SOUND *sound_resource);
- void d_sound_stop_all();
- void d_sound_stop(int playback_key);
- int d_sound_play(DARNIT_SOUND *sound_resource, int loop, int vol_l, int vol_r, int jmpto);
- int d_sound_playback_status(int playback_key);
- void d_sound_playback_volume_set(unsigned int playback_key, int vol_l, int vol_r);
- void d_sound_mix_callback_set(void (*callback)(void *ignore, void *mixdata, int bytes));
- void d_sound_compression_enable();
- void d_sound_compression_disable();
Sets the playback mode when loading an audio resource.
typedef enum {
DARNIT_AUDIO_PRELOAD = 0,
DARNIT_AUDIO_STREAM = 1,
} DARNIT_AUDIO_MODE;If set to preload, the entire sound file is loaded and rendered to raw PCM into RAM (this uses ca. 172 kB per second of audio for stereo sound, or half that for mono.) Use this for sound effects, as latency matters more than memory usage, but don't use it for music.
Selects the number of channels to use for playback. This does not make a difference on the amount of playback slots it uses.
typedef enum {
DARNIT_AUDIO_MONO = 1,
DARNIT_AUDIO_STEREO = 2,
} DARNIT_AUDIO_CHANNELS;If stereo is selected for a mono file or vice versa, the audio stream is converted to the desired channel count. If the file is streamed from disk, this will add some overhead when going from stereo->mono, but not when going from mono->sterero, as duplicating a channel is faster than decoding one.