Skip to content

Commit db13d3c

Browse files
Add basic A2DP BluetoothAudio documentation (earlephilhower#2217)
1 parent f8c1ec1 commit db13d3c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/a2dp.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Bluetooth Audio (A2DP Source and Sink)
2+
======================================
3+
4+
The PicoW can be used as a Bluetooth Audio sink or source with the ``BluetoothAudio`` class.
5+
Operation is generally handled "automatically" in the background so while the audio is
6+
playing or streaming the main application can perform other operations (like displaying
7+
playback info, polling buttons for controls, etc.)
8+
9+
.. code :: cpp
10+
11+
#include <BluetoothAudio.h>
12+
...
13+
14+
**Note about CPU usage:** Bluetooth SBC audio is a compressed format. That means
15+
that it takes non-trivial amounts of CPU to compress on send, or decompress on receive.
16+
Transmitting precompressed audio from, say, MP3 or AAC, requires first decompressing
17+
the source file into raw PCM and then re-compressing them in the SBC format. You may
18+
want to consider overclocking in this case to avoid underflow.
19+
20+
A2DPSink
21+
--------
22+
23+
This class implements slave sink-mode operation with player control (play, pause, etc.) and
24+
can play the received and decoded SBC audio to ``PWMAudio``, ``I2S``, or a user-created
25+
`BluetoothAudioConsumer`` class.
26+
27+
The ``A2DPSink.ino`` example demonstrates turning a PicoW into a Bluetooth headset with
28+
``PWMAudio``.
29+
30+
A2DPSource
31+
-----------
32+
33+
This class implements a master source-mode SBC Bluetooth A2DP audio connection which
34+
transmits audio using the standard ``Stream`` interface (like ``I2S`` or ``PWMAudio``.
35+
The main application connects to a Bluetooth speaker and then writes samples into a buffer
36+
that's automatically transmitted behind the scenes.
37+
38+
The ``A2DPSource.ino`` example shows how to connect to a Bluetooth speaker, transmit
39+
data, and respond to commands from the speaker.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ For the latest version, always check https://github.com/earlephilhower/arduino-p
4646

4747
Bluetooth <bluetooth>
4848
Bluetooth HID Master <hidmaster>
49+
Bluetooth Audio (A2DP) <a2dp>
4950

5051
Single File USB Drive <singlefile>
5152
FatFSUSB - full FS access over USB <fatfsusb>

0 commit comments

Comments
 (0)