<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">The&nbsp;</span><a href="https://www.espressif.com/en/products/hardware/esp32/overview" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">ESP32</span></a><span style="font-size: 11px;">&nbsp;provides a&nbsp;</span><a href="https://de.wikipedia.org/wiki/A2DP" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">Bluetooth A2DP API</span></a><span style="font-size: 11px;">&nbsp;that receives sound data e.g. from your&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">Mobile Phone</span></strong><span style="font-size: 11px;">&nbsp;and makes it available via a callback method. The output is a&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">PCM data stream&nbsp;</span></strong><span style="font-size: 11px;">decoded from SBC format. The documentation can be found&nbsp;</span><a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2s.html" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">here.&nbsp;</span></a></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><a href="https://en.wikipedia.org/wiki/I%C2%B2S" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">I2S</span></a><span style="font-size: 11px;">&nbsp;is an electrical serial bus interface standard used for connecting digital audio devices together. It is used to communicate&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">PCM audio data&nbsp;</span></strong><span style="font-size: 11px;">between integrated circuits in an electronic device.</span></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">So we can just feed the input from Bluetooth to the&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">I2S</span></strong><span style="font-size: 11px;">&nbsp;output: An example for this from Expressive can be found on&nbsp;</span><a href="https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/bluedroid/classic_bt/a2dp_sink" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">Github</span></a><span style="font-size: 11px;">.</span></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">Unfortunately this example did not make me happy so I decided to convert it into a simple C++ class that is very easy to use from an&nbsp;</span><a href="https://www.arduino.cc/en/guide/environment" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">Arduino Software IDE.</span></a></p>
<h3 style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: roboto, helvetica, arial, sans-serif; font-weight: 500; line-height: 1.618; color: #3c4858; margin: 0px 0px 15px; background-color: #ffffff;"><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">A Simple I2S Example</span></strong></h3>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">Here is the simplest example which just uses the proper default settings:</span></p>
<pre style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; overflow: auto; font-family: menlo, monaco, consolas, &quot;courier new&quot;, monospace; padding: 9.5px; margin-top: 0px; margin-bottom: 30px; line-height: 1.42857; word-break: break-all; overflow-wrap: break-word; color: #333333; background-color: #f5f5f5; border: 1px solid rgb(204, 204, 204); border-radius: 4px;">
   <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: menlo, monaco, consolas, &quot;courier new&quot;, monospace; padding: 0px; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"><span style="font-size: 11px;">#include &lt;arduino.h&gt;
#include "esp32_bt_music_receiver.h"
BlootoothA2DSink a2d_sink;
void setup() {
a2d_sink.start("MyMusic");
}
void loop() {
}
</span></code>
   </pre>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">This creates a new Bluetooth device with the name “MyMusic” and the output will be sent to the following default&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">I2S pins</span></strong><span style="font-size: 11px;">:</span><br style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; line-height: 2;" /><span style="font-size: 11px;">– bck_io_num =&gt; GPIO 26,</span><br style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; line-height: 2;" /><span style="font-size: 11px;">– ws_io_num =&gt; GPIO 25,</span><br style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; line-height: 2;" /><span style="font-size: 11px;">– data_out_num =&gt; GPIO 22</span></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">These need to be connected to an external&nbsp;</span><a href="https://en.wikipedia.org/wiki/Digital-to-analog_converter" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">external DAC</span></a><span style="font-size: 11px;">. You can define your own pins easily by calling the set_pin_config method.</span></p>
<h3 style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: roboto, helvetica, arial, sans-serif; font-weight: 500; line-height: 1.618; color: #3c4858; margin: 0px 0px 15px; background-color: #ffffff;"><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">Output to the Internal DAC</span></strong></h3>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">You can also send the output directly to the&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">internal DAC of the ESP32&nbsp;</span></strong><span style="font-size: 11px;">by providing the corresponding&nbsp;</span><a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2s.html" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">i2s_config</span></a><span style="font-size: 11px;">:</span></p>
<pre style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; overflow: auto; font-family: menlo, monaco, consolas, &quot;courier new&quot;, monospace; padding: 9.5px; margin-top: 0px; margin-bottom: 30px; line-height: 1.42857; word-break: break-all; overflow-wrap: break-word; color: #333333; background-color: #f5f5f5; border: 1px solid rgb(204, 204, 204); border-radius: 4px;">
   <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: menlo, monaco, consolas, &quot;courier new&quot;, monospace; padding: 0px; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"><span style="font-size: 11px;">#include &lt;arduino.h&gt;
