Merges #34 Major redesign of Tuner, Channel and Alias management.

Changes to model, view and controller components and updates all gui
editors.  Removes the configuration panel and tree and replaces with 3
new panels.  Updates playlist.xml to a new playlist_v2.xml format.
This commit is contained in:
denny
2016-04-01 08:23:49 -04:00
450 changed files with 19560 additions and 22805 deletions

View File

@@ -6,7 +6,6 @@ import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.JLayeredPane;
@@ -16,15 +15,12 @@ import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import module.ProcessingChain;
import net.miginfocom.swing.MigLayout;
import sample.Listener;
import sample.SampleType;
import sample.complex.ComplexBuffer;
import sample.real.RealBuffer;
import sample.real.RealSampleListener;
import settings.ColorSetting.ColorSettingName;
import settings.ColorSettingMenuItem;
import settings.Setting;
@@ -40,15 +36,13 @@ import spectrum.menu.FFTWindowTypeItem;
import spectrum.menu.FrameRateItem;
import spectrum.menu.SmoothingItem;
import spectrum.menu.SmoothingTypeItem;
import controller.ResourceManager;
import controller.channel.Channel;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelProcessingManager;
import dsp.filter.Filters;
import dsp.filter.FloatHalfBandFilter;
import dsp.filter.Window.WindowType;
import dsp.filter.halfband.real.HalfBandFilter_RB_RB;
import dsp.filter.hilbert.HilbertTransform;
import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
public class ChannelSpectrumPanel extends JPanel
@@ -57,11 +51,8 @@ public class ChannelSpectrumPanel extends JPanel
SettingChangeListener,
SpectralDisplayAdjuster
{
private static final Logger mLog = LoggerFactory.getLogger( ChannelSpectrumPanel.class );
private static final long serialVersionUID = 1L;
// private ResourceManager mResourceManager;
private DFTProcessor mDFTProcessor = new DFTProcessor( SampleType.REAL );
private DFTResultsConverter mDFTConverter = new RealDecibelConverter();
private JLayeredPane mLayeredPane;
@@ -71,8 +62,6 @@ public class ChannelSpectrumPanel extends JPanel
private Channel mCurrentChannel;
private int mSampleBufferSize = 2400;
private float[] mSamples = new float[ mSampleBufferSize ];
private int mSamplePointer = 0;
private HalfBandFilter_RB_RB mDecimatingFilter = new HalfBandFilter_RB_RB(
Filters.FIR_HALF_BAND_31T_ONE_EIGHTH_FCO.getCoefficients(), 1.0f, true );
@@ -80,10 +69,13 @@ public class ChannelSpectrumPanel extends JPanel
private AtomicBoolean mEnabled = new AtomicBoolean();
private SettingsManager mSettingsManager;
private ChannelProcessingManager mChannelProcessingManager;
public ChannelSpectrumPanel( SettingsManager settingsManager )
public ChannelSpectrumPanel( SettingsManager settingsManager,
ChannelProcessingManager channelProcessingManager )
{
mSettingsManager = settingsManager;
mChannelProcessingManager = channelProcessingManager;
if( mSettingsManager != null )
{
@@ -99,7 +91,7 @@ public class ChannelSpectrumPanel extends JPanel
/* Set the DFTProcessor to the decimated 24kHz sample rate */
mDFTProcessor.frequencyChanged(
new FrequencyChangeEvent( Event.SAMPLE_RATE_CHANGE_NOTIFICATION, 24000 ) );
new FrequencyChangeEvent( Event.NOTIFICATION_SAMPLE_RATE_CHANGE, 24000 ) );
initGui();
}
@@ -166,15 +158,18 @@ public class ChannelSpectrumPanel extends JPanel
{
switch( event.getEvent() )
{
case CHANGE_SELECTED:
if( !event.getChannel().isSelected() )
case NOTIFICATION_SELECTION_CHANGE:
//ChannelSelectionManager ensures that only 1 channel can be
//selected and any previously selected channel will be first
//deselected before we get a new selection event
if( event.getChannel().isSelected() )
{
stop();
if( mCurrentChannel != null )
{
stop();
mCurrentChannel = null;
}
mCurrentChannel = null;
}
else
{
mCurrentChannel = event.getChannel();
if( mEnabled.get() )
@@ -182,17 +177,13 @@ public class ChannelSpectrumPanel extends JPanel
start();
}
}
if( event.getChannel().isSelected() &&
mCurrentChannel != event.getChannel() )
else
{
stop();
mCurrentChannel = event.getChannel();
start();
mCurrentChannel = null;
}
break;
case CHANNEL_DISABLED:
case NOTIFICATION_PROCESSING_STOP:
if( event.getChannel() == mCurrentChannel )
{
if( mEnabled.get() )
@@ -203,32 +194,36 @@ public class ChannelSpectrumPanel extends JPanel
mCurrentChannel = null;
}
break;
case CHANNEL_ENABLED:
if( event.getChannel() == mCurrentChannel &&
!event.getChannel().isProcessing() )
{
stop();
mCurrentChannel = null;
}
break;
}
}
private void start()
{
if( mEnabled.get() && mCurrentChannel != null && mCurrentChannel.isProcessing() )
if( mEnabled.get() && mCurrentChannel != null && mCurrentChannel.getEnabled() )
{
mCurrentChannel.getProcessingChain().addRealBufferListener( this );
mDFTProcessor.start();
ProcessingChain processingChain = mChannelProcessingManager
.getProcessingChain( mCurrentChannel );
if( processingChain != null )
{
processingChain.addRealBufferListener( this );
mDFTProcessor.start();
}
}
}
private void stop()
{
if( mCurrentChannel != null && mCurrentChannel.isProcessing() )
if( mCurrentChannel != null && mCurrentChannel.getEnabled() )
{
mCurrentChannel.getProcessingChain().removeRealBufferListener( this );
ProcessingChain processingChain = mChannelProcessingManager
.getProcessingChain( mCurrentChannel );
if( processingChain != null )
{
processingChain.removeRealBufferListener( this );
}
}
mDFTProcessor.stop();

View File

@@ -37,7 +37,7 @@ import sample.Listener;
import sample.SampleType;
import sample.complex.ComplexBuffer;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeListener;
import source.tuner.frequency.IFrequencyChangeProcessor;
import spectrum.converter.DFTResultsConverter;
import controller.NamingThreadFactory;
import dsp.filter.Window;
@@ -48,7 +48,7 @@ import dsp.filter.Window.WindowType;
* of DFT results, using configurable fft size and output dispatch timelines.
*/
public class DFTProcessor implements Listener<ComplexBuffer>,
FrequencyChangeListener,
IFrequencyChangeProcessor,
IDFTWidthChangeProcessor
{
private final static Logger mLog =
@@ -61,9 +61,9 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
//sample rate tuner (10 MHz) producing 153 frames per second and the lowest
//DFT processing frame rate of 12 frames per second. This means that the
//maximum size needed is 153 / 12 = 11 frames per DFT processing iteration
//so we set it at 12.
//so we set it at 12.
private BlockingQueue<ComplexBuffer> mQueue = new ArrayBlockingQueue<>( 12 );
private ScheduledExecutorService mScheduler = Executors
.newScheduledThreadPool( 1, new NamingThreadFactory( "spectrum dft" ) );
@@ -97,15 +97,15 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
public DFTProcessor( SampleType sampleType )
{
setSampleType( sampleType );
setFrameRate( 20 );
loadSettings();
}
private void loadSettings()
{
int frameRate = SystemProperties.getInstance()
.get( DFTProcessor.FRAME_RATE_PROPERTY, 20 );
int frameRate = SystemProperties.getInstance().get( FRAME_RATE_PROPERTY, 20 );
setFrameRate( frameRate );
}
@@ -187,10 +187,10 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
}
mFrameRate = framesPerSecond;
SystemProperties properties = SystemProperties.getInstance();
properties.set( FRAME_RATE_PROPERTY, String.valueOf( mFrameRate ) );
properties.save();
calculateConsumptionRate();
@@ -491,7 +491,7 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
{
switch( event.getEvent() )
{
case SAMPLE_RATE_CHANGE_NOTIFICATION:
case NOTIFICATION_SAMPLE_RATE_CHANGE:
mSampleRate = event.getValue().intValue();
calculateConsumptionRate();
break;

View File

@@ -32,7 +32,6 @@ import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.JPanel;
@@ -47,16 +46,16 @@ import settings.SettingChangeListener;
import settings.SettingsManager;
import source.tuner.TunerChannel;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeListener;
import source.tuner.frequency.IFrequencyChangeProcessor;
import controller.channel.Channel;
import controller.channel.Channel.ChannelType;
import controller.channel.ChannelEvent;
import controller.channel.ChannelEventListener;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
public class OverlayPanel extends JPanel
implements ChannelEventListener,
FrequencyChangeListener,
IFrequencyChangeProcessor,
SettingChangeListener
{
private static final long serialVersionUID = 1L;
@@ -101,8 +100,7 @@ public class OverlayPanel extends JPanel
// private List<Channel> mChannels = new ArrayList<Channel>();
//
//Currently visible/displayable channels
private CopyOnWriteArrayList<Channel> mVisibleChannels =
new CopyOnWriteArrayList<Channel>();
private CopyOnWriteArrayList<Channel> mVisibleChannels = new CopyOnWriteArrayList<Channel>();
private ChannelDisplay mChannelDisplay = ChannelDisplay.ALL;
//Defines the offset at the bottom of the spectral display to account for
@@ -111,14 +109,14 @@ public class OverlayPanel extends JPanel
private LabelSizeManager mLabelSizeMonitor = new LabelSizeManager();
private SettingsManager mSettingsManager;
private ChannelManager mChannelManager;
private ChannelModel mChannelModel;
/**
* Translucent overlay panel for displaying channel configurations,
* processing channels, selected channels, frequency labels and lines, and
* a cursor with a frequency readout.
*/
public OverlayPanel( SettingsManager settingsManager,
ChannelManager channelManager )
ChannelModel channelModel )
{
mSettingsManager = settingsManager;
@@ -127,11 +125,11 @@ public class OverlayPanel extends JPanel
mSettingsManager.addListener( this );
}
mChannelManager = channelManager;
mChannelModel = channelModel;
if( mChannelManager != null )
if( mChannelModel != null )
{
mChannelManager.addListener( this );
mChannelModel.addListener( this );
}
addComponentListener( mLabelSizeMonitor );
@@ -145,14 +143,13 @@ public class OverlayPanel extends JPanel
public void dispose()
{
if( mChannelManager != null )
if( mChannelModel != null )
{
mChannelManager.removeListener( this );
mChannelModel.removeListener( this );
}
mChannelManager = null;
mChannelModel = null;
// mChannels.clear();
mVisibleChannels.clear();
if( mSettingsManager != null )
@@ -530,14 +527,14 @@ public class OverlayPanel extends JPanel
{
if( mChannelDisplay == ChannelDisplay.ALL ||
( mChannelDisplay == ChannelDisplay.ENABLED &&
channel.isProcessing() ) )
channel.getEnabled() ) )
{
//Choose the correct background color to use
if( channel.isSelected() )
{
graphics.setColor( mColorChannelConfigSelected );
}
else if( channel.isProcessing() )
else if( channel.getEnabled() )
{
graphics.setColor( mColorChannelConfigProcessing );
}
@@ -571,7 +568,7 @@ public class OverlayPanel extends JPanel
double yAxis = 0;
//Draw the system label and adjust the y-axis position
String system = channel.hasSystem() ? channel.getSystem().getName() : " ";
String system = channel.hasSystem() ? channel.getSystem() : " ";
yAxis += drawLabel( graphics,
system,
@@ -581,7 +578,7 @@ public class OverlayPanel extends JPanel
width );
//Draw the site label and adjust the y-axis position
String site = channel.hasSite() ? channel.getSite().getName() : " ";
String site = channel.hasSite() ? channel.getSite() : " ";
yAxis += drawLabel( graphics,
site,
@@ -599,27 +596,24 @@ public class OverlayPanel extends JPanel
width );
//Draw the decoder label
drawLabel( graphics,
channel.getDecodeConfiguration().getDecoderType()
.getShortDisplayString(),
this.getFont(),
xAxis,
yAxis,
width );
}
long frequency = tunerChannel.getFrequency();
double frequencyAxis = getAxisFromFrequency( frequency );
drawChannelCenterLine( graphics, frequencyAxis );
/* Draw Automatic Frequency Control line */
if( channel.hasFrequencyControl() )
{
long error = frequency + channel.getFrequencyCorrection();
drawLabel( graphics, channel.getDecodeConfiguration().getDecoderType().getShortDisplayString(),
this.getFont(), xAxis, yAxis, width );
long frequency = tunerChannel.getFrequency();
drawAFC( graphics, frequencyAxis, getAxisFromFrequency( error ) );
double frequencyAxis = getAxisFromFrequency( frequency );
drawChannelCenterLine( graphics, frequencyAxis );
/* Draw Automatic Frequency Control line */
int correction = channel.getChannelFrequencyCorrection();
if( correction != 0 )
{
long error = frequency + correction;
drawAFC( graphics, frequencyAxis, getAxisFromFrequency( error ) );
}
}
}
}
@@ -676,11 +670,11 @@ public class OverlayPanel extends JPanel
{
switch( event.getEvent() )
{
case SAMPLE_RATE_CHANGE_NOTIFICATION:
case NOTIFICATION_SAMPLE_RATE_CHANGE:
mBandwidth = event.getValue().intValue();
mLabelSizeMonitor.update();
break;
case FREQUENCY_CHANGE_NOTIFICATION:
case NOTIFICATION_FREQUENCY_CHANGE:
mFrequency = event.getValue().longValue();
mLabelSizeMonitor.update();
break;
@@ -689,20 +683,12 @@ public class OverlayPanel extends JPanel
}
/**
* Reset the visible channel configs list
* Reset the visible channels list
*/
mVisibleChannels.clear();
long minimum = getMinFrequency();
long maximum = getMaxFrequency();
for( Channel channel: mChannelManager.getChannels() )
{
if( channel.isWithin( minimum, maximum ) )
{
mVisibleChannels.add( channel );
}
}
mVisibleChannels.addAll(
mChannelModel.getChannelsInFrequencyRange( getMinFrequency(),
getMaxFrequency() ) );
}
/**
@@ -716,30 +702,38 @@ public class OverlayPanel extends JPanel
switch( event.getEvent() )
{
// case CHANNEL_ADDED:
case CHANNEL_ENABLED:
// if( !mChannels.contains( channel ) )
// {
// mChannels.add( channel );
// }
if( channel.isWithin( getMinFrequency(), getMaxFrequency() ) &&
!mVisibleChannels.contains( channel ) )
case NOTIFICATION_ADD:
case NOTIFICATION_PROCESSING_START:
if( !mVisibleChannels.contains( channel ) &&
channel.isWithin( getMinFrequency(), getMaxFrequency() ) )
{
mVisibleChannels.add( channel );
}
break;
case CHANNEL_DELETED:
// mChannels.remove( channel );
case NOTIFICATION_DELETE:
mVisibleChannels.remove( channel );
break;
case CHANNEL_PROCESSING_STOPPED:
case NOTIFICATION_PROCESSING_STOP:
if( channel.getChannelType() == ChannelType.TRAFFIC )
{
// mChannels.remove( channel );
mVisibleChannels.remove( channel );
}
break;
case NOTIFICATION_CONFIGURATION_CHANGE:
if( mVisibleChannels.contains( channel ) &&
!channel.isWithin( getMinFrequency(), getMaxFrequency() ) )
{
mVisibleChannels.remove( channel );
}
if( !mVisibleChannels.contains( channel ) &&
channel.isWithin( getMinFrequency(), getMaxFrequency() ) )
{
mVisibleChannels.add( channel );
}
break;
default:
break;
}
repaint();

View File

@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014,2015 Dennis Sheirer
* Copyright (C) 2014-2016 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import javax.swing.JCheckBoxMenuItem;
@@ -54,7 +53,6 @@ import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import properties.SystemProperties;
import sample.Listener;
import sample.SampleType;
@@ -62,12 +60,10 @@ import sample.complex.ComplexBuffer;
import settings.ColorSetting.ColorSettingName;
import settings.ColorSettingMenuItem;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
import source.tuner.TunerSelectionListener;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.FrequencyChangeListener;
import source.tuner.frequency.IFrequencyChangeProcessor;
import spectrum.OverlayPanel.ChannelDisplay;
import spectrum.converter.ComplexDecibelConverter;
import spectrum.converter.DFTResultsConverter;
@@ -80,18 +76,17 @@ import spectrum.menu.SmoothingTypeItem;
import com.jidesoft.swing.JideSplitPane;
import controller.ConfigurationControllerModel;
import controller.channel.Channel;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
import controller.channel.ChannelUtils;
import dsp.filter.Window.WindowType;
import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
public class SpectralDisplayPanel extends JPanel
implements Listener<ComplexBuffer>,
FrequencyChangeListener,
IDFTWidthChangeProcessor,
TunerSelectionListener
IFrequencyChangeProcessor,
IDFTWidthChangeProcessor
{
private static final long serialVersionUID = 1L;
@@ -103,7 +98,6 @@ public class SpectralDisplayPanel extends JPanel
public static final String FFT_SIZE_PROPERTY = "spectral.display.dft.size";
public static final int NO_ZOOM = 0;
public static final int MAX_ZOOM = 6;
private DFTSize mDFTSize = DFTSize.FFT04096;
private int mZoom = 0;
@@ -116,9 +110,9 @@ public class SpectralDisplayPanel extends JPanel
private OverlayPanel mOverlayPanel;
private DFTProcessor mDFTProcessor;
private DFTResultsConverter mDFTConverter;
private PlaylistManager mPlaylistManager;
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SettingsManager mSettingsManager;
private ConfigurationControllerModel mController;
private Tuner mTuner;
/**
@@ -133,25 +127,18 @@ public class SpectralDisplayPanel extends JPanel
* the DFT is translated to decibels for display in the spectrum and
* waterfall components.
*/
public SpectralDisplayPanel( ChannelManager channelManager,
ConfigurationControllerModel controller,
PlaylistManager playlistManager,
public SpectralDisplayPanel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager )
{
mController = controller;
mPlaylistManager = playlistManager;
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSettingsManager = settingsManager;
mSpectrumPanel = new SpectrumPanel( mSettingsManager );
mOverlayPanel = new OverlayPanel( mSettingsManager, channelManager );
mOverlayPanel = new OverlayPanel( mSettingsManager, mChannelModel );
mWaterfallPanel = new WaterfallPanel( mSettingsManager );
//Register to receive tuner selection events
if( mController != null )
{
mController.addListener( (TunerSelectionListener)this );
}
init();
loadSettings();
@@ -163,9 +150,9 @@ public class SpectralDisplayPanel extends JPanel
String rawSize = properties.get( FFT_SIZE_PROPERTY, DFTSize.FFT04096.name() );
DFTSize size = null;
if( rawSize != null )
DFTSize size = null;
if( rawSize != null )
{
try
{
@@ -173,16 +160,16 @@ public class SpectralDisplayPanel extends JPanel
}
catch( Exception e )
{
//Do nothing, we couldn't parse the stored value
//Do nothing
}
}
if( size == null )
{
size = DFTSize.FFT04096;
}
setDFTSize( size );
if( size == null )
{
size = DFTSize.FFT04096;
}
setDFTSize( size );
}
public void dispose()
@@ -190,13 +177,6 @@ public class SpectralDisplayPanel extends JPanel
/* De-register from receiving samples when the window closes */
clearTuner();
if( mController != null )
{
mController.removeListener( (TunerSelectionListener)this );
}
mController = null;
mPlaylistManager = null;
mSettingsManager = null;
mDFTProcessor.dispose();
@@ -229,8 +209,8 @@ public class SpectralDisplayPanel extends JPanel
mDFTSize = size;
SystemProperties properties = SystemProperties.getInstance();
properties.set( FFT_SIZE_PROPERTY, size.name() );
properties.save();
setZoom( 0, 0, 0 );
}
@@ -427,7 +407,6 @@ public class SpectralDisplayPanel extends JPanel
/**
* Receives frequency change events -- primarily from tuner components.
*/
@Override
public void frequencyChanged( FrequencyChangeEvent event )
{
mOverlayPanel.frequencyChanged( event );
@@ -444,11 +423,10 @@ public class SpectralDisplayPanel extends JPanel
}
/**
* Responds to tuner selection event by deregistering from the current
* Responds to tuner event by deregistering from the current
* complex sample buffer source and registering with the tuner argument.
*/
@Override
public void tunerSelected( Tuner tuner )
public void showTuner( Tuner tuner )
{
clearTuner();
@@ -459,7 +437,7 @@ public class SpectralDisplayPanel extends JPanel
if( mTuner != null )
{
//Register to receive frequency change events
mTuner.addListener( (FrequencyChangeListener)this );
mTuner.getTunerController().addListener( this );
//Register the dft processor to receive samples from the tuner
mTuner.addListener( (Listener<ComplexBuffer>)mDFTProcessor );
@@ -468,19 +446,13 @@ public class SpectralDisplayPanel extends JPanel
//Fire frequency and sample rate change events so that the spectrum
//and overlay panels can synchronize
try
{
frequencyChanged( new FrequencyChangeEvent(
Event.FREQUENCY_CHANGE_NOTIFICATION, mTuner.getFrequency() ) );
frequencyChanged( new FrequencyChangeEvent(
Event.SAMPLE_RATE_CHANGE_NOTIFICATION, mTuner.getSampleRate() ) );
}
catch ( SourceException e )
{
mLog.info( "DFTProcessor - exception during new tuner setup - "
+ "couldn't get frequency from the tuner", e );
}
frequencyChanged( new FrequencyChangeEvent(
Event.NOTIFICATION_FREQUENCY_CHANGE,
mTuner.getTunerController().getFrequency() ) );
frequencyChanged( new FrequencyChangeEvent(
Event.NOTIFICATION_SAMPLE_RATE_CHANGE,
mTuner.getTunerController().getSampleRate() ) );
}
}
@@ -492,7 +464,7 @@ public class SpectralDisplayPanel extends JPanel
if( mTuner != null )
{
//Deregister for frequency change events from the tuner
mTuner.removeListener( (FrequencyChangeListener)this );
mTuner.getTunerController().removeListener( this );
//Deregister the dft processor from receiving samples
mTuner.removeListener( (Listener<ComplexBuffer>)mDFTProcessor );
@@ -653,8 +625,9 @@ public class SpectralDisplayPanel extends JPanel
for( Channel channel: channels )
{
JMenu channelMenu = ChannelUtils.getContextMenu(
mPlaylistManager, channel, SpectralDisplayPanel.this );
JMenu channelMenu = ChannelUtils.getContextMenu( mChannelModel,
mChannelProcessingManager, channel,
SpectralDisplayPanel.this );
if( channelMenu != null )
{
@@ -676,10 +649,7 @@ public class SpectralDisplayPanel extends JPanel
for( DecoderType type: DecoderType.getPrimaryDecoders() )
{
decoderMenu.add( new DecoderItem( mController,
frequency,
type ) );
decoderMenu.add( new DecoderItem( type, frequency ) );
}
frequencyMenu.add( decoderMenu );
@@ -958,17 +928,14 @@ public class SpectralDisplayPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private ConfigurationControllerModel mController;
private ChannelModel mChannelModel;
private long mFrequency;
private DecoderType mDecoder;
public DecoderItem( ConfigurationControllerModel controller,
long frequency,
DecoderType type )
public DecoderItem( DecoderType type, long frequency )
{
super( type.getDisplayString() );
mController = controller;
mFrequency = frequency;
mDecoder = type;
@@ -977,7 +944,7 @@ public class SpectralDisplayPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
mController.createChannel( mFrequency, mDecoder );
mChannelModel.createChannel( mDecoder, mFrequency );
}
} );
}

