mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-09 14:08:58 +01:00
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
|
namespace DSP::HLE
|
||||||
{
|
{
|
||||||
|
struct VolumeData
|
||||||
|
{
|
||||||
|
u16 volume;
|
||||||
|
u16 volume_delta;
|
||||||
|
};
|
||||||
|
|
||||||
struct PBMixer
|
struct PBMixer
|
||||||
{
|
{
|
||||||
u16 main_left;
|
VolumeData main_left, main_right;
|
||||||
u16 main_left_delta;
|
VolumeData auxA_left, auxA_right;
|
||||||
u16 main_right;
|
VolumeData auxB_left, auxB_right;
|
||||||
u16 main_right_delta;
|
// This somewhat strange-looking order of surround channels
|
||||||
|
// allows the ucode to use the 2-channel IROM function mix_two_add()
|
||||||
u16 auxA_left;
|
// when mixing (auxb_s and main_s) or (main_s and auxa_s).
|
||||||
u16 auxA_left_delta;
|
VolumeData auxB_surround;
|
||||||
u16 auxA_right;
|
VolumeData main_surround;
|
||||||
u16 auxA_right_delta;
|
VolumeData auxA_surround;
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PBMixerWii
|
struct PBMixerWii
|
||||||
{
|
{
|
||||||
// volume mixing values in .15, 0x8000 = ca. 1.0
|
VolumeData main_left, main_right;
|
||||||
u16 main_left;
|
VolumeData auxA_left, auxA_right;
|
||||||
u16 main_left_delta;
|
VolumeData auxB_left, auxB_right;
|
||||||
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;
|
|
||||||
|
|
||||||
// Note: the following elements usage changes a little in DPL2 mode
|
// Note: the following elements usage changes a little in DPL2 mode
|
||||||
// TODO: implement and comment it in the mixer
|
// TODO: implement and comment it in the mixer
|
||||||
u16 auxC_left;
|
VolumeData auxC_left, auxC_right;
|
||||||
u16 auxC_left_delta;
|
VolumeData main_surround;
|
||||||
u16 auxC_right;
|
VolumeData auxA_surround;
|
||||||
u16 auxC_right_delta;
|
VolumeData auxB_surround;
|
||||||
|
VolumeData auxC_surround;
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PBMixerWM
|
struct PBMixerWM
|
||||||
{
|
{
|
||||||
u16 main0;
|
VolumeData main0, aux0;
|
||||||
u16 main0_delta;
|
VolumeData main1, aux1;
|
||||||
u16 aux0;
|
VolumeData main2, aux2;
|
||||||
u16 aux0_delta;
|
VolumeData main3, aux3;
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PBInitialTimeDelay
|
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.
|
// 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 = vd->volume;
|
||||||
u16 volume_delta = pvol[1];
|
u16 volume_delta = vd->volume_delta;
|
||||||
|
|
||||||
// If volume ramping is disabled, set volume_delta to 0. That way, the
|
// 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,
|
// 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.
|
// Apply a global volume ramp using the volume envelope parameters.
|
||||||
for (u32 i = 0; i < count; ++i)
|
for (u32 i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
samples[i] = std::clamp(((s32)samples[i] * pb.vol_env.cur_volume) >> 15, -32767,
|
const s32 sample = ((s32)samples[i] * pb.vol_env.cur_volume) >> 15;
|
||||||
32767); // -32768 ?
|
samples[i] = std::clamp(sample, -32767, 32767); // -32768 ?
|
||||||
pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta;
|
pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user