xmos / lib_xua

XMOS USB Audio
Other
17 stars 13 forks source link

Rate control for "hybrid" configuration of vf incorrect #27

Closed ed-xmos closed 6 years ago

ed-xmos commented 6 years ago

In the case where USB rate is 16k and audio rate 48k (AUD_TO_USB_RATIO=3), userBufferManagement is called at too slow a rate (16k instead of 48k).

The issue is the call to DoSampleTransfer https://github.com/xmos/lib_xua/blob/master/lib_xua/src/core/audiohub/xua_audiohub.xc#L792 is guarded by audioToUsbRatioCounter. However UserBufferManagement is called in DoSampleTransfer so will be called at the USB rate, not the audio rate for the hybrid config.

This should be able to fixed by putting the ((AUD_TO_USB_RATIO - 1) == audioToUsbRatioCounter) check in DoSampleTransfer around the communication with decouple() and leaving userBufferManagement to be called at the audio rate.

ed-xmos commented 6 years ago

I have made an initial attempt at fixing this. I think this addresses the lib_xua issue but it does not work in sw_vocalfusion.

@larry-xmos I think the next issue is that USB_TO_BECLEAR_RATIO controls both downsampling of the AEC ref and upsampling of the processed mics. For the hybrid config to work, these defines need to be separated into two controls.

xross commented 6 years ago

Replied on https://github.com/xmos/sw_vocalfusion/issues/221

When AUD_TO_USB_RATIO is used the down-sampling in xua_audiohub should be invoked - meaning that the data passed to DoSampleTransfer() is pre-downsampled and this running at the "USB Rate" (i.e. 16khz) is the right thing to do. Think lib_xua is okay. I believe issue lies in sw_vocalfusion makefile/config

@larry-xmos I think the next issue is that USB_TO_BECLEAR_RATIO controls both downsampling of >the AEC ref and upsampling of the processed mics. For the hybrid config to work, these defines need >to be separated into two controls.

The first change has caused this issue - USB_TO_BECLEAR_RATIO should be 1 and thus no up-sampling should invoked.