Made AudioHandler volumes more consistent + added tests to avoid weird settings

origin/fixingSettings
thmaillarb 3 years ago
parent bbee7397a9
commit d6d95a8a22

@ -1,11 +1,11 @@
// #include "../test/testTextureLoader.c"
// #include "../test/testFontLoader.c"
// #include "../test/testAudioHandler.c"
#include "../test/testAudioHandler.c"
// #include "../test/testGenerateurTexture.c"
//#include "../test/testGameInterface.c"
//#include "../test/testConnectionMenu.c"
//#include "../test/testDrawMainMenu.c
#include "../test/testSettingsView.c"
//#include "../test/testSettingsView.c"
//#include "../test/testCreationMenu.c"
//#include "../test/testGameInterface.c"
//#include "../test/testConnectionMenu.c"
@ -18,7 +18,7 @@
int main(int argc, char *argv[]) {
//testTextureLoader();
//testAudioHandler();
testAudioHandler();
//testFontLoader();
//testGenerateurTexture();
//testTextInput();
@ -30,7 +30,7 @@ int main(int argc, char *argv[]) {
//testConnectionMenu();
//testDrawMainMenu();
//testCreationMenu();
testSettingsView();
// testSettingsView();
return 0;
}

@ -92,19 +92,25 @@ AudioHandler newAudioHandler(int masterVol, int volMusic, int volSFX) {
}
void changeMusicVol(AudioHandler* ah, int volMusic) {
if (volMusic > 10) volMusic = 10;
if (volMusic < 0) volMusic = 0;
ah->volMusic = volMusic;
Mix_VolumeMusic(ah->volMusic * ah->masterVol * 0.1);
Mix_VolumeMusic(ah->volMusic * ah->masterVol);
}
void changeSFXVol(AudioHandler* ah, int volSFX) {
if (volSFX > 10) volSFX = 10;
if (volSFX < 0) volSFX = 0;
ah->volSFX = volSFX;
Mix_Volume(-1, ah->volSFX * ah->masterVol * 0.1);
Mix_Volume(-1, ah->volSFX * ah->masterVol);
}
void changeMasterVol(AudioHandler* ah, int masterVol) {
if (masterVol > 10) masterVol = 10;
if (masterVol < 0) masterVol = 0;
ah->masterVol = masterVol;
Mix_VolumeMusic(ah->volMusic * ah->masterVol * 0.1);
Mix_Volume(-1, ah->volSFX * ah->masterVol * 0.1);
Mix_VolumeMusic(ah->volMusic * ah->masterVol);
Mix_Volume(-1, ah->volSFX * ah->masterVol);
}
void freeAudioHandler(AudioHandler* audioHandler) {

@ -10,7 +10,7 @@ void testAudioHandler(void) {
exit(errno);
}
AudioHandler ah = newAudioHandler(100, 100);
AudioHandler ah = newAudioHandler(10, 10, 10);
if (ah.canPlayAudio == false) {
perror("AudioHandler");
SDL_Quit();
@ -61,13 +61,13 @@ void testAudioHandler(void) {
printf("Playing louder (vol = 128) the SFX, testing with SFX_testClick\n");
changeSFXVol(128);
changeSFXVol(&ah, 128);
playSFX(SFX_testClick, ah);
SDL_Delay(2000);
printf("Playing quieter (vol = 10) the SFX, testing with SFX_testClick\n");
changeSFXVol(10);
changeSFXVol(&ah, 1);
playSFX(SFX_testClick, ah);
SDL_Delay(2000);

Loading…
Cancel
Save