DSPRelated.com
Tutorials

An Alternative Form of the Pure Real Tone DFT Bin Value Formula

Cedron DawgCedron Dawg December 17, 2017

Cedron Dawg derives an alternative exact formula for DFT bin values of a pure real tone, sacrificing algebraic simplicity for better numerical behavior near integer-valued frequencies. By rewriting cosine differences as products of sines and shifting to a delta frame of reference, the derivation avoids catastrophic cancellation and preserves precision for near-integer tones. The analysis also shows the integer-frequency case is a degenerate limit that yields the familiar M/2 e^{iφ} bin value.


Design IIR Butterworth Filters Using 12 Lines of Code

Neil RobertsonNeil Robertson December 10, 201711 comments

Build a working lowpass IIR Butterworth filter from first principles in just 12 lines of Matlab using Neil Robertson's butter_synth.m. The post walks through the analog prototype poles, frequency pre-warping, bilinear transform pole mapping, adding N zeros at z = -1, and gain normalization so the result matches Matlab's built-in butter function. It's a compact, hands-on guide with clear formulas and code.


Simplest Calculation of Half-band Filter Coefficients

Neil RobertsonNeil Robertson November 20, 20179 comments

Half-band FIR filters put the cutoff at one-quarter of the sampling rate, and nearly half their coefficients are exactly zero, which makes them highly efficient for decimation-by-2 and interpolation-by-2. This post shows the straightforward window-method derivation of half-band coefficients from the ideal sinc impulse response, providing a clear, hands-on explanation for engineers learning filter design. It also points to equiripple options such as Matlab's firhalfband and a later Parks-McClellan implementation.


Improved Three Bin Exact Frequency Formula for a Pure Real Tone in a DFT

Cedron DawgCedron Dawg November 6, 2017

Cedron Dawg extends his two-bin exact frequency formulas to a three-bin DFT estimator for a pure real tone, and presents the derivation in computational order for practical use. The method splits complex bin values into real and imaginary parts, forms vectors A, B, and C, applies a sqrt(2) variance rescaling, and computes frequency via a projection-based closed form. Numerical tests compare the new formula to prior work and show improved accuracy when the tone lies between bins.


There and Back Again: Time of Flight Ranging between Two Wireless Nodes

Qasim ChaudhariQasim Chaudhari October 23, 20175 comments

Conventional timestamping seems too coarse for centimeter-level RF ranging, yet many products claim and deliver that precision. This post unpacks the fundamentals behind high-resolution wireless ranging, contrasting common RF approaches such as RSSI, ToA, PoA, TDoA, and AoA. It also explains how device timestamps and counter registers work, giving engineers a practical starting point for implementing or evaluating time-of-flight ranging systems.


Two Bin Exact Frequency Formulas for a Pure Real Tone in a DFT

Cedron DawgCedron Dawg October 4, 20179 comments

Cedron Dawg derives exact, closed-form frequency formulas that recover a pure real tone from just two DFT bins using a geometric vector approach. The method projects bin-derived vectors onto a plane orthogonal to a constraint vector to eliminate amplitude and phase, yielding an explicit cos(alpha) estimator; a small adjustment improves noise performance so the estimator rivals and slightly betters earlier two-bin methods.


Exact Near Instantaneous Frequency Formulas Best at Zero Crossings

Cedron DawgCedron Dawg July 20, 2017

Cedron Dawg derives time-domain formulas that yield near-instantaneous frequency estimates optimized for zero crossings of pure tones. Complementing his earlier peak-optimized results, these difference-ratio formulas work for real and complex signals, produce four-sample estimators similar to Turners, and cancel amplitude terms, making them attractive low-latency options for clean tones while warning they degrade in noise and at peaks.


Exact Near Instantaneous Frequency Formulas Best at Peaks (Part 2)

Cedron DawgCedron Dawg June 11, 20174 comments

Cedron Dawg derives a second family of exact time domain formulas for single-tone frequency estimation that trade a few extra calculations for improved noise robustness. Built from [1+cos]^k binomial weighting of neighbor-pair sums, the closed-form estimators are exact and are best evaluated at signal peaks for real tones, while complex tones do not share the zero-crossing limitation. Coefficients up to k=9 are provided.


Modeling a Continuous-Time System with Matlab

Neil RobertsonNeil Robertson June 6, 20172 comments

Neil Robertson demonstrates a practical workflow for converting a continuous-time transfer function H(s) into an exact discrete-time H(z) using Matlab's impinvar. He walks through a 3rd-order Butterworth example, shows how to match impulse and step responses, and compares frequency response and group delay so engineers can see where the discrete model stays accurate and when sampling-rate limits cause departure.


How to Find a Fast Floating-Point atan2 Approximation

Nic TaylorNic Taylor May 26, 201716 comments

This post shows how a compact, fast atan2 can be built from a Remez-derived arctangent approximation and a matching 3rd-order polynomial. It walks through using Boost's remez_minimax to recover coefficients 0.97239411 and -0.19194795, integrating the polynomial into an atan2 with quadrant reduction, and applying branch reduction, bit tricks, and SSE2 SIMD to cut runtime while keeping max error under about 0.005 radians.


