Menu

SpectrumViewer for Windows / blog: Recent posts

Accuracy of filter coefficient calculations

With the addition of the Martin Vicanek matched second order BPF filter option, it becomes apparent double precision math isn't good enough for coefficient calculation in all cases. Here is an example. Starting with version 1.40, all filter coefficient calculations are done with mpfr 128 bit precision math and trig functions.
New command line arguments rlcdumpcoef= and mpfrcoef= can be used to see the difference:... read more

Posted by sduplichan 2025-01-07

PwrLPF fix

The PwrLPF slider and corresponding stage count selection box controls a set of identical low pass filters that smooths the rectified output of each band pass filter. Versions prior to 1.40 have a shortcoming (bug) where the cutoff slider isn't adjusted for stage count. This is fixed in version 1.4. The operation of previous versions can be seen here by adjusting the stage count slider on line 2. To see how the fix works, use the slider on line 1 to enable it, then once again change the stage count slider. With the fix, the -3dB cutoff point becomes independent of stage count. Without the fix, the LPF cutoff frequency decreases significantly with stage count.
The actual adjustment factor is calculated on line 102. To find this formula, I first tried asking some AI services:
What is the cutoff frequency of a low pass filter composed of N cascaded identical ideal second order stages as a function of Q, N and frequency?
To make a low pass filter with cutoff frequency Fc from a cascade of N identical ideal second order stages, what is the needed stage natural frequency?
AI confidently provided many wrong answers but never a correct answer. I finally derived the equation myself here.

Posted by sduplichan 2025-01-06

Vectorization using AVX-512, AVX-2 and AVX

With the latest AMD processors adding support for AVX-512, the benefits of vectorization become bigger than ever. The processor can now issue 8 double precision floating operations in parallel, per thread. This includes multiply/add, and even square root!
The program uses the processor feature detection function automatically run by the Microsoft Visual Studio supplied startup code. To see the AVX level supported, run the command line help:
sv help
Look for this line:
groupsize= limit double precision vectorization level [8]
The 8 shows that 8 double precision operations will be issued in parallel. Here are the other possibilities:
8: AVX-512
4: AVX-2
2: AVX
The command line option groupsize= lets you force a different vectorization level than detected.
Here is example code generation. The function updateIIR2stage8wAVX512 updates 8 two stage biquad filters in parallel. Thanks to the extra 16 registers available with AVX-512, the compiler is able to load the coefficients once and not have to reload them for each stage updated:... read more

Posted by sduplichan 2025-01-06

New version coming early 2025

A big performance improvement results from vectorization of the IIR BPF plus LPF stages. The entire code path will process 8 (or 4 or 2) FMAs and other double precision operations in parallel. This gives a roughly 300% performance improvement on my AMD 9950X system. AVX-512, AVX-2, AVX are supported. Older hardware will still work too. Another optimization is the sharing of filter coefficients when multiple identical stages are used. This applies to both the BPF and LPF.... read more

Posted by sduplichan 2024-12-31

Effect of stage count on bandpass filter response shape

A single RLC filter section can act as a narrow band filter to isolate a single frequency. Its frequency selectivity can be adjusted by varying the Q value. But the standard Q value only describes the filter response at -3 dB. What about the bandwidth at much greater attenuation values, such as -30 dB? While increasing the Q value of a single stage RLC bandpass filter narrows the -3 dB bandwidth to any desired value, the bandwidth at a higher attenuation value, such as -30 dB, is still quite wide and not as selective as might be desired. The pass band can be narrowed at higher levels of attenuation using multiple identical RLC stages. This is described in an27af.pdf.
Here is a desmos graph is a desmos graph that shows the effect. The first slider, n, is the number of RLC stages. Move that slider to see the effect of stage count on the overall response curve.

Posted by sduplichan 2023-09-28

How good is your PCM sine wave test tone?

Software such as REW, Audacity, SOX and others can generate a steady sine wave test tone and write it to a PCM encoded wav file. How far from ideal is the reconstructed result? Differences between an ideal sine wave and a perfectly reconstructed PCM file are due to encoding round-off losses, and in some cases to imperfections in the encoding software. Unwanted noise harmonics due to encoding round-off loss can be minimized but not eliminated by increasing sample bit depth. Unwanted noise harmonics due to encoding round-off loss can be completely eliminated by using a sample rate of 3, 4, or 6 times the sine frequency. See here for a more detailed explanation.
Once the unwanted harmonics are eliminated by choosing a sample rate of 3, 4, or 6 times the sine frequency, is it possible to further improve the file be making the sine peak to peak range exactly -1 to +1? In other words, eliminate the effect of rounding sine values altogether, even for the fundamental? The answer is yes. Choose the sample rate:sine ratio as 4:1, and use unattenuated sine values 0, 1, 0, -1. When zero is converted to a wav file sample, no rounding loss occurs so no unwanted harmonics are introduced. When 1 (or -1) is converted to a wav file sample, no rounding loss occurs either. When no rounding loss occurs during digitization of the sine data, the digitized data exactly reconstructs the original sine wave.
Here is an example. The sample format is 16-bit integer, but other sample formats produce exactly the same perfect result:... read more

Posted by sduplichan 2022-12-26

But is it real-time?

As a SCADA engineer in the early 1980's, I was often asked if our company's equipment was real-time. 'Of course' I said. The IBM Series/1 minicomputer we used on some projects even had an OS named ' Event Driven Executive (EDX) '. Remote equipment used an in-house multitasking OS.

Of course the definition of real-time depends on what you are monitoring. For glacier flow data, USPS might qualify as real time. But what about audio spectrum data? The audio data arrives continuously and needs to be displayed continuously to qualify as real-time, in my opinion. On a modern computer, it's hard to call anything less than 60 frames per second 'continuous display'. So to me, a spectrum display must update 60 times per second or faster to be called real time.... read more

Posted by sduplichan 2022-08-18
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.