Cross-Correlation Makes Quick Work Of Ads

Once relegated to the proverbial Linux loving Firefox user, ad blocking has moved into public view among increased awareness of privacy and the mechanisms of advertising on the internet. At the annual family gathering, when That Relative asks how to setup their new laptop, we struggle through a dissertation on the value of ad blockers and convince them to install one. But what about mediums besides the internet? Decades ago Tivo gave us one button to jump through recorded TV. How about the radio? If available, satellite radio may be free of The Hated Advertisement. But terrestrial radio and online streams? [tomek] wasn’t satisfied with an otherwise sublime experience listening streaming Polish Radio Three and decided to build a desktop tool to detect and elide ads from the live audio stream.

[tomek] was aware of this hip knowledge domain called Digital Signal Processing but hadn’t done any of it themselves. Like many algorithmic problems the first step was to figure out the fastest way to bolt together a prototype to prove a given technique worked. We were as surprised as [tomek] by how simple this turned out to be. Fundamentally it required a single function – cross-correlation – to measure the similarity of two data samples (audio files in this case). And it turns out that Octave provides it in the box. After snipping the start-of-ad jingle out of a sample file and comparing it to a radio program [tomek] got the graph at the left. The conspicuous spike is the location of the jingle in the audio file.

At this point all that was left was packaging it all into a one click tool to listen to the radio without loading an entire analysis package. Conveniently Octave is open source software, so [tomek] was able to dig through its sources until they found the bones of the critical xcorr() function. [tomek] adapted their code to pour the audio into a circular buffer in order to use an existing Java FFT library, and the magic was done. Piping the stream out of ffmpeg and into the ad detector yielded events when the given ad jingle samples were detected.

[tomek] packaged that tool into a standalone executable, but the gem here is the followup post. After removing ads in the online stream they adapted a RaspberryPi to listen to an FM receiver and remote control their Yamaha tuner over the network. So when the tuner is playing Radio Three the Pi notices and ducks the audio appropriately to avoid those pesky ads. Video of this after the break.

https://www.youtube.com/watch?v=hmdEd4WlKE8

