Config for Unicast Client (Gateway) and Unicast Server (Headset) with Bidirectional Audio

Hi, 

I'm trying to set up two nRF5340 Audio boards - one as a unicast client (gateway) and the other as a unicast server (headset). I have seperate config files for both that essentially are the clones of the prj.conf file from the samples, but have small changes specific to each board.

I am trying to evaluate the walkie-talkie demo with the below params: 

CONFIG_WALKIE_TALKIE_DEMO=y

CONFIG_AUDIO_SOURCE_I2S=y
Here i am using an external mic instead of the PDM onboard. But using this config, the board only transmits audio from Gateway to headset. I wanted to flip the direction of audio, from headset to gateway. How do i achieve it?
  • Hi,

    Unicast client with bidirectional audio:  You can enable this feature by setting the `CONFIG_STREAM_BIDIRECTIONAL` Kconfig option to `y` in the configuration file https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/nrf5340_audio/doc/configuration.html#selecting-the-cis-bidirectional-communication 

    Additionally, there's a walkie-talkie demo that showcases bidirectional audio streaming. This demo can be enabled by setting the `CONFIG_WALKIE_TALKIE_DEMO` Kconfig option to `y` https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/nrf5340_audio/doc/configuration.html#enabling-the-walkie-talkie-demo

    Regarding the bidirectional unicast server: Follow the instructions here https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/nrf5340_audio/unicast_server/README.html. The unicast server application implements the CIS headset mode. By default, it's set up for unidirectional communication, but it can be configured for bidirectional audio.

    To enable bidirectional audio for the unicast server, you need to modify the configuration as follows:

    1. Open the `applications/nrf5340_audio/prj.conf` file (for debug version) or `applications/nrf5340_audio/prj_release.conf` file (for release version).
    2. Set the `CONFIG_STREAM_BIDIRECTIONAL` Kconfig option to `y`.

    As stated inhttps://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/nrf5340_audio/doc/configuration.html#selecting-the-cis-bidirectional-communication:


    "To switch to the bidirectional mode, set the CONFIG_STREAM_BIDIRECTIONAL Kconfig option to y in the applications/nrf5340_audio/prj.conf file (for the debug version) or in the applications/nrf5340_audio/prj_release.conf file (for the release version)."

    In the bidirectional configuration, the headset device (unicast server) will send audio from the on-board PDM microphone, allowing for two-way communication between the server and client.

    Remember that to test this setup, you'll need at least three nRF5340 Audio Development Kits: one for the unicast client (gateway) and two for the unicast servers (headsets).

    Kind regards,
    Andreas

  • Hi Ahaug,

    Thanks for the response. As I have mentioned, my current config consists of the CONFIG_WALKIE_TALKIE_DEMO set to true. But with this param enabled, i cannot integrate an external Mic. It only works with PDM.

    I have also tried the other approach using CONFIG_STREAM_BIDIRECTIONAL. In this config setting, the external Mic does not work even after declaring it in config, Only PDM works: 

    CONFIG_STREAM_BIDIRECTIONAL=y
    CONFIG_AUDIO_SOURCE_I2S=y

    My end goal is to send audio from headset (client) to gateway (server) using the external mic on nrf5340 Audio DK kit.

  • Ah, yes, you're right. I see now that it does only support PDM. Apologies for mixing it up.

    I had a chat with some of our audio experts to understand this better. They summarized it as follows:

    What you need to do is to modify the data flow from PDM-mic -> HW-codec -> nRF5340 (I2S) to match how you've set it up with your external microphone. nrf5340_audio\src\modules\audio_i2s.c could be relevant for this. I'm assuming that your microphone is an I2S microphone, and in this case you don' have to use HW codec from the microphone to the SoC.

    I hope this is enough to get you started

    Kind regards,
    Andreas

  • My Mic is an external contact microphone (Analog). I wanted to use an external contact microphone instead of the pdm mic.

    I am not sure but this might be a bug. The hw_codec.c file consists of configuration for the gateway to set the config according to pdm mic or line-in mic, but there was no config for the headset.

    #if ((CONFIG_AUDIO_DEV == GATEWAY) && (CONFIG_AUDIO_SOURCE_I2S))
    if (IS_ENABLED(CONFIG_WALKIE_TALKIE_DEMO)) {
    ret = cs47l63_comm_reg_conf_write(pdm_mic_enable_configure,
    ARRAY_SIZE(pdm_mic_enable_configure));
    if (ret) {
    return ret;
    }
    } else {
    ret = cs47l63_comm_reg_conf_write(line_in_enable, ARRAY_SIZE(line_in_enable));
    if (ret) {
    return ret;
    }
    }
    #endif /* ((CONFIG_AUDIO_DEV == GATEWAY) && (CONFIG_AUDIO_SOURCE_I2S)) */
    
    #if ((CONFIG_AUDIO_DEV == HEADSET) && CONFIG_STREAM_BIDIRECTIONAL)
    
    if (IS_ENABLED(CONFIG_WALKIE_TALKIE_DEMO)){
    ret = cs47l63_comm_reg_conf_write(pdm_mic_enable_configure,
    ARRAY_SIZE(pdm_mic_enable_configure));
    if (ret){
    return ret;
    }
    } else {
    ret = cs47l63_comm_reg_conf_write(line_in_enable, ARRAY_SIZE(line_in_enable));
    if (ret){
    return ret;
    }
    }
    #endif /* ((CONFIG_AUDIO_DEV == HEADSET) && CONFIG_STREAM_BIDIRECTIONAL) */
    
    /* Toggle FLL to start up CS47L63 */
    ret = cs47l63_comm_reg_conf_write(FLL_toggle, ARRAY_SIZE(FLL_toggle));
    if (ret) {
    return ret;
    }
    
    return 0;
    }
    The above block of code is what i have added instead in function hw_codec_default_conf_enable() in hw_codec.c. 
  •  I think even if you call cs47l63_comm_reg_conf_write(pdm_mic_enable_configure,
    ARRAY_SIZE(pdm_mic_enable_configure)); in headset code, it is still using the on-board PDM mic, instead of your external mic.

    You said you are using an Analog external mic, I assue that would be similar to the 'Line-In' of the 5340 Audio DK, so you need to call cs47l63_comm_reg_conf_write(line_in_enable, ARRAY_SIZE(line_in_enable)); and also try to feed your Analog mic data to the line-in iterface of the on-board HW codec cs47l63.

Related