mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 11:07:35 -05:00
Channel Spectral Display
- Adds Channel Spectrum tab to display FFT of the audio output of the currently selected channel - Upgrades to JTransforms 3.0 FFT library - Adds three new context menus to main and channel spectral displays: -- Baseline - affects the vertical rendering baseline of the FFT -- Amplification - affects the vertical height of each FFT bin -- Averaging - affects how many FFTs are averaged to produce the display
This commit is contained in:
38
src/spectrum/converter/RealDecibelConverter.java
Normal file
38
src/spectrum/converter/RealDecibelConverter.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package spectrum.converter;
|
||||
|
||||
public class RealDecibelConverter extends DFTResultsConverter
|
||||
{
|
||||
/**
|
||||
* Converts the output of the JTransforms FloatFFT_1D.realForward()
|
||||
* calculation into a normalized power spectrum in decibels, per description
|
||||
* in Lyons, Understanding Digital Signal Processing, 3e, page 141.
|
||||
*/
|
||||
@Override
|
||||
public void receive( float[] results )
|
||||
{
|
||||
float dc = Math.abs( results[ 0 ] );
|
||||
|
||||
/* Ensure we have power in the DC power bin (bin 0), otherwise don't
|
||||
* dispatch the results */
|
||||
if( dc != 0 )
|
||||
{
|
||||
/* Note: we're only processing 1/4 of the output samples */
|
||||
float[] processed = new float[ results.length / 4 + 1 ];
|
||||
|
||||
for( int x = 0; x < processed.length - 2; x ++ )
|
||||
{
|
||||
int index = ( x + 1 ) * 2;
|
||||
|
||||
double magnitude = ( ( results[ index ] * results[ index ] ) +
|
||||
( results[ index + 1 ] * results[ index + 1 ] ) );
|
||||
|
||||
processed[ x ] = 10.0f *
|
||||
(float)( Math.log10( magnitude / dc ) );
|
||||
}
|
||||
|
||||
processed[ processed.length - 1 ] = processed[ 0 ];
|
||||
|
||||
dispatch( processed );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user