Skip to content

Commit

Permalink
BASS for SFX: Added more Dreamcast-like 2D volume control (experiment…
Browse files Browse the repository at this point in the history
…al). This fixes the water sound at the end of EV0002 (Sonic beats Chaos 0).
  • Loading branch information
PiKeyAr committed Feb 7, 2025
1 parent a3739ed commit ec93185
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion SADXModLoader/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,20 @@ static void __cdecl IsndVolume_r(int vol, int handleno)
auto channel = bass_channels[handleno];
if (channel)
{
BASS_ChannelSetAttribute(channel, BASS_ATTRIB_VOL, SEVolume / 100.0f * ((float)(min(127, vol) + 127) / 254.0f));
// Old volume formula
//BASS_ChannelSetAttribute(channel, BASS_ATTRIB_VOL, SEVolume / 100.0f * ((float)(min(127, vol) + 127) / 254.0f));

// This is what the Dreamcast version does according to decompiled code.
// It also resolves the problem with -100 still being audible, which wasn't the case on DC.
if (vol > 0)
vol = vol / 6;
vol += 106; // To make it add up to 127 when the original non-divided value is 127? Lol
if (vol < 0)
vol = 0;
else if (vol > 127)
vol = 127;
// SEVolume divided by 166 here instead of 100 to adjust for the overall volume increase with the new formula, otherwise it's really loud.
BASS_ChannelSetAttribute(channel, BASS_ATTRIB_VOL, ((SEVolume / 166.0f) * (float)vol)/127.0f);
}
}

Expand Down

0 comments on commit ec93185

Please sign in to comment.