mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -05:00
Resolves issue with correct display and scaling of decibel values in
both the spectral and waterfall displays. Resolves issue with gain loss in HilbertTransform.
This commit is contained in:
@@ -7,33 +7,22 @@ public class RealDecibelConverter extends DFTResultsConverter
|
||||
{
|
||||
private static final Logger mLog = LoggerFactory.getLogger( RealDecibelConverter.class );
|
||||
|
||||
private float mDynamicRangeReference;
|
||||
|
||||
public RealDecibelConverter()
|
||||
{
|
||||
setSampleSize( 24.0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the bit depth to establish the maximum dynamic range. All
|
||||
* FFT bin values will be scaled according to this value.
|
||||
*/
|
||||
@Override
|
||||
public void setSampleSize( double size )
|
||||
{
|
||||
assert( 2.0 <= size && size <= 32.0 );
|
||||
|
||||
mDynamicRangeReference = (float)Math.pow( 2.0d, size );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Note: this is only calculating the lower half of the spectrum
|
||||
*/
|
||||
@Override
|
||||
public void receive( float[] results )
|
||||
{
|
||||
float dftScalor = 1.0f / (float)( results.length ^ 2 );
|
||||
|
||||
float[] processed = new float[ results.length / 4 ];
|
||||
|
||||
int index = 0;
|
||||
@@ -42,12 +31,9 @@ public class RealDecibelConverter extends DFTResultsConverter
|
||||
{
|
||||
index = x * 2;
|
||||
|
||||
float normalizedMagnitude = 10.0f * (float)Math.log10(
|
||||
processed[ x ] = 20.0f * (float)Math.log10(
|
||||
( ( results[ index ] * results[ index ] ) +
|
||||
( results[ index + 1 ] * results[ index + 1 ] ) ) /
|
||||
mDynamicRangeReference );
|
||||
|
||||
processed[ x ] = normalizedMagnitude;
|
||||
( results[ index + 1 ] * results[ index + 1 ] ) ) * dftScalor );
|
||||
}
|
||||
|
||||
dispatch( processed );
|
||||
|
||||
Reference in New Issue
Block a user