Python Web Proxy Convinces Sonos To Stream YouTube

[Maurice-Michel Didelot] owns a Sonos smart speaker, and was lamenting the devices inability (or plain unwillingness) to stream music from online sources without using a subscription service. YouTube Music will work, but being a subscription product there is a monthly fee, which sucks since you can listen to plenty of content on YouTube for free. [Maurice] decided that the way forward was to dig into how the Sonos firmware accesses ‘web radio’ sources, and see if that could be leveraged to stream audio from YouTube via some kind of on-the-fly stream conversion process.

What? No MP4 support for web radio? Curses!

So let’s dig in to how [Maurice] chose to approach this. The smart speaker can be configured to add various streaming audio sources, and allows you add custom sources for those. The Sonos firmware supports a variety of audio codecs, besides MP3, but YouTube uses the MP4 format. Sonos won’t handle that from a web radio source, so what was there to do, but make a custom converter?

After a little digging, it was determined that Sonos supports AAC encoding (which is how MP4 encodes audio) but needs it wrapped in an ADTS (Audio Data Transport Stream) container. By building a reverse web-proxy application, in python using Flask, it was straightforward enough to grab the YouTube video ID from the web radio request, forward a request to YouTube using a modified version of pytube tweaked to not download the video, but stream it. Pytube enabled [Maurice] to extract the AAC audio ‘atoms’ from the MP4 container, and then wrap them up with ADTS and forward them onto the Sonos device, which happily thinks it’s just a plain old MP3 radio stream, even if it isn’t.

Sonos doesn’t have the best reputation, let’s say, but you can’t deny that there’s some pretty slick tech going on inside. Here’s a neat hack we covered last year, adding Sonos support to an old school speaker, and a nice teardown of a IKEA Sonos-compatible unit, which uses some neat design hacks.

Thanks [mip] for the tip!

Featured image by Charles Deluvio on Unsplash.

Know Audio: A Mess Of Cables

We’ve now spent several months in this series journeying through the world of audio, and along the way we’ve looked at the various parts of a Hi-Fi system from the speaker backwards to the source. It’s been an enjoyable ride full of technical detail and examining Hi-Fi myths in equal measure, but now it’s time to descend into one of the simplest yet most controversial areas of audio reproduction. Every audio component, whether digital or analogue, must be connected into whatever system it is part of, and this is the job of audio cables, sometimes referred to as interconnects. They are probably the single component most susceptible to tenuous claims about their performance, with audiophiles prepared to spend vast sums on cables claimed to deliver that extra bit of listening performance. Is there something in it, or are they all the same bits of wire with the expensive ones being a scam? Time to take a look.

What Makes A Nearly Good Cable

In a typical domestic audio system with digital and analogue signals you might expect to find two types of cable, electrical interconnects that could carry either analogue or digital signals, and optical ones for digital signals. We’re here to talk about the electrical cables here as they’re the ones used for analogue signals, so lets start with a little transmission line theory. Continue reading “Know Audio: A Mess Of Cables”

Woodworking, Blinkenlites, And FFT’s Dance To The Music

We all have that one project on our minds that we’d love to build if we could just find the right combination of time, energy, and knowledge to dive right in. For [Jonathan], that project was a sound sculpture that’s finally made it from concept to complete. [Jonathan] describes the sound sculpture as the culmination of a decade of learning, and in a moment you’ll understand why.

The sculpture itself is a beautiful display of woodwork mixed with what appear to be individually addressable LED’s. The varying length of the individual enclosures evokes the idea that the sculpture is somehow involved in the sound production, which is a nice touch.

An Adafruit microphone module feeds detected audio into a PSoC 5 microcontroller. You’d expect that [Jonathan] just used one of the FFT libraries that are available. But you’ll recall that this was the culmination of a decade of learning- why so? Because [Jonathan] went through the process of procuring his own grey hairs by writing his own FFT function. A homebrew FFT function and blinkenlites? What’s not to love!

You may also enjoy this discussion of Sine Waves, Square Waves, and FFT’s with our own Bil Herd.

Continue reading “Woodworking, Blinkenlites, And FFT’s Dance To The Music”

