Radio ad blocker
Or how I learned to stop worrying and use DSP cargo
cult to mute the broadcast commercials
Analysing radio broadcast
Starting
jingle
Ad 1 Ad 2 Ad 3
Ending
jingle
Volume controlSample analyser
Broadcast
Research process: finding a
sample in the sound stream
Redefining the problem
• Let’s make it a simpler problem, by taking away the part
that we can figure out ourselves

• We can split the incoming stream into sound samples of
some length (moving window)

• So let’s try to find a way to compare two sound samples
Waveforms
Recorded jingle
Broadcast sample
Frequency domain
FFT(Broadcast sample)
FFT(Recorded jingle)
Cross correlation
Matching samples
Not matching samples
Prototyping with Octave
pkg load signal;
stream = audioread('stream.wav');
jingle1 = audioread('commercial-start.wav');
jingle2 = audioread('commercial-end.wav');
function retval = get_sample(data, from, to)
retval = data(from*32000 : to*32000-1);
endfunction
sample = get_sample(stream, 134, 135.5);
plot(sample);
plot(jingle2);
plot(real(fft(sample)));
plot(real(fft(jingle2)));
plot(xcorr(sample, jingle2));
Java implementation
Analyser
Broadcast
PCM
stdout
jingle 1
stdin
stderrrtl_fm -M wbfm 
-f 89.50M 
-g 0 
-r 48000
ffmpeg -i 
http://41.dktr.pl:8000/trojka.ogg 
-f s16le 
-acodec pcm_s16le 
-
play -r 48000 
-b 16 
-c 2 
-e signed 
-t raw -
Reading PCM data
byte[] rawBuffer = new byte[4096];
final int SAMPLE_SIZE = 4; // 2 bytes * 2 channels
ByteBuffer sample = ByteBuffer.allocate(SAMPLE_SIZE);
sample.order(ByteOrder.LITTLE_ENDIAN);
while (true) {
int length = input.read(rawBuffer);
// consume the rawBuffer
for (int i = 0; i < length; i += SAMPLE_SIZE) {
sample.clear();
sample.put(rawBuffer, i, SAMPLE_SIZE);
sample.rewind();
while (sample.hasRemaining()) {
short left = sample.getShort();
short right = sample.getShort();
// ...
}
}
}
Analysing stream with
window
Writeposition
Round-robin buffer
Porting xcorr from Octave
N = max(length(X),length(Y));
maxlag = N - 1;
M = 2^nextpow2(N + maxlag);
pre = fft( postpad( prepad( X(:), length(X)+maxlag ), M) );
post = fft( postpad( Y(:), M ) );
cor = ifft( pre .* conj(post) );
R = cor(1:2*maxlag+1);
R = real(R);
public class Waveform {
private final float[] buffer;
private final int length;
// ...
}
Waveform x = currentWindow;
Waveform y = jingle
.setPadding(jingle.getSize() + windowSize - 1, next2Pow)
.doFft();
x.doFft();
x.doConjAndMultiply(y);
x.doIfft();
float[] result = y.getMaxReal(2 * windowSize + 1);
FFT usage in Java
// https://github.com/wendykierp/JTransforms
import org.jtransforms.fft.FloatFFT_1D;
short[] shortBuffer; // (-32678,32767)
float[] buffer = shortBuffer / 32768;
// fft()
FloatFFT_1D fft = new FloatFFT_1D(length);
fft.realForwardFull(buffer);
// ifft()
fft.complexInverse(buffer, true);
buffer[i]; // i%2 == 0; real part
buffer[i+1]; // imaginary part
Toolbox
• sox package for uncompressed files (wav, raw, etc.)

• sox - conversion

• play - playback

• ffmpeg - decoding compressed streams/files (ogg, mp3)

• Octave

• Audacity

More Related Content

PDF
Tweaking the Base Score: Lucene/Solr Similarities Explained
PDF
Activate 2019: Tweaking the Base Score: Lucene/Solr Similarities Explained
PDF
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...
PDF
Golang design4concurrency
PDF
機械学習によるデータ分析 実践編
PDF
Python faster for loop
PPTX
Fourier transforms of discrete signals (DSP) 5
Tweaking the Base Score: Lucene/Solr Similarities Explained
Activate 2019: Tweaking the Base Score: Lucene/Solr Similarities Explained
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...
Golang design4concurrency
機械学習によるデータ分析 実践編
Python faster for loop
Fourier transforms of discrete signals (DSP) 5

What's hot (20)

