With Arduino library support on an ARM Cortex M4 processor, it’s no surprise that we’re fans of the Teensy 3.1. And lately, [Paul Stoffregen] has been building out the Audio Library for this platform, making it even more appealing to the synth / audio geeks among us. And now, with just the addition of a highfalutin LED and some software, the Teensy can output digital audio over optical fiber.
S/PDIF, and more specifically optical TOSLINK, uses LED light sent down an optical fiber to encode audio data. The advantage of this over any voltage-level signals (like with regular wires) is that the source and destination devices aren’t electrically connected at all, which gets rid of the dreaded ground loop hum and any RF interference.
An S/PDIF audio data stream is a bit complex, but if you’re interested [Micah Scott] has a fantastic dissection of it up on her blog. Of course, you don’t have to know anything about any of that to simply use S/PDIF with the Teensy Audio Library.
We love open source hardware and software because of the collaborations that make ultra-rapid development of niche stuff like this possible. You can follow along with the development of the Teensy’s S/PDIF capabilities on the PJRC forum. Contributor [Frank B] modestly claims that “everything was already on the internet”, but that doesn’t make it any less cool that they got from zero to working library in a few weeks. (And note the clever use of a precomputed lookup table for speed.)
On the hardware side, [Paul] has posted up his adapter board for a cheap, but very professional looking, optical TOSLINK sender. But if you’re feeling ghetto, you can simply use a red LED pointed just right into the optical cable.
The end result? Lossless transmission of CD-quality audio from an Arduino-esque microcontroller, sent on a beam of light, for less than the cost of a latté.
[Entropia] decided to try his hand at rolling is own sound card. He picked out a DAC chip, started his prototyping by studying the reference design from the datasheet, then went through several iterations to arrive at this working model.
He chose to base the board around the PCM2706. It’s a digital to analog converter that has built-in USB support; perfect for his needs. It’s got a headphone amplifier, but is also capable of putting out S/PDIF signals for a digital amplifier to pick up and use. Not bad for a part that can be had for right around eight bucks.
The first PCB he designed had a few electrical and footprint errors. But he was able to get it to run by adding some point-to-point jumpers, and bending the legs of his capacitors to fit the board area. With those issued accounted for he ordered a second batch of boards. These went together nicely, but the headphone output was incredibly loud. Turns out the filtering circuit had the wrong resistor and capacitor values. Changing them around, and swapping the audio output so that the correct channels were patched to the audio jack brings it to the first release version seen above.
[Mike Field] took what he had learned with a few past projects and combined them to make this FPGA-based SPDIF audio pass-through. In order to get the SPDIF signal ready for the FPGA he needed a few components to use for level conversion. Once everything was connected he used a first in first out (FIFO) buffer to ensure that the outgoing bitrate is the same as the input, while still allowing enough time for the FPGA to do some digital manipulation.
This reminds us of the NeTV, which is an HDMI pass-through device. That one allows you to overlay your own video information to any TV that has an HDMI port. This would allow you patch into any audio system that’s using SPDIF, letting you inject your own audio, such as a paging system in a public lobby, or the ringing of a phone when you get a call, or to create your own sounds.
We like his overhand knot cable management system to keep those jumper wires from becoming too much of a mess on the breadboard.
[Mike Field] just finished implementing SPDIF generation on an FPGA. SPDIF is an industry standard for transmitting digital audio signals; the acronym stands for Sony/Philips Digital Interconnect Format. It’s been around for more than a decade and since it’s found on most home-audio equipment, building an SPDIF output into your projects may be quite a desirable feature. [Mike] mentions several ideas for this functionality like building high-end test equipment, or providing a high-quality output for electronic instruments.
He first jumped into analyzing the specification in order to determine the hardware requirements. Due to some issues with jitter, he found it necessary to use a 100 MHz clock signal. This pushes the jitter down to +/- 5ns of jitter, which he concedes may raise the hackles of audio purists, but does satisfy the published standard. Output requires just one pin of the FPGA and the five components seen above. A hex inverter (74HC04) voltage divider, capacitor, and RCA connector transmit the 0.5V signal to your audio-receiver of choice. Of course, since TOSLINK fiber optic connectors use the same protocol, you could redesign the output and make this an optical connection.
[Beth] had the idea for transmitting digital audio over S/PDIF on a Propeller a few years ago, but only just got around to a writeup. For that, we thank her.
The writeup has a marvelous walkthrough of the S/PDIF protocol and the problems associated with with generating the signal. S/PDIF is a relatively resource-intensive protocol – the signal is clocked at 64x the audio sample rate. That signal is doubled for biphase mark code, keeping everything in sync. [Beth] says the microcontroller would neet at least 24 MIPS of processing power just to generate the S/PDIF signal – processing audio would be another task altogether. Because of the processing power needed, and the weird clock rates needed, [Beth] decided to go with the Propeller. The implementation uses only one core of the Propeller, leaving another seven cores available for sound synthesis or even a visualization over VGA.
[Beth] admits this could be done with just about any microcontroller (although it would need to be clocked at a multiple of 4.096 MHz for a 32kHz audio stream), but we really appreciate the work that went into bit-banging this signal.
Video of [Nick] at Gadget Gangster playing around with digital audio on a Propeller after the break.
Continue reading “Digital Audio on the Parallax Propeller”
When [linux-works] found himself needing a switch that could convert coax to opto, he made one. The main chip is a cd4052 cmos analog switch, which he says is really cheap. The rest is pretty self explanatory. This setup can switch between 4 different inputs as well as do the coax to opto conversion.