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:
denny
2015-11-08 08:17:34 -05:00
parent 70e62ebb35
commit f0dc9452c8
10 changed files with 214 additions and 83 deletions

View File

@@ -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 );