PDF
Concurrency with Go
PDF
Golang concurrency design
PPTX
20190221 fourier series
PDF
Intel® Xeon® Phi Coprocessor High Performance Programming
PPTX
Malloc() and calloc() in c
PDF
Reconsidering tracing in Ceph - Mohamad Gebai
PPTX
Dynamic Memory allocation
PDF
Reconstruction
PDF
Demystifying the Go Scheduler
PDF
Introduction to go
PPTX
Tensorflow in practice by Engineer - donghwi cha
PDF
spectralmethod
PPTX
Fft analysis
PPTX
Dynamic memory allocation
PPTX
fourier transform of DT signals
PPTX
C dynamic ppt
PPT
Animation in Java
PDF
TensorFlow Dev Summit 2017 요약
PDF
5.MLP(Multi-Layer Perceptron)
PDF
[ShaderX5] 8 1 Postprocessing Effects In Design
Concurrency with Go
Golang concurrency design
20190221 fourier series
Intel® Xeon® Phi Coprocessor High Performance Programming
Malloc() and calloc() in c
Reconsidering tracing in Ceph - Mohamad Gebai
Dynamic Memory allocation
Reconstruction
Demystifying the Go Scheduler
Introduction to go
Tensorflow in practice by Engineer - donghwi cha
spectralmethod
Fft analysis
Dynamic memory allocation
fourier transform of DT signals
C dynamic ppt
Animation in Java
TensorFlow Dev Summit 2017 요약
5.MLP(Multi-Layer Perceptron)
[ShaderX5] 8 1 Postprocessing Effects In Design
Ad

Similar to Radio ad blocker (20)

PDF
Digital signal processing through speech, hearing, and Python
PDF
Stft vs. mfcc
PDF
Shereef_MP3_decoder
PDF
Introductory Lecture to Audio Signal Processing
PPT
13486500-FFT.ppt
PDF
Multirate sim
PDF
3 f3 3_fast_ fourier_transform
DOCX
The method of comparing two audio files
DOCX
The method of comparing two audio files
PDF
FPGA-based implementation of speech recognition for robocar control using MFCC
PPTX
Digital Signal Processing Tutorial Using Python
PDF
Res701 research methodology fft1
PDF
Technical Documentation_Embedded_Acoustic_DSP_Projects
PDF
Design and Construction of Musical Lighting Water Fountain
ODP
What Shazam doesn't want you to know
PPT
noise removal in matlab
PPTX
Guitar Tone Analyzer and Note Plotter Presentation
DOCX
Matlab code for comparing two microphone files
DOCX
Matlab code for comparing two microphone files
PPTX
Wavelet Transform and DSP Applications
Digital signal processing through speech, hearing, and Python
Stft vs. mfcc
Shereef_MP3_decoder
Introductory Lecture to Audio Signal Processing
13486500-FFT.ppt
Multirate sim
3 f3 3_fast_ fourier_transform
The method of comparing two audio files
The method of comparing two audio files
FPGA-based implementation of speech recognition for robocar control using MFCC
Digital Signal Processing Tutorial Using Python
Res701 research methodology fft1
Technical Documentation_Embedded_Acoustic_DSP_Projects
Design and Construction of Musical Lighting Water Fountain
What Shazam doesn't want you to know
noise removal in matlab
Guitar Tone Analyzer and Note Plotter Presentation
Matlab code for comparing two microphone files
Matlab code for comparing two microphone files
Wavelet Transform and DSP Applications
Ad

More from Tomasz Rękawek (9)

