Code cleanup & changed max volume to 127

This commit is contained in:
NoHomoBoi 2020-06-12 03:22:08 -05:00
parent 56c6590bf3
commit 7c341334f0
6 changed files with 10 additions and 18 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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);

View file

@ -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[] = {

View file

@ -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 };

View file

@ -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;