How the Cooley-Tukey FFT Algorithm Works | Part 1 - Repeating Calculations

Mark NewmanMark Newman November 11, 20244 comments

The Fourier Transform is a powerful tool, used in many technologies, from audio processing to wireless communication. However, calculating the FT can be computationally expensive. The Cooley-Tukey Fast Fourier Transform (FFT) algorithm provides a significant speedup. It exploits the repetitive nature of calculations within the Discrete Fourier Transform (DFT), the mathematical foundation of the FT. By recognizing patterns in the DFT calculations and reusing intermediate results, the FFT vastly reduces the number of operations required. In this series of articles, we will look at how the Cooley-Tukey FFT algorithm works.


Computing Translated Frequencies in Digitizing and Downsampling Analog Bandpass Signals

Rick LyonsRick Lyons October 31, 20131 comment

Textbooks rarely give ready formulas for tracking where individual spectral lines land after bandpass sampling or decimation. Rick Lyons provides three concise equations, with Matlab code, that compute translated frequencies for analog bandpass sampling, real digital downsampling, and complex downsampling. Practical examples show how to place the sampled image at fs/4 and how to translate a complex bandpass to baseband for efficient demodulation.


Multimedia Processing with FFMPEG

Karthick Kumaran A S VKarthick Kumaran A S V November 16, 2015

FFMPEG is a set of libraries and a command line tool for encoding and decoding audio and video in many different formats. It is a free software project for manipulating/processing multimedia data. Many open source media players are based on FFMPEG libraries.


Modeling Anti-Alias Filters

Neil RobertsonNeil Robertson September 26, 2021

Modeling anti-alias filters brings textbook aliasing examples to life. This post shows how to build discrete-time models G(z) for analog Butterworth and Chebyshev lowpass anti-alias filters, compares bilinear transform and impulse invariance, and simulates ADC input/output including aliasing of sinusoids and Gaussian noise. It concludes that impulse invariance gives better stopband accuracy and includes Matlab helper functions.


How the Cooley-Tukey FFT Algorithm Works | Part 4 - Twiddle Factors

Mark NewmanMark Newman December 2, 202410 comments

The beauty of the FFT algorithm is that it does the same thing over and over again. It treats every stage of the calculation in exactly the same way. However, this. “one-size-fits-all” approach, although elegant and simple, causes a problem. It misaligns samples and introduces phase distortions during each stage of the algorithm. To overcome this, we need Twiddle Factors, little phase correction factors that push things back into their correct positions before continuing onto the next stage.


Modeling a Continuous-Time System with Matlab

Neil RobertsonNeil Robertson June 6, 20172 comments

Neil Robertson demonstrates a practical workflow for converting a continuous-time transfer function H(s) into an exact discrete-time H(z) using Matlab's impinvar. He walks through a 3rd-order Butterworth example, shows how to match impulse and step responses, and compares frequency response and group delay so engineers can see where the discrete model stays accurate and when sampling-rate limits cause departure.


Learn to Use the Discrete Fourier Transform

Neil RobertsonNeil Robertson September 28, 2024

Discrete-time sequences arise in many ways: a sequence could be a signal captured by an analog-to-digital converter; a series of measurements; a signal generated by a digital modulator; or simply the coefficients of a digital filter. We may wish to know the frequency spectrum of any of these sequences. The most-used tool to accomplish this is the Discrete Fourier Transform (DFT), which computes the discrete frequency spectrum of a discrete-time sequence. The DFT is easily calculated using software, but applying it successfully can be challenging. This article provides Matlab examples of some techniques you can use to obtain useful DFT’s.


Exponential Smoothing with a Wrinkle

Cedron DawgCedron Dawg December 17, 20154 comments

Cedron Dawg shows how pairing forward and backward exponential smoothing produces exact, frequency-dependent dampening for sinusoids while canceling time-domain lag. The average of the two passes scales the tone by a closed-form factor, and their difference acts like a first-derivative with a quarter-cycle phase shift. The post derives the analytic dampening formulas, compares them to the derivative, and includes a Python demo for DFT preprocessing.


Generating Partially Correlated Random Variables

Harry ComminHarry Commin March 23, 201921 comments

Designing signals to match a target covariance is simpler than it sounds. This post shows how to build partially correlated complex signals by hand for the two-signal case, then generalizes to N signals using the Cholesky decomposition. Short MATLAB examples demonstrate the two-line implementation and the article highlights numerical caveats when a covariance is only positive semidefinite.


Add the Hilbert Transformer to Your DSP Toolkit, Part 2

Neil RobertsonNeil Robertson December 4, 20223 comments

This post shows a simple practical route to a Hilbert transformer by starting from a half-band FIR filter and tweaking its symmetry. It walks through a 19-tap example synthesized with Matlab's firpm (Parks-McClellan), explains the required frequency scaling, and shows how even-numbered taps become (or can be forced) zero through symmetry and coefficient quantization. Useful design rules are summarized for choosing ntaps.