#include "esp32_bt_music_receiver.h"
BlootoothA2DSink a2d_sink;
void setup() {
static const i2s_config_t i2s_config = {
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN),
.sample_rate = 44100, // corrected by info from bluetooth
.bits_per_sample = (i2s_bits_per_sample_t) 16, /* the DAC module will only take the 8bits from MSB */
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = false
};
a2d_sink.set_i2s_config(i2s_config);
a2d_sink.start("MyMusic");
}
void loop() {
}
</span></code>
   </pre>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">The output goes now to the&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">DAC pins G26/G27</span></strong><span style="font-size: 11px;">.</span></p>
<h3 style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: roboto, helvetica, arial, sans-serif; font-weight: 500; line-height: 1.618; color: #3c4858; margin: 0px 0px 15px; background-color: #ffffff;"><span style="font-size: 11px;">Installation</span></h3>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">The library</span></strong><span style="font-size: 11px;">&nbsp;with the examples can be found on&nbsp;</span><a href="https://github.com/pschatzmann/esp32_bt_music_receiver" target="_blank" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; background-color: transparent; color: #e91e63; text-decoration-line: none; transition: all 0.3s ease 0s;"><span style="font-size: 11px;">Github</span></a></p>
<h3 style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: roboto, helvetica, arial, sans-serif; font-weight: 500; line-height: 1.618; color: #3c4858; margin: 0px 0px 15px; background-color: #ffffff;"><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">Conclusion</span></strong></h3>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">This is the perfect functionality to revive my old&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">Technics SU-Z2 Amplifier:&nbsp;</span></strong><span style="font-size: 11px;">I can use it now by streaming my music from my&nbsp;</span><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><span style="font-size: 11px;">Android Phone or IPAD.</span></strong></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><strong style="box-sizing: border-box; -webkit-tap-highlight-color: transparent;"><img loading="lazy" src="https://www.pschatzmann.ch/wp-content/uploads/2020/03/su-z2-300x131.png" alt="" width="300" class="alignnone size-medium wp-image-1198" srcset="https://www.pschatzmann.ch/wp-content/uploads/2020/03/su-z2-300x131.png 300w, https://www.pschatzmann.ch/wp-content/uploads/2020/03/su-z2.png 512w" sizes="(max-width: 300px) 100vw, 300px" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; border: 0px; vertical-align: middle; max-width: 100%; height: auto; margin-bottom: 12px;" /></strong></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">Initially I wanted to use the ESP32 also to stream some Internet Radios via WIFI using http – but in the end it turned out to be much simpler to use one of the many Music Apps from a Mobile Phone&nbsp; with Bluetooth as output!</span></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><span style="font-size: 11px;">The only task left now is to build a casing…</span></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">&nbsp;</span></p>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin-bottom: 15px; line-height: 1.618; color: #3c4858; font-family: roboto, helvetica, arial, sans-serif; background-color: #ffffff;"><img loading="lazy" src="https://www.pschatzmann.ch/wp-content/uploads/2020/03/IMG_20200327_170046-225x300.png" alt="" width="470" class="alignnone wp-image-1314" srcset="https://www.pschatzmann.ch/wp-content/uploads/2020/03/IMG_20200327_170046-225x300.png 225w, https://www.pschatzmann.ch/wp-content/uploads/2020/03/IMG_20200327_170046.png 480w" sizes="(max-width: 470px) 100vw, 470px" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; border: 0px; vertical-align: middle; max-width: 100%; height: auto; margin-bottom: 12px;" /></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">&nbsp;</span></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">&nbsp;</span></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">The ESP32 provides a Bluetooth A2DP API that receives sound data e.g. from your Mobile Phone and makes it available via a callback method. The output is a PCM data stream decoded from SBC format. The documentation can be found&nbsp;</span><a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2s.html" rel="nofollow" target="_blank" style="box-sizing: border-box; background-color: initial; color: #0366d6; text-decoration-line: none;"><span style="font-size: 11px;">here</span></a><span style="font-size: 11px;">.</span></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">I2S is an electrical serial bus interface standard used for connecting digital audio devices together. It is used to communicate PCM audio data between integrated circuits in an electronic device.</span></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">So we can just feed the input from Bluetooth to the I2S output: An example for this from Expressive can be found on&nbsp;</span><a href="http://https//github.com/espressif/esp-idf/tree/master/examples/bluetooth/bluedroid/classic_bt/a2dp_sink" rel="nofollow" target="_blank" style="box-sizing: border-box; background-color: initial; color: #0366d6; text-decoration-line: none;"><span style="font-size: 11px;">Github</span></a><span style="font-size: 11px;">.</span></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">Unfortunately this example did not make me happy so I decided to convert it into a simple C++ class that is very easy to use from an Arduino Software IDE.</span></p>
<h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid rgb(234, 236, 239); color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><a id="user-content-a-simple-i2s-example" class="anchor" aria-hidden="true" href="https://github.com/pschatzmann/esp32_bt_music_receiver#a-simple-i2s-example" target="_blank" style="box-sizing: border-box; background-color: initial; color: #0366d6; text-decoration-line: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span style="font-size: 11px;">A Simple I2S Example</span></h2>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">Here is the simplest example which just uses the proper default settings:</span></p>
<pre style="box-sizing: border-box; font-family: sfmono-regular, consolas, &quot;liberation mono&quot;, menlo, monospace; margin-top: 0px; margin-bottom: 16px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: #f6f8fa; border-radius: 6px; color: #24292e;">
   <code style="box-sizing: border-box; font-family: sfmono-regular, consolas, &quot;liberation mono&quot;, menlo, monospace; padding: 0px; margin: 0px; background: initial; border-radius: 6px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; overflow-wrap: normal;"><span style="font-size: 11px;">#include &lt;arduino.h&gt;
