From fe82b5ed65145aabf24f4c5825baa8b670c76b83 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 10 Jun 2022 02:14:04 -0700 Subject: [PATCH] [DSD] Reduce volume level of decimator output As the decimator has shown to be twice as loud as it should be, the volume should be reduced by half when converting DSD to PCM with it. Signed-off-by: Christopher Snowhill --- Audio/Chain/ConverterNode.mm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Audio/Chain/ConverterNode.mm b/Audio/Chain/ConverterNode.mm index c8ce36da2..ef722f391 100644 --- a/Audio/Chain/ConverterNode.mm +++ b/Audio/Chain/ConverterNode.mm @@ -783,6 +783,10 @@ tryagain: } if(inpOffset != inpSize && floatOffset == floatSize) { +#if DSD_DECIMATE + const float scaleModifier = (inputFormat.mBitsPerChannel == 1) ? 0.5f : 1.0f; +#endif + size_t inputSamples = (inpSize - inpOffset) / floatFormat.mBytesPerPacket; ioNumberPackets = (UInt32)inputSamples; @@ -864,7 +868,11 @@ tryagain: amountReadFromFC = (int)(outputDone * floatFormat.mBytesPerPacket); - scale_by_volume((float *)floatBuffer, amountReadFromFC / sizeof(float), volumeScale); + scale_by_volume((float *)floatBuffer, amountReadFromFC / sizeof(float), volumeScale +#if DSD_DECIMATE + * scaleModifier +#endif + ); floatSize = amountReadFromFC; floatOffset = 0;