Added S/PDIF output using I2S peripheral (#235)

* Added S/PDIF output using I2S peripheral

* Added AudioOutputSPDIF to README and PROGMEM changes
This commit is contained in:
Ivan Kostoski authored and GitHub committed 2020-02-07 13:05:03 -08:00
1 parent 2c52aeaf44
commit a7a8b917d2
4 files changed
+455

No files matched your search

+18
View File
@@ -158,6 +158,8 @@ AudioOutputI2S: Interface for any I2S 16-bit DAC. Sends stereo or mono signals
AudioOutputI2SNoDAC: Abuses the I2S interface to play music without a DAC. Turns it into a 32x (or higher) oversampling delta-sigma DAC. Use the schematic below to drive a speaker or headphone from the I2STx pin (i.e. Rx). Note that with this interface, depending on the transistor used, you may need to disconnect the Rx pin from the driver to perform serial uploads. Mono-only output, of course.
AudioOutputSPDIF (experimental): Another way to abuse the I2S peripheral to send out BMC encoded S/PDIF bitstream. To interface with S/PDIF receiver it needs optical or coaxial transceiver, for which some examples can be found at https://www.epanorama.net/documents/audio/spdif.html. It should work even with the simplest form with red LED and current limiting resistor, fed into TOSLINK cable. Due to BMC coding, actual symbol rate on the pin is 4x normal I2S data rate and for each 16bit sample it needs to send out 64bits. On ESP32 with APLL it seems to work well, for up to 48KHz sample rate source. On ESP8266, it seems to hit some hardware limits and your mileage may wary. So far, it seems to work only with 32KHz sampling rate (probably due to whole number clock division), which is the minimum sample rate specified for the SPDIF interface.
AudioOutputSerialWAV: Writes a binary WAV format with headers to the Serial port. If you capture the serial output to a file you can play it back on your development system.
AudioOutputSPIFFSWAV: Writes a binary WAV format with headers to a SPIFFS filesystem. Ensure the FS is mounted and SPIFFS is started before calling. USe the SetFilename() call to pick the output file before starting.
@@ -234,6 +236,22 @@ If you've built the amp but are not getting any sound, @msmcmickey wrote up a ve
2. If connected properly, do you have ~5 volts between the collector and emitter?
3. Was the transistor possibly damaged/overheated during soldering, or by connecting it improperly? Out-of-circuit diode check voltage drop test using a multimeter from base->emitter and base->collector should be between .5 and .7 volts. If it's shorted or open or conducting in both directions, then replace it and make sure it's connected properly.
## SPDIF optical output
The proper way would be using optical TOSLINK transmitter (i.e. TOTXxxx). For testing, you can try with ~660nm red LED and resistor. Same as your basic Blink project with external LED, just that the LED will blink a bit faster.
```
____
ESP Pin -------|____|--------+
|
---
V LED
---
|
Ground ---------------------+
```
For ESP8266 with red LED (~1.9Vf drop) you need minimum 150Ohm resistor (12mA max per pin).
On ESP8266 output pin is fixed (GPIO3/RX0), while on ESP32 it is confgurable with `AuditOutputSPDIF(gpio_num)`.
## Using external SPI RAM to increase buffer
A class allows you to use a 23lc1024 SPI RAM from Microchip as input buffer. This chip connects to ESP8266 HSPI port and uses an [external SPI RAM library](https://github.com/Gianbacchio/ESP8266_Spiram).
You need to choose another pin than GPIO15 for Cs as this pin is already used by the I2S port. Here is an example with the Cs pin plugged to GPIO00 on NodeMCU board.