nrf5340 Stereo Audio output

Hello,

I am using nrf5340 module with external hardware audio codec to test stereo audio output.

I use nrf5340 module as the headset to connect with Pixel 7 mobile phone,and refer to this post,I modify the code to below:

static void audio_headset_configure(void)
{
	if (IS_ENABLED(CONFIG_SW_CODEC_LC3)) {
		sw_codec_cfg.sw_codec = SW_CODEC_LC3;
	} else {
		ERR_CHK_MSG(-EINVAL, "No codec selected");
	}

#if (CONFIG_STREAM_BIDIRECTIONAL)
	sw_codec_cfg.encoder.enabled = true;
	sw_codec_cfg.encoder.channel_mode = SW_CODEC_STEREO;

	if (IS_ENABLED(CONFIG_SW_CODEC_LC3)) {
		sw_codec_cfg.encoder.bitrate = CONFIG_LC3_BITRATE;
	} else {
		ERR_CHK_MSG(-EINVAL, "No codec selected");
	}
#endif /* (CONFIG_STREAM_BIDIRECTIONAL) */

	sw_codec_cfg.decoder.channel_mode = SW_CODEC_STEREO;
	sw_codec_cfg.decoder.enabled = true;
}

When playing audio,the noise is very serious.

Is there anything else that needs to be modified?

The nRF Connect SDK version I used is v2.2.0-rc1.

Parents
  • Hi, 

    Is it possible to provide the log from the headset? That would be very helpful for us to investigate the issue.

    Regards,
    Amanda H.

  • Hello Amanda,

    This is the RTT log from the headset.

    HL [00:00:00.253,540] <inf> fw_info: HEADSET left device
    HL [00:00:00.277,648] <wrn> bt_hci_core: Controller to host flow control not supported
    HL [00:00:00.280,761] <inf> bt_hci_core: No ID address. App must call settings_load()
    HL [00:00:00.280,822] <inf> ble: MAC: 00:00:00:00:00:00 (public)
    HL [00:00:00.281,372] <inf> ble: Controller version: 3310
    HL [00:00:00.377,166] <inf> cis_headset: Advertising successfully started
    HL [00:00:16.464,355] <inf> cis_headset: Connected: 75:0D:76:D9:5D:2F (random)
    HL [00:00:27.787,231] <inf> ble_audio_services: Volume = 193, mute state = 0
    HL [00:00:34.537,048] <inf> cis_headset: Codec config for LC3:
    HL [00:00:34.537,078] <inf> cis_headset: Frequency: 48000 Hz
    HL [00:00:34.537,078] <inf> cis_headset: Frame Duration: 10000 us
    HL [00:00:34.537,078] <inf> cis_headset: Channel allocation: 0x1
    HL [00:00:34.537,109] <inf> cis_headset: Octets per frame: 120 (96000 kbps)
    HL [00:00:34.537,109] <inf> cis_headset: Frames per SDU: 1
    HL [00:00:34.627,380] <inf> cis_headset: Presentation delay 4000 ms is set by initiator
    HL [00:00:34.716,979] <wrn> bt_ascs: CCID 2 is unknown
    HL [00:00:34.732,238] <wrn> audio_datapath: I2S RX overrun. Single msg
    HL [00:00:35.599,182] <inf> audio_datapath: Drft comp state: CALIB
    HL [00:00:35.601,135] <wrn> audio_datapath: Data received, total underruns: 876
    HL [00:00:35.699,157] <inf> audio_datapath: Drft comp state: OFFSET
    HL [00:00:35.732,147] <wrn> audio_datapath: Data received, total underruns: 877
    HL [00:00:35.943,084] <inf> audio_datapath: Drft comp state: LOCKED
    HL [00:00:35.948,699] <inf> audio_datapath: Pres comp state: MEAS
    HL [00:00:36.058,715] <inf> audio_datapath: Pres comp state: WAIT
    HL [00:00:36.158,691] <inf> audio_datapath: Pres comp state: INIT
    HL [00:00:36.168,701] <inf> audio_datapath: Pres comp state: MEAS
    HL [00:00:36.278,686] <inf> audio_datapath: Pres comp state: LOCKED
    HL [00:00:37.438,629] <inf> audio_datapath: sdu_ref_us not from consecutive frames
    HL [00:00:37.438,629] <inf> audio_datapath: Pres comp state: WAIT
    HL [00:00:37.440,948] <wrn> audio_datapath: Data received, total underruns: 887
    HL [00:00:37.528,625] <inf> audio_datapath: Pres comp state: INIT
    HL [00:00:37.538,604] <inf> audio_datapath: Pres comp state: MEAS
    HL [00:00:37.648,620] <inf> audio_datapath: Pres comp state: LOCKED
    HL [00:00:39.891,815] <wrn> audio_datapath: Data received, total underruns: 888

  • Hi, 

    LandyWang said:
    HL [00:00:34.537,078] <inf> cis_headset: Frequency: 48000 Hz
    HL [00:00:34.537,078] <inf> cis_headset: Frame Duration: 10000 us
    HL [00:00:34.537,078] <inf> cis_headset: Channel allocation: 0x1
    HL [00:00:34.537,109] <inf> cis_headset: Octets per frame: 120 (96000 kbps)
    HL [00:00:34.537,109] <inf> cis_headset: Frames per SDU: 1

    Seems that it only modified the headset for decoding the received packet in stereo mode. However, the Published Audio Capabilities Service (PACS) is not adjusted for that the headset supports 2 channels. And the default PACS in our project is for TWS topology, which means the headset will only accept one channel audio stream. So mobile phone sends a single-channel encoded frame to the headset, and the headset tries to decode it as stereo audio.

    LandyWang said:
    HL [00:00:34.537,078] <inf> cis_headset: Channel allocation: 0x1

    Mobile phone only sends left-channel data

    Here is a quick example, (CAUTION: no guarantee and no warranty, just for reference)

    https://github.com/rick1082/sdk-nrf/commit/70e89352cbc429c29ebe725a7af5ac9a562211d0#diff-42e1fc6ae4cf6357455296de58f9d6343fecd9b4da84da826d9fdf71e5e86eb8

    1. We have to expose that the support channel count is 2
    2. We have to expose that the support channel allocation is left and right

    -Amanda H

