Merge pull request #12301 from Tilka/ax_volume

AX: fix envelope volume for Wii ucodes
This commit is contained in:
Admiral H. Curtiss 2023-11-17 18:18:16 +01:00 committed by GitHub
commit dc0814ae46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -424,7 +424,14 @@ void ProcessVoice(PB_TYPE& pb, const AXBuffers& buffers, u16 count, AXMixControl
// Apply a global volume ramp using the volume envelope parameters.
for (u32 i = 0; i < count; ++i)
{
const s32 sample = ((s32)samples[i] * pb.vol_env.cur_volume) >> 15;
#ifdef AX_GC
// signed on GameCube
const s32 volume = (s16)pb.vol_env.cur_volume;
#else
// unsigned on Wii
const s32 volume = (u16)pb.vol_env.cur_volume;
#endif
const s32 sample = ((s32)samples[i] * volume) >> 15;
samples[i] = std::clamp(sample, -32767, 32767); // -32768 ?
pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta;
}