summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTortuga veloz <danielcampora@outlook.es>2025-03-12 14:20:31 +0100
committerAlejandro Asenjo Nitti <96613413+sonicdcer@users.noreply.github.com>2025-03-24 02:50:18 -0400
commit638616a67e1cd824e6cec48113b7544f9934e8d0 (patch)
tree1f7b6624f5b647b1909d8197653c064876e60969
parent86fd2b43752c654dd7dd1b3f9baad30d6f5715bf (diff)
Fix music playback. Attempt at fixing reverb.
-rw-r--r--.gitmodules2
-rw-r--r--src/audio/audio_playback.c15
-rw-r--r--src/audio/audio_synthesis.c9
-rw-r--r--src/audio/mixer.c7
4 files changed, 17 insertions, 16 deletions
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]++;
}
}