From ccf7c66588501a090ab25003f3d646b22c03b243 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 20 May 2014 17:18:01 +0100 Subject: [PATCH] Sample shift up after volume macs no longer done in audio(). Now done in mixer(). This allows lower bits to be properly retained for 32bit (and DSD native) --- module_usb_audio/audio.xc | 8 +------- module_usb_audio/mixer/mixer.xc | 11 +++++++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/module_usb_audio/audio.xc b/module_usb_audio/audio.xc index debf9695..36c57a0a 100755 --- a/module_usb_audio/audio.xc +++ b/module_usb_audio/audio.xc @@ -261,9 +261,6 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out, unsigned divide, unsi for(int i = 0; i < NUM_USB_CHAN_OUT; i++) { int tmp = inuint(c_out); -#if defined(OUT_VOLUME_IN_MIXER) && defined(OUT_VOLUME_AFTER_MIX) - tmp<<=3; -#endif samplesOut[i] = tmp; } } @@ -451,9 +448,6 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out, unsigned divide, unsi for(int i = 0; i < NUM_USB_CHAN_OUT; i++) { int tmp = inuint(c_out); -#if defined(OUT_VOLUME_IN_MIXER) && defined(OUT_VOLUME_AFTER_MIX) - tmp<<=3; -#endif samplesOut[i] = tmp; } } @@ -542,7 +536,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out, unsigned divide, unsi } else if(dsdMode == DSD_MODE_DOP) { - if(!everyOther) + if(!everyOther) { dsdSample_l = ((samplesOut[0] & 0xffff00) << 8); dsdSample_r = ((samplesOut[1] & 0xffff00) << 8); diff --git a/module_usb_audio/mixer/mixer.xc b/module_usb_audio/mixer/mixer.xc index 04723ddc..f85aefe9 100644 --- a/module_usb_audio/mixer/mixer.xc +++ b/module_usb_audio/mixer/mixer.xc @@ -214,7 +214,10 @@ static void getSamplesFromHost(chanend c, xc_ptr samples, int base, unsigned und read_via_xc_ptr_indexed(mult, multOut, i); {h, l} = macs(mult, sample, 0, 0); h<<=3; - +#if (STREAM_FORMAT_OUTPUT_RESOLUTION_32BIT_USED == 1) + h |= (l >>29)& 0x7; // Note: This step is not required if we assume sample depth is 24bit (rather than 32bit) + // Note: We need all 32bits for Native DSD +#endif write_via_xc_ptr_indexed(multOut, index, val); write_via_xc_ptr_indexed(samples,base+i,h); #else @@ -248,7 +251,11 @@ static void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr mu #warning OUT Vols in mixer, AFTER mix & map read_via_xc_ptr_indexed(mult, multOut, i); {h, l} = macs(mult, sample, 0, 0); - //h <<= 3 done in audio thread + h<<=3; // Shift used to be done in audio thread but now done here incase of 32bit support +#if (STREAM_FORMAT_OUTPUT_RESOLUTION_32BIT_USED == 1) + h |= (l >>29)& 0x7; // Note: This step is not required if we assume sample depth is 24bit (rather than 32bit) + // Note: We need all 32bits for Native DSD +#endif outuint(c, h); #else outuint(c, sample);