25 thoughts on “Cross-Correlation Makes Quick Work Of Ads

      1. All ads are indirect forced charges, because the money paid to you by the advertisers is taken out of the consumers who ultimately pay those ads in the price of the products and services they buy.

        The fact that you show ads and have viewers means that someone’s digging into our back pockets to take the money, and that leaves us with no choice but to pay; therefore you’re not giving us stuff for free, and what’s worse you’re actually making even non-viewers of your site pay.

        The ad-economy is basically a sham.

        1. Is it true for all ads, really? For example, if I made a new product, without advertisements my sales would be really low and thus price would have to be very high. But I paid for advertisements, more people who need the product would find it, and would pay less for it. Who is the one who loses here, or is it win-win?

          1. “Who is the one who loses here, or is it win-win?”

            Anyone who doesn’t need or want your product but is forced to view the ads?

            You make a valid point about advertisements as in they can be useful to get the word out about a new or even renewed product, but i would argue that there are much more effective ways of targeting possible customers. I run both a script and ad blocking add-ons in my browser so the only ads i really see are the reviews of products that are done by the websites that i visit. I would argue that this is the most effective form of advertisement in terms of cost of running versus potential customers reached. Random web advertisements are just taking a shotgun approach and the targeted ones are usually behind the curve (only showing you ads after you have purchased a product or used a service). Radio ads can be useful if you run a local venue like a restaurant or bar but for the most part the entire advertisement industry is broken, so much so due to their flimsy correlations between views or clicks and actual purchases. the only true feedback mechanism is “surveys” which i would postulate are statistically flawed, often due to small sample sizes but also due to the inherent bias of asking people who have just bought a service/product how they found out about the product while not being able to survey people who have bought a competitive product or no product at all.

          2. There’s two kinds of ads:
            1) informing the consumers about the availability of products
            2) pushing your brand or product to create needs and eclipse your competition

            99% of ads are of type 2. When type 1 sort of advertisement is warranted, the consumers usually search for the information themselves instead. Very very few people just stumble upon some random ad and go “Hey, that’s just what the doctor ordered!” because all the ad-slots are filled by type-2 advertisers.

            In other words, a company like Apple makes you pay extra to serve you advertisement that convince people to buy Apple instead of some cheaper brand – one that would be a google search away in the case you really needed a new computer. Where’s the win in that?

          3. >”Anyone who doesn’t need or want your product but is forced to view the ads?”

            All people lose, because the extra cost of pointless ads is pushed onto the consumers, who then push the cost onto other consumers because most consumers are producers of some sort.

            So you don’t buy Apple or view their ads, but your grocery-store owning neighbor gets confused by the constant bombardment and buys one, and then charges you and a host of other people a cent extra each to pay the cost of the computer and the ad.

      2. Ouch. Just in case, I was asking because my intent was to actually donate :P

        Technically speaking (the best kind of speaking) I’m not blocking ads, I’m blocking javascript. Ultimately this tends to have a similar effect however.
        Also I don’t do that due to entitlement, I do so because in general the Internet is not a safe place.

        But really what’s the alternative? Is it only acceptable to count as part of the viewership and community when risking so much, vs the other extreme of not being welcome? Is there no room for a middle ground of safe web browsing while directly supporting you?

        I really do hope you’ll reconsider.

        1. I read your question in the spirit intended. ‘Someone’ must have been getting crabby before bedtime.

          Good intent aside, I suspect tip jars on the internet don’t work as well as could be hoped, and paid subscriptions tend to generate scorn.

      3. im confused, i already don’t see any ads on this site but i would like to chip in a bit of money every now and then to help this site. A donation link would definitely help with this as i dont feel bad about the advertisers loosing out on the money but i do feel bad about HAD having to work with a tighter budget because of loss of advertising revenue. The OP wasnt suggesting a donation link with the removal of ads as enticement, just a donation link for the sake of donations. Most of us can remove the ads on our own without any input from you.

        Ps, putting in anti-ad-blocking code into your website will definitely stop me from visiting any site.

  1. I recall there being some sideband information that told the car digital radios to turn up the volume or something during ads. This should be very easy to find and work around with our fancy SDRs and stuff today.

  2. I am hip to this. My local NPR station is run by Purdue Kindergarten. Today with repeated train wrecks (two things at once) I had to stream All Things Considered from Indy. Our local affiliate has the highest number of repeated urges to donate, go to their facesbook, or their website, use their app for Android or Apple, or listen online than any of dozens of public stations I have heard. That was dozens even before the web from one location no less. Since all these pleas are recorded, matching them against a mute list should be easy with the processing speed available now.

    I am not good at code and wrestling anything beyond a GUI, but I want this. I have never watched RDS in action, as in song title then end of song break etc. I assume something could parse it’s content or is it ambiguous on purpose. This is for radio not streams, but then they have their ID which the same actions can be extracted from. RDS was first tested here in Lafayette to Kokomo for Delco. Come to think of it the stream on something I heard with VLC shows a “support XXXX station” or something like that when the song title disappears on ending during a break.

    Otherwise the best public streams I get are heaven on earth, no need for any muting at all. Publicradiofan.com is a great source to find such streams.

    1. NPR is the worse by far, and if you really wanna get PO’ed, search around and see what some of their people make. They are not poor. They could get kids to do most of their jobs for free. And I am not kidding. Outside of that our local NPR, WSKG, play blatantly sexist ads, um I mean, um, mantras from big donors, on a regular basis. NPR was also definitely not a fan community based LPFM. And the thought that they are brought to you by “listeners like you” is laughable. FIrst they will never get a cent from me running their sexist ads, but more to the point, some poor old lady on a fixed income gives them blood money, that they probably laugh at. Their bread and butter are the very comperations they claim have no influence over them. Just listen to who their major benefactors are. I trust regular broadcast news as much as I trust NPR. Normal broadcasters need to answer to their listeners, NPR needs to answer to the big benefactors. Big difference. And the way they jump on something and act like it is near and dear to their hearts. WITH, another NPR station. I have some breaking news for you. Aretha Franklin is STILL DEAD. I think yesterday they finally stopped with the “breaking news” on that story. And for a station that I can never recall playing one of her tunes, they sure made up for it once she was dead. Just the nastiest kind of parasites. But they placate the pseudo intellectuals I guess.

      (rant mode off….)

      1. My favorite thing is when the NPR crowd spends several hours on the perils of “social” media tracking your thoughts and tilting elections, etc….
        Then, throughout that chatter they “invite you to join in the conversation” (only) via (you guessed it!) social media.
        The icing on the cake is how often the segment is sponsored by some automotive tracking device from X brand car insurance company.

  3. > [tomek] was aware … but hadn’t done any of it *themselves*.
    > [tomek] was able to dig through its sources until *they* found

    Bad personal form used? Tomek is a single person (male).

  4. Wouldn’t this work against audio streams that have a broadly diverse set of musical types? Conversely, then, wouldn’t this favor dull uniformity in audio programming? If so, SiriusXM has it already.

  5. Ha, this was actually somewhere down on my to-do list. Nice that now we have this proof of concept. How about a more systematic approach so we would have a P2P/cloud broadcasting timestamps of when ads start and end on all TV and radio channels? An engine to collect signatures of all ads and use that to learn all the opening/closing jingles? We may soon get rid of almost all advertising on broadcast media, just like we did on the web.

  6. I would like to see more info on this. The 7 second clip was not much to go on. I would love to copy my large OTR collection over to another machine and be able to run a robot to find and remove ad’s. It would also be potentially cool for it to be able to split the file into pieces so you could introduce new material where the ads were.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.