wip #34 - removed some wrapper methods from tuner since the tuner

controller is now exposed (frequency, sample rate, channel count, etc)
This commit is contained in:
denny
2016-03-13 07:38:29 -04:00
parent 415f95ec89
commit 0605760fcd
16 changed files with 32 additions and 198 deletions

View File

@@ -99,12 +99,6 @@ public abstract class Tuner implements ITunerChannelProvider
mName = name; mName = name;
} }
/**
* Applies the settings from a saved tuner configuration setting object
*/
public abstract void apply( TunerConfiguration config )
throws SourceException;
/** /**
* Unique identifier for this tuner, used to lookup a tuner configuration * Unique identifier for this tuner, used to lookup a tuner configuration
* from the settings manager. * from the settings manager.
@@ -135,23 +129,11 @@ public abstract class Tuner implements ITunerChannelProvider
return mName; return mName;
} }
/**
* Sample rate of complex data coming from the Tuner
* @return
*/
public abstract int getSampleRate();
/** /**
* Sample size in bits * Sample size in bits
*/ */
public abstract double getSampleSize(); public abstract double getSampleSize();
/**
* Tuner Local Oscillator Frequency
* @return - frequency in Hertz
*/
public abstract long getFrequency() throws SourceException;
/** /**
* Returns a tuner frequency channel source, tuned to the correct frequency * Returns a tuner frequency channel source, tuned to the correct frequency
* *
@@ -166,11 +148,6 @@ public abstract class Tuner implements ITunerChannelProvider
public abstract TunerChannelSource getChannel( TunerChannel channel ) public abstract TunerChannelSource getChannel( TunerChannel channel )
throws RejectedExecutionException, SourceException; throws RejectedExecutionException, SourceException;
/**
* Count of currently sourced channels (TunerChannel).
*/
public abstract int getChannelCount();
/** /**
* Releases the tuned channel resources * Releases the tuned channel resources
* *

View File

@@ -97,16 +97,18 @@ public class TunerChannelSource extends ComplexSource
mTunerChannel = tunerChannel; mTunerChannel = tunerChannel;
mTunerFrequency = mTuner.getFrequency(); mTunerFrequency = mTuner.getTunerController().getFrequency();
/* Setup the frequency translator to the current source frequency */ /* Setup the frequency translator to the current source frequency */
long frequencyOffset = mTunerFrequency - mTunerChannel.getFrequency(); long frequencyOffset = mTunerFrequency - mTunerChannel.getFrequency();
mMixer = new Oscillator( frequencyOffset, mTuner.getSampleRate() ); mMixer = new Oscillator( frequencyOffset,
mTuner.getTunerController().getSampleRate() );
/* Fire a sample rate change event to setup the decimation chain */ /* Fire a sample rate change event to setup the decimation chain */
frequencyChanged( new FrequencyChangeEvent( frequencyChanged( new FrequencyChangeEvent(
Event.NOTIFICATION_SAMPLE_RATE_CHANGE, mTuner.getSampleRate() ) ); Event.NOTIFICATION_SAMPLE_RATE_CHANGE,
mTuner.getTunerController().getSampleRate() ) );
} }

View File

