USB Audio Class Example

nRF5 SDK v15.2.0

This information applies to the nRF52840 SoC only.

This example uses the USB audio class module . See the documentation of this module for links to relevant specification documents.

This example shows how to declare and register two audio class instances to the USB library:

  • Headphones audio class (2 channel, Fs=48Khz, 16bit PCM format)
  • Microphone audio class (2 channel, Fs=48Khz, 16bit PCM format)

Both classes will enumerate as separate devices. Input audio stream (headphones) is passed to the output audio stream (microphone).

Page-1 Sheet.251 Process.245 Host Host Process.231 Device Device Dynamic connector Dynamic connector.246 Headphones stream Headphones stream Dynamic connector.247 Dynamic connector.248 Dynamic connector.249 Microphone stream Microphone stream Dynamic connector.250
Input and output audio streams

Setup

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\usbd_audio

LED assignments:

  • LED 1 shows the USB bus state:
    • ON: State RESUME
    • OFF: State SUSPEND
  • LED 2 shows the USB device library status:
    • ON: USB library STARTED
    • OFF: USB library STOPPED
  • LED 3 shows that a USB audio stream frame has been received:
    • TOGGLE - New frame received
  • LED 4 shows that a USB audio stream frame has been transmitted:
    • TOGGLE - New frame transmitted

Testing

Test the USB Audio Class Example application by performing the following steps:

  1. Compile and program the application.
  2. Connect the development kit to the host computer.
  3. Choose "nRF52 USB Audio Demo" headphones as a default audio output device.
  4. Choose "nRF52 USB Audio Demo" microphone as a default audio input device.
  5. Start audio streaming, for example by playing an audio file on your PC.
  6. Start audio recording.
  7. Verify the recorded audio stream.