Bluetooth LE Audio - STM32WBA LC3 Codec

Revision as of 17:05, 3 August 2023 by Registered User
Under construction.png Coming soon

1. STM32WBA LC3 Codec

The LC3 codec is an algorithm allowing to compress audio data for transmitting over the air.

This codec must be supported by any application build over the Generic Audio Framework and BLE 5.2 isochronous feature. It runs channel independently, has a complexity similar to Opus, and can be used for either voice and music with a better quality.

1.1. LC3 configuration

BLE profile configures an LC3 session defined by:

  • The sampling frequency : 8, 16, 24, 32 ,44.1 or 48 kHz
  • The frame duration : 7.5 or 10ms

The frame duration varies a little with 44.1 kHz, refers to LC3 specification for details

Then it also configures each channels referring to the session with additional information:

  • The mode : encoding or decoding
  • The PCM sample width : 16, 24 or 32 bits
  • The bitrate within a list of recommended bitrates

The LC3 supports bitrate updates, but BLE profiles don't use this feature

Also, the ST LC3 codec embed a Packet Loss Concealment algorithm based on the annex B of the LC3 specification. This algorithm ensure signal continuity and reduced glitches in cases of corrupted/missing packet and is triggered by either an external indicator BFI or an internal frame analysis.

Picture data flow

At the encoder side, the data flow if the following

  • Data Input
    • PCM signal buffered into an Nf samples per channel, this size is linked to the frame duration and frequency.
    • For example, 10ms frame at 32kHz leads to 320 samples
  • Data Output
    • An encoded buffer per frame per channel of size Nbytes, this size is directly linked to the bitrate and is withing the range of 20 to 400 bytes.
    • In our example, 64kbps leads to 80 bytes, so compression factor of 8 for 16bits/sample

1.2. LC3 requirement

Our LC3 implementation is based of floating point numbers and needs to access the FPU for fast computation as well as the support of DSP instructions. Also, since it's an heavy process, it is recommenced to use high core clock with Instruction Cache enabled. The library provided is compiled for cortex M33 with speed optimization.

Provided by the application, the following RAM must be allocated for running the full feature LC3:

  • 604 bytes per session
  • 4820 bytes per encoding channel
  • 8340 bytes per decoding channel

Also, at least 7000 bytes are allocated by the encoder over the stack, or 4700 bytes if the only decoder is used.

The flash footprint of the full codec represents around 120 kBytes and can be reduced at the linking time if only one mode is used.

Finally here is an overview of the CPU load required picture of CPU load

This LC3 implementation is SIG certified with the QDID : XXXXX