@@ -120,6 +120,11 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
return mFrequencyController.getFrequency(); return mFrequencyController.getFrequency();
} }
public int getSampleRate()
{
return mFrequencyController.getBandwidth();
}
public double getFrequencyCorrection() public double getFrequencyCorrection()
{ {
return mFrequencyController.getFrequencyCorrection(); return mFrequencyController.getFrequencyCorrection();

View File

@@ -133,14 +133,8 @@ public class TunerEditor extends Editor<Tuner>
tuner.getTunerController().addListener( mFrequencyControl ); tuner.getTunerController().addListener( mFrequencyControl );
//Set the displayed frequency without adjusting the tuner's frequency //Set the displayed frequency without adjusting the tuner's frequency
try mFrequencyControl.setFrequency(
{ tuner.getTunerController().getFrequency(), false );
mFrequencyControl.setFrequency( tuner.getFrequency(), false );
}
catch( SourceException e )
{
mLog.debug( "Couldn't get frequency from tuner: " + tuner.getUniqueID() );
}
} }
else else
{ {

View File

@@ -96,7 +96,7 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
try try
{ {
tuner.apply( config ); tuner.getTunerController().apply( config );
mTuners.add( tuner ); mTuners.add( tuner );
@@ -222,13 +222,13 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
case TUNER_TYPE: case TUNER_TYPE:
return tuner.getTunerType().getLabel(); return tuner.getTunerType().getLabel();
case SAMPLE_RATE: case SAMPLE_RATE:
int sampleRate = tuner.getSampleRate(); int sampleRate = tuner.getTunerController().getSampleRate();
return mSampleRateFormat.format( sampleRate / 1E6D ) + MHZ; return mSampleRateFormat.format( sampleRate / 1E6D ) + MHZ;
case FREQUENCY: case FREQUENCY:
try try
{ {
long frequency = tuner.getFrequency(); long frequency = tuner.getTunerController().getFrequency();
return mFrequencyFormat.format( frequency / 1E6D ) + MHZ; return mFrequencyFormat.format( frequency / 1E6D ) + MHZ;
} }
@@ -237,7 +237,7 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
return 0; return 0;
} }
case CHANNEL_COUNT: case CHANNEL_COUNT:
return tuner.getChannelCount(); return tuner.getTunerController().getChannelCount();
case SPECTRAL_DISPLAY_MAIN: case SPECTRAL_DISPLAY_MAIN:
return "Main"; return "Main";
case SPECTRAL_DISPLAY_NEW: case SPECTRAL_DISPLAY_NEW:

View File

@@ -48,12 +48,6 @@ public class AirspyTuner extends Tuner
return (AirspyTunerController)getTunerController(); return (AirspyTunerController)getTunerController();
} }
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
getController().apply( config );
}
@Override @Override
public String getUniqueID() public String getUniqueID()
{ {
@@ -81,35 +75,12 @@ public class AirspyTuner extends Tuner
return TunerType.AIRSPY_R820T; return TunerType.AIRSPY_R820T;
} }
@Override
public int getSampleRate()
{
int rate = 0;
try
{
rate = getController().getCurrentSampleRate();
}
catch ( SourceException e )
{
mLog.error( "Error while getting sample rate from controller", e );
}
return rate;
}
@Override @Override
public double getSampleSize() public double getSampleSize()
{ {
return 13.0; return 13.0;
} }
@Override
public long getFrequency() throws SourceException
{
return getController().getFrequency();
}
@Override @Override
public TunerChannelSource getChannel( TunerChannel channel ) public TunerChannelSource getChannel( TunerChannel channel )
throws RejectedExecutionException, SourceException throws RejectedExecutionException, SourceException
@@ -131,14 +102,6 @@ public class AirspyTuner extends Tuner
return source; return source;
} }
@Override
public int getChannelCount()
{
return getController().getChannelCount();
}
@Override @Override
public void releaseChannel( TunerChannelSource source ) public void releaseChannel( TunerChannelSource source )
{ {

View File

@@ -427,7 +427,7 @@ public class AirspyTunerController extends TunerController
/** /**
* Airspy sample rate object that matches the current sample rate setting. * Airspy sample rate object that matches the current sample rate setting.
*/ */
public AirspySampleRate getSampleRate() public AirspySampleRate getAirspySampleRate()
{ {
return getSampleRate( mSampleRate ); return getSampleRate( mSampleRate );
} }

View File

@@ -68,30 +68,12 @@ public class B100Tuner extends Tuner
return TunerType.ETTUS_WBX; return TunerType.ETTUS_WBX;
} }
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
mLog.error( "B100 Tuner - can't apply tuner configuration" );
}
@Override
public int getSampleRate()
{
return 0;
}
@Override @Override
public double getSampleSize() public double getSampleSize()
{ {
return 16.0; return 16.0;
} }
@Override
public long getFrequency() throws SourceException
{
return 0;
}
@Override @Override
public TunerChannelSource getChannel( TunerChannel channel ) public TunerChannelSource getChannel( TunerChannel channel )
throws RejectedExecutionException, SourceException throws RejectedExecutionException, SourceException
@@ -100,13 +82,6 @@ public class B100Tuner extends Tuner
return null; return null;
} }
@Override
public int getChannelCount()
{
// TODO Auto-generated method stub
return 0;
}
@Override @Override
public void releaseChannel( TunerChannelSource source ) public void releaseChannel( TunerChannelSource source )
{ {

View File

@@ -73,30 +73,12 @@ public class FCDTuner extends MixerTuner
return getController().getUSBAddress(); return getController().getUSBAddress();
} }
@Override
public void apply( TunerConfiguration config )throws SourceException
{
getController().apply( config );
}
@Override
public int getSampleRate()
{
return (int)mMixerTunerType.getAudioFormat().getSampleRate();
}
@Override @Override
public double getSampleSize() public double getSampleSize()
{ {
return 16.0; return 16.0;
} }
@Override
public long getFrequency() throws SourceException
{
return getController().getFrequency();
}
@Override @Override
public TunerChannelSource getChannel( TunerChannel tunerChannel ) public TunerChannelSource getChannel( TunerChannel tunerChannel )
throws RejectedExecutionException, SourceException throws RejectedExecutionException, SourceException
@@ -111,12 +93,6 @@ public class FCDTuner extends MixerTuner
return source; return source;
} }
@Override
public int getChannelCount()
{
return getController().getChannelCount();
}
/** /**
* Releases the tuned channel so that the tuner controller can tune to * Releases the tuned channel so that the tuner controller can tune to
* other frequencies as needed. * other frequencies as needed.

View File

@@ -70,6 +70,7 @@ public abstract class FCDTunerController extends TunerController
*/ */
public FCDTunerController( Device device, public FCDTunerController( Device device,
DeviceDescriptor descriptor, DeviceDescriptor descriptor,
int sampleRate,
int minTunableFrequency, int minTunableFrequency,
int maxTunableFrequency ) int maxTunableFrequency )
{ {
@@ -77,7 +78,7 @@ public abstract class FCDTunerController extends TunerController
maxTunableFrequency, maxTunableFrequency,
DC_SPIKE_AVOID_BUFFER, DC_SPIKE_AVOID_BUFFER,
USABLE_BANDWIDTH_PERCENT ); USABLE_BANDWIDTH_PERCENT );
mFrequencyController.setSampleRate( sampleRate );
mDevice = device; mDevice = device;
mDeviceDescriptor = descriptor; mDeviceDescriptor = descriptor;
} }