#include "esp32_bt_music_receiver.h"
BlootoothA2DSink a2d_sink;
void setup() {
    a2d_sink.start("MyMusic");
}
void loop() {
}
</span></code>
   </pre>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">This creates a new Bluetooth device with the name “MyMusic” and the output will be sent to the following default I2S pins: – bck_io_num = 26, – ws_io_num = 25, – data_out_num = 22,</span></p>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">which need to be conected to an external DAC. You can define your own pins easily by calling the set_pin_config method.</span></p>
<h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid rgb(234, 236, 239); color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><a id="user-content-output-to-the-internal-dac" class="anchor" aria-hidden="true" href="https://github.com/pschatzmann/esp32_bt_music_receiver#output-to-the-internal-dac" target="_blank" style="box-sizing: border-box; background-color: initial; color: #0366d6; text-decoration-line: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span style="font-size: 11px;">Output to the Internal DAC</span></h2>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">You can also send the output directly to the internal DAC of the ESP32 by providing the corresponding i2s_config:</span></p>
<pre style="box-sizing: border-box; font-family: sfmono-regular, consolas, &quot;liberation mono&quot;, menlo, monospace; margin-top: 0px; margin-bottom: 16px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: #f6f8fa; border-radius: 6px; color: #24292e;">
   <code style="box-sizing: border-box; font-family: sfmono-regular, consolas, &quot;liberation mono&quot;, menlo, monospace; padding: 0px; margin: 0px; background: initial; border-radius: 6px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; overflow-wrap: normal;"><span style="font-size: 11px;">#include &lt;arduino.h&gt;
#include "esp32_bt_music_receiver.h"
BlootoothA2DSink a2d_sink;
void setup() {
    static const i2s_config_t i2s_config = {
        .mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN),
        .sample_rate = 44100, // corrected by info from bluetooth
        .bits_per_sample = (i2s_bits_per_sample_t) 16, /* the DAC module will only take the 8bits from MSB */
        .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
        .communication_format = I2S_COMM_FORMAT_I2S_MSB,
        .intr_alloc_flags = 0, // default interrupt priority
        .dma_buf_count = 8,
        .dma_buf_len = 64,
        .use_apll = false
    };
    a2d_sink.set_i2s_config(i2s_config);
    a2d_sink.start("MyMusic");
}
void loop() {
}
</span></code>
   </pre>
<p style="box-sizing: border-box; margin-bottom: 16px; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">The output goes now to the DAC pins G26/G27.</span></p>
<h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid rgb(234, 236, 239); color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><a id="user-content-installation" class="anchor" aria-hidden="true" href="https://github.com/pschatzmann/esp32_bt_music_receiver#installation" target="_blank" style="box-sizing: border-box; background-color: initial; color: #0366d6; text-decoration-line: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span style="font-size: 11px;">Installation</span></h2>
<p style="box-sizing: border-box; color: #24292e; font-family: -apple-system, blinkmacsystemfont, &quot;segoe ui&quot;, helvetica, arial, sans-serif, &quot;apple color emoji&quot;, &quot;segoe ui emoji&quot;; background-color: #ffffff;"><span style="font-size: 11px;">You can download the library as zip and call include Library -&gt; zip library. Or you can git clone this project into the Arduino libraries folder</span></p>