Audio.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: Beerware
7 #pragma once
8 
9 #include <SDL.h>
10 #include <SDL_mixer.h>
11 
18 typedef struct Audio_t
19 {
21  Uint16 u16AudioFormat;
22  Sint16 s16Channels;
23  Sint16 s16ChunkSize;
24 
25 } Audio;
26 
33 typedef struct Music_t
34 {
35  Mix_Music* pstMusic;
36  Sint8 s8Loops;
37 
38 } Music;
39 
40 void Audio_Free(Audio* pstAudio);
41 void Audio_FreeMusic(Music* pstMusic);
42 Sint8 Audio_Init(Audio** pstAudio);
43 Sint8 Audio_InitMusic(const char* pacFileName, const Sint8 s8Loops, Music** pstMusic);
44 Sint8 Audio_PlayMusic(const Uint16 u16FadeInMs, const Music* pstMusic);
Sint8 Audio_InitMusic(const char *pacFileName, const Sint8 s8Loops, Music **pstMusic)
Initialise music file.
Definition: Audio.c:111
Sint16 s16ChunkSize
Chunk size.
Definition: Audio.h:23
Sint8 s8Loops
Loop count.
Definition: Audio.h:36
struct Music_t Music
Music handle type.
void Audio_Free(Audio *pstAudio)
Free audio mixer.
Definition: Audio.c:21
Sint32 s32SamplingFrequency
Sampling frequency.
Definition: Audio.h:20
Sint16 s16Channels
Channels.
Definition: Audio.h:22
Uint16 u16AudioFormat
Audio format.
Definition: Audio.h:21
void Audio_FreeMusic(Music *pstMusic)
Free/Unload music file.
Definition: Audio.c:38
Audio mixer handle data.
Definition: Audio.h:18
Sint8 Audio_Init(Audio **pstAudio)
Initialise audio mixer.
Definition: Audio.c:62
Sint8 Audio_PlayMusic(const Uint16 u16FadeInMs, const Music *pstMusic)
Play music file.
Definition: Audio.c:144
void Audio_FreeMusic(Music *pstMusic)
Free/Unload music file.
Definition: Audio.c:38
Sint8 Audio_Init(Audio **pstAudio)
Initialise audio mixer.
Definition: Audio.c:62
Music handle data.
Definition: Audio.h:33
Sint8 Audio_InitMusic(const char *pacFileName, const Sint8 s8Loops, Music **pstMusic)
Initialise music file.
Definition: Audio.c:111
Sint8 Audio_PlayMusic(const Uint16 u16FadeInMs, const Music *pstMusic)
Play music file.
Definition: Audio.c:144
Audio handler include header.
struct Audio_t Audio
Audio mixer handle type.
Mix_Music * pstMusic
SDL2 music handle.
Definition: Audio.h:35
void Audio_Free(Audio *pstAudio)
Free audio mixer.
Definition: Audio.c:21