PPTX
Deep-dive into cloud-native AEM deployments based on Kubernetes
PDF
Emulating Game Boy in Java
PDF
Zero downtime deployments for the Sling-based apps using Docker
PDF
CRX2Oak - all the secrets of repository migration
PDF
SlingQuery
PPTX
Code metrics
PDF
Inter-Sling communication with message queue
PDF
Sling Dynamic Include
PPTX
Shooting rabbits with sling
Deep-dive into cloud-native AEM deployments based on Kubernetes
Emulating Game Boy in Java
Zero downtime deployments for the Sling-based apps using Docker
CRX2Oak - all the secrets of repository migration
SlingQuery
Code metrics
Inter-Sling communication with message queue
Sling Dynamic Include
Shooting rabbits with sling

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
UiPath Agentic Automation session 1: RPA to Agents
PPTX
2018-HIPAA-Renewal-Training for executives
PPTX
Modernising the Digital Integration Hub
PPT
What is a Computer? Input Devices /output devices
PPTX
The various Industrial Revolutions .pptx
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PPT
Module 1.ppt Iot fundamentals and Architecture
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PPTX
Configure Apache Mutual Authentication
NewMind AI Weekly Chronicles – August ’25 Week III
Developing a website for English-speaking practice to English as a foreign la...
1 - Historical Antecedents, Social Consideration.pdf
Credit Without Borders: AI and Financial Inclusion in Bangladesh
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Getting started with AI Agents and Multi-Agent Systems
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
Improvisation in detection of pomegranate leaf disease using transfer learni...
Chapter 5: Probability Theory and Statistics
A contest of sentiment analysis: k-nearest neighbor versus neural network
Consumable AI The What, Why & How for Small Teams.pdf
UiPath Agentic Automation session 1: RPA to Agents
2018-HIPAA-Renewal-Training for executives
Modernising the Digital Integration Hub
What is a Computer? Input Devices /output devices
The various Industrial Revolutions .pptx
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
Module 1.ppt Iot fundamentals and Architecture
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Configure Apache Mutual Authentication

Radio ad blocker

  • 1. Radio ad blocker Or how I learned to stop worrying and use DSP cargo cult to mute the broadcast commercials
  • 2. Analysing radio broadcast Starting jingle Ad 1 Ad 2 Ad 3 Ending jingle Volume controlSample analyser Broadcast
  • 3. Research process: finding a sample in the sound stream
  • 4. Redefining the problem • Let’s make it a simpler problem, by taking away the part that we can figure out ourselves • We can split the incoming stream into sound samples of some length (moving window) • So let’s try to find a way to compare two sound samples
  • 8. Prototyping with Octave pkg load signal; stream = audioread('stream.wav'); jingle1 = audioread('commercial-start.wav'); jingle2 = audioread('commercial-end.wav'); function retval = get_sample(data, from, to) retval = data(from*32000 : to*32000-1); endfunction sample = get_sample(stream, 134, 135.5); plot(sample); plot(jingle2); plot(real(fft(sample))); plot(real(fft(jingle2))); plot(xcorr(sample, jingle2));
  • 9. Java implementation Analyser Broadcast PCM stdout jingle 1 stdin stderrrtl_fm -M wbfm -f 89.50M -g 0 -r 48000 ffmpeg -i http://41.dktr.pl:8000/trojka.ogg -f s16le -acodec pcm_s16le - play -r 48000 -b 16 -c 2 -e signed -t raw -
  • 10. Reading PCM data byte[] rawBuffer = new byte[4096]; final int SAMPLE_SIZE = 4; // 2 bytes * 2 channels ByteBuffer sample = ByteBuffer.allocate(SAMPLE_SIZE); sample.order(ByteOrder.LITTLE_ENDIAN); while (true) { int length = input.read(rawBuffer); // consume the rawBuffer for (int i = 0; i < length; i += SAMPLE_SIZE) { sample.clear(); sample.put(rawBuffer, i, SAMPLE_SIZE); sample.rewind(); while (sample.hasRemaining()) { short left = sample.getShort(); short right = sample.getShort(); // ... } } }
  • 13. Porting xcorr from Octave N = max(length(X),length(Y)); maxlag = N - 1; M = 2^nextpow2(N + maxlag); pre = fft( postpad( prepad( X(:), length(X)+maxlag ), M) ); post = fft( postpad( Y(:), M ) ); cor = ifft( pre .* conj(post) ); R = cor(1:2*maxlag+1); R = real(R); public class Waveform { private final float[] buffer; private final int length; // ... } Waveform x = currentWindow; Waveform y = jingle .setPadding(jingle.getSize() + windowSize - 1, next2Pow) .doFft(); x.doFft(); x.doConjAndMultiply(y); x.doIfft(); float[] result = y.getMaxReal(2 * windowSize + 1);
  • 14. FFT usage in Java // https://github.com/wendykierp/JTransforms import org.jtransforms.fft.FloatFFT_1D; short[] shortBuffer; // (-32678,32767) float[] buffer = shortBuffer / 32768; // fft() FloatFFT_1D fft = new FloatFFT_1D(length); fft.realForwardFull(buffer); // ifft() fft.complexInverse(buffer, true); buffer[i]; // i%2 == 0; real part buffer[i+1]; // imaginary part
  • 15. Toolbox • sox package for uncompressed files (wav, raw, etc.) • sox - conversion • play - playback • ffmpeg - decoding compressed streams/files (ogg, mp3) • Octave • Audacity