#736 New JavaFX spectral display and waterfall for both tuner and channel spectrums. (#2637)

* Popout configuration panel (top-left of display)
* Themed color support
* Reworked signal averating/smoothing
* Optional decibel overlay with corrected decibel calculations
* Integrated noise floor slider in  channel view
* Traffic channel overlays
* Popup channel information when hovering over playlist channels.
* Removes legacy swing components.

Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
Denny Sheirer
2026-11-13 07:30:31 -05:00
committed by GitHub
parent 73fc85aa76
commit 9641d2ef59
53 changed files with 7121 additions and 3644 deletions

View File

@@ -46,10 +46,12 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
private static final String FRAME_RATE_PROPERTY = "spectral.display.frame.rate";
//The Cosine and Hann windows seem to offer the best spectral display with minimal bin leakage/smearing
private WindowType mWindowType = WindowType.BLACKMAN_HARRIS_7;
private volatile WindowType mWindowType = WindowType.BLACKMAN_HARRIS_7;
private volatile boolean mWindowChanged = true;
private volatile boolean mUnityGainWindow = false;
private float[] mWindow;
private DFTSize mDFTSize = DFTSize.FFT04096;
private DFTSize mNewDFTSize = DFTSize.FFT04096;
private volatile DFTSize mNewDFTSize = DFTSize.FFT04096;
private FloatFFT_1D mFFT = new FloatFFT_1D(mDFTSize.getSize());
private int mFrameRate;
private AtomicBoolean mRunning = new AtomicBoolean();
@@ -62,13 +64,14 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
public ComplexDftProcessor()
{
mFrameRate = SystemProperties.getInstance().get(FRAME_RATE_PROPERTY, 20);
setWindowType(mWindowType);
mWindow = createWindow(mWindowType, mDFTSize.getSize(), mUnityGainWindow);
start();
}
public void dispose()
{
stop();
mExecutorService.shutdown();
mListeners.clear();
mWindow = null;
@@ -79,15 +82,87 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
return mWindowType;
}
/**
* Queues a window type change. The processor applies the change before the next calculation.
*/
public void setWindowType(WindowType windowType)
{
mWindowType = windowType;
updateWindow();
if(windowType != null)
{
mWindowType = windowType;
mWindowChanged = true;
}
}
private void updateWindow()
/**
* Scales the window to unity coherent gain, so that a full scale complex tone centered in a bin has a DFT
* magnitude equal to the DFT size, regardless of the window type. Use this with a full scale (dBFS) converter.
* Defaults to false, which leaves the window coefficients unscaled.
*/
public void setUnityGainWindow(boolean unityGain)
{
mWindow = WindowFactory.getWindow(mWindowType, mDFTSize.getSize() * 2);
mUnityGainWindow = unityGain;
mWindowChanged = true;
}
/**
* Creates the window coefficients for interleaved complex samples, with the same coefficient applied to the I
* and Q values of each sample.
* @param type of window. Kaiser windows need extra parameters, so Kaiser uses a Blackman-Harris 7 window.
* @param size of the DFT in complex samples
* @param unityGain to scale the window so the coefficients sum to the DFT size (unity coherent gain)
* @return interleaved window coefficients, twice the DFT size
*/
public static float[] createWindow(WindowType type, int size, boolean unityGain)
{
if(type == null || type == WindowType.KAISER)
{
type = WindowType.BLACKMAN_HARRIS_7;
}
float[] window = WindowFactory.getWindow(type, size);
double sum = 0.0;
for(float coefficient: window)
{
sum += coefficient;
}
float scale = (unityGain && sum > 0) ? (float)(size / sum) : 1.0f;
float[] interleaved = new float[size * 2];
for(int x = 0; x < size; x++)
{
interleaved[2 * x] = window[x] * scale;
interleaved[2 * x + 1] = window[x] * scale;
}
return interleaved;
}
/**
* Equivalent noise bandwidth of the window type, in DFT bins. This is how much wider the window's noise
* bandwidth is than one bin: 1.0 for no window and about 2 to 4 for the low leakage windows.
*/
public static double getNoiseBandwidth(WindowType type)
{
if(type == null || type == WindowType.KAISER)
{
type = WindowType.BLACKMAN_HARRIS_7;
}
int size = 4096;
float[] window = WindowFactory.getWindow(type, size);
double sum = 0.0;
double sumSquares = 0.0;
for(float coefficient: window)
{
sum += coefficient;
sumSquares += coefficient * coefficient;
}
return sum > 0 ? size * sumSquares / (sum * sum) : 1.0;
}
/**
@@ -110,6 +185,15 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
}
public void setFrameRate(int framesPerSecond)
{
setFrameRateNoSave(framesPerSecond);
SystemProperties.getInstance().set(FRAME_RATE_PROPERTY, mFrameRate);
}
/**
* Sets the frame rate without saving it as the default frame rate setting.
*/
public void setFrameRateNoSave(int framesPerSecond)
{
if(framesPerSecond < 1 || framesPerSecond > 1000)
{
@@ -118,7 +202,6 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
}
mFrameRate = framesPerSecond;
SystemProperties.getInstance().set(FRAME_RATE_PROPERTY, mFrameRate);
restart();
}
@@ -176,6 +259,11 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
{
//If this throws an IO exception, the buffer queue is (temporarily) empty and we return from the method
float[] samples = mDftBufferManager.get(mDFTSize.getSize());
if(mWindow == null || mWindow.length != samples.length)
{
mWindow = createWindow(mWindowType, mDFTSize.getSize(), mUnityGainWindow);
}
WindowFactory.apply(mWindow, samples);
mFFT.complexForward(samples);
mPreviousSamples = samples;
@@ -237,7 +325,7 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
}
/**
* Checks for a queued FFT width change request and applies it. This
* Checks for a queued FFT width or window change request and applies it. This
* method will only be accessed by the scheduled executor that gains
* access to run a calculate method, thus providing thread safety.
*/
@@ -246,9 +334,15 @@ public class ComplexDftProcessor<T extends INativeBuffer> implements Listener<T>
if(mNewDFTSize.getSize() != mDFTSize.getSize())
{
mDFTSize = mNewDFTSize;
updateWindow();
mWindowChanged = true;
mFFT = new FloatFFT_1D(mDFTSize.getSize());
}
if(mWindowChanged)
{
mWindowChanged = false;
mWindow = createWindow(mWindowType, mDFTSize.getSize(), mUnityGainWindow);
}
}
public void clearBuffer()