Skip to content

Commit 7af9c83

Browse files
greg-ferrlubos
authored andcommitted
doc: audio: document sd card playback module
Added information about the SD card playback module. OCT-2790. Signed-off-by: Grzegorz Ferenc <[email protected]>
1 parent 8f5608b commit 7af9c83

File tree

3 files changed

+210
-6
lines changed

3 files changed

+210
-6
lines changed

applications/nrf5340_audio/doc/configuration.rst

Lines changed: 164 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,74 @@ Configuring the nRF5340 Audio applications
99

1010
|config|
1111

12+
.. _nrf53_audio_app_kconfigs:
13+
14+
Configuration options
15+
*********************
16+
17+
The application comes with the following application-specific Kconfig options:
18+
19+
.. _CONFIG_STREAM_BIDIRECTIONAL:
20+
21+
CONFIG_STREAM_BIDIRECTIONAL
22+
Enables bidirectional communication mode for CIS streams.
23+
24+
.. _CONFIG_WALKIE_TALKIE_DEMO:
25+
26+
CONFIG_WALKIE_TALKIE_DEMO
27+
Enables the walkie-talkie demo functionality using bidirectional streams.
28+
29+
.. _CONFIG_TRANSPORT_BIS:
30+
31+
CONFIG_TRANSPORT_BIS
32+
Enables Auracast™ (broadcast) mode for working with broadcast sources and sinks.
33+
34+
.. _CONFIG_BT_AUDIO_USE_BROADCAST_NAME_ALT:
35+
36+
CONFIG_BT_AUDIO_USE_BROADCAST_NAME_ALT
37+
Enables BIS mode with two gateways, allowing headsets to switch between gateways.
38+
39+
.. _CONFIG_BT_AUDIO_BROADCAST_NAME_ALT:
40+
41+
CONFIG_BT_AUDIO_BROADCAST_NAME_ALT
42+
Provides an alternative name for the second gateway in BIS mode.
43+
44+
.. _CONFIG_AUDIO_SOURCE_I2S:
45+
46+
CONFIG_AUDIO_SOURCE_I2S
47+
Switches from USB audio source to 3.5 mm jack analog input using I2S.
48+
49+
.. _CONFIG_NRF5340_AUDIO_SD_CARD_MODULE:
50+
51+
CONFIG_NRF5340_AUDIO_SD_CARD_MODULE
52+
Enables the SD card module (enabled by default on the nRF5340 Audio DK).
53+
54+
.. _CONFIG_SD_CARD_PLAYBACK:
55+
56+
CONFIG_SD_CARD_PLAYBACK
57+
Enables SD card playback functionality.
58+
59+
.. _CONFIG_SD_CARD_PLAYBACK_STACK_SIZE:
60+
61+
CONFIG_SD_CARD_PLAYBACK_STACK_SIZE
62+
Sets the stack size for the SD card playback thread (default: 4096).
63+
64+
.. _CONFIG_SD_CARD_PLAYBACK_RING_BUF_SIZE:
65+
66+
CONFIG_SD_CARD_PLAYBACK_RING_BUF_SIZE
67+
Sets the size of the ring buffer for audio data (default: 960).
68+
69+
.. _CONFIG_SD_CARD_PLAYBACK_THREAD_PRIO:
70+
71+
CONFIG_SD_CARD_PLAYBACK_THREAD_PRIO
72+
Sets the priority for the SD card playback thread (default: 7).
73+
1274
.. _nrf53_audio_app_configuration_select_bidirectional:
1375

1476
Selecting the CIS bidirectional communication
1577
*********************************************
1678

17-
To switch to the bidirectional mode, set the ``CONFIG_STREAM_BIDIRECTIONAL`` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file (for the debug version) or in the :file:`applications/nrf5340_audio/prj_release.conf` file (for the release version).
79+
To switch to the bidirectional mode, set the :ref:`CONFIG_STREAM_BIDIRECTIONAL<nrf53_audio_app_kconfigs>` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file (for the debug version) or in the :file:`applications/nrf5340_audio/prj_release.conf` file (for the release version).
1880

