|
| 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. |
0 commit comments