• Home
  • History
  • Annotate
Name
Date
Size
#Lines
LOC

..--

.github/workflows/18-Mar-2025-9485

conformance/18-Mar-2025-1,7961,773

fuzz/18-Mar-2025-240135

include/18-Mar-2025-923342

python/18-Mar-2025-1,057758

src/18-Mar-2025-13,7809,584

tables/18-Mar-2025-364233

test/18-Mar-2025-15,68912,039

tools/18-Mar-2025-1,109603

wasm/18-Mar-2025-6720

zephyr/18-Mar-2025-54

.gitattributesD18-Mar-202573 32

.gitignoreD18-Mar-202558 87

CONTRIBUTING.mdD18-Mar-20251.1 KiB2920

LICENSED18-Mar-202511.1 KiB203169

MakefileD18-Mar-20253.9 KiB174105

README.mdD18-Mar-20255 KiB182125

meson.buildD18-Mar-20251.1 KiB4132

meson_options.txtD18-Mar-2025778 2421

pyproject.tomlD18-Mar-2025451 2318

README.md

1# Low Complexity Communication Codec (LC3)
2
3LC3 and LC3 Plus are audio codecs designed for low-latency audio transport.
4
5- LC3 is specified by [_the Bluetooth Special Interset Group for the LE Audio
6  protocol_](https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=502107&vId=542963)
7
8- LC3 Plus is defined by [_ETSI TS 103 634_](https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.04.01_60/ts_103634v010401p.pdf)
9
10In addition to LC3, following features of LC3 Plus are proposed:
11- Frame duration of 2.5 and 5ms.
12- High-Resolution mode, 48 KHz, and 96 kHz sampling rates.
13
14## Overview
15
16The directory layout is as follows :
17- include:      Library interface
18- src:          Source files
19- tools:        Standalone encoder/decoder tools
20- python:       Python wrapper
21- test:         Unit testing framework
22- fuzz:         Roundtrip fuzz testing harness
23- build:        Building outputs
24- bin:          Compilation output
25
26## How to build
27
28The default toolchain used is GCC. Invoke `make` to build the library.
29
30```sh
31$ make -j
32```
33
34Compiled library `liblc3.so` will be found in `bin` directory.
35
36LC3 Plus features can be selectively disabled :
37- `LC3_PLUS=0` disable the support of 2.5ms and 5ms frame durations.
38- `LC3_PLUS_HR=0` turns off the support of the High-Resolution mode.
39
40Only Bluetooth LC3 features will be included using the following command:
41
42```sh
43$ make LC3_PLUS=0 LC3_PLUS_HR=0 -j
44```
45
46#### Cross compilation
47
48The cc, as, ld and ar can be selected with respective Makefile variables `CC`,
49`AS`, `LD` and `AR`. The `AS` and `LD` selections are optionnal, and fallback
50to `CC` selection when not defined.
51
52The `LIBC` must be set to `bionic` for android cross-compilation. This switch
53prevent link with `pthread` and `rt` libraries, that is included in the
54bionic libc.
55
56Following example build for android, using NDK toolset.
57
58```sh
59$ make -j CC=path_to_android_ndk_prebuilt/toolchain-prefix-clang LIBC=bionic
60```
61
62Compiled library will be found in `bin` directory.
63
64#### Web Assembly (WASM)
65
66Web assembly compilation is supported using LLVM WebAssembly backend.
67Installation of LLVM compiler and linker is needed:
68
69```sh
70# apt install clang lld
71```
72
73The webasm object is compiled using:
74```sh
75$ make CC="clang --target=wasm32"
76```
77
78## Tools
79
80Tools can be all compiled, while invoking `make` as follows :
81
82```sh
83$ make tools
84```
85
86The standalone encoder `elc3` take a `wave` file as input and encode it
87according given parameter. The LC3 binary file format used is the non
88standard format described by the reference encoder / decoder tools.
89The standalone decoder `dlc3` do the inverse operation.
90
91Refer to `elc3 -h` or `dlc3 -h` for options.
92
93Note that `elc3` output bitstream to standard output when output file is
94omitted. On the other side `dlc3` read from standard input when input output
95file are omitted.
96In such way you can easly test encoding / decoding loop with :
97
98```sh
99$ alias elc3="LD_LIBRARY_PATH=`pwd`/bin `pwd`/bin/elc3"
100$ alias dlc3="LD_LIBRARY_PATH=`pwd`/bin `pwd`/bin/dlc3"
101$ elc3 <in.wav> -b <bitrate> | dlc3 > <out.wav>
102```
103
104Adding Linux `aplay` tools, you will be able to instant hear the result :
105
106```sh
107$ alias elc3="LD_LIBRARY_PATH=`pwd`/bin `pwd`/bin/elc3"
108$ alias dlc3="LD_LIBRARY_PATH=`pwd`/bin `pwd`/bin/dlc3"
109$ elc3 <in.wav> -b <bitrate> | dlc3 | aplay -D pipewire
110```
111
112## Test
113
114A python implementation of the encoder is provided in `test` diretory.
115The C implementation is unitary validated against this implementation and
116intermediate values given in Appendix C of the LC3 specification.
117
118#### Prerequisite
119
120```sh
121# apt install python3 python3-dev python3-pip
122$ pip3 install scipy numpy
123```
124
125#### Running test suite
126
127```sh
128$ make test
129```
130
131## Fuzzing
132
133Roundtrip fuzz testing harness is available in `fuzz` directory.
134LLVM `clang` and `clang++` compilers are needed to run fuzzing.
135
136The encoder and decoder fuzzers can be run, for 1 million iterations, using
137target respectively `dfuzz` and `efuzz`. The `fuzz` target runs both.
138
139```sh
140$ make efuzz    # Run encoder fuzzer for 1M iteration
141$ make dfuzz    # Run decoder fuzzer for 1M iteration
142$ make fuzz -j  # Run encoder and decoder fuzzers in parallel
143```
144
145## Qualification / Conformance
146
147The implementation is qualified under the [_QDID 194161_](https://launchstudio.bluetooth.com/ListingDetails/160904) as part of Google Fluoride 1.5.
148
149The conformance reports can be found [here](conformance/README.md)
150
151## Listening Test
152
153The codec was [_here_](https://hydrogenaud.io/index.php/topic,122575.0.html)
154subjectively evaluated in a blind listening test.
155
156
157## Meson build system
158
159Meson build system is also available to build and install lc3 codec in Linux
160environment.
161
162```sh
163$ meson setup build
164$ cd build && meson install
165```
166
167## Python wrapper
168
169A python wrapper, installed as follows, is available in the `python` directory.
170
171```sh
172$ python3 -m pip install .
173```
174
175Decoding and encoding tools are provided in `python/tools`, like C tools,
176you can easly test encoding / decoding loop with :
177
178```sh
179$ python3 ./python/tools/encoder.py <in.wav> --bitrate <bitrate> | \
180  python3 ./python/tools/decoder.py > <out.wav>
181```
182