parent
fcf2395d1d
commit
8cf39bb99e
@ -1,32 +0,0 @@
|
|||||||
#include "engine/Audio.h"
|
|
||||||
#include <SDL2/SDL_mixer.h>
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
void testAudio(void) {
|
|
||||||
char path1[] = "../rsrc/music/testMus.mp3";
|
|
||||||
char path2[] = "../rsrc/music/base_tardi.mp3";
|
|
||||||
Mix_Music* music = NULL;
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_AUDIO) != 0) {
|
|
||||||
perror("SDL");
|
|
||||||
exit(errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Mix_OpenAudio(44100,MIX_DEFAULT_FORMAT,MIX_DEFAULT_CHANNELS,1024) != 0) {
|
|
||||||
SDL_Quit();
|
|
||||||
perror("SDL Mixer");
|
|
||||||
exit(errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
switchMusic(music,path1);
|
|
||||||
SDL_Delay(5000);
|
|
||||||
switchMusic(music,path2);
|
|
||||||
SDL_Delay(5000);
|
|
||||||
|
|
||||||
Mix_FreeMusic(music);
|
|
||||||
SDL_Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
#include "engine/AudioHandler.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
void testAudioHandler(void) {
|
||||||
|
if (SDL_Init(SDL_INIT_AUDIO) != 0) {
|
||||||
|
perror("SDL");
|
||||||
|
exit(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioHandler ah = newAudioHandler(100, 100);
|
||||||
|
if (ah.canPlayAudio == false) {
|
||||||
|
perror("AudioHandler");
|
||||||
|
SDL_Quit();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("AudioHandler created!\n");
|
||||||
|
|
||||||
|
printf("Now (normally) playing base_tardi...\n");
|
||||||
|
playMusic(MUSIC_base_tardi, ah);
|
||||||
|
|
||||||
|
SDL_Delay(2000);
|
||||||
|
|
||||||
|
printf("Switching to testMus\n");
|
||||||
|
playMusic(MUSIC_testMus, ah);
|
||||||
|
|
||||||
|
SDL_Delay(5000);
|
||||||
|
|
||||||
|
printf("Playing SFX");
|
||||||
|
|
||||||
|
playSFX(SFX_testClick, ah);
|
||||||
|
|
||||||
|
SDL_Delay(1000);
|
||||||
|
|
||||||
|
printf("Freeing AudioHandler\n");
|
||||||
|
freeAudioHandler(&ah);
|
||||||
|
|
||||||
|
if (ah.canPlayAudio == true) {
|
||||||
|
printf("Failed to free AudioHandler!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue