forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
applications: nrf5340_audio: LC3 Decoder Audio Module
Implement the LC3 T2 decoder audio module. Signed-off-by: Graham Wacey <[email protected]>
- Loading branch information
Showing
19 changed files
with
2,085 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright(c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
#ifndef _LC3_DECODER_H_ | ||
#define _LC3_DECODER_H_ | ||
|
||
#include "audio_defines.h" | ||
#include "audio_module.h" | ||
|
||
#define LC3_DECODER_PCM_NUM_BYTES_MONO \ | ||
((CONFIG_LC3_DECODER_SAMPLE_RATE_HZ * CONFIG_LC3_DECODER_BIT_DEPTH_OCTETS * \ | ||
CONFIG_LC3_DECODER_FRAME_DURATION_US) / \ | ||
1000000) | ||
|
||
/** | ||
* @brief Private pointer to the module's parameters. | ||
*/ | ||
extern struct audio_module_description *lc3_decoder_description; | ||
|
||
/** | ||
* @brief Private pointer to the decoders handle. | ||
*/ | ||
struct lc3_decoder_handle; | ||
|
||
/** | ||
* @brief The module configuration structure. | ||
*/ | ||
struct lc3_decoder_configuration { | ||
/* Sample rate for the decoder instance. */ | ||
uint32_t sample_rate_hz; | ||
|
||
/* Number of valid bits for a sample (bit depth). | ||
* Typically 16 or 24. | ||
*/ | ||
uint8_t bits_per_sample; | ||
|
||
/* Number of bits used to carry a sample of size bits_per_sample. | ||
* For example, say we have a 24 bit sample stored in a 32 bit | ||
* word (int32_t), then: | ||
* bits_per_sample = 24 | ||
* carrier_size = 32 | ||
*/ | ||
uint32_t carried_bits_per_sample; | ||
|
||
/* Frame duration for this decoder instance. */ | ||
uint32_t data_len_us; | ||
|
||
/* A flag indicating if the decoded buffer is sample interleaved or not. */ | ||
bool interleaved; | ||
|
||
/* Channel locations for this decoder instance. */ | ||
uint32_t locations; | ||
|
||
/* Maximum bitrate supported by the decoder. */ | ||
uint32_t bitrate_bps_max; | ||
}; | ||
|
||
/** | ||
* @brief Private module context. | ||
*/ | ||
struct lc3_decoder_context { | ||
/* Array of decoder channel handles. */ | ||
struct lc3_decoder_handle *lc3_dec_channel[CONFIG_LC3_DEC_CHANNELS_MAX]; | ||
|
||
/* Number of decoder channel handles. */ | ||
uint32_t dec_handles_count; | ||
|
||
/* The decoder configuration. */ | ||
struct lc3_decoder_configuration config; | ||
|
||
/* Minimum coded bytes required for this decoder instance. */ | ||
uint16_t coded_bytes_req; | ||
|
||
/* Audio sample bytes per frame. */ | ||
size_t sample_frame_bytes; | ||
|
||
/* Number of successive frames to which PLC has been applied. */ | ||
uint16_t plc_count; | ||
}; | ||
|
||
#endif /* _LC3_DECODER_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Copyright (c) 2023 Nordic Semiconductor | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lc3_decoder.c) | ||
|
||
target_include_directories(app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/include/audio_module | ||
${ZEPHYR_NRF_MODULE_DIR}/include/audio_modules) | ||
|
||
zephyr_include_directories( | ||
${ZEPHYR_BASE}/../nrfxlib/lc3/codec/inc | ||
${ZEPHYR_BASE}/../nrfxlib/lc3/platform/os/inc | ||
${ZEPHYR_BASE}/../nrfxlib/lc3/platform/os/baremetal/inc | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
menu "Audio Modules" | ||
|
||
config AUDIO_MODULE_T2_LC3_DECODER | ||
bool "Enable the T2 LC3 decoder" | ||
default y | ||
help | ||
Enable the T2 LC3 decoder audio module in test mode. | ||
|
||
config AUDIO_MODULE_T2_LC3_DECODER_TEST | ||
bool "Enable the T2 LC3 decoder" | ||
default n | ||
help | ||
Enable the T2 LC3 decoder audio module in test mode. | ||
|
||
config LC3_DEC_CHANNELS_MAX | ||
int "Maximum audio channels" | ||
default 2 | ||
help | ||
The maximum audio channels the decoder can support. | ||
|
||
choice LC3_DECODER_FRAME_DURATION | ||
prompt "Select frame duration - 7.5 ms frame duration is not tested" | ||
default LC3_DECODER_FRAME_DURATION_10_MS | ||
help | ||
LC3 supports frame duration of 7.5 and 10 ms. | ||
|
||
config LC3_DECODER_FRAME_DURATION_7_5_MS | ||
bool "7.5 ms" | ||
|
||
config LC3_DECODER_FRAME_DURATION_10_MS | ||
bool "10 ms" | ||
endchoice | ||
|
||
config LC3_DECODER_FRAME_DURATION_US | ||
int | ||
default 7500 if LC3_DECODER_FRAME_DURATION_7_5_MS | ||
default 10000 if LC3_DECODER_FRAME_DURATION_10_MS | ||
help | ||
Audio frame duration in µs. | ||
|
||
choice LC3_DECODER_SYSTEM_SAMPLE_RATE | ||
prompt "System audio sample rate" | ||
default LC3_DECODER_SAMPLE_RATE_48000_HZ | ||
help | ||
This configuration reflects the decoding sample rate. | ||
|
||
config LC3_DECODER_SAMPLE_RATE_8000_HZ | ||
bool "8 kHz" | ||
help | ||
Sample rate of 16kHz. | ||
|
||
config LC3_DECODER_SAMPLE_RATE_16000_HZ | ||
bool "16 kHz" | ||
help | ||
Sample rate of 16kHz. | ||
|
||
config LC3_DECODER_SAMPLE_RATE_24000_HZ | ||
bool "24 kHz" | ||
help | ||
Sample rate of 24kHz. | ||
|
||
config LC3_DECODER_SAMPLE_RATE_32000_HZ | ||
bool "32 kHz" | ||
help | ||
Sample rate of 16kHz. | ||
|
||
config LC3_DECODER_SAMPLE_RATE_44100_HZ | ||
bool "44.1 kHz" | ||
help | ||
Sample rate of 16kHz. | ||
|
||
config LC3_DECODER_SAMPLE_RATE_48000_HZ | ||
bool "48 kHz" | ||
help | ||
Sample rate of 48kHz. | ||
endchoice | ||
|
||
config LC3_DECODER_SAMPLE_RATE_HZ | ||
int | ||
default 8000 if LC3_DECODER_SAMPLE_RATE_8000_HZ | ||
default 16000 if LC3_DECODER_SAMPLE_RATE_16000_HZ | ||
default 24000 if LC3_DECODER_SAMPLE_RATE_24000_HZ | ||
default 32000 if LC3_DECODER_SAMPLE_RATE_32000_HZ | ||
default 44100 if LC3_DECODER_SAMPLE_RATE_44100_HZ | ||
default 48000 if LC3_DECODER_SAMPLE_RATE_48000_HZ | ||
help | ||
I2S supports 16, 24, and 48 kHz sample rates for both input and output. | ||
USB supports only 48 kHz for input. | ||
|
||
choice LC3_DECODER_BIT_DEPTH | ||
prompt "Audio bit depth" | ||
default LC3_DECODER_BIT_DEPTH_16 | ||
help | ||
Select the bit depth for audio. | ||
|
||
config LC3_DECODER_BIT_DEPTH_16 | ||
bool "16 bit audio" | ||
|
||
config LC3_DECODER_BIT_DEPTH_32 | ||
bool "32 bit audio" | ||
endchoice | ||
|
||
config LC3_DECODER_BIT_DEPTH_BITS | ||
int | ||
default 16 if LC3_DECODER_BIT_DEPTH_16 | ||
default 32 if LC3_DECODER_BIT_DEPTH_32 | ||
help | ||
Bit depth of one sample in storage. | ||
|
||
config LC3_DECODER_BIT_DEPTH_OCTETS | ||
int | ||
default 2 if LC3_DECODER_BIT_DEPTH_16 | ||
default 4 if LC3_DECODER_BIT_DEPTH_32 | ||
help | ||
Bit depth of one sample in storage given in octets. | ||
|
||
config LC3_DECODER_THREAD_PRIO | ||
int "Priority for the decoder thread" | ||
default 3 | ||
help | ||
This is a preemptible thread. | ||
|
||
config LC3_DECODER_STACK_SIZE | ||
int "Stack size for the decoder thread" | ||
default 4092 if LC3_DECODER_BIT_DEPTH_16 | ||
default 5115 if LC3_DECODER_BIT_DEPTH_32 | ||
help | ||
The modules thread stack size. | ||
|
||
osource "../nrfxlib/lc3/Kconfig" | ||
|
||
#----------------------------------------------------------------------------# | ||
menu "Log levels" | ||
|
||
module = AUDIO_MODULE_LC3_DECODER | ||
module-str = t2_lc3_decoder | ||
source "subsys/logging/Kconfig.template.log_config" | ||
|
||
endmenu # Log levels | ||
endmenu # Audio Modules |
Oops, something went wrong.