1981
.. _nrf53_audio_app_configuration_enable_walkie_talkie:
2082

@@ -23,7 +85,7 @@ Enabling the walkie-talkie demo
2385

2486
The walkie-talkie demo uses one or two bidirectional streams from the gateway to one or two headsets.
2587
The PDM microphone is used as input on both the gateway and headset device.
26-
To switch to using the walkie-talkie, set the ``CONFIG_WALKIE_TALKIE_DEMO`` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file (for the debug version) or in the :file:`applications/nrf5340_audio/prj_release.conf` file (for the release version).
88+
To switch to using the walkie-talkie, set the :ref:`CONFIG_WALKIE_TALKIE_DEMO<nrf53_audio_app_kconfigs>` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file (for the debug version) or in the :file:`applications/nrf5340_audio/prj_release.conf` file (for the release version).
2789

2890
Enabling the Auracast™ (broadcast) mode
2991
=======================================
@@ -38,8 +100,8 @@ Enabling the BIS mode with two gateways
38100
In addition to the standard BIS mode with one gateway, you can also add a second gateway device.
39101
The BIS headsets can then switch between the two gateways and receive audio stream from one of the two gateways.
40102

41-
To configure the second gateway, add both the ``CONFIG_TRANSPORT_BIS`` and the ``CONFIG_BT_AUDIO_USE_BROADCAST_NAME_ALT`` Kconfig options set to ``y`` to the :file:`applications/nrf5340_audio/prj.conf` file for the debug version and to the :file:`applications/nrf5340_audio/prj_release.conf` file for the release version.
42-
You can provide an alternative name to the second gateway using the ``CONFIG_BT_AUDIO_BROADCAST_NAME_ALT`` or use the default alternative name.
103+
To configure the second gateway, add both the :ref:`CONFIG_TRANSPORT_BIS<nrf53_audio_app_kconfigs>` and the :ref:`CONFIG_BT_AUDIO_USE_BROADCAST_NAME_ALT<nrf53_audio_app_kconfigs>` Kconfig options set to ``y`` to the :file:`applications/nrf5340_audio/prj.conf` file for the debug version and to the :file:`applications/nrf5340_audio/prj_release.conf` file for the release version.
104+
You can provide an alternative name to the second gateway using the :ref:`CONFIG_BT_AUDIO_BROADCAST_NAME_ALT<nrf53_audio_app_kconfigs>` or use the default alternative name.
43105

44106
You build each BIS gateway separately using the normal procedures from :ref:`nrf53_audio_app_building`.
45107
After building the first gateway, configure the required Kconfig options for the second gateway and build the second gateway firmware.
@@ -53,7 +115,7 @@ Selecting the analog jack input using I2S
53115
In the default configuration, the gateway application uses USB as the audio source.
54116
The :ref:`nrf53_audio_app_building` and the testing steps also refer to using the USB serial connection.
55117

56-
To switch to using the 3.5 mm jack analog input, set the ``CONFIG_AUDIO_SOURCE_I2S`` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file for the debug version and in the :file:`applications/nrf5340_audio/prj_release.conf` file for the release version.
118+
To switch to using the 3.5 mm jack analog input, set the :ref:`CONFIG_AUDIO_SOURCE_I2S<nrf53_audio_app_kconfigs>` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file for the debug version and in the :file:`applications/nrf5340_audio/prj_release.conf` file for the release version.
57119

