#1291 Updates DC removal processing across tuner sample streams to run on a periodic timer to reduce overall processing requirements. Updates build version to 0.5.0 beta 5 (#1292)

Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
Denny Sheirer
2022-07-23 08:14:31 -04:00
committed by GitHub
parent 414ba25d61
commit 48a93990e8
7 changed files with 330 additions and 72 deletions

View File

@@ -26,16 +26,20 @@ import java.nio.ByteBuffer;
*/
public class ByteNativeBufferFactory implements INativeBufferFactory
{
private static final float DC_FILTER_GAIN = 0.007f; //Normalizes DC over period of ~142 (1 / .007) buffers
private float mAverageDc = 0.0f;
private DcCorrectionManager mDcCorrectionManager = new DcCorrectionManager();
@Override
public INativeBuffer getBuffer(ByteBuffer samples, long timestamp)
{
byte[] copy = new byte[samples.capacity()];
samples.get(copy);
calculateDc(copy);
return new ByteNativeBuffer(copy, timestamp, mAverageDc);
if(mDcCorrectionManager.shouldCalculateDc())
{
calculateDc(copy);
}
return new ByteNativeBuffer(copy, timestamp, mDcCorrectionManager.getAverageDc());
}
/**
@@ -55,7 +59,6 @@ public class ByteNativeBufferFactory implements INativeBufferFactory
dcAccumulator /= samples.length;
dcAccumulator -= 127.5f;
dcAccumulator /= 128.0f;
dcAccumulator -= mAverageDc;
mAverageDc += (dcAccumulator * DC_FILTER_GAIN);
mDcCorrectionManager.adjust(dcAccumulator);
}
}