Signal processing tips from Hackaday

Signal processing is an electrical engineering subfield that focuses on analysing, modifying and synthesizing signals such as sound, images and biological measurements. Electronic signal processing was first revolutionized by the MOSFET and then single-chip digital signal processor (DSP). Digital signal processing is the processing of digitized discrete-time sampled signals. Processing is done by general-purpose computers or by digital circuits such as ASICs, field-programmable gate arrays or specialized digital signal processors (DSP chips).

Hackaday has published an in interesting series of articles on signal processing, and here are some picks from it:

RTFM: ADCs And DACs
https://hackaday.com/2019/10/16/rtfm-adcs-and-dacs/

DSP Spreadsheet: IQ Diagrams
https://hackaday.com/2019/11/15/dsp-spreadsheet-iq-diagrams/

Sensor Filters For Coders
https://hackaday.com/2019/09/06/sensor-filters-for-coders/

DSP Spreadsheet: FIR Filtering
https://hackaday.com/2019/10/03/dsp-spreadsheet-fir-filtering/

Fourier Explained: [3Blue1Brown] Style!
https://hackaday.com/2019/07/13/fourier-explained-3blue1brown-style/

DSP Spreadsheet: Frequency Mixing
https://hackaday.com/2019/11/01/dsp-spreadsheet-frequency-mixing/

Spice With A Sound Card
https://hackaday.com/2019/07/03/spice-with-a-sound-card/
- check also A real-time netlist based audio circuit plugin at https://github.com/thadeuluiz/RTspice

Reverse Engineering The Sound Blaster
https://hackaday.com/2019/06/19/reverse-engineering-the-sound-blaster/

FM Signal Detection The Pulse-Counting Way
https://hackaday.com/2019/08/28/fm-signal-detection-the-pulse-counting-way/

DSP Spreadsheet: IQ Diagrams< https://hackaday.com/2019/11/15/dsp-spreadsheet-iq-diagrams/

Here is an extra, not from Hackaday, but an interesting on-line signal processing tool for generating sounds
https://z.musictools.live/#95

164 Comments

  1. Tomi Engdahl says:

    Samplerates: the higher the better, right?
    https://www.youtube.com/watch?v=-jCwIsT0X8M

    In this video tutorial, Dan Worrall explains when and why you should use higher samplerates for your recordings and mixing sessions, and more importantly… when you should NOT. Also, Dan goes in depth about oversampling vs. higher sample rates.

    Reply
  2. Tomi Engdahl says:

    Comb filters have found use as powerline (50/60Hz) harmonic cancellation filters in audio applications, and form the basis of so called CIC (cascaded integrator–comb) filters used for anti-aliasing in decimation (sample rate reduction), and anti-imaging in interpolation (sample rate increase) applications. https://www.advsolned.com/fir-comb-filter/ #DSP #engineering #audio

    Reply
  3. Tomi Engdahl says:

    What does the Laplace Transform really tell us? A visual explanation (plus applications)
    https://www.youtube.com/watch?v=n2y7n6jw5d0

    Viewer comments:

    I’m seriously amazed that people from the 1700s figured this out while i could only understand it fully after seeing the 3D plots…

    I am a retired engineering professor and taught this material for years. Yet I still find it very useful to see it presented by someone else since there is always some new perspective that I acquire. Excellent presentation!

    Reply
  4. Tomi Engdahl says:

    Applying the Laplace Transform in LTspice to Model Transfer Functions
    Oct. 5, 2021
    https://www.electronicdesign.com/technologies/analog/article/21177396/analog-devices-applying-the-laplace-transform-in-ltspice-to-model-transfer-functions?utm_source=EG%20ED%20Analog%20%26%20Power%20Source&utm_medium=email&utm_campaign=CPS210930010&o_eid=7211D2691390C9R&rdx.ident%5Bpull%5D=omeda%7C7211D2691390C9R&oly_enc_id=7211D2691390C9R

    Transfer functions analyze how system output changes depending on the input. This article details how to implement a transfer function in LTspice, comparing ideal vs. modeled responses and presenting example scenarios.

    Reply
  5. Tomi Engdahl says:

    This is why you’re learning differential equations
    https://www.youtube.com/watch?v=ifbaAqfqpc4

    Reply
  6. Tomi Engdahl says:

    In signal processing, the need sometimes arises to nudge or fine-tune the sampling instants of a signal by a fraction of a sample. An FIR Farrow delay filter is typically employed to achieve this task, and may be combined with a traditional integer delay line in order to achieve a universal fractional length delay line. https://www.advsolned.com/farrow-fractional-delay-filter/ #DSP #algorithms #sensor #engineering #audio #iot

    Reply
  7. Tomi Engdahl says:

    Pluto Spectrum Analyzer Uses Command Line
    https://hackaday.com/2021/11/15/pluto-spectrum-analyzer-uses-command-line/

    If you don’t care about shortwave frequencies, the PlutoSDR is a great deal. The device is supposed to be an evaluation board for Analog Device’s radio chips, but it does great as a software-defined radio that can receive and transmit and it even runs Linux internally. [SignalsEverywhere] shows how to use it as a spectrum analyzer that works from the command line

    The software used is Retrogram. Despite the ASCII graphics, the program has many features. You can use simple keystrokes to change the center frequency, the sampling rate, the bandwidth, and more. You can run the software on a Linux host or compile a binary on the box or cross-compile using tools on the Raspberry Pi.

    The Pluto connects via USB but looks like a network adapter.

    We noticed on the GitHub site that plans are in the works for generic device support like the ubiquitous RTLSDR dongles. We’d love to see someone pick up that work. There are also plans for mouse tuning, waterfall displays, and HTML output.

    Retrogram – A Command Line Spectrum Analyzer For The PlutoSDR
    https://www.youtube.com/watch?v=2dJGL1rBlIo

    Reply
  8. Tomi Engdahl says:

    Impulse Response | Audio Laboratory | Captain Pikant | Thomann
    https://m.youtube.com/watch?v=d-1Zn1LvhB4&fbclid=IwAR0vAqxLrTXD6mxMa4W16X3rrW_azhwzCGQWrwG0VkTVwiKKo_7JKdaTRLY

    In the last episode, we promised to show you another type of reverb. So spotlight on the impulse response (IR).

    Reply
  9. Tomi Engdahl says:

    EEVblog #1213 – The Oscilloscope Interpolation Trap!
    https://www.youtube.com/watch?v=W4twnd-YQQ4

    Oscilloscope Sin X/x Interpolation can be a trap for young players, find out why.
    https://www.eevblog.com/forum/blog/eevblog-1213-the-oscilloscope-interpolation-trap/

    Reply
  10. Tomi Engdahl says:

    #305: Measuring Total Harmonic Distortion THD using an FFT on an oscilloscope
    https://www.youtube.com/watch?v=s_cVP5gu4SY

    This video shows how to use the FFT function on an oscilloscope to measure the relative amplitude of the harmonic distortion components of a signal, and then take those results and compute the THD, or Total Harmonic Distortion. Actual measurements are shown, and results are validated by a THD calculator in the scope as well as a THD measuring multimeter.

    Reply
  11. Tomi Engdahl says:

    A Super Speedy Lightweight Lossless Compression Algorithm
    https://hackaday.com/2021/11/30/a-super-speedy-lightweight-lossless-compression-algorithm/

    Dominic Szablewski] was tinkering around with compressing RGB images, when he stumbled upon idea of how to make a simple lossless compression algorithm, resulting in the Quite OK Image Format, which seems to offer comparable file sizes to the PNG format but is so simple it runs up to 50 times faster for compression and up to four times faster for decompression. Implementation can be achieved with a miniscule 300 lines of C. Need a bit more detail on the real-world performance? Well [Dominic] has that covered too, with a complete set of benchmarks for your perusal.

    QOI – The “Quite OK Image” format for fast, lossless image compression
    https://github.com/phoboslab/qoi

    Reply
  12. Tomi Engdahl says:

    Samplerates: the higher the better, right?
    https://www.youtube.com/watch?v=-jCwIsT0X8M

    In this video tutorial, Dan Worrall explains when and why you should use higher samplerates for your recordings and mixing sessions, and more importantly… when you should NOT. Also, Dan goes in depth about oversampling vs. higher sample rates.

    Viewer comments:

    Georgia Tech Professor of Electrical and Computer Engineering in the Digital Signal Processing Technical Interest Group here… This is the first explanation of sampling, aliasing, upsampling/downsampling, antialiasing filters, etc. I’ve seen/heard, in print or in video, in 20 years that (a) didn’t make me cringe at any point, and (b) completely blew me away with how illuminating it was.

    I can say exactly the same!
    I have designed and built a DSP guitar amplifier. I have seen a lot of videos and articles that are incorrect and / or misleading.
    This one is superb!

    This is, in my mind, the clearest and most informative demonstration and explanation of sample rates, aliasing, and the tricky bits of digital audio I’ve ever encountered. I’m also digging the Reaper mixer setup.

    Aligns with my own experiences and lessons over the years: bandpass everything, all audio is bandpassed at some stage anyway so you better do it.. before it is too late and the signal encounters something that can’t cope with its demands. Distortion and heat will be the result of that and you will get degraded audio signal.

    Also: Hi-res record releases are not meant for consumer consumption, you once again have to deal with bandpassing the signal before it hits your speaker. The end result is intermodulation distortion in the analog chain too. Most of it will be turned to heat but it is never a good idea to push too wide of a sausage thru a too small hole… A good speaker has ultra- and infrasonic filtering but one of the principles i have picked out is that it is far better to cut the signal before amplification than after. If for nothing else, components are smaller and the circuit design can be considerably better.

    “If the song is good and the mix is good, no one will care about a bit of aliasing!” Phew … sanity is finally restored.

    Reply
  13. Tomi Engdahl says:

    Jetson Nano Convolution Reverb
    https://hackaday.io/project/183681-jetson-nano-convolution-reverb

    Turn your unused Jetsons into a real time audio effect modules with CUDA
    E/S PronkE/S Pronk

    Reply
  14. Tomi Engdahl says:

    Does Digital Create Analog Stairsteps? (Public)
    https://www.youtube.com/watch?v=OwjHE1DQSyA

    There are beliefs out there that digital creates “stairsteps” in the audio because digital can not grab the info in between samples.

    Is info lost?

    If so, would this “lost” info result in “stairsteps” and graininess?

    What info would be lost and is the loss of info visible as stairsteps?

    Is .999999 repeating actually exactly equal to 1?

    I will answer some or most of these curiosities.

    Cool cool !!

    00:00 Intro
    00:42 Logic behind stair stepping
    01:52 Looking for stair steps
    03:00 Sending stair steps into a console
    04:40 Raising the frequency
    05:20 Creating or eliminating stairsteps
    05:55 Lost information
    06:55 What info is lost
    08:10 Summary

    Viewer comments:

    Yes, yes, yes! Digital audio is bandlimited. An instantaneous rise would require infinite bandwidth. Luckily, our hearing is limited as well though sadly it also deteriorates with age.

    Btw, it’s not that frequencies above half the sample rate (e.g. above 24 kHz for 48 kHz sampling) are not “captured”. They are, but they fold back. A 24+1=25 kHz tone will fold back down to 24-1=23 kHz. Aliasing!
    That is the “information loss” – once sampled you cannot separate aliased from the real stuff anymore. To prevent this all converters do filtering beforehand, to get rid of all the >24 kHz content before the sampling process. (Well actually you cannot get rid of it or aliasing, but when you attenuate far enough all the aliased stuff will drown in the noise floor.)

    It’s also really interesting to understand how this filtering is implemented in converters. A naive approach would be to construct some complex analog lowpass filter. Too expensive, too high tolerances, hard to get good performance.
    Instead you just take a very simple analog lowpass filter that operates way above the audio range, sample at very high frequencies (think MHz), filter digitally to cut stuff above 24 kHz and convert the signal down to the desired sampling rate.

    In my DSP courses usually we just say the analog input (ADC) filter prevents aliasing and the output (DAC) analog filter is a “smoothing” filter. Oversampling allows us to use “softer” and cheaper analog filters on both ends.

    You’re right at the boundary of audio and engineering, I love it!

    Obviously the sample rate has the biggest impact on bandwidth. Are you able to investigate the bandwidth of the analog input and output circuits? It would be fun to see if you could inject a signal beyond the first Nyquist zone and see it fold back. It all depends on the analog filtering.

    Not going to dive that far, trying to stay with useful practical info and myth busting

    Hey Dave! Really enjoy your videos. I wonder if it’s possible to test the “smoothing” that you mentioned some consoles do for between samples in order to smooth out the waveform. Which consoles do it better than others…

    The consoles do smooth. If the sample rate is 48k, then one may think there would be 48,000 little stair steps per second. But a 48k sample rate can only recreate sound up to 23Khz. Way way below the frequencies that would be needed to create 48khz stair steps.

    The console can not create sample rate stair steps on it’s analog outputs. The stairsteps don’t need to be smoothed as they can not exist

    Great video, as usual. Lots of ways of looking at this and you do a great job of explaining. Worth remembering that for undistorted operation every A/D converter must be preceded by a low pass filter and every D/A converter must be followed by a matching low pass filter. No matter what kind of equipment.

    Reply
  15. Tomi Engdahl says:

    The Unreasonable Effectiveness of JPEG: A Signal Processing Approach
    https://www.youtube.com/watch?v=0me3guauqOU

    Chapters:
    00:00 Introducing JPEG and RGB Representation
    2:15 Lossy Compression
    3:41 What information can we get rid of?
    4:36 Introducing YCbCr
    6:10 Chroma subsampling/downsampling
    8:10 Images represented as signals
    9:52 Introducing the Discrete Cosine Transform (DCT)
    11:32 Sampling cosine waves
    12:43 Playing around with the DCT
    17:38 Mathematically defining the DCT
    21:02 The Inverse DCT
    22:45 The 2D DCT
    23:49 Visualizing the 2D DCT
    24:35 Introducing Energy Compaction
    26:05 Brilliant Sponsorship
    27:23 Building an image from the 2D DCT
    28:20 Quantization
    30:23 Run-length/Huffman Encoding within JPEG
    32:56 How JPEG fits into the big picture of data compression

    The JPEG algorithm is rather complex and in this video, we break down the core parts of the algorithm, specifically color spaces, YCbCr, chroma subsampling, the discrete cosine transform, quantization, and lossless encoding. The majority of the focus is on the mathematical and signal processing insights that lead to advancements in image compression and the big themes in compression as a whole that we can take away from it.

    Reply
  16. Tomi Engdahl says:

    https://www.facebook.com/groups/2600net/permalink/3241557489400687/

    The documentation that describes how the LTE signals are modulated
    This contains 886 ms of data recorded at 30.72 Msps, and has much more than what we will be looking at here (in fact there is a PRACH right at the beginning). In this recording, the phone happens to be using Band 20. Specifically, a 10 MHz channel at 847 MHz. The demodulation is done in a Jupyter notebook using NumPy.

    Demodulation of the LTE uplink
    https://destevez.net/2022/02/demodulation-of-the-lte-uplink/

    Reply
  17. Tomi Engdahl says:

    CTSD Precision ADCs (Part 3): Inherent Alias Rejection Made Possible
    March 1, 2022
    Part 3 looks at the design complexity of alias-rejection solutions and highlights the alias-free nature of continuous-time sigma-delta (CTSD) ADCs, which improves the immunity to interferers without any added peripheral design.
    https://www.electronicdesign.com/technologies/analog/article/21234897/analog-devices-ctsd-precision-adcs-part-3-inherent-alias-rejection-made-possible?utm_source=EG%20ED%20Analog%20%26%20Power%20Source&utm_medium=email&utm_campaign=CPS220225022&o_eid=7211D2691390C9R&rdx.ident%5Bpull%5D=omeda%7C7211D2691390C9R&oly_enc_id=7211D2691390C9R

    Reply
  18. Tomi Engdahl says:

    What is it About Audio Distortion? Understanding Nonlinearity
    https://www.allaboutcircuits.com/technical-articles/what-is-it-about-audio-distortion/

    Learn about how system nonlinearity creates distortion in audio signals that impacts the sounds we hear. We will examine sine waves, harmonics, and intermodulation distortion.
    We spend a lot of time thinking and talking about distortion in audio, and even sometimes listening to it, but what is it really and why does it matter?

    Reply
  19. Tomi Engdahl says:

    There are generally two types of distortion:

    Frequency distortion—caused by insufficient bandwidth and non-flat frequency response between the bandwidth limits
    Nonlinearity distortion—caused by nonlinearities in the hardware.

    https://www.allaboutcircuits.com/technical-articles/what-is-it-about-audio-distortion/

    Reply
  20. Tomi Engdahl says:

    From https://fb.watch/dgfe3Zr-q9/ comments

    well what you need to use is some background subtraction technique. In your setup since the artist is moving you can compare frames and then filter out those changing. Now that’s just from the top of my head but if you check here for example https://github.com/topics/background-removal there are tons of ways to achieve background removal

    Also seems like opencv may have a basic bg removal https://docs.opencv.org/3.4/d1/dc5/tutorial_background_subtraction.html the advantage maybe that it could be faster in comparison to the kinect which I believe is only 30fps

    Thank you, but the algorithms you mention seem to work on rendered videos, not real time. Anyway if there are solutions reall time i dont need on the moment, as I don’t have another camera. Kinect is what i have, plus a phone that i need to document the installation with, so cant use.

    Reply
  21. Tomi Engdahl says:

    #262: IQ Modulator Basics: Operation, measurements, impairments
    https://www.youtube.com/watch?v=RHFZUqUM8DY

    This video discusses the basics of an IQ modulator, discusses and demonstrates its operation, shows a few typical modulation types as well as the effects of various impairments. It also shows the basic SSB Suppression test. I use a combination of a few Mini-Circuits mixers (ADE-1ASK) for much of the video, and also show one of their IQ Modulator modules (ZFMIQ-10M).

    Reply
  22. Tomi Engdahl says:

    ADSL Router As Effects Pedal
    https://hackaday.com/2022/09/08/adsl-router-as-effects-pedal/

    Moore’s law might not be as immutable as we once though thought it was, as chip makers struggle to fit more and more transistors on a given area of silicon. But over the past few decades it’s been surprisingly consistent, with a lot of knock-on effects. As computers get faster, everything else related to them gets faster as well, and the junk drawer tends to fill quickly with various computer peripherals and parts that might be working fine, but just can’t keep up the pace. [Bonsembiante] had an old ADSL router that was well obsolete as a result of these changing times, but instead of tossing it, he turned it into a guitar effects pedal.

    The principle behind this build is that the router is essentially a Linux machine, complete with ALSA support. Of course this means flashing a custom firmware which is not the most straightforward task, but once the sound support was added to the device, it was able to interface with a USB sound card. An additional C++ program was created which handles the actual audio received from the guitar and sound card. For this demo, [Bonsembiante] programmed a ring buffer and feeds it back into the output to achieve an echo effect, but presumably any effect or a number of effects could be programmed.

    How to connect a guitar to an ADSL router?
    https://bonsembiante.hashnode.dev/how-to-connect-a-guitar-to-an-adsl-router

    https://github.com/bonsembiante/router-audio-dsp

    Pedal-Pi, Simple Programmable Guitar Pedal
    https://hackaday.com/2017/09/12/pedal-pi-simple-programmable-guitar-pedal/

    Reply
  23. Tomi Engdahl says:

    Getting Started with the FV-1:

    A first look into DSP
    http://electric-canary.com/fv1start.html

    Reply
  24. Tomi Engdahl says:

    Equalize Your Listening With HiFiScan
    https://hackaday.com/2022/09/12/equalize-your-listening-with-hifiscan/

    Audiophiles will go to such extents to optimize the quality of their audio chain that they sometimes defy parody. But even though the law of diminishing returns eventually becomes a factor there is something in maintaining a good set of equipment. But what if your audio gear is a little flawed, can you fix it electronically? Enter HiFiScan, a piece of Python software to analyse audio performance by emitting a range of frequencies and measuring the result with a microphone.

    This is hardly a new technique, and it’s one which PA engineers have used for a long time to tune out feedback resonances, but an easy tool bringing it to the domestic arena is well worth a look. HiFiScan is a measuring tool so it won’t magically correct any imperfections in your system, however it can export data in a format suitable for digital effects packages.

    https://github.com/erdewit/HiFiScan

    Reply
  25. Tomi Engdahl says:

    Visual Analyser is a complete professional real time software, transform your PC in a full set of measurement instruments; no new hardware necessary (you can use the Sound Card of your PC) or you can use a specific external hardware
    https://www.sillanumsoft.org/

    Reply
  26. Tomi Engdahl says:

    NTSC encoding/decoding in C89 using only integers and fixed point math. Can be used as an image filter for games or real-time applications
    https://github.com/LMP88959/NTSC-CRT

    Reply
  27. Tomi Engdahl says:

    https://www.facebook.com/groups/2600net/permalink/3505034019719698/

    For my other totally original hack let’s consider that an ex girlfriend lived in an apartment complex that had a gate. In order to get in someone had to answer the phone and press 9. The callbox apparently was configured so you could not enter a code, but you could dial a resident or have a proximity card which I didn’t have. My ex girlfriend had a pc running windows xp at the time with one of those winmodems. This was probably the pinnacle of the pci modem back in 2005. So anyways I connected the dots and saw that her winmodem came with the ability to understand call waiting and that it could work as a voicemail system. The land line also had caller id. Her roommate was also constantly on the phone. So let’s assume I could program her voicemail software to answer the phone if the callbox called and to play the number 9 DTMF. If the roommate was on the phone the modem could also intercept the call waiting tone and switch over and play the 9 and switch back without annoying the roommate. We tried holding another phone up to the first phone and pressing the 9 but that didn’t work. So this is how I did it. We can use sox to create 2 wav files made from a sine wave. To get 9 we need 852 and 1477. The first 2 commands produce the 2 wav files and the third one mix them together. I’m sure you could script this to dial anything you wanted. I loaded the wav into the voicemail software and it worked perfectly for the remainder of her living in that complex. Her roommates were also pretty happy about it.
    sox -s -w -t nul -r 44100 -c 1 /dev 852.wav synth 1 sine 852
    sox -s -w -t nul -r 44100 -c 1 /dev 1477.wav synth 1 sine 1477
    soxmix 1477.wav 852.wav 9.wav

    Reply
  28. Tomi Engdahl says:

    https://hackaday.com/2023/02/07/count-leading-zeros-for-efficient-logarithms/

    Ihsan Kehribar] points out a clever trick you can use to quickly and efficiently compute the logarithm of a 32-bit integer. The technique relies on the CLZ instruction which counts the number of leading zeros in a machine word and is available in many modern processors. Typical algorithms used to compute logarithms are not quick and have a variable execution time depending on the input value. The technique [Ihsan] is using is both fast and has a constant run time.

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*