This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to change USB Audio class in ncs

Hi,

I'm trying the USB Audio in ncs .

dts is like below:

&usbd {
	compatible = "nordic,nrf-usbd";
	status = "okay";

	hs_0 {
		label = "HEADSET";
		compatible = "usb-audio-hs";
		mic-feature-mute;
		mic-channel-l;
		mic-channel-r;

		hp-feature-mute;
		hp-channel-l;
		hp-channel-r;
	};
};

And prj.conf:

CONFIG_USB_DEVICE_AUDIO=y and other USB relevant  defines.

It works,and  the usb audio  data size from PC in 1ms is 192 bytes.

This is equal to 48K sample rate and 16bit.

And how to change the sample rate and other usb audio class params?

Thanks.

Parents
  • Hi all

    I had the same problem (for many days), wanted 44.1kHz sampling rate in stead of the default 48kHz. With the hint from Andrej102 I changed the content of the usb_audio_internal.h file as follows:

    // fs = 48kHz version
    #define INIT_AS_FORMAT_I(ch_cnt, res)               \
    {                               \
        .bLength = sizeof(struct format_type_i_descriptor), \
        .bDescriptorType = USB_DESC_CS_INTERFACE,       \
        .bDescriptorSubtype = USB_AUDIO_FORMAT_TYPE,        \
        .bFormatType = 0x01,                    \
        .bNrChannels = MAX(1, ch_cnt),              \
        .bSubframeSize = res/8,                 \
        .bBitResolution = res,                  \
        .bSamFreqType = 1,                  \
        .tSamFreq = {0x80, 0xBB, 0x00},             \
    }
    */
    // fs= 44100Hz version
    #define INIT_AS_FORMAT_I(ch_cnt, res)               \
    {                               \
        .bLength = sizeof(struct format_type_i_descriptor), \
        .bDescriptorType = USB_DESC_CS_INTERFACE,       \
        .bDescriptorSubtype = USB_AUDIO_FORMAT_TYPE,        \
        .bFormatType = 0x01,                    \
        .bNrChannels = MAX(1, ch_cnt),              \
        .bSubframeSize = res/8,                 \
        .bBitResolution = res,                  \
        .bSamFreqType = 1,                  \
        .tSamFreq = {0x44, 0xAC, 0x00},         \
    }

    And it worked. Remember, in Windows, to delete the audio drivers under Audio inputs and outputs AND Sound, video and game controllers in Device manager between changes to make them take effect.

    Baldur

Reply
  • Hi all

    I had the same problem (for many days), wanted 44.1kHz sampling rate in stead of the default 48kHz. With the hint from Andrej102 I changed the content of the usb_audio_internal.h file as follows:

    // fs = 48kHz version
    #define INIT_AS_FORMAT_I(ch_cnt, res)               \
    {                               \
        .bLength = sizeof(struct format_type_i_descriptor), \
        .bDescriptorType = USB_DESC_CS_INTERFACE,       \
        .bDescriptorSubtype = USB_AUDIO_FORMAT_TYPE,        \
        .bFormatType = 0x01,                    \
        .bNrChannels = MAX(1, ch_cnt),              \
        .bSubframeSize = res/8,                 \
        .bBitResolution = res,                  \
        .bSamFreqType = 1,                  \
        .tSamFreq = {0x80, 0xBB, 0x00},             \
    }
    */
    // fs= 44100Hz version
    #define INIT_AS_FORMAT_I(ch_cnt, res)               \
    {                               \
        .bLength = sizeof(struct format_type_i_descriptor), \
        .bDescriptorType = USB_DESC_CS_INTERFACE,       \
        .bDescriptorSubtype = USB_AUDIO_FORMAT_TYPE,        \
        .bFormatType = 0x01,                    \
        .bNrChannels = MAX(1, ch_cnt),              \
        .bSubframeSize = res/8,                 \
        .bBitResolution = res,                  \
        .bSamFreqType = 1,                  \
        .tSamFreq = {0x44, 0xAC, 0x00},         \
    }

    And it worked. Remember, in Windows, to delete the audio drivers under Audio inputs and outputs AND Sound, video and game controllers in Device manager between changes to make them take effect.

    Baldur

Children
No Data
Related