diff --git a/Source/APU/2A03.cpp b/Source/APU/2A03.cpp index ad75845a..71de9cc2 100644 --- a/Source/APU/2A03.cpp +++ b/Source/APU/2A03.cpp @@ -198,16 +198,16 @@ int C2A03::GetChannelLevelRange(int Channel) const } -void C2A03::UpdateMixingAPU1(double v) { +void C2A03::UpdateMixingAPU1(double v, bool UseSurveyMix) { // NSFPlay output waveform ranges from 0 - 8191 - // should not affect legacy mixing - Synth2A03SS.volume(v, 8191); + // legacy mixing absolutely requires the range 10000 + Synth2A03SS.volume(v, UseSurveyMix ? 8191 : 10000); } -void C2A03::UpdateMixingAPU2(double v) { +void C2A03::UpdateMixingAPU2(double v, bool UseSurveyMix) { // NSFPlay output waveform ranges from 0 - 8191 - // should not affect legacy mixing - Synth2A03TND.volume(v, 8191); + // legacy mixing absolutely requires the range 10000 + Synth2A03TND.volume(v, UseSurveyMix ? 8191 : 10000); } void C2A03::ClockSequence() diff --git a/Source/APU/2A03.h b/Source/APU/2A03.h index 08ebb3ff..38a03586 100644 --- a/Source/APU/2A03.h +++ b/Source/APU/2A03.h @@ -99,8 +99,8 @@ class C2A03 : public CSoundChip2 int GetChannelLevelRange(int Channel) const override; public: - void UpdateMixingAPU1(double v); - void UpdateMixingAPU2(double v); + void UpdateMixingAPU1(double v, bool UseSurveyMix = false); + void UpdateMixingAPU2(double v, bool UseSurveyMix = false); void ClockSequence(); // // // diff --git a/Source/APU/FDS.cpp b/Source/APU/FDS.cpp index 230c3b13..9a8451c5 100644 --- a/Source/APU/FDS.cpp +++ b/Source/APU/FDS.cpp @@ -232,12 +232,7 @@ void CFDS::UpdateMixLevel(double v, bool UseSurveyMix) // (m_SynthFDS: FdsAudio) used to generate output samples between [0..63] inclusive, // but was changed to [0 .. 63*1152] inclusive to prevent quantization at low volumes. - if (UseSurveyMix) - m_SynthFDS.volume(v, 63 * 1152); - else - // The following mixing levels match nsfplay's FDS output, - // using 2A03 Pulse as a baseline. - m_SynthFDS.volume(v * 1.122f, 256 * 1152); + m_SynthFDS.volume(UseSurveyMix ? v : (v * 1.122f), UseSurveyMix ? (63 * 1152) : (256 * 1152)); } /// Input: diff --git a/Source/APU/Mixer.cpp b/Source/APU/Mixer.cpp index 42985d38..37f2885d 100644 --- a/Source/APU/Mixer.cpp +++ b/Source/APU/Mixer.cpp @@ -148,7 +148,7 @@ void CMixer::SetChipLevel(chip_level_t Chip, float Level) float CMixer::GetAttenuation(bool UseSurveyMix) const { - float Attenuation = 1.0f; + float ATTENUATION_2A03 = 1.0f; if (!UseSurveyMix) { const float ATTENUATION_VRC6 = 0.80f; @@ -161,22 +161,17 @@ float CMixer::GetAttenuation(bool UseSurveyMix) const // Increase headroom if some expansion chips are enabled if (m_iExternalChip & SNDCHIP_VRC6) - Attenuation *= ATTENUATION_VRC6; - + ATTENUATION_2A03 *= ATTENUATION_VRC6; if (m_iExternalChip & SNDCHIP_VRC7) - Attenuation *= ATTENUATION_VRC7; - + ATTENUATION_2A03 *= ATTENUATION_VRC7; if (m_iExternalChip & SNDCHIP_FDS) - Attenuation *= ATTENUATION_FDS; - + ATTENUATION_2A03 *= ATTENUATION_FDS; if (m_iExternalChip & SNDCHIP_MMC5) - Attenuation *= ATTENUATION_MMC5; - + ATTENUATION_2A03 *= ATTENUATION_MMC5; if (m_iExternalChip & SNDCHIP_N163) - Attenuation *= ATTENUATION_N163; - + ATTENUATION_2A03 *= ATTENUATION_N163; if (m_iExternalChip & SNDCHIP_S5B) // // // 050B - Attenuation *= ATTENUATION_S5B; + ATTENUATION_2A03 *= ATTENUATION_S5B; } else { // attenuation scaling is exponential based on total chips used @@ -188,10 +183,10 @@ float CMixer::GetAttenuation(bool UseSurveyMix) const if (m_iExternalChip & SNDCHIP_N163) TotalChipsUsed++; if (m_iExternalChip & SNDCHIP_S5B) TotalChipsUsed++; - Attenuation *= static_cast(1.0 / (float)TotalChipsUsed); + ATTENUATION_2A03 *= static_cast(1.0 / (float)TotalChipsUsed); } - return Attenuation; + return ATTENUATION_2A03; } void CMixer::RecomputeEmuMixState() @@ -229,8 +224,8 @@ void CMixer::RecomputeEmuMixState() // Maybe the range argument, as well as the constant factor in the volume, // should be supplied by the CSoundChip2 subclass rather than CMixer. - chip2A03.UpdateMixingAPU1(Volume * m_fLevelAPU1); - chip2A03.UpdateMixingAPU2(Volume * m_fLevelAPU2); + chip2A03.UpdateMixingAPU1(Volume * m_fLevelAPU1, UseSurveyMixing); + chip2A03.UpdateMixingAPU2(Volume * m_fLevelAPU2, UseSurveyMixing); chipFDS.UpdateMixLevel(Volume * m_fLevelFDS, UseSurveyMixing); chipN163.UpdateMixLevel(Volume * m_fLevelN163, UseSurveyMixing); diff --git a/Source/APU/VRC7.cpp b/Source/APU/VRC7.cpp index 880304ea..b86b80f8 100644 --- a/Source/APU/VRC7.cpp +++ b/Source/APU/VRC7.cpp @@ -203,7 +203,7 @@ void CVRC7::UpdateMixLevel(double v, bool UseSurveyMix) SetDirectVolume(UseSurveyMix ? v : (v * AMPLIFY)); // emu2413's waveform output ranges from -4095...4095 - m_SynthVRC7.volume(v, 8191); + m_SynthVRC7.volume(v, UseSurveyMix ? 8191 : 10000); } void CVRC7::UpdatePatchSet(int PatchSelection, bool UseExternalOPLLChip, uint8_t* PatchSet)