I am starting with Usb audio UAC2 on a RT1021 dev. board with "evkmimxrt1020_dev_composite_hid_audio_unified_freertos" example.
I managed to change the bit resolution to 24 bit or 32 bit instead of 16 bit default and I modified in "usb_device_descriptor.h" line to #define AUDIO_IN_SAMPLING_RATE_KHZ (96) to have 96000Hz sample rate but when I run the example my Linux still detects the dev board as a 48Khz sample rate one.
This happens only when I compile with #define USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 (1U) in "usb-device_config.h" header, instead, if I use #define USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 (0U) it shows correct 96000Hz sample rate.
There is a way to correct this when #define USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 (1U) changing any usb descriptor field when the board is an UAC2 device?
Using alsacap in Linux:
With #define USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 (1U):
Card 3, ID `DEMO', name `USB AUDIO+HID DEMO'
Device 0, ID `USB Audio', name `USB Audio', 1 subdevices (1 available)
2 channels, sampling rate 48000..48000 Hz
Sample formats: S24_3LE
Subdevice 0, name `subdevice #0'
With #define USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 (0U):
Card 3, ID `DEMO', name `USB AUDIO+HID DEMO'
Device 0, ID `USB Audio', name `USB Audio', 1 subdevices (1 available)
2 channels, sampling rate 96000..96000 Hz
Sample formats: S24_3LE
Subdevice 0, name `subdevice #0'
Jose.
Solved! Go to Solution.
Hi @Escalator2023,
In order to change the frequency with UAC2.0 you will need to modify these values as well in USB_DeviceAudioCompositeInit(). I just tried it and it is working on my side.
Please try it and tell me if it works for you.
Regards,
Daniel.
Yes, sample rate change works, thanks Daniel.
I only confirmed it with 16 bit stereo and different sample rates because with more bit resolution (like 24 or 32 bit) Linux cannot give me back the correct format when I plug it so I will check in a Windows computer to see if I need to change anything more for higher resolution work.
My target is 24/32 bit stereo at 96Khz. I modified these lines:
/* Audio data format */
#define AUDIO_OUT_FORMAT_CHANNELS (0x02U)
#define AUDIO_OUT_FORMAT_BITS (24)
#define AUDIO_OUT_FORMAT_SIZE (0x03)
#define AUDIO_IN_FORMAT_CHANNELS (0x02U)
#define AUDIO_IN_FORMAT_BITS (24)
#define AUDIO_IN_FORMAT_SIZE (0x03)
Hi,
I’m already taking a look into this. Please give me some time to get deeper in this.
Regard,
Daniel.
Hi @Escalator2023,
In order to change the frequency with UAC2.0 you will need to modify these values as well in USB_DeviceAudioCompositeInit(). I just tried it and it is working on my side.
Please try it and tell me if it works for you.
Regards,
Daniel.