Last week I tried to connect the Teensy's SPDIF output sinks to a cheap USB audio dongle (like this but from ebay and costing less than $10). It wouldn't pick up any sound, no matter if I used AudioOutputSPDIF, AudioOutputSPDIF2 or AudioOutputSPDIF3. Looking at the code I noticed the channel status was not implemented and suspected the lack of the "copy permitted" bit to be the problem. This was easy to check for AudioOutputSPDIF3 since the channel status bitstream is implemented as a register:
This was enough to get working audio from AudioOutputSPDIF3. But what about the I2S based AudioOutputSPDIF and AudioOutputSPDIF2?
They required a bit more work; for starters the VUCP_INVALID definition was incorrect and wasn't marking V as invalid at all, but was just setting U and C instead. I fixed that, added a mask to flip U and C (the total number of set bits must be even to keep the parity bit clear), reworked the encoding a bit and added a bit "array" based on the channel status:
github.com
This got audio working for AudioOutputSPDIF. But I wasn't going to duplicate all that work for AudioOutputSPDIF2; instead I templated the code so it could be used by both I2S-based SPDIF interfaces:
github.com
Now all three output interfaces work correctly with my USB dongle.
I know there's been a few queries in the past by people asking to implement the various AES-EBU standards over SPDIF, these are basically the same thing but with slightly different channel status formats. If someone was inclined they could extend my channel_status class to accommodate those, but for now I'm happy just having the copy_permitted bit set in the output.
SPDIF_STCSCH = 1 << 21; // set copyright permitted bit in control channelThis was enough to get working audio from AudioOutputSPDIF3. But what about the I2S based AudioOutputSPDIF and AudioOutputSPDIF2?
They required a bit more work; for starters the VUCP_INVALID definition was incorrect and wasn't marking V as invalid at all, but was just setting U and C instead. I fixed that, added a mask to flip U and C (the total number of set bits must be even to keep the parity bit clear), reworked the encoding a bit and added a bit "array" based on the channel status:
set copyright permitted bit in channel status for output_spdif and ou… · A-Dunstan/Audio@c86f41e
…tput_spdif3
This got audio working for AudioOutputSPDIF. But I wasn't going to duplicate all that work for AudioOutputSPDIF2; instead I templated the code so it could be used by both I2S-based SPDIF interfaces:
template SPDIF I2S code so it is shared between AudioOutputSPDIF and … · A-Dunstan/Audio@701aa56
…AudioOutputSPDIF2
Now all three output interfaces work correctly with my USB dongle.
I know there's been a few queries in the past by people asking to implement the various AES-EBU standards over SPDIF, these are basically the same thing but with slightly different channel status formats. If someone was inclined they could extend my channel_status class to accommodate those, but for now I'm happy just having the copy_permitted bit set in the output.