58120
When testing the application, an additional audio jack cable is required to use I2S.
59121
Use this cable to connect the audio source (PC) to the analog **LINE IN** on the development kit.
@@ -82,6 +144,102 @@ You can use one of the following options, depending on how you decide to build t
82144
83145
west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DEXTRA_CONF_FILE=".\unicast_server\overlay-unicast_server.conf" -Dnrf5340_audio_SHIELD=nrf21540ek -Dipc_radio_SHIELD=nrf21540ek
84146
85-
To set the TX power output, use the ``CONFIG_BT_CTLR_TX_PWR_ANTENNA`` and ``CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB`` Kconfig options in :file:`applications/nrf5340_audio/sysbuild/ipc_radio/prj.conf`.
147+
To set the TX power output, use the :kconfig:option:`CONFIG_BT_CTLR_TX_PWR_ANTENNA` and :kconfig:option:`CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB` Kconfig options in :file:`applications/nrf5340_audio/sysbuild/ipc_radio/prj.conf`.
86148

87149
See :ref:`ug_radio_fem` for more information about FEM in the |NCS|.
150+
151+
.. _nrf53_audio_app_configuration_sd_card_playback:
152+
153+
Enabling SD card playback
154+
*************************
155+
156+
The SD Card Playback module allows you to play audio files directly from an SD card inserted into the nRF5340 Audio development kit.
157+
This feature supports both WAV and LC3 audio file formats and is compatible with all nRF5340 Audio applications.
158+
159+
File format support requirements
160+
================================
161+
162+
The SD card playback module supports both WAV and LC3 audio file formats.
163+
The audio files must meet the following requirements:
164+
165+
* WAV files must be 48 kHz, 16-bit, mono PCM format.
166+
* LC3 files must be in the LC3 file format with proper headers.
167+
168+
SD card requirements
169+
====================
170+
171+
Make sure the SD card meets the following requirements:
172+
173+
* Formatted with FAT32 or exFAT file system.
174+
* Audio files are placed in the root directory or subdirectories.
175+
176+
Configuring SD card playback
177+
============================
178+
179+
To enable SD card playback functionality, you need to set the following Kconfig options to ``y``:
180+
181+
* :ref:`CONFIG_NRF5340_AUDIO_SD_CARD_MODULE<nrf53_audio_app_kconfigs>` - to enable the SD card module; this option is enabled by default on nRF5340 Audio DK
182+
* :ref:`CONFIG_SD_CARD_PLAYBACK<nrf53_audio_app_kconfigs>` - to enable the playback functionality
183+
184+
Optionally, you can also set the following Kconfig options:
185+
186+
* :ref:`CONFIG_SD_CARD_PLAYBACK_STACK_SIZE<nrf53_audio_app_kconfigs>`
187+
* :ref:`CONFIG_SD_CARD_PLAYBACK_RING_BUF_SIZE<nrf53_audio_app_kconfigs>`
188+
* :ref:`CONFIG_SD_CARD_PLAYBACK_THREAD_PRIO<nrf53_audio_app_kconfigs>`
189+
190+
Shell commands for SD card playback
191+
===================================
192+
193+
When SD card playback is enabled, the following shell commands are available:
194+
195+
.. list-table:: SD card playback shell commands
196+
:header-rows: 1
197+
198+
* - Command
199+
- Description
200+
* - ``sd_card_playback play_wav <filename>.wav``
201+
- Play a WAV file from the SD card
202+
* - ``sd_card_playback play_lc3 <filename>.lc3``
203+
- Play an LC3 file from the SD card
204+
* - ``sd_card_playback list_files``
205+
- List files in the current directory
206+
* - ``sd_card_playback cd <directory>``
207+
- Change to a different directory
208+
* - ``sd_card_playback cd /``
209+
- Return to the root directory
210+
211+
To issue these commands, you can use the RTT or UART serial connection.
212+
213+
Example usage
214+
=============
215+
216+
To play audio from the SD card, complete the following steps:
217+
218+
1. Configure the SD card playback module in your application as described in `Configuring SD card playback`_.
219+
#. :ref:`Build and run the application <nrf53_audio_app_building>`.
220+
#. Insert a properly formatted SD card with audio files into the development kit.
221+
#. Connect to the device using the RTT or UART serial connection.
222+
For example, you can use the `Serial Terminal app`_ to connect to the device.
223+
#. In the terminal:
224+
225+
a. Issue the following command to list files on the SD card:
226+
227+
.. code-block:: console
228+
229+
sd_card_playback list_files
230+
231+
b. Issue the following command to play a WAV file:
232+
233+
.. code-block:: console
234+
235+
sd_card_playback play_wav <filename>.wav
236+
237+
c. Issue the following command to play an LC3 file:
238+
239+
.. code-block:: console
240+
241+
sd_card_playback play_lc3 <filename>.lc3
242+
243+
The audio from the SD card will be mixed with any existing audio stream and played through the device's audio output.
244+
#. To stop the playback, issue the ``sd_card_playback stop`` command.
245+
#. To exit the shell, issue the ``exit`` command.