View File

@@ -31,6 +31,7 @@ import org.usb4java.DeviceDescriptor;
import settings.SettingsManager; import settings.SettingsManager;
import source.SourceException; import source.SourceException;
import source.tuner.MixerTunerType;
import source.tuner.TunerClass; import source.tuner.TunerClass;
import source.tuner.TunerType; import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration; import source.tuner.configuration.TunerConfiguration;
@@ -61,6 +62,7 @@ public class FCD1TunerController extends FCDTunerController
{ {
super( device, super( device,
descriptor, descriptor,
(int)MixerTunerType.FUNCUBE_DONGLE_PRO.getAudioFormat().getSampleRate(),
sMINIMUM_TUNABLE_FREQUENCY, sMINIMUM_TUNABLE_FREQUENCY,
sMAXIMUM_TUNABLE_FREQUENCY ); sMAXIMUM_TUNABLE_FREQUENCY );
} }

View File

@@ -29,6 +29,7 @@ import org.usb4java.DeviceDescriptor;
import settings.SettingsManager; import settings.SettingsManager;
import source.SourceException; import source.SourceException;
import source.tuner.MixerTunerType;
import source.tuner.TunerClass; import source.tuner.TunerClass;
import source.tuner.TunerType; import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration; import source.tuner.configuration.TunerConfiguration;
@@ -52,6 +53,7 @@ public class FCD2TunerController extends FCDTunerController
{ {
super( device, super( device,
descriptor, descriptor,
(int)MixerTunerType.FUNCUBE_DONGLE_PRO_PLUS.getAudioFormat().getSampleRate(),
sMINIMUM_TUNABLE_FREQUENCY, sMINIMUM_TUNABLE_FREQUENCY,
sMAXIMUM_TUNABLE_FREQUENCY ); sMAXIMUM_TUNABLE_FREQUENCY );
} }

