From de29b11a88dbdd3af0824e59b51528b91ee73c54 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 30 Nov 2017 22:49:38 +0100 Subject: First commit. Version works on Linux (keyboard only, not configurable) --- src/psp/audio.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/psp/audio.c (limited to 'src/psp/audio.c') diff --git a/src/psp/audio.c b/src/psp/audio.c new file mode 100644 index 0000000..7b4242f --- /dev/null +++ b/src/psp/audio.c @@ -0,0 +1,87 @@ +#include "audio.h" +#include "../game.h" + +void PHL_AudioInit() +{ + oslInitAudio(); +} + +void PHL_AudioClose() +{ + oslDeinitAudio(); +} + +//Each system can use a custom music file format +OSL_SOUND* PHL_LoadMusic(char* fname, int loop) +{ + char stream = 0; + + OSL_SOUND* result = NULL; + + char fullPath[40]; + strcpy(fullPath, fname); + strcat(fullPath, ".bgm"); + + FILE* file; + + if ( (file = fopen(fullPath, "r")) ) { + fclose(file); + result = oslLoadSoundFile(fullPath, stream); + oslSetSoundLoop(result, loop); + } + + return result; +} + +OSL_SOUND* PHL_LoadSound(char* fname) +{ + char stream = 0; + + OSL_SOUND* result = NULL; + + char fullPath[40]; + strcpy(fullPath, fname); + + FILE* file; + + if ( (file = fopen(fullPath, "r")) ) { + fclose(file); + result = oslLoadSoundFile(fullPath, stream); + oslSetSoundLoop(result, 0); + } + + return result; +} + + +void PHL_PlayMusic(OSL_SOUND* snd) +{ + //Music always plays on the first channel + PHL_PlaySound(snd, 0); +} + +void PHL_PlaySound(OSL_SOUND* snd, int channel) +{ + if (snd) { + oslPlaySound(snd, channel); + } +} + +void PHL_StopMusic() +{ + PHL_StopSound(bgmMusic, 0); +} + +void PHL_StopSound(OSL_SOUND* snd, int channel) +{ + if (snd) { + oslStopSound(snd); + } +} + +void PHL_FreeSound(OSL_SOUND* snd) +{ + if (snd) { + oslDeleteSound(snd); + } +} \ No newline at end of file -- cgit v1.2.3