applications/nrf5340_audio/doc/firmware_architecture.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,48 @@ The received audio data in the I2S-based firmware devices follows the following
288288
#. The audio decoder decodes the data and sends the uncompressed audio data (PCM) back to the :file:`audio_datapath.c` module.
289289
#. The :file:`audio_datapath.c` module continuously feeds the uncompressed audio data to the hardware codec.
290290
#. The hardware codec receives the uncompressed audio data over the inter-IC sound (I2S) interface and performs the digital-to-analog (DAC) conversion to an analog audio signal.
291+
292+
.. _nrf53_audio_app_overview_architecture_sd_card_playback:
293+
294+
SD card playback module overview
295+
================================
296+
297+
The SD Card Playback module (:file:`sd_card_playback.c`) provides functionality to play audio files directly from an SD card.
298+
This module works alongside the existing audio system and can mix SD card audio with Bluetooth audio streams.
299+
300+
The module is compatible with all nRF5340 Audio applications.
301+
302+
The SD Card Playback module consists of the following components:
303+
304+
* File system interface - Uses the SD card module (:file:`sd_card.c`) to read files from the FAT32/exFAT file system
305+
* Audio format support - Handles both WAV and LC3 file formats with proper header parsing
306+
* Ring buffer management - Uses a ring buffer to store audio data for smooth playback
307+
* Thread management - Runs in a dedicated thread to handle file reading and audio processing
308+
* Audio mixing - Integrates with the PCM mixing system to combine SD card audio with other audio sources
309+
310+
For information about how to enable SD card playback, see :ref:`nrf53_audio_app_configuration_sd_card_playback`.
311+
312+
SD card playback audio processing flow
313+
--------------------------------------
314+
315+
The SD card playback module uses the following processing flow:
316+
317+
1. User selects an audio file using shell commands.
318+
#. Module reads and validates the file header (WAV or LC3 format).
319+
#. Audio data is read from the SD card in chunks.
320+
#. For LC3 files, the data is decoded using the LC3 decoder.
321+
#. Audio data is stored in a ring buffer for continuous playback.
322+
#. The module provides a mixing function that can be called by the audio system.
323+
#. Thread manages the playback state and timing.
324+
325+
Integration with audio system
326+
-----------------------------
327+
328+
The SD Card Playback module integrates with the existing audio system through the PCM mixing interface.
329+
The module provides the ``sd_card_playback_mix_with_stream()`` function that can be called by the audio datapath to mix SD card audio with other audio sources.
330+
331+
This integration allows for scenarios such as:
332+
333+
* Playing background music from SD card while receiving Bluetooth audio.
334+
* Mixing multiple audio sources.
335+
* Providing local audio content when Bluetooth connections are not available.

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ nRF5340 Audio
237237
The :ref:`net_buf_interface` will also contain the metadata about the audio stream in the ``user_data`` section of the API.
238238
This change was done to transition to standard Zephyr APIs, as well as to have a structured way to pass N-channel audio between modules.
239239
* The optional buildprog tool to use `nRF Util`_ instead of nrfjprog that has been deprecated.
240+
* The documentation pages with information about the :ref:`SD card playback module <nrf53_audio_app_overview_architecture_sd_card_playback>` and :ref:`how to enable it <nrf53_audio_app_configuration_sd_card_playback>`.
240241

241242
* Removed:
242243

0 commit comments

Comments
 (0)