diff --git a/include/functions.h b/include/functions.h index 7a640e42ad..052acebb1c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1951,7 +1951,7 @@ void func_800F64E0(u8 arg0); void func_800F6584(u8 arg0); void Audio_SetEnvReverb(s8 reverb); void Audio_SetCodeReverb(s8 reverb); -void func_800F6700(s8 arg0); +void func_800F6700(s8 audioSetting); void Audio_SetBaseFilter(u8); void Audio_SetExtraFilter(u8); void Audio_SetCutsceneFlag(s8 flag); diff --git a/include/z64audio.h b/include/z64audio.h index 96b374db65..e83c155f79 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -24,6 +24,13 @@ #define AUDIO_RELOCATED_ADDRESS_START K0BASE +typedef enum { + /* 0 */ SOUNDMODE_STEREO, + /* 1 */ SOUNDMODE_HEADSET, + /* 2 */ SOUNDMODE_SURROUND, + /* 3 */ SOUNDMODE_MONO +} SoundMode; + typedef enum { /* 0 */ ADSR_STATE_DISABLED, /* 1 */ ADSR_STATE_INITIAL, diff --git a/src/code/audio_load.c b/src/code/audio_load.c index 00a246febf..c1ef5b947e 100644 --- a/src/code/audio_load.c +++ b/src/code/audio_load.c @@ -1168,7 +1168,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { gAudioContext.totalTaskCount = 0; gAudioContext.rspTaskIndex = 0; gAudioContext.curAiBufIndex = 0; - gAudioContext.soundMode = 0; + gAudioContext.soundMode = SOUNDMODE_STEREO; gAudioContext.curTask = NULL; gAudioContext.rspTask[0].task.t.data_size = 0; gAudioContext.rspTask[1].task.t.data_size = 0; diff --git a/src/code/audio_playback.c b/src/code/audio_playback.c index 8c032b8f26..030b9a888b 100644 --- a/src/code/audio_playback.c +++ b/src/code/audio_playback.c @@ -30,7 +30,7 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) { sub->bitField0.stereoStrongLeft = false; sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; - if (stereoHeadsetEffects && gAudioContext.soundMode == 1) { + if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_HEADSET)) { smallPanIndex = pan >> 1; if (smallPanIndex > 0x3F) { smallPanIndex = 0x3F; @@ -42,7 +42,7 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) { volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[0x7F - pan]; - } else if (stereoHeadsetEffects && gAudioContext.soundMode == 0) { + } else if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_STEREO)) { strongLeft = strongRight = 0; sub->headsetPanRight = 0; sub->headsetPanLeft = 0; @@ -79,7 +79,7 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) { break; } - } else if (gAudioContext.soundMode == 3) { + } else if (gAudioContext.soundMode == SOUNDMODE_MONO) { sub->bitField0.stereoHeadsetEffects = false; sub->bitField0.usesHeadsetPanEffects = false; volLeft = 0.707f; // approx 1/sqrt(2) diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c index 5a48f35e13..631014d096 100644 --- a/src/code/code_800EC960.c +++ b/src/code/code_800EC960.c @@ -122,7 +122,7 @@ f32 D_801305E4[4] = { 1.0f, 1.12246f, 1.33484f, 1.33484f }; // 2**({0, 2, 5, 5}/ f32 D_801305F4 = 1.0f; u8 sGanonsTowerLevelsVol[8] = { 127, 80, 75, 73, 70, 68, 65, 60 }; u8 sEnterGanonsTowerTimer = 0; -s8 D_80130604 = 2; +s8 sSoundMode = SOUNDMODE_SURROUND; s8 D_80130608 = 0; s8 sAudioCutsceneFlag = 0; s8 sSpecReverb = 0; @@ -3987,7 +3987,7 @@ void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx) { case BANK_ENV: case BANK_ENEMY: case BANK_VOICE: - if (D_80130604 == 2) { + if (sSoundMode == SOUNDMODE_SURROUND) { sp38 = func_800F3990(*entry->posY, entry->sfxParams); } FALLTHROUGH; @@ -3997,7 +3997,8 @@ void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx) { reverb = Audio_ComputeSoundReverb(bankId, entryIdx, channelIdx); panSigned = Audio_ComputeSoundPanSigned(*entry->posX, *entry->posZ, entry->token); freqScale = Audio_ComputeSoundFreqScale(bankId, entryIdx) * *entry->freqScale; - if (D_80130604 == 2) { + + if (sSoundMode == SOUNDMODE_SURROUND) { behindScreenZ = sBehindScreenZ[(entry->sfxParams & SFX_FLAG_10) >> SFX_FLAG_10_SHIFT]; if (!(entry->sfxParams & SFX_FLAG_11)) { if (*entry->posZ < behindScreenZ) { @@ -4023,7 +4024,7 @@ void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx) { if ((baseFilter | sAudioExtraFilter) != 0) { filter = (baseFilter | sAudioExtraFilter); - } else if (D_80130604 == 2 && !(entry->sfxParams & SFX_FLAG_13)) { + } else if ((sSoundMode == SOUNDMODE_SURROUND) && !(entry->sfxParams & SFX_FLAG_13)) { filter = func_800F37B8(behindScreenZ, entry, panSigned); } break; @@ -5010,29 +5011,32 @@ void Audio_SetCodeReverb(s8 reverb) { } } -void func_800F6700(s8 arg0) { - s8 sp1F; +void func_800F6700(s8 audioSetting) { + s8 soundModeIndex; - switch (arg0) { + switch (audioSetting) { case 0: - sp1F = 0; - D_80130604 = 0; + soundModeIndex = SOUNDMODE_STEREO; + sSoundMode = SOUNDMODE_STEREO; break; + case 1: - sp1F = 3; - D_80130604 = 3; + soundModeIndex = SOUNDMODE_MONO; + sSoundMode = SOUNDMODE_MONO; break; + case 2: - sp1F = 1; - D_80130604 = 1; + soundModeIndex = SOUNDMODE_HEADSET; + sSoundMode = SOUNDMODE_HEADSET; break; + case 3: - sp1F = 0; - D_80130604 = 2; + soundModeIndex = SOUNDMODE_STEREO; + sSoundMode = SOUNDMODE_SURROUND; break; } - Audio_SeqCmdE0(SEQ_PLAYER_BGM_MAIN, sp1F); + Audio_SeqCmdE0(SEQ_PLAYER_BGM_MAIN, soundModeIndex); } void Audio_SetBaseFilter(u8 filter) { @@ -5255,7 +5259,7 @@ void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId) { Audio_QueueSeqCmd(0x80000000 | (SEQ_PLAYER_BGM_MAIN << 24) | (port << 0x10) | (channelIdx << 8) | val); } - Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, CHANNEL_IO_PORT_7, NATURE_CHANNEL_UNK, D_80130604); + Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, CHANNEL_IO_PORT_7, NATURE_CHANNEL_UNK, sSoundMode); } } diff --git a/src/code/code_800F9280.c b/src/code/code_800F9280.c index b1d28d681d..a139b254f8 100644 --- a/src/code/code_800F9280.c +++ b/src/code/code_800F9280.c @@ -16,7 +16,12 @@ u8 sSeqCmdWrPos = 0; u8 sSeqCmdRdPos = 0; u8 D_80133408 = 0; u8 D_8013340C = 1; -u8 D_80133410[] = { 0, 1, 2, 3 }; +u8 sSoundModeList[] = { + SOUNDMODE_STEREO, + SOUNDMODE_HEADSET, + SOUNDMODE_SURROUND, + SOUNDMODE_MONO, +}; u8 gAudioSpecId = 0; u8 D_80133418 = 0; @@ -342,7 +347,7 @@ void Audio_ProcessSeqCmd(u32 cmd) { switch (subOp) { case 0: // set sound mode - Audio_QueueCmdS32(0xF0000000, D_80133410[val]); + Audio_QueueCmdS32(0xF0000000, sSoundModeList[val]); break; case 1: // set sequence starting disabled?