AX: put each volume and its ramp delta into a dedicated struct (NFC)
This commit is contained in:
parent
83858e68d4
commit
f65b7066f5
|
@ -7,87 +7,45 @@
|
|||
|
||||
namespace DSP::HLE
|
||||
{
|
||||
struct VolumeData
|
||||
{
|
||||
u16 volume;
|
||||
u16 volume_delta;
|
||||
};
|
||||
|
||||
struct PBMixer
|
||||
{
|
||||
u16 main_left;
|
||||
u16 main_left_delta;
|
||||
u16 main_right;
|
||||
u16 main_right_delta;
|
||||
|
||||
u16 auxA_left;
|
||||
u16 auxA_left_delta;
|
||||
u16 auxA_right;
|
||||
u16 auxA_right_delta;
|
||||
|
||||
u16 auxB_left;
|
||||
u16 auxB_left_delta;
|
||||
u16 auxB_right;
|
||||
u16 auxB_right_delta;
|
||||
|
||||
u16 auxB_surround;
|
||||
u16 auxB_surround_delta;
|
||||
u16 main_surround;
|
||||
u16 main_surround_delta;
|
||||
u16 auxA_surround;
|
||||
u16 auxA_surround_delta;
|
||||
VolumeData main_left, main_right;
|
||||
VolumeData auxA_left, auxA_right;
|
||||
VolumeData auxB_left, auxB_right;
|
||||
// This somewhat strange-looking order of surround channels
|
||||
// allows the ucode to use the 2-channel IROM function mix_two_add()
|
||||
// when mixing (auxb_s and main_s) or (main_s and auxa_s).
|
||||
VolumeData auxB_surround;
|
||||
VolumeData main_surround;
|
||||
VolumeData auxA_surround;
|
||||
};
|
||||
|
||||
struct PBMixerWii
|
||||
{
|
||||
// volume mixing values in .15, 0x8000 = ca. 1.0
|
||||
u16 main_left;
|
||||
u16 main_left_delta;
|
||||
u16 main_right;
|
||||
u16 main_right_delta;
|
||||
|
||||
u16 auxA_left;
|
||||
u16 auxA_left_delta;
|
||||
u16 auxA_right;
|
||||
u16 auxA_right_delta;
|
||||
|
||||
u16 auxB_left;
|
||||
u16 auxB_left_delta;
|
||||
u16 auxB_right;
|
||||
u16 auxB_right_delta;
|
||||
|
||||
VolumeData main_left, main_right;
|
||||
VolumeData auxA_left, auxA_right;
|
||||
VolumeData auxB_left, auxB_right;
|
||||
// Note: the following elements usage changes a little in DPL2 mode
|
||||
// TODO: implement and comment it in the mixer
|
||||
u16 auxC_left;
|
||||
u16 auxC_left_delta;
|
||||
u16 auxC_right;
|
||||
u16 auxC_right_delta;
|
||||
|
||||
u16 main_surround;
|
||||
u16 main_surround_delta;
|
||||
u16 auxA_surround;
|
||||
u16 auxA_surround_delta;
|
||||
u16 auxB_surround;
|
||||
u16 auxB_surround_delta;
|
||||
u16 auxC_surround;
|
||||
u16 auxC_surround_delta;
|
||||
VolumeData auxC_left, auxC_right;
|
||||
VolumeData main_surround;
|
||||
VolumeData auxA_surround;
|
||||
VolumeData auxB_surround;
|
||||
VolumeData auxC_surround;
|
||||
};
|
||||
|
||||
struct PBMixerWM
|
||||
{
|
||||
u16 main0;
|
||||
u16 main0_delta;
|
||||
u16 aux0;
|
||||
u16 aux0_delta;
|
||||
|
||||
u16 main1;
|
||||
u16 main1_delta;
|
||||
u16 aux1;
|
||||
u16 aux1_delta;
|
||||
|
||||
u16 main2;
|
||||
u16 main2_delta;
|
||||
u16 aux2;
|
||||
u16 aux2_delta;
|
||||
|
||||
u16 main3;
|
||||
u16 main3_delta;
|
||||
u16 aux3;
|
||||
u16 aux3_delta;
|
||||
VolumeData main0, aux0;
|
||||
VolumeData main1, aux1;
|
||||
VolumeData main2, aux2;
|
||||
VolumeData main3, aux3;
|
||||
};
|
||||
|
||||
struct PBInitialTimeDelay
|
||||
|
|
|
@ -361,10 +361,10 @@ void GetInputSamples(PB_TYPE& pb, s16* samples, u16 count, const s16* coeffs)
|
|||
}
|
||||
|
||||
// Add samples to an output buffer, with optional volume ramping.
|
||||
void MixAdd(int* out, const s16* input, u32 count, u16* pvol, s16* dpop, bool ramp)
|
||||
void MixAdd(int* out, const s16* input, u32 count, VolumeData* vd, s16* dpop, bool ramp)
|
||||
{
|
||||
u16& volume = pvol[0];
|
||||
u16 volume_delta = pvol[1];
|
||||
u16& volume = vd->volume;
|
||||
u16 volume_delta = vd->volume_delta;
|
||||
|
||||
// If volume ramping is disabled, set volume_delta to 0. That way, the
|
||||
// mixing loop can avoid testing if volume ramping is enabled at each step,
|
||||
|
@ -411,8 +411,8 @@ 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)
|
||||
{
|
||||
samples[i] = std::clamp(((s32)samples[i] * pb.vol_env.cur_volume) >> 15, -32767,
|
||||
32767); // -32768 ?
|
||||
const s32 sample = ((s32)samples[i] * pb.vol_env.cur_volume) >> 15;
|
||||
samples[i] = std::clamp(sample, -32767, 32767); // -32768 ?
|
||||
pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue