SlideShare a Scribd company logo
1 of 15
Download to read offline
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

What's hot

Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency designHyejong
 
20190221 fourier series
20190221 fourier series20190221 fourier series
20190221 fourier seriesgrantkobe
 
Intel® Xeon® Phi Coprocessor High Performance Programming
Intel® Xeon® Phi Coprocessor High Performance ProgrammingIntel® Xeon® Phi Coprocessor High Performance Programming
Intel® Xeon® Phi Coprocessor High Performance ProgrammingBrian Gesiak
 
Malloc() and calloc() in c
Malloc() and calloc() in cMalloc() and calloc() in c
Malloc() and calloc() in cMahesh Tibrewal
 
Reconsidering tracing in Ceph - Mohamad Gebai
Reconsidering tracing in Ceph - Mohamad GebaiReconsidering tracing in Ceph - Mohamad Gebai
Reconsidering tracing in Ceph - Mohamad GebaiCeph Community
 
Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocationGrishma Rajput
 
Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Schedulermatthewrdale
 
Introduction to go
Introduction to goIntroduction to go
Introduction to goJaehue Jang
 
Tensorflow in practice by Engineer - donghwi cha
Tensorflow in practice by Engineer - donghwi chaTensorflow in practice by Engineer - donghwi cha
Tensorflow in practice by Engineer - donghwi chaDonghwi Cha
 
fourier transform of DT signals
fourier transform of DT signalsfourier transform of DT signals
fourier transform of DT signalstejaspatel1998
 
Animation in Java
Animation in JavaAnimation in Java
Animation in JavaAlan Goo
 
TensorFlow Dev Summit 2017 요약
TensorFlow Dev Summit 2017 요약TensorFlow Dev Summit 2017 요약
TensorFlow Dev Summit 2017 요약Jin Joong Kim
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 艾鍗科技
 
[ShaderX5] 8 1 Postprocessing Effects In Design
[ShaderX5] 8 1 Postprocessing Effects In Design[ShaderX5] 8 1 Postprocessing Effects In Design
[ShaderX5] 8 1 Postprocessing Effects In Design종빈 오
 

What's hot (20)

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

Similar to Radio ad blocker

Spectral Analysis of Sample Rate Converter
Spectral Analysis of Sample Rate ConverterSpectral Analysis of Sample Rate Converter
Spectral Analysis of Sample Rate ConverterCSCJournals
 
Digital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and PythonDigital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and PythonMel Chua
 
Sampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptxSampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptxHamzaJaved306957
 
DSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time Signals
DSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time SignalsDSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time Signals
DSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time SignalsAmr E. Mohamed
 
Sound analysis and processing with MATLAB
Sound analysis and processing with MATLABSound analysis and processing with MATLAB
Sound analysis and processing with MATLABTan Hoang Luu
 
Digital Signal Processing[ECEG-3171]-Ch1_L06
Digital Signal Processing[ECEG-3171]-Ch1_L06Digital Signal Processing[ECEG-3171]-Ch1_L06
Digital Signal Processing[ECEG-3171]-Ch1_L06Rediet Moges
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation志璿 楊
 
Fast Fourier Transform (FFT) of Time Series in Kafka Streams
Fast Fourier Transform (FFT) of Time Series in Kafka StreamsFast Fourier Transform (FFT) of Time Series in Kafka Streams
Fast Fourier Transform (FFT) of Time Series in Kafka StreamsHostedbyConfluent
 
CHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐ
CHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐCHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐ
CHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐlykhnh386525
 
Networks lab manual ecp62
Networks lab manual ecp62Networks lab manual ecp62
Networks lab manual ecp62Basil John
 
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLABDIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLABMartin Wachiye Wafula
 
Ning_Mei.ASSIGN02
Ning_Mei.ASSIGN02Ning_Mei.ASSIGN02
Ning_Mei.ASSIGN02宁 梅
 
pulse modulation technique (Pulse code modulation).pptx
pulse modulation technique (Pulse code modulation).pptxpulse modulation technique (Pulse code modulation).pptx
pulse modulation technique (Pulse code modulation).pptxNishanth Asmi
 

Similar to Radio ad blocker (20)

Dsp Lab Record
Dsp Lab RecordDsp Lab Record
Dsp Lab Record
 
Spectral Analysis of Sample Rate Converter
Spectral Analysis of Sample Rate ConverterSpectral Analysis of Sample Rate Converter
Spectral Analysis of Sample Rate Converter
 
Digital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and PythonDigital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and Python
 
Sampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptxSampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptx
 
DSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time Signals
DSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time SignalsDSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time Signals
DSP_2018_FOEHU - Lec 02 - Sampling of Continuous Time Signals
 
Multirate sim
Multirate simMultirate sim
Multirate sim
 
Sound analysis and processing with MATLAB
Sound analysis and processing with MATLABSound analysis and processing with MATLAB
Sound analysis and processing with MATLAB
 
Digital Signal Processing[ECEG-3171]-Ch1_L06
Digital Signal Processing[ECEG-3171]-Ch1_L06Digital Signal Processing[ECEG-3171]-Ch1_L06
Digital Signal Processing[ECEG-3171]-Ch1_L06
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation
 
Fast Fourier Transform (FFT) of Time Series in Kafka Streams
Fast Fourier Transform (FFT) of Time Series in Kafka StreamsFast Fourier Transform (FFT) of Time Series in Kafka Streams
Fast Fourier Transform (FFT) of Time Series in Kafka Streams
 
ASR_final
ASR_finalASR_final
ASR_final
 
Multrate dsp
Multrate dspMultrate dsp
Multrate dsp
 
CHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐ
CHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐCHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐ
CHƯƠNG 2 KỸ THUẬT TRUYỀN DẪN SỐ - THONG TIN SỐ
 
Networks lab manual ecp62
Networks lab manual ecp62Networks lab manual ecp62
Networks lab manual ecp62
 
Lab manual
Lab manualLab manual
Lab manual
 
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLABDIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
 
Speech Signal Processing
Speech Signal ProcessingSpeech Signal Processing
Speech Signal Processing
 
Ning_Mei.ASSIGN02
Ning_Mei.ASSIGN02Ning_Mei.ASSIGN02
Ning_Mei.ASSIGN02
 
pulse modulation technique (Pulse code modulation).pptx
pulse modulation technique (Pulse code modulation).pptxpulse modulation technique (Pulse code modulation).pptx
pulse modulation technique (Pulse code modulation).pptx
 
Gaussian
GaussianGaussian
Gaussian
 

More from Tomasz Rękawek

Deep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on KubernetesDeep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on KubernetesTomasz Rękawek
 
Emulating Game Boy in Java
Emulating Game Boy in JavaEmulating Game Boy in Java
Emulating Game Boy in JavaTomasz Rękawek
 
Zero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using DockerZero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using DockerTomasz Rękawek
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationTomasz Rękawek
 
Inter-Sling communication with message queue
Inter-Sling communication with message queueInter-Sling communication with message queue
Inter-Sling communication with message queueTomasz Rękawek
 
Shooting rabbits with sling
Shooting rabbits with slingShooting rabbits with sling
Shooting rabbits with slingTomasz Rękawek
 

More from Tomasz Rękawek (9)

Deep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on KubernetesDeep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on Kubernetes
 
Emulating Game Boy in Java
Emulating Game Boy in JavaEmulating Game Boy in Java
Emulating Game Boy in Java
 
Zero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using DockerZero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using Docker
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migration
 
SlingQuery
SlingQuerySlingQuery
SlingQuery
 
Code metrics
Code metricsCode metrics
Code metrics
 
Inter-Sling communication with message queue
Inter-Sling communication with message queueInter-Sling communication with message queue
Inter-Sling communication with message queue
 
Sling Dynamic Include
Sling Dynamic IncludeSling Dynamic Include
Sling Dynamic Include
 
Shooting rabbits with sling
Shooting rabbits with slingShooting rabbits with sling
Shooting rabbits with sling
 

Recently uploaded

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Recently uploaded (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

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