Reply
  • Hi, 

    LandyWang said:
    HL [00:00:34.537,078] <inf> cis_headset: Frequency: 48000 Hz
    HL [00:00:34.537,078] <inf> cis_headset: Frame Duration: 10000 us
    HL [00:00:34.537,078] <inf> cis_headset: Channel allocation: 0x1
    HL [00:00:34.537,109] <inf> cis_headset: Octets per frame: 120 (96000 kbps)
    HL [00:00:34.537,109] <inf> cis_headset: Frames per SDU: 1

    Seems that it only modified the headset for decoding the received packet in stereo mode. However, the Published Audio Capabilities Service (PACS) is not adjusted for that the headset supports 2 channels. And the default PACS in our project is for TWS topology, which means the headset will only accept one channel audio stream. So mobile phone sends a single-channel encoded frame to the headset, and the headset tries to decode it as stereo audio.

    LandyWang said:
    HL [00:00:34.537,078] <inf> cis_headset: Channel allocation: 0x1

    Mobile phone only sends left-channel data

    Here is a quick example, (CAUTION: no guarantee and no warranty, just for reference)

    https://github.com/rick1082/sdk-nrf/commit/70e89352cbc429c29ebe725a7af5ac9a562211d0#diff-42e1fc6ae4cf6357455296de58f9d6343fecd9b4da84da826d9fdf71e5e86eb8

    1. We have to expose that the support channel count is 2
    2. We have to expose that the support channel allocation is left and right

    -Amanda H

Children
Related