1 /* Copyright (C) 2010-2018 The RetroArch team 2 * 3 * --------------------------------------------------------------------------------------- 4 * The following license statement only applies to this file (audio_mixer.h). 5 * --------------------------------------------------------------------------------------- 6 * 7 * Permission is hereby granted, free of charge, 8 * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation the rights to 10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #ifndef __LIBRETRO_SDK_AUDIO_MIXER__H 24 #define __LIBRETRO_SDK_AUDIO_MIXER__H 25 26 #include <stdint.h> 27 #include <stddef.h> 28 #include <stdlib.h> 29 30 #ifdef HAVE_CONFIG_H 31 #include "config.h" 32 #endif 33 34 #include <boolean.h> 35 #include <retro_common_api.h> 36 37 RETRO_BEGIN_DECLS 38 39 enum audio_mixer_type 40 { 41 AUDIO_MIXER_TYPE_NONE = 0, 42 AUDIO_MIXER_TYPE_WAV, 43 AUDIO_MIXER_TYPE_OGG, 44 AUDIO_MIXER_TYPE_MOD, 45 AUDIO_MIXER_TYPE_FLAC, 46 AUDIO_MIXER_TYPE_MP3 47 }; 48 49 typedef struct audio_mixer_sound audio_mixer_sound_t; 50 typedef struct audio_mixer_voice audio_mixer_voice_t; 51 52 typedef void (*audio_mixer_stop_cb_t)(audio_mixer_sound_t* sound, unsigned reason); 53 54 /* Reasons passed to the stop callback. */ 55 #define AUDIO_MIXER_SOUND_FINISHED 0 56 #define AUDIO_MIXER_SOUND_STOPPED 1 57 #define AUDIO_MIXER_SOUND_REPEATED 2 58 59 void audio_mixer_init(unsigned rate); 60 61 void audio_mixer_done(void); 62 63 audio_mixer_sound_t* audio_mixer_load_wav(void *buffer, int32_t size); 64 audio_mixer_sound_t* audio_mixer_load_ogg(void *buffer, int32_t size); 65 audio_mixer_sound_t* audio_mixer_load_mod(void *buffer, int32_t size); 66 audio_mixer_sound_t* audio_mixer_load_flac(void *buffer, int32_t size); 67 audio_mixer_sound_t* audio_mixer_load_mp3(void *buffer, int32_t size); 68 69 void audio_mixer_destroy(audio_mixer_sound_t* sound); 70 71 audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, 72 bool repeat, float volume, audio_mixer_stop_cb_t stop_cb); 73 74 void audio_mixer_stop(audio_mixer_voice_t* voice); 75 76 float audio_mixer_voice_get_volume(audio_mixer_voice_t *voice); 77 78 void audio_mixer_voice_set_volume(audio_mixer_voice_t *voice, float val); 79 80 void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bool override); 81 82 RETRO_END_DECLS 83 84 #endif 85