mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 09:07:27 -05:00
Work in progress.
-Started work on new channel editor channel viewer/controller -Removed a number of unused buffer package classes -Moved automatic frequency control to be a module and removed special handling -Added IUnfilteredRealBufferListener & Provider interfaces -Completely removed the ResourceManager class
This commit is contained in:
60
src/dsp/filter/dc/DCRemovalFilter_RealBuffer.java
Normal file
60
src/dsp/filter/dc/DCRemovalFilter_RealBuffer.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package dsp.filter.dc;
|
||||
|
||||
import sample.Listener;
|
||||
import sample.real.RealBuffer;
|
||||
|
||||
public class DCRemovalFilter_RealBuffer implements Listener<RealBuffer>
|
||||
{
|
||||
private Listener<RealBuffer> mListener;
|
||||
/**
|
||||
* Removes DC bias present across the samples in the buffer by calculating
|
||||
* the mean DC component and subtracting that component from each of the
|
||||
* samples.
|
||||
*/
|
||||
public DCRemovalFilter_RealBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
public RealBuffer filter( RealBuffer buffer )
|
||||
{
|
||||
double accumulator = 0.0d;
|
||||
|
||||
for( float sample: buffer.getSamples() )
|
||||
{
|
||||
accumulator += sample;
|
||||
}
|
||||
|
||||
float mean = (float)( accumulator / (double)buffer.getSamples().length );
|
||||
|
||||
for( float sample: buffer.getSamples() )
|
||||
{
|
||||
sample -= mean;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( RealBuffer buffer )
|
||||
{
|
||||
if( mListener != null )
|
||||
{
|
||||
mListener.receive( filter( buffer ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener( Listener<RealBuffer> listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void removeListener()
|
||||
{
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user