Decoding S/PDIF With A Microcontroller Brings A Few Headaches

The average punter shunts audio around with analog 3.5 mm cables, RCA jacks, or Bluetooth on a regular basis. A useful standard that hasn’t really bothered most of us is S/PDIF, standing for Sony/Phillips Digital Interface. It’s a useful way to pump digital audio around over copper cables or optic fiber. [Andrew Jeddeloh] got curious about the standard after contemplating some long cable runs in his home, and decided to try decoding it.

The target for [Andrew]’s development efforts was the STM32L476 Discovery, which had no SPDIF decoding hardware on board. Instead, [Andrew] tinkered with the peripherals he had to see what would work. In the end, a cavalcade of internal timers were daisy chained to allow the microcontroller to recover a clock from the self-clocked S/PDIF signal. This was then used to generate a clock to sync up the onboard SPI hardware to actually read in the 16-bit PCM data from the S/PDIF signal.

[Andrew]’s original broader plan was to pipe the S/PDIF data to the onboard I2S DAC, though he struggled manipulating the remaining resources on the STM chip to do so successfully. Anyone wishing to have a crack can take a look at [Andrew]’s code over on GitHub. If completed, the STM32L476 would become a useful analog endpoint for S/PDIF streams, allowing you to pump tunes digitally over long distances without signal degradation. If you know the key to getting it done, sound off in the comments! Alternatively, if you need to get up and running more quickly, the Teensy platform has you covered!

All You Need To Know About I2S

Last month we marked the 40th birthday of the CD, and it was as much an obituary as a celebration because those polycarbonate discs are fast becoming a rarity. There is one piece of technology from the CD age that is very much still with us though, and it lives on in the standard for sending serial digital audio between chips. The protocol is called I2S and comes as a hardware peripheral on many microcontrollers. It’s a surprisingly simple interface that’s quite easy to work with and thus quite hackable, so it’s worth a bit of further investigation.

It’s A Simple Enough Interface

Don’t confuse this with the other Philips Semiconductor protocol: I2C. Inter-Integrated Circuit protocol has the initials IIC, and the double letter was shortened to come up with the “eye-squared-see” nomenclature we’ve come to love from I2C. Brought to life in 1982, this predated I2S by four years which explains the somewhat strange abbreviation for “Inter-Integrated Circuit Sound”.

The protocol has stuck around because it’s very handy for dealing with the firehose of serial data associated with high-quality digital audio. It’s so handy that you’ve likely heard of it being used for other purposes than audio, which I’ll get to in a little bit. But first, what does I2S actually do?

Continue reading “All You Need To Know About I2S”

Tracktorino Shields You From Poor Interfaces

On-screen controls in a digital audio workstation expand the power of a DJ or musician, but they are not intuitive for everyone. The tactility of buttons, knobs, sliders and real-world controls feels nothing like using a mouse, trackpad, or even a touchscreen. Unfortunately, devices meant to put control into a DJs hands can be unavailable due to location or cost. [Gustavo Silveira] took charge of the situation so he could help other DJs and musicians take control of their workstations with a customized MIDI interface for Traktor DJ software.

MIDI is a widely used serial protocol which has evolved from a DIN connector to USB, and now it is also wireless. This means that the Traktorino is not locked to Traktor despite the namesake. On the Hackaday.io page, there’s even a list of other workstations it will work with, but since many workstations, all the good ones anyway, accept MIDI hardware like this, the real list is a lot longer.

The custom circuit board is actually a shield. Using an Arduino UNO, the current poster child of the Arduino world, opens up the accessibility for many people who don’t know specialized software. A vector drawing for a lasercut enclosure is also included. This means that even the labeling on the buttons are not locked into English language.

Here’s another project which combined laser cutting and MIDI to make some very clever buttons or turn your DIN MIDI connector into USB.

Continue reading “Tracktorino Shields You From Poor Interfaces”

Patents On MP3 Format Due To Expire

MP3 took off in the late 90s as the digital music format. It then proceeded to slaughter the CD, and launch the file sharing revolution as well. It’s a proud format that has roots stretching all the way back to the early 1980s, when the possibility of sending music over ISDN lines was first considered. Now the patents on it are beginning to expire and its licencing program has been terminated.

The MP3 standard was the property of Fraunhofer IIS, and the original licencing model was intended such that encoders would be expensive, and decoders relatively inexpensive. This would allow people to buy software to listen to MP3s cheaply, but the creation of MP3s would be expensive, and thus handled by studios and music labels. This all changed when a high-quality MP3 encoder was leaked to the public, and suddenly it became possible to readily convert your CDs at home into the MP3 format.

