### Amplifiers and External DAC
ESP32 Dev Boards have their own Digital Audio Converter, so they have the capabaility to be hooked up directly to a amplifier and play a sound. However, the audio quality that the ESP32 can get on its own
is very choppy. (If you want to try this method, which uses the cheap amplifiers we have in the lab, check out this tutorial.) The Arduino Uno can only play a very, very small WAV, [and at poor quality](https://github.com/charliegerard/dev-notes/blob/master/arduino/wavFilesWithoutSdCard.md).
This is where EXTERNAL DACs come in! You can offload the task of converting the digital signal to audio to another board, and get much better sound quality.
In order to hook up the MAX98357A you will want to hook up the MAX98357A to these pins on your esp32:
MAX98357A | esp32
------------- | -------------
LRC | 25
BCLK| 5
DIN| 26
GAIN| GND
GND | GND
VCC | 3.3V
Then attach the speaker wires to the screw terminals.
###Streaming Sound to the Amp
Here we are streaming a sound directly to the amp directly from the memory of the esp32. Downloading this sound file
and put it in the same directory as the code below.
```
#include
#include "Sound.h"
#define sample_rate 48000.0
I2SClass I2S;
void setup() {
I2S.setPins(5, 25, 26, -1, -1); //SCK, WS, SDOUT, SDIN, MCLK
I2S.begin(I2S_MODE_STD, sample_rate, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO);
Serial.begin(115200);
}
void loop() {
Serial.println("playing the sound");
for (float i = 0; i < 54066 ; i++)
{
//convert 8 bit to 16 bit
uint16_t sample = map(hello[(int)(i )], 0, 255, 0, 32767);
//you can only write an 8bit integer at a time so we read the 16 bit integer, 8 bits at a time
I2S.write((uint8_t *)&sample, 2);
}
}
```