diff --git a/.gitmodules b/.gitmodules index 53673b4b..a893b7a8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,4 +6,4 @@ url = https://github.com/HarbourMasters/Torch [submodule "libultraship"] path = libultraship - url = https://github.com/dcampora/libultraship.git + url = https://github.com/Kenix3/libultraship.git diff --git a/src/audio/audio_playback.c b/src/audio/audio_playback.c index b1c75dca..03d4b639 100644 --- a/src/audio/audio_playback.c +++ b/src/audio/audio_playback.c @@ -140,11 +140,8 @@ void Audio_InitNoteSub(Note* note, NoteAttributes* noteAttr) { } } else { // Surround 5.1 - const float vol_voice = 0.8f; - const float vol_music = 0.707f; - if (stereo.s.is_voice) { // VOICE - panVolumeCenter = vol_voice; + panVolumeCenter = 1.0f; } else if (stereo.s.is_sfx) { // SFX float pan_angle = (float)(pan + 64) / 128 * 2 * M_PI; @@ -164,13 +161,11 @@ void Audio_InitNoteSub(Note* note, NoteAttributes* noteAttr) { panVolumeRight = fmaxf(0, cosf(pan_angle - front_right)); // Front Right panVolumeRearLeft = fmaxf(0, cosf(pan_angle - rear_left)); // Rear Left panVolumeRearRight = fmaxf(0, cosf(pan_angle - rear_right)); // Rear Right - - // printf("pan: %d, pan_angle: %f, left: %f, right: %f, rleft: %f, rright: %f\n", pan, pan_angle, panVolumeLeft, panVolumeRight, panVolumeRearLeft, panVolumeRearRight); } else { // MUSIC - panVolumeLeft = vol_music; - panVolumeRight = vol_music; - panVolumeRearLeft = vol_music; - panVolumeRearRight = vol_music; + panVolumeLeft = gStereoPanVolume[pan]; + panVolumeRight = gStereoPanVolume[ARRAY_COUNT(gStereoPanVolume) - 1 - pan]; + panVolumeRearLeft = gStereoPanVolume[pan]; + panVolumeRearRight = gStereoPanVolume[ARRAY_COUNT(gStereoPanVolume) - 1 - pan]; } } diff --git a/src/audio/audio_synthesis.c b/src/audio/audio_synthesis.c index 5ad68b49..1558adfc 100644 --- a/src/audio/audio_synthesis.c +++ b/src/audio/audio_synthesis.c @@ -727,6 +727,11 @@ Acmd* AudioSynth_LoadReverbSamples(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s s16 sp62; s16 sp60; + u16 left_channel = DMEM_LEFT_CH; + if (GetNumAudioChannels() == 6) { + left_channel = DMEM_REAR_LEFT_CH; + } + aClearBuffer(aList++, DMEM_WET_LEFT_CH, DMEM_2CH_SIZE); if (gSynthReverbs[reverbIndex].downsampleRate == 1) { @@ -735,7 +740,7 @@ Acmd* AudioSynth_LoadReverbSamples(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s aList = AudioSynth_LoadRingBufferPart(aList, sp64->lengthA + DMEM_WET_LEFT_CH, 0, sp64->lengthB, reverbIndex); } - aAddMixer(aList++, DMEM_2CH_SIZE, DMEM_WET_LEFT_CH, DMEM_LEFT_CH); + aAddMixer(aList++, DMEM_2CH_SIZE, DMEM_WET_LEFT_CH, left_channel); aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH); } else { sp62 = (sp64->startPos & 7) * 2; @@ -751,7 +756,7 @@ Acmd* AudioSynth_LoadReverbSamples(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s aSetBuffer(aList++, 0, sp62 + DMEM_UNCOMPRESSED_NOTE, DMEM_WET_RIGHT_CH, aiBufLen * 2); aResample(aList++, gSynthReverbs[reverbIndex].resampleFlags, gSynthReverbs[reverbIndex].unk_0A, OS_K0_TO_PHYSICAL(gSynthReverbs[reverbIndex].unk_34)); - aAddMixer(aList++, DMEM_2CH_SIZE, DMEM_WET_LEFT_CH, DMEM_LEFT_CH); + aAddMixer(aList++, DMEM_2CH_SIZE, DMEM_WET_LEFT_CH, left_channel); aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH); } diff --git a/src/audio/mixer.c b/src/audio/mixer.c index a2b1798b..c2f9f3ea 100644 --- a/src/audio/mixer.c +++ b/src/audio/mixer.c @@ -710,9 +710,10 @@ void aEnvMixerImpl(uint16_t in_addr, uint16_t n_samples, bool swap_reverb, *dry[j] = clamp16(*dry[j] + samples[j]); dry[j]++; - if (j >= 4) { - // Apply reverb only to the rear channels (4 and 5) - *wet[j] = clamp16(*wet[j] + (samples[swapped[j % 2]] * vol_wet >> 16)); + if (j < 2) { + // Apply reverb only to the front stereo channels wet + // They will be mixed with the rear channels later + *wet[j] = clamp16(*wet[j] + (samples[swapped[j]] * vol_wet >> 16)); wet[j]++; } }