View File

@@ -23,24 +23,20 @@ import java.awt.event.WindowListener;
import javax.swing.JFrame;
import playlist.PlaylistManager;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
import source.tuner.Tuner;
import controller.ConfigurationControllerModel;
import controller.ResourceManager;
import controller.channel.ChannelManager;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
public class SpectrumFrame extends JFrame implements WindowListener
{
private static final long serialVersionUID = 1L;
private ResourceManager mResourceManager;
private SpectralDisplayPanel mSpectralDisplayPanel;
public SpectrumFrame( ChannelManager channelManager,
ConfigurationControllerModel controller,
PlaylistManager playlistManager,
public SpectrumFrame( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager,
Tuner tuner )
{
@@ -50,10 +46,10 @@ public class SpectrumFrame extends JFrame implements WindowListener
setLayout( new MigLayout( "insets 0 0 0 0", "[grow]", "[grow]") );
mSpectralDisplayPanel = new SpectralDisplayPanel( channelManager,
controller, playlistManager, settingsManager );
mSpectralDisplayPanel.tunerSelected( tuner );
mSpectralDisplayPanel = new SpectralDisplayPanel( channelModel,
channelProcessingManager, settingsManager );
mSpectralDisplayPanel.showTuner( tuner );
add( mSpectralDisplayPanel, "grow" );
/* Register a shutdown listener */

View File

@@ -17,8 +17,6 @@
******************************************************************************/
package spectrum.converter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Converts complex DFT output to scaled dB values with a maximum amplitude of
@@ -61,9 +59,6 @@ import org.slf4j.LoggerFactory;
*/
public class ComplexDecibelConverter extends DFTResultsConverter
{
private final static Logger mLog =
LoggerFactory.getLogger( ComplexDecibelConverter.class );
/**
* Converts the output of the JTransforms FloatFFT_1D.complexForward()
* calculation into the power spectrum in decibels, normalized to the