Refactoring to use COMPLEX and REAL sample terms throughout

This commit is contained in:
dennis.sheirer
2014-10-31 13:58:20 +00:00
parent 34268f32b3
commit d34abdd2fa
50 changed files with 530 additions and 239 deletions

View File

@@ -6,6 +6,6 @@ public abstract class FloatSource extends Source implements Provider<Float>
{
public FloatSource( String name )
{
super( name, SampleType.FLOAT );
super( name, SampleType.REAL );
}
}

View File

@@ -0,0 +1,13 @@
package source;
import sample.Provider;
import sample.real.RealBuffer;
public abstract class RealSource extends Source implements Provider<RealBuffer>
{
public RealSource( String name )
{
super( name, SampleType.REAL );
}
}

View File

@@ -1,13 +0,0 @@
package source;
import sample.Provider;
import sample.simplex.SimplexBuffer;
public abstract class SimplexSource extends Source implements Provider<SimplexBuffer>
{
public SimplexSource( String name )
{
super( name, SampleType.FLOAT );
}
}

View File

@@ -25,7 +25,7 @@ public abstract class Source
protected String mName;
protected SampleType mSampleType;
public enum SampleType { COMPLEX, FLOAT }
public enum SampleType { COMPLEX, REAL }
public Source( String name, SampleType sampleType )
{

View File

@@ -82,9 +82,9 @@ public class MixerManager
return sInstance;
}
public SimplexMixerSource getSource( ProcessingChain processingChain )
public RealMixerSource getSource( ProcessingChain processingChain )
{
SimplexMixerSource retVal = null;
RealMixerSource retVal = null;
SourceConfiguration config =
processingChain.getChannel().getSourceConfiguration();
@@ -120,7 +120,7 @@ public class MixerManager
if( dataLine != null )
{
return new SimplexMixerSource( dataLine,
return new RealMixerSource( dataLine,
MONO,
mixerName,
new ShortAdapter() );
@@ -148,7 +148,7 @@ public class MixerManager
if( dataLine != null )
{
return new SimplexMixerSource( dataLine, STEREO,
return new RealMixerSource( dataLine, STEREO,
mixerName, new ChannelShortAdapter(
mixerConfig.getChannel() ) );
}

View File

@@ -31,14 +31,14 @@ import org.slf4j.LoggerFactory;
import sample.Listener;
import sample.adapter.SampleAdapter;
import sample.simplex.SimplexBuffer;
import source.SimplexSource;
import sample.real.RealBuffer;
import source.RealSource;
import source.SourceException;
public class SimplexMixerSource extends SimplexSource
public class RealMixerSource extends RealSource
{
private final static Logger mLog =
LoggerFactory.getLogger( SimplexMixerSource.class );
LoggerFactory.getLogger( RealMixerSource.class );
private long mFrequency = 0;
private int mBufferSize = 16384;
@@ -50,13 +50,13 @@ public class SimplexMixerSource extends SimplexSource
private int mBytesPerFrame = 0;
private SampleAdapter mSampleAdapter;
CopyOnWriteArrayList<Listener<SimplexBuffer>> mSampleListeners =
new CopyOnWriteArrayList<Listener<SimplexBuffer>>();
CopyOnWriteArrayList<Listener<RealBuffer>> mSampleListeners =
new CopyOnWriteArrayList<Listener<RealBuffer>>();
/**
* Simplex Mixer Source - constructs a reader on the mixer/sound card target
* Real Mixer Source - constructs a reader on the mixer/sound card target
* data line using the specified audio format (sample size, sample rate )
* and broadcasts simplex buffers (float arrays) to all registered listeners.
* and broadcasts real buffers (float arrays) to all registered listeners.
* Reads buffers sized to 10% of the sample rate specified in audio format.
*
* @param targetDataLine - mixer or sound card to be used
@@ -69,7 +69,7 @@ public class SimplexMixerSource extends SimplexSource
* mixer into float array data. Can optionally invert the channel data if
* the left/right stereo channels are inverted.
*/
public SimplexMixerSource( TargetDataLine targetDataLine,
public RealMixerSource( TargetDataLine targetDataLine,
AudioFormat format,
String name,
SampleAdapter sampleAdapter )
@@ -81,7 +81,7 @@ public class SimplexMixerSource extends SimplexSource
mSampleAdapter = sampleAdapter;
}
public void setListener( Listener<SimplexBuffer> listener )
public void setListener( Listener<RealBuffer> listener )
{
mSampleListeners.add( listener );
@@ -95,7 +95,7 @@ public class SimplexMixerSource extends SimplexSource
}
}
public void removeListener( Listener<SimplexBuffer> listener )
public void removeListener( Listener<RealBuffer> listener )
{
mSampleListeners.remove( listener );
@@ -106,13 +106,13 @@ public class SimplexMixerSource extends SimplexSource
}
}
public void broadcast( SimplexBuffer samples )
public void broadcast( RealBuffer samples )
{
Iterator<Listener<SimplexBuffer>> it = mSampleListeners.iterator();
Iterator<Listener<RealBuffer>> it = mSampleListeners.iterator();
while( it.hasNext() )
{
Listener<SimplexBuffer> next = it.next();
Listener<RealBuffer> next = it.next();
/* if this is the last (or only) listener, send him the original
* buffer, otherwise send him a copy of the buffer */
@@ -226,7 +226,7 @@ public class SimplexMixerSource extends SimplexSource
mSampleAdapter.convert( buffer );
/* Dispatch samples to registered listeners */
broadcast( new SimplexBuffer( samples ) );
broadcast( new RealBuffer( samples ) );
}
catch ( Exception e )
{

View File

@@ -491,8 +491,6 @@ public class HackRFTunerController extends TunerController
*/
public void setSampleRate( HackRFSampleRate rate ) throws UsbException
{
mLog.debug( "Setting sample rate to:" + rate.name() );
setSampleRateManual( rate.getRate(), 1 );
mFrequencyController.setSampleRate( rate.getRate() );

View File

@@ -29,7 +29,7 @@ import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import sample.simplex.SimplexSampleListener;
import sample.real.RealSampleListener;
public class FloatWaveSource extends WaveSource
{
@@ -44,7 +44,7 @@ public class FloatWaveSource extends WaveSource
private int mBufferPointer = 0;
private int mBufferLength;
private ShortBuffer mBufferWrapper;
private SimplexSampleListener mListener;
private RealSampleListener mListener;
private static int BUFFER_SAMPLE_SIZE = 2000;
@@ -70,7 +70,7 @@ public class FloatWaveSource extends WaveSource
*/
public FloatWaveSource( File file, boolean loop ) throws IOException
{
super( file, SampleType.FLOAT );
super( file, SampleType.REAL );
mLoop = loop;
}
@@ -272,12 +272,12 @@ public class FloatWaveSource extends WaveSource
/**
* Adds a new listener to receive samples as they are read from the wave file
*/
public void setListener( SimplexSampleListener listener )
public void setListener( RealSampleListener listener )
{
mListener = listener;
}
public void removeListener( SimplexSampleListener listener )
public void removeListener( RealSampleListener listener )
{
mListener = null;
}