phantasia

Phantasia - 2D SDL3 RPG prototype.
git clone git://git.beep.wimdupont.com/phantasia.git
Log | Files | Refs | README | LICENSE

audio.h (1077B)


      1 #ifndef PH_ENGINE_AUDIO_H
      2 #define PH_ENGINE_AUDIO_H
      3 
      4 typedef struct {
      5 	const char *path;
      6 	float gain;
      7 } PhAudioDef;
      8 
      9 float ph_audio_distance_gain(float listener_x, float listener_y,
     10 	float source_x, float source_y, float max_distance);
     11 
     12 #if PH_USE_SDL
     13 #include <SDL3/SDL.h>
     14 
     15 enum { PH_AUDIO_CLIP_MAX = 64, PH_AUDIO_EFFECT_VOICES = 8 };
     16 
     17 typedef struct {
     18 	SDL_AudioSpec spec;
     19 	Uint8 *data;
     20 	Uint32 length;
     21 	float gain;
     22 } PhAudioClip;
     23 
     24 typedef struct {
     25 	SDL_AudioDeviceID device;
     26 	SDL_AudioStream *music_stream;
     27 	SDL_AudioStream *effect_streams[PH_AUDIO_EFFECT_VOICES];
     28 	SDL_AudioSpec device_spec;
     29 	PhAudioClip clips[PH_AUDIO_CLIP_MAX];
     30 	int clip_count;
     31 	int music_id;
     32 	int music_enabled;
     33 	int effects_enabled;
     34 	int next_effect_voice;
     35 } PhAudio;
     36 
     37 int ph_audio_init(PhAudio *audio, const PhAudioDef *defs, int count);
     38 void ph_audio_music(PhAudio *audio, int id);
     39 void ph_audio_effect(PhAudio *audio, int id, float gain);
     40 void ph_audio_set_enabled(PhAudio *audio, int music, int effects);
     41 void ph_audio_update(PhAudio *audio);
     42 void ph_audio_destroy(PhAudio *audio);
     43 #endif
     44 
     45 #endif