Memory/CPU performance improvement and Audio/Mixer source restructuring

Converted to use float primitives and to keep samples in buffer format until the sample rate is decimated to 48kHz.  
Added new non-recursive, CIC decimation filter -- untested

Updated sound card/mixer input source management.  Now testing for mono/stereo support for each card and limiting channel choices accordingly.  Separated the mixersource into a ComplexMixer and and SimplexMixerSource.  The ComplexMixer is used for sound card based tuners like the funcube.  The SimplexMixerSource is used for demodulated sound card inputs.

Interfaces for sample handling - standardized on using 'Complex' to indicate I/Q samples and 'Simplex' to indicate demodulated float samples.  The processing chain now accepts either a decimated (48k) list of complex samples from a tuner channel source, or a 48k simplex buffer (array of demodulated float samples).

Resolved issue with HackRF tuner not applying tuner configuration information.
This commit is contained in:
dennis.sheirer
2014-10-26 10:11:30 +00:00
parent 0ad710fea2
commit e61c3a891c
71 changed files with 1754 additions and 619 deletions

View File

@@ -52,12 +52,12 @@ import org.usb4java.Transfer;
import org.usb4java.TransferCallback;
import sample.Listener;
import sample.complex.ComplexBuffer;
import source.SourceException;
import source.tuner.FrequencyChangeEvent;
import source.tuner.FrequencyChangeEvent.Attribute;
import source.tuner.TunerController;
import source.tuner.TunerType;
import util.TimeStamp;
import buffer.FloatAveragingBuffer;
import controller.ResourceManager;
@@ -107,8 +107,8 @@ public abstract class RTL2832TunerController extends TunerController
private ByteSampleAdapter mSampleAdapter = new ByteSampleAdapter();
private CopyOnWriteArrayList<Listener<Float[]>> mSampleListeners =
new CopyOnWriteArrayList<Listener<Float[]>>();
private CopyOnWriteArrayList<Listener<ComplexBuffer>> mSampleListeners =
new CopyOnWriteArrayList<Listener<ComplexBuffer>>();
private LinkedTransferQueue<byte[]> mFilledBuffers =
new LinkedTransferQueue<byte[]>();
@@ -1342,7 +1342,7 @@ public abstract class RTL2832TunerController extends TunerController
* Adds a sample listener. If the buffer processing thread is
* not currently running, starts it running in a new thread.
*/
public void addListener( Listener<Float[]> listener )
public void addListener( Listener<ComplexBuffer> listener )
{
mSampleListeners.add( listener );
@@ -1352,7 +1352,7 @@ public abstract class RTL2832TunerController extends TunerController
Thread thread = new Thread( mBufferProcessor );
thread.setDaemon( true );
thread.setName( "Sample Processor" );
thread.setName( "RTL2832 Sample Processor" );
thread.start();
}
@@ -1362,7 +1362,7 @@ public abstract class RTL2832TunerController extends TunerController
* Removes the sample listener. If this is the last registered listener,
* shuts down the buffer processing thread.
*/
public void removeListener( Listener<Float[]> listener )
public void removeListener( Listener<ComplexBuffer> listener )
{
mSampleListeners.remove( listener );
@@ -1375,23 +1375,23 @@ public abstract class RTL2832TunerController extends TunerController
/**
* Dispatches float sample buffers to all registered listeners
*/
public void broadcast( Float[] samples )
public void broadcast( ComplexBuffer buffer )
{
Iterator<Listener<Float[]>> it = mSampleListeners.iterator();
Iterator<Listener<ComplexBuffer>> it = mSampleListeners.iterator();
while( it.hasNext() )
{
Listener<Float[]> next = it.next();
Listener<ComplexBuffer> next = it.next();
/* if this is the last (or only) listener, send him the original
* buffer, otherwise send him a copy of the buffer */
if( it.hasNext() )
{
next.receive( Arrays.copyOf( samples, samples.length ) );
next.receive( buffer.copyOf() );
}
else
{
next.receive( samples );
next.receive( buffer );
}
}
}
@@ -1406,7 +1406,7 @@ public abstract class RTL2832TunerController extends TunerController
Executors.newScheduledThreadPool( 2 );
private ScheduledFuture<?> mSampleDispatcherTask;
private ScheduledFuture<?> mSampleRateCounterTask;
private ArrayList<Transfer> mTransfers;
private CopyOnWriteArrayList<Transfer> mTransfers;
private AtomicBoolean mRunning = new AtomicBoolean();
@Override
@@ -1573,7 +1573,7 @@ public abstract class RTL2832TunerController extends TunerController
*/
private void prepareTransfers() throws LibUsbException
{
mTransfers = new ArrayList<Transfer>();
mTransfers = new CopyOnWriteArrayList<Transfer>();
for( int x = 0; x < TRANSFER_BUFFER_POOL_SIZE; x++ )
{
@@ -1616,10 +1616,9 @@ public abstract class RTL2832TunerController extends TunerController
for( byte[] buffer: buffers )
{
//TODO: convert this to float primitive
Float[] samples = mSampleAdapter.convert( buffer );
float[] samples = mSampleAdapter.convert( buffer );
broadcast( samples );
broadcast( new ComplexBuffer( samples ) );
}
}
}