Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // in src/audio/external.c (above play_music in my case)
- void set_sequence_player_volume(s32 player, f32 volume) {
- gSequencePlayers[player].volumeScale = volume;
- }
- // in src/game/sound_init.c (above thread4_sound)
- #define MAX_VOLUME 127
- unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME
- unsigned int configMusicVolume = MAX_VOLUME;
- unsigned int configSfxVolume = MAX_VOLUME;
- unsigned int configEnvVolume = MAX_VOLUME;
- void change_audio_volumes(void) {
- const f32 master_mod = (f32)configMasterVolume / 127.0f;
- set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * master_mod);
- set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
- set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);
- }
- // in thread4_sound, change_audio_volumes() is called at the bottom of while (TRUE) like this
- void thread4_sound(UNUSED void *arg) {
- audio_init();
- sound_init();
- // Zero-out unused vector
- vec3f_copy(unused80339DC0, gVec3fZero);
- osCreateMesgQueue(&sSoundMesgQueue, sSoundMesgBuf, ARRAY_COUNT(sSoundMesgBuf));
- set_vblank_handler(1, &sSoundVblankHandler, &sSoundMesgQueue, (OSMesg) 512);
- while (TRUE) {
- OSMesg msg;
- osRecvMesg(&sSoundMesgQueue, &msg, OS_MESG_BLOCK);
- if (gResetTimer < 25) {
- struct SPTask *spTask;
- profiler_log_thread4_time();
- spTask = create_next_audio_frame_task();
- if (spTask != NULL) {
- dispatch_audio_sptask(spTask);
- }
- profiler_log_thread4_time();
- }
- #ifdef TARGET_N64 // TODO: save to EEPROM
- change_audio_volumes();
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement