nmrr / signal-processing-in-100-lines

A 100 lines example of signal processing written in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

signal-processing-in-100-lines

A 100 lines example of signal processing written in C++

In this example, a noisy square wave signal is generated. This signal is passed into a low-pass filter to reduce noise. An automatic gain control (AGC) is used to prevent fluctuation of the amplitude and get a constant output signal. Then, a limiter limits output value of each sample to a fixed value to avoid impossible value during conversion to 16-bit (hard clipping)

Build the example :

g++ -Wall -pipe -Ofast main.cpp -o signalprocessing

Run the example :

./signalprocessing > out

Use audacity (or other audio software) and import output data as Raw Data using the following parameters :

  • Signed 16-bit PCM
  • Little-endian
  • 1 Channel (Mono)
  • Sample rate : 44100

Cutoff frequency can be adjusted by changing the value of the variable lowPassSamples : a lower value will rise cutoff frequency.

About

A 100 lines example of signal processing written in C++

License:MIT License


Languages

Language:C++ 100.0%