One hangover of this ownership of the MP3 standard was that when you installed certain FOSS software, such as Audacity or a Linux distro, you would find that you had to go and do some legwork to find an MP3 codec. That was because it wasn’t worth the legal trouble for the FOSS authors to arrange a workaround, and trading in proprietary software is the antithesis to everything they stand for.

However, now that more of the relevant patents are expiring, you can now expect MP3 support to be baked into more software. It may be more than a little late, with more advanced audio formats beginning to take over, but it’s great to know that Fedora, for one, is starting to include MP3 support with their releases.

If you’d like to read more about the history of the MP3, check out this great article from NPR. Fraunhofer have their own great history site, too. If all this talk of advanced audio formats has gotten you excited, check out this MP3 decoder written for the ESP8266.

[Thanks to Tim Trzepacz for the tip!]

Hackaday Prize Entry: Superb Audio With The Teensy

The Raspberry Pi and Teensy 3 both have I2S interfaces, and that means these boards can be used to play very high quality audio. A codec and an I2S interface is one thing, but turning that digital stream into a quality analog output is another thing entirely. You need only look at audiophile forums for enough mis- and disinformation for that evidence.

For his Hackaday Prize entry [William Hollender] is building an audio board for the Teensy 3.x. It features very high-end opamps, the right filters, and the correct topology to turn a digital audio stream into an analog signal that would please the most temperamental ear.

The Teensy Super Audio Board uses the Cirrus CS4272 audio codec chip, a high quality chip that can handle sample rates of up to 192kHz at 24 bit depth. This chip doesn’t include the analog input and output buffers, and this means [William] has quite a build in front of him. This means using high quality opamps, low noise power supplies, and knowing how to build a circuit and measure its noise.

So far, the tests revealed incredible dynamic range, flatness, and frequency response of this tiny little board. It also works with the Raspberry Pi. Now it’s just a matter of getting a few more of these boards put together for the Best Product part of the Hackaday Prize.

 

The 2015 Hackaday Prize is sponsored by:

The Four Thousand Dollar MP3 Player

[Pat]’s friend got a Pono for Christmas, a digital audio player that prides itself on having the highest fidelity of any music player. It’s a digital audio device designed in hand with [Neil Young], a device that had a six million dollar Kickstarter, and is probably the highest-spec audio device that will be released for the foreseeable future.

The Pono is an interesting device. Where CDs have 16-bit, 44.1 kHz audio, the Pono can play modern lossless formats – up to 24-bit, 192 kHz audio. There will undoubtedly be audiophiles arguing over the merits of higher sampling rates and more bits, but there is one way to make all those arguments moot: building an MP3 player out of an oscilloscope.

Digital audio players are limited by the consumer market; there’s no economical way to put gigasamples per second into a device that will ultimately sell for a few thousand dollars. Oscilloscopes are not built for the consumer market, though, and the ADCs and DACs in a medium-range scope will always be above what a simple audio player can manage.

[Pat] figured the Tektronicx MDO3000 series scope sitting on his bench would be a great way to capture and play music and extremely high bit rates. He recorded a song to memory at a ‘lazy’ 1 Megasample per second through analog channel one. From there, a press of the button made this sample ready for playback (into a cheap, battery-powered speaker, of course).

Of course this entire experiment means nothing. the FLAC format can only handle a sampling rate of up to 655 kilosamples per second. While digital audio formats could theoretically record up to 2.5 Gigasamples per second, the question of ‘why’ would inevitably enter into the minds of audio engineers and anyone with an ounce of sense. Short of recording music from the master tapes or another analog source directly into an oscilloscope, there’s no way to obtain music at this high of a bit rate. It’s just a dumb demonstration, but it is the most expensive MP3 player you can buy.

Protocol Snooping Digital Audio

More and more clubs are going digital. When you go out to hear a band, they’re plugging into an ADC (analog-to-digital converter) box on stage, and the digitized audio data is transmitted to the mixing console over Ethernet. This saves the venue having to run many audio cables over long distances, but it’s a lot harder to hack on. So [Michael] trained popular network analysis tools on his ProCo Momentum gear to see just what the data looks like.

[Michael]’s writeup of the process is a little sparse, but he name-drops all the components you’d need to get the job done. First, he simply looks at the raw data using Wireshark. Once he figured out how the eight channels were split up, he used the command-line version (tshark) and a standard Unix command-line tool (cut) to pull the data apart. Now he’s got a text representation for eight channels of audio data.

Using xxd to convert the data from text to binary, he then played it using sox to see what it sounded like. No dice, yet. After a bit more trial and error, he realized that the data was unsigned, big-endian integers.  He tried again, and everything sounded good. Success!

While this is not a complete reverse-engineering tutorial like this one, we think that it hits the high points: using a bunch of the right tools and some good hunches to figure out an obscure protocol.