diff --git a/README.md b/README.md index 21be092..335c5e7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ All this code is released under the GPL, and all of it is to be used at your own ## Usage Create an AudioInputXXX source pointing to your input file, an AudioOutputXXX sink as either an I2SDAC, I2S-sw-DAC, or as a "SerialWAV" which simply writes a mostly-correct WAV file to the Serial port which can be dumped to a file on your development system, and an AudioGeneratorXXX to actually take that input and decode it and send to the output. -After creation, you need to call the AudioGeneratorXXX::loop() routine from inside your own main loop one or more times. This will automatically read as much of the file as needed and fill up the I2S buffers and immediately return. Since this is not interrupt driven, if you have large delay()s in your code, you may end up with hiccups in playback. Either break large delays into very small ones with calls to AudioGenerator::loop(), or reduce the sampling rate to require fewer samples per second. +After creation, you need to call the AudioGeneratorXXX::loop() routine from inside your own main loop() one or more times. This will automatically read as much of the file as needed and fill up the I2S buffers and immediately return. Since this is not interrupt driven, if you have large delay()s in your code, you may end up with hiccups in playback. Either break large delays into very small ones with calls to AudioGenerator::loop(), or reduce the sampling rate to require fewer samples per second. ## Example See the examples directory for some simple examples, but the following snippet can play an MP3 file over the simulated I2S DAC: @@ -60,6 +60,8 @@ ESP8266-I2SOUT (Rx) --+ 2N3904 (NPN) ESP8266-GND ---------------- GND +---+ K| | \ R| USB 5V ------------------------------+ +-| + +You may also want to add a 220uF cap from USB5V to GND just to help filter out any voltage droop during high volume playback. ```` If you don't have a 5V source available on your ESP model, you can use the 5V from your USB serial adapter, or even the 3V from the ESP8266 (but it'll be lower volume). Don't try and drive the speaker without the transistor, the ESP8266 pins can't give enough current to drive even a headphone well and you may end up damaging your device. @@ -71,7 +73,7 @@ USB-5V -- Speaker + Terminal 2N3904-Collector -- Speaker - Terminal ```` -Basically the transistor acts as a switch and requires only a drive of 1/beta (~1/1000 for the transistor specified) times the speaker current. As shown you've got a max power of ~2.4W into the speaker. +Basically the transistor acts as a switch and requires only a drive of 1/beta (~1/1000 for the transistor specified) times the speaker current. As shown you've got a max current of (5-0.7)/8=540mA and a power of 0.54^2 * 8 = ~2.3W into the speaker. ## Porting to other microcontrollers There's no ESP8266-specific code in the AudioGenerator routines, so porting to other controllers should be relatively easy assuming they have the same endianness as the Xtensa core used. Drop me a line if you're doing this, I may be able to help point you in the right direction.