View File

@@ -65,30 +65,12 @@ public class HackRFTuner extends Tuner
return TunerType.HACKRF; return TunerType.HACKRF;
} }
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
getController().apply( config );
}
@Override
public int getSampleRate()
{
return getController().getSampleRate();
}
@Override @Override
public double getSampleSize() public double getSampleSize()
{ {
return 11.0; return 11.0;
} }
@Override
public long getFrequency() throws SourceException
{
return getController().getFrequency();
}
@Override @Override
public TunerChannelSource getChannel( TunerChannel channel ) public TunerChannelSource getChannel( TunerChannel channel )
throws RejectedExecutionException, SourceException throws RejectedExecutionException, SourceException
@@ -103,12 +85,6 @@ public class HackRFTuner extends Tuner
return source; return source;
} }
@Override
public int getChannelCount()
{
return getController().getChannelCount();
}
@Override @Override
public void releaseChannel( TunerChannelSource source ) public void releaseChannel( TunerChannelSource source )
{ {

View File

@@ -81,27 +81,6 @@ public class RTL2832Tuner extends Tuner
return getController().getTunerType(); return getController().getTunerType();
} }
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
getController().apply( config );
}
@Override
public int getSampleRate()
{
try
{
return getController().getCurrentSampleRate();
}
catch( SourceException e )
{
mLog.error( "RTL2832 Tuner - couldn't get sample rate", e );
}
return 0;
}
public void setSampleRate( SampleRate sampleRate ) throws SourceException public void setSampleRate( SampleRate sampleRate ) throws SourceException
{ {
try try
@@ -123,12 +102,6 @@ public class RTL2832Tuner extends Tuner
return 11.0; return 11.0;
} }
@Override
public long getFrequency() throws SourceException
{
return getController().getFrequency();
}
public void setFrequency( int frequency ) throws SourceException public void setFrequency( int frequency ) throws SourceException
{ {
getController().setFrequency( frequency ); getController().setFrequency( frequency );
@@ -158,12 +131,6 @@ public class RTL2832Tuner extends Tuner
return source; return source;
} }
@Override
public int getChannelCount()
{
return getController().getChannelCount();
}
/** /**
* Releases the tuned channel so that the tuner controller can tune to * Releases the tuned channel so that the tuner controller can tune to
* other frequencies as needed. * other frequencies as needed.

View File

@@ -976,7 +976,7 @@ public abstract class RTL2832TunerController extends TunerController
return mSampleRate.getRate(); return mSampleRate.getRate();
} }
public int getSampleRate() throws SourceException public int getSampleRateFromTuner() throws SourceException
{ {
try try
{ {

View File

@@ -447,19 +447,13 @@ public class SpectralDisplayPanel extends JPanel
//Fire frequency and sample rate change events so that the spectrum //Fire frequency and sample rate change events so that the spectrum
//and overlay panels can synchronize //and overlay panels can synchronize
try frequencyChanged( new FrequencyChangeEvent(
{ Event.NOTIFICATION_FREQUENCY_CHANGE,
frequencyChanged( new FrequencyChangeEvent( mTuner.getTunerController().getFrequency() ) );
Event.NOTIFICATION_FREQUENCY_CHANGE, mTuner.getFrequency() ) );
frequencyChanged( new FrequencyChangeEvent( frequencyChanged( new FrequencyChangeEvent(
Event.NOTIFICATION_SAMPLE_RATE_CHANGE, mTuner.getSampleRate() ) ); Event.NOTIFICATION_SAMPLE_RATE_CHANGE,
} mTuner.getTunerController().getSampleRate() ) );
catch ( SourceException e )
{
mLog.info( "DFTProcessor - exception during new tuner setup - "
+ "couldn't get frequency from the tuner", e );
}
} }
} }