forked from jaildesigner-jailgames/jaildoctors_dilemma
102 lines
2.1 KiB
C++
102 lines
2.1 KiB
C++
#ifdef JA_USESDLMIXER
|
|
#include "jail_audio.h"
|
|
#include <SDL2/SDL.h>
|
|
#include <SDL2/SDL_mixer.h>
|
|
#include <stdio.h>
|
|
|
|
struct JA_Sound_t {}; // Dummy structs
|
|
struct JA_Music_t {};
|
|
|
|
int JA_freq {48000};
|
|
SDL_AudioFormat JA_format {AUDIO_S16};
|
|
Uint8 JA_channels {2};
|
|
|
|
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
|
|
JA_freq = freq;
|
|
JA_format = format;
|
|
JA_channels = channels;
|
|
Mix_OpenAudio(JA_freq, JA_format, JA_channels, 1024);
|
|
}
|
|
|
|
void JA_Quit() {
|
|
Mix_CloseAudio();
|
|
}
|
|
|
|
JA_Music_t *JA_LoadMusic(const char* filename) {
|
|
return (JA_Music_t*)Mix_LoadMUS(filename);
|
|
}
|
|
|
|
void JA_PlayMusic(JA_Music_t *music, const int loop) {
|
|
Mix_PlayMusic((Mix_Music*)music, loop);
|
|
}
|
|
|
|
void JA_PauseMusic() {
|
|
Mix_PauseMusic();
|
|
}
|
|
|
|
void JA_ResumeMusic() {
|
|
Mix_ResumeMusic();
|
|
}
|
|
|
|
void JA_StopMusic() {
|
|
Mix_HaltMusic();
|
|
}
|
|
|
|
JA_Music_state JA_GetMusicState() {
|
|
if (Mix_PausedMusic()) {
|
|
return JA_MUSIC_PAUSED;
|
|
} else if (Mix_PlayingMusic()) {
|
|
return JA_MUSIC_PLAYING;
|
|
} else {
|
|
return JA_MUSIC_STOPPED;
|
|
}
|
|
}
|
|
|
|
void JA_DeleteMusic(JA_Music_t *music) {
|
|
Mix_FreeMusic((Mix_Music*)music);
|
|
}
|
|
|
|
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
|
|
return NULL;
|
|
}
|
|
|
|
JA_Sound_t *JA_LoadSound(const char* filename) {
|
|
JA_Sound_t *sound = (JA_Sound_t*)Mix_LoadWAV(filename);
|
|
return sound;
|
|
}
|
|
|
|
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
|
|
return Mix_PlayChannel(-1, (Mix_Chunk*)sound, loop);
|
|
}
|
|
|
|
void JA_DeleteSound(JA_Sound_t *sound) {
|
|
Mix_FreeChunk((Mix_Chunk*)sound);
|
|
}
|
|
|
|
void JA_PauseChannel(const int channel) {
|
|
Mix_Pause(channel);
|
|
}
|
|
|
|
void JA_ResumeChannel(const int channel) {
|
|
Mix_Resume(channel);
|
|
}
|
|
|
|
void JA_StopChannel(const int channel) {
|
|
Mix_HaltChannel(channel);
|
|
}
|
|
|
|
JA_Channel_state JA_GetChannelState(const int channel) {
|
|
if (Mix_Paused(channel)) {
|
|
return JA_CHANNEL_PAUSED;
|
|
} else if (Mix_Playing(channel)) {
|
|
return JA_CHANNEL_PLAYING;
|
|
} else {
|
|
return JA_CHANNEL_FREE;
|
|
}
|
|
}
|
|
|
|
int JA_SetVolume(int volume) {
|
|
return Mix_Volume(-1, volume);
|
|
}
|
|
#endif
|