Know Audio: Mixtapes, Tape Loops, And Razor Blades

In our no-nonsense journey through the world of audio technology we’ve so far have looked at digital audio and the vinyl disk recording. What’s missing? Magnetic tape, the once-ubiquitous recording medium that first revolutionised the broadcast and recording industries in the mid-20th-century, and went on to be a mainstay of home audio before spawning the entire field of personal audio. Unless you’re an enthusiast or collector, it’s likely you won’t have a tape deck in your audio setup here in 2021 and you’ll probably be loading your 8-bit games from SD card rather than cassette, but surprisingly there are still plenty of audio cassettes released as novelties or ephemeral collectables.

The Device That Made The Sound Of The Latter Half Of The 20th Century

"Like a travelling razor blade", a Blattnerphone steel-strip tape recorder at the BBC in 1937. Douglas Hallam, Jr., Public domain.
“Like a travelling razor blade”, a Blattnerphone steel-strip tape recorder at the BBC in 1937. Douglas Hallam, Jr., Public domain.

The first magnetic recordings were made directly on metal wires, but metal fatigues as it bends. By coating a flexible plastic tape in ferrous particles, the same simple technique of laying down an audio signal as variations in the magnetic field could be made smaller, lighter, and more robust. But the key to the format’s runaway success is the technical advancements that differentiate those 1950s machines from their wire recorder ancestors.

Whether it is a humble cassette recorder or a top-end studio multitrack, all tape recorders are very similar. There are two reels that hold the tape: the playback reel that houses the recording, and the take-up reel that stores the tape as it plays in the machine. The take-up reel is lightly driven to run faster than the tape speed, and the playback reel has a slight braking force to keep the tape under tension at all times. Continue reading “Know Audio: Mixtapes, Tape Loops, And Razor Blades”

Paper Plate Surround Sound System

With the holiday season, you might turn to paper plates to cut down on dishwashing after having family or friends over. But what do you do with the extras? If you are [TKOR] you make some speakers. The process is fairly simple and if you know how a speaker works, you won’t find any surprises, but there are some neat techniques you might pick up. You can see the video below.

A drill and a steel rod help with the coil winding duty. You can probably adapt the technique to make other kinds of coils and we’d rig up an encoder to count revolutions, too.

Continue reading “Paper Plate Surround Sound System”

Know Audio: Get Into The Groove

The legendary Technics SL1200 direct-drive turntable, as used by countless DJs. Dydric [CC BY-SA 2.5)], via Wikimedia Commons.
The legendary Technics SL1200 direct-drive turntable, as used by countless DJs. Photo by Dydric CC-BY-SA 2.5
For me, the vinyl record player is the spiritual home of my audio listening experience, probably because I’m of the last generation to grow up when vinyl was king. The 12″ album, with its full-size sleeve and copious sleeve notes, used to be an integral part of musical enjoyment that hasn’t been adequately replicated in the age of streaming.

And like anyone who became an adult while CD players were still expensive luxury items, I started my journey into Hi-Fi with a turntable set-up that sounded pretty good. Since a new generation have in recent years rediscovered vinyl, it’s once again something that should be part of any review of audio technology.

I would have started this piece with a full run-down of the constituent parts of a good turntable, but since that’s a piece that I wrote back in 2017, it’s time to investigate some of the audiophile claims about vinyl recordings. It’s fair to say that this is an area where a lot of complete rubbish is spouted by people who should know better, and that’s something I find immensely entertaining to poke fun at. Buckle up. Continue reading “Know Audio: Get Into The Groove”

Binaural Hearing Modeled With An Arduino

You don’t have two ears by accident. [Stoppi] has a great post about this, along with a video you can see below. (The text is in German, but that’s what translation is for.) The point to having two ears is that you receive audio information from slightly different angles and distances in each ear and your amazing brain can deduce a lot of spatial information from that data.

For the Arduino demonstration, cheap microphone boards take the place of your ears. A servo motor points to the direction of sound. This would be a good gimmick for a Halloween prop or a noise-sensitive security camera.

Continue reading “Binaural Hearing Modeled With An Arduino”