SPU: Emulate SOUNDBIAS and 10-bit degrade

This commit is contained in:
Nadia Holmquist Pedersen
2021-08-16 23:47:54 +02:00
parent d5a20ad3c8
commit 418b351986
9 changed files with 83 additions and 2 deletions

View File

@ -81,6 +81,8 @@ Platform::Mutex* AudioLock;
u16 Cnt;
u8 MasterVolume;
u16 Bias;
bool ApplyBias;
bool Degrade10Bit;
Channel* Channels[16];
CaptureUnit* Capture[2];
@ -190,6 +192,14 @@ void SetBias(u16 bias)
Bias = bias;
}
void SetApplyBias(bool enable) {
ApplyBias = enable;
}
void SetDegrade10Bit(bool enable) {
Degrade10Bit = enable;
}
Channel::Channel(u32 num)
{
@ -795,6 +805,21 @@ void Mix(u32 dummy)
if (rightoutput < -0x8000) rightoutput = -0x8000;
else if (rightoutput > 0x7FFF) rightoutput = 0x7FFF;
// The original DS and DS lite degrade the output from 16 to 10 bit before output
if (Degrade10Bit)
{
leftoutput &= 0xFFFFFFC0;
rightoutput &= 0xFFFFFFC0;
}
// Add SOUNDBIAS value
// The value used by all commercial games is 0x200, so we subtract that so it won't offset the final sound output.
if (ApplyBias == true)
{
leftoutput += (Bias << 6) - 0x8000;
rightoutput += (Bias << 6) - 0x8000;
}
// OutputBufferFrame can never get full because it's
// transfered to OutputBuffer at the end of the frame
OutputBackbuffer[OutputBackbufferWritePosition ] = leftoutput >> 1;