mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
SPU: Emulate SOUNDBIAS and 10-bit degrade
This commit is contained in:
25
src/SPU.cpp
25
src/SPU.cpp
@ -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;
|
||||
|
Reference in New Issue
Block a user