• Welcome to ASR. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

esp32 spdif input

netham45

Member
Joined
Mar 25, 2025
Messages
7
Likes
16
I've made a decoder for receiving S/PDIF on an ESP32


How it works:

It uses RMT to capture raw pulse timings from a GPIO pin. It shoves these into a ringbuf that a processing thread pulls from.

The processing thread is ran on it's own core and converts from the RMT timings

The processing thread waits for a preamble it recognizes and decodes the SPDIF preample + PCM data from the input frame

It then waits until it has L,R samples then writes them to another ringbuf in sync to ensure channel sync

Usage:
Import spdif_in.h
Call spdif_receiver_init(<gpio pin>) to initialize the receiver, this will start receiving
Call spdif_receiver_read(buffer, size) to read data in from SPDIF

It runs the decoding thread on core 1 and is only just able to keep up on an esp32s3 set to 240MHz. I would recommend not running any other tasks on the same core and ensuring your CPU is set to full speed in idf.py menuconfig


With this I am able to decode and transmit spdif received from two different toslink devices (a TV, and a USB -> Toslink cable) just fine. I haven't tested on anything else.


I figured this might be a place where people would be interested in this.
 
Last edited:
Will give it a try!
Do you think it could be done so that it captures adat and/or 5.1?
 
Will give it a try!
Do you think it could be done so that it captures adat and/or 5.1?
You could for sure capture it for external processing but I'm not sure decoding those on esp32 is feasible

I don't capture all of the header info I believe is needed for that in this
 
  • Like
Reactions: MCH
Back
Top Bottom