From 7c341334f0d8e78ac585b16c1b9d35dba0c143d3 Mon Sep 17 00:00:00 2001 From: NoHomoBoi <36680385+KiritoDv@users.noreply.github.com> Date: Fri, 12 Jun 2020 03:22:08 -0500 Subject: [PATCH] Code cleanup & changed max volume to 127 --- src/audio/external.c | 14 ++------------ src/audio/external.h | 2 +- src/audio/seqplayer.h | 1 + src/game/options_menu.c | 2 +- src/pc/configfile.c | 2 +- src/pc/pc_main.c | 7 ++++--- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/audio/external.c b/src/audio/external.c index 4c37f8ad..9f28ec32 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -2062,18 +2062,8 @@ void play_dialog_sound(u8 dialogID) { #endif } -void setBackgroundMusicVolume(f32 volume){ - bool needsToUpdate = false; - for(int i = 0; i < 16; i++){ - f32 currentVolume = gSequencePlayers[SEQ_PLAYER_LEVEL].channels[i]->volume; - if(volume != currentVolume){ - gSequencePlayers[SEQ_PLAYER_LEVEL].channels[i]->volume = volume; - needsToUpdate = true; - } - } - if(needsToUpdate){ - update_game_sound(); - } +void setBackgroundMusicVolume(s32 volume){ + func_8031D838(SEQ_PLAYER_LEVEL, 0, volume); } void play_music(u8 player, u16 seqArgs, u16 fadeTimer) { diff --git a/src/audio/external.h b/src/audio/external.h index 2cc97b1f..ef902a51 100644 --- a/src/audio/external.h +++ b/src/audio/external.h @@ -37,7 +37,7 @@ void sound_banks_disable(u8 player, u16 bankMask); void sound_banks_enable(u8 player, u16 bankMask); void func_80320A4C(u8 bankIndex, u8 arg1); void play_dialog_sound(u8 dialogID); -void setBackgroundMusicVolume(f32 volume); +void setBackgroundMusicVolume(s32 volume); void play_music(u8 player, u16 seqArgs, u16 fadeTimer); void stop_background_music(u16 seqId); void fadeout_background_music(u16 arg0, u16 fadeOut); diff --git a/src/audio/seqplayer.h b/src/audio/seqplayer.h index 7d91faeb..005b5193 100644 --- a/src/audio/seqplayer.h +++ b/src/audio/seqplayer.h @@ -9,6 +9,7 @@ void sequence_channel_disable(struct SequenceChannel *seqPlayer); void sequence_player_disable(struct SequencePlayer* seqPlayer); void audio_list_push_back(struct AudioListItem *list, struct AudioListItem *item); void *audio_list_pop_back(struct AudioListItem *list); +void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume); void process_sequences(s32 iterationsRemaining); void init_sequence_player(u32 player); void init_sequence_players(void); diff --git a/src/game/options_menu.c b/src/game/options_menu.c index b82d6a22..660a6d4f 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -260,7 +260,7 @@ static struct Option optsVideo[] = { static struct Option optsAudio[] = { DEF_OPT_SCROLL( optsAudioStr[0], &configMasterVolume, 0, MAX_VOLUME, 1 ), - DEF_OPT_SCROLL( optsAudioStr[1], &configMusicVolume, 0, 100, 1), + DEF_OPT_SCROLL( optsAudioStr[1], &configMusicVolume, 0, MAX_VOLUME, 1), }; static struct Option optsCheats[] = { diff --git a/src/pc/configfile.c b/src/pc/configfile.c index a3055f73..6a6b6bd4 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -51,7 +51,7 @@ ConfigWindow configWindow = { }; unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME -unsigned int configMusicVolume = 100; +unsigned int configMusicVolume = MAX_VOLUME; // Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse) unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 }; diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 3db52ed1..8843930f 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -73,6 +73,9 @@ void send_display_list(struct SPTask *spTask) { void produce_one_frame(void) { gfx_start_frame(); + + setBackgroundMusicVolume((s32)configMusicVolume); + game_loop_one_iteration(); thread6_rumble_loop(NULL); @@ -87,9 +90,7 @@ void produce_one_frame(void) { u32 num_audio_samples = audio_cnt < 2 ? 528 : 544;*/ create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples); } - //printf("Audio samples before submitting: %d\n", audio_api->buffered()); - - setBackgroundMusicVolume(configMusicVolume / 100.0); + //printf("Audio samples before submitting: %d\n", audio_api->buffered()); // scale by master volume (0-127) const s32 mod = (s32)configMasterVolume;