2014-10-27 21:22:29 -04:00
# include "AppFrame.h"
# include "wx/wxprec.h"
# ifndef WX_PRECOMP
# include "wx/wx.h"
# endif
2015-01-06 00:57:57 -05:00
# include "wx/numdlg.h"
2015-01-08 23:57:58 -05:00
# include "wx/filedlg.h"
2015-01-06 00:57:57 -05:00
2014-10-27 21:22:29 -04:00
# if !wxUSE_GLCANVAS
# error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
# endif
2014-10-28 21:39:59 -04:00
# include <vector>
2014-11-16 16:51:45 -05:00
# include "AudioThread.h"
2014-11-16 19:02:40 -05:00
# include "CubicSDR.h"
2015-01-09 17:17:56 -05:00
# include "DataTree.h"
2015-01-14 22:14:57 -05:00
# include "ColorTheme.h"
2015-10-20 23:00:10 -04:00
# include "DemodulatorMgr.h"
2014-10-27 21:22:29 -04:00
2014-11-21 21:50:14 -05:00
# include <thread>
2014-12-27 23:47:56 -05:00
# include <wx/panel.h>
2015-03-08 17:31:43 -04:00
# ifdef __linux__
# include "CubicSDR.xpm"
# endif
2014-10-28 21:39:59 -04:00
wxBEGIN_EVENT_TABLE ( AppFrame , wxFrame )
//EVT_MENU(wxID_NEW, AppFrame::OnNewWindow)
2015-07-15 00:32:36 -04:00
EVT_CLOSE ( AppFrame : : OnClose )
2014-12-31 21:31:37 -05:00
EVT_MENU ( wxID_ANY , AppFrame : : OnMenu )
2014-11-17 18:14:37 -05:00
EVT_COMMAND ( wxID_ANY , wxEVT_THREAD , AppFrame : : OnThread )
2014-10-28 21:39:59 -04:00
EVT_IDLE ( AppFrame : : OnIdle )
2015-10-25 14:09:59 -04:00
EVT_SPLITTER_DCLICK ( wxID_ANY , AppFrame : : OnDoubleClickSash )
EVT_SPLITTER_UNSPLIT ( wxID_ANY , AppFrame : : OnUnSplit )
2014-10-27 21:22:29 -04:00
wxEND_EVENT_TABLE ( )
2016-01-03 19:00:26 -05:00
# ifdef USE_HAMLIB
# include "RigThread.h"
# endif
2015-10-25 14:09:59 -04:00
2014-10-27 21:22:29 -04:00
AppFrame : : AppFrame ( ) :
2015-08-12 19:39:11 -04:00
wxFrame ( NULL , wxID_ANY , CUBICSDR_TITLE ) , activeDemodulator ( NULL ) {
2014-10-27 21:22:29 -04:00
2015-03-08 20:17:19 -04:00
# ifdef __linux__
SetIcon ( wxICON ( cubicsdr ) ) ;
# endif
2014-11-15 23:41:41 -05:00
wxBoxSizer * vbox = new wxBoxSizer ( wxVERTICAL ) ;
2014-12-28 20:55:05 -05:00
wxBoxSizer * demodVisuals = new wxBoxSizer ( wxVERTICAL ) ;
2015-10-27 01:56:49 -04:00
demodTray = new wxBoxSizer ( wxHORIZONTAL ) ;
2015-01-04 17:11:20 -05:00
wxBoxSizer * demodScopeTray = new wxBoxSizer ( wxVERTICAL ) ;
2016-02-15 17:43:10 -05:00
wxBoxSizer * demodTunerTray = new wxBoxSizer ( wxHORIZONTAL ) ;
2014-12-27 23:47:56 -05:00
2016-04-07 20:00:59 -04:00
int attribList [ ] = { WX_GL_RGBA , WX_GL_DOUBLEBUFFER , 0 } ;
//wxGLAttributes attribList;
//attribList.PlatformDefaults().RGBA().DoubleBuffer().EndList();
//attribList.PlatformDefaults().MinRGBA(8, 8, 8, 8).DoubleBuffer().Depth(16).EndList();
2015-02-09 20:49:21 -05:00
2015-10-25 14:09:59 -04:00
mainSplitter = new wxSplitterWindow ( this , wxID_MAIN_SPLITTER , wxDefaultPosition , wxDefaultSize , wxSP_3DSASH | wxSP_LIVE_UPDATE ) ;
2016-01-13 23:07:21 -05:00
mainSplitter - > SetSashGravity ( 10.0 / 37.0 ) ;
2015-10-25 14:09:59 -04:00
mainSplitter - > SetMinimumPaneSize ( 1 ) ;
wxPanel * demodPanel = new wxPanel ( mainSplitter , wxID_ANY ) ;
2015-10-27 01:56:49 -04:00
gainCanvas = new GainCanvas ( demodPanel , attribList ) ;
gainSizerItem = demodTray - > Add ( gainCanvas , 0 , wxEXPAND | wxALL , 0 ) ;
gainSizerItem - > Show ( false ) ;
gainSpacerItem = demodTray - > AddSpacer ( 1 ) ;
gainSpacerItem - > Show ( false ) ;
2015-10-25 14:09:59 -04:00
demodModeSelector = new ModeSelectorCanvas ( demodPanel , attribList ) ;
2015-11-30 21:58:54 -05:00
demodModeSelector - > addChoice ( " FM " ) ;
demodModeSelector - > addChoice ( " FMS " ) ;
2016-05-11 23:05:56 -04:00
demodModeSelector - > addChoice ( " NBFM " ) ;
2015-11-30 21:58:54 -05:00
demodModeSelector - > addChoice ( " AM " ) ;
demodModeSelector - > addChoice ( " LSB " ) ;
demodModeSelector - > addChoice ( " USB " ) ;
demodModeSelector - > addChoice ( " DSB " ) ;
demodModeSelector - > addChoice ( " I/Q " ) ;
2015-11-17 18:57:42 -05:00
demodModeSelector - > setSelection ( " FM " ) ;
2016-02-08 23:52:40 -05:00
demodModeSelector - > setHelpTip ( " Choose modulation type: Frequency Modulation (Hotkey F), Amplitude Modulation (A) and Lower (L), Upper (U), Double Side-Band and more. " ) ;
2016-06-23 22:13:03 -04:00
demodModeSelector - > SetMinSize ( wxSize ( 50 , - 1 ) ) ;
demodModeSelector - > SetMaxSize ( wxSize ( 50 , - 1 ) ) ;
2015-01-05 19:12:16 -05:00
demodTray - > Add ( demodModeSelector , 2 , wxEXPAND | wxALL , 0 ) ;
2015-05-29 07:45:15 -04:00
2015-11-15 13:52:54 -05:00
# ifdef ENABLE_DIGITAL_LAB
2015-11-23 21:32:50 -05:00
demodModeSelectorAdv = new ModeSelectorCanvas ( demodPanel , attribList ) ;
2015-11-30 21:58:54 -05:00
demodModeSelectorAdv - > addChoice ( " ASK " ) ;
demodModeSelectorAdv - > addChoice ( " APSK " ) ;
demodModeSelectorAdv - > addChoice ( " BPSK " ) ;
demodModeSelectorAdv - > addChoice ( " DPSK " ) ;
demodModeSelectorAdv - > addChoice ( " PSK " ) ;
demodModeSelectorAdv - > addChoice ( " FSK " ) ;
demodModeSelectorAdv - > addChoice ( " GMSK " ) ;
demodModeSelectorAdv - > addChoice ( " OOK " ) ;
demodModeSelectorAdv - > addChoice ( " ST " ) ;
demodModeSelectorAdv - > addChoice ( " SQAM " ) ;
demodModeSelectorAdv - > addChoice ( " QAM " ) ;
demodModeSelectorAdv - > addChoice ( " QPSK " ) ;
2015-06-09 11:00:05 -04:00
demodModeSelectorAdv - > setHelpTip ( " Choose advanced modulation types. " ) ;
2016-06-24 14:44:35 -04:00
demodModeSelectorAdv - > SetMinSize ( wxSize ( 50 , - 1 ) ) ;
demodModeSelectorAdv - > SetMaxSize ( wxSize ( 50 , - 1 ) ) ;
2015-06-09 11:00:05 -04:00
demodTray - > Add ( demodModeSelectorAdv , 3 , wxEXPAND | wxALL , 0 ) ;
2015-11-24 23:32:40 -05:00
# endif
2015-11-23 21:32:50 -05:00
2015-11-23 22:03:14 -05:00
modemPropertiesUpdated . store ( false ) ;
2015-11-23 21:32:50 -05:00
modemProps = new ModemProperties ( demodPanel , wxID_ANY ) ;
2015-11-28 23:03:07 -05:00
modemProps - > SetMinSize ( wxSize ( 200 , - 1 ) ) ;
modemProps - > SetMaxSize ( wxSize ( 200 , - 1 ) ) ;
2015-11-24 23:00:43 -05:00
modemProps - > Hide ( ) ;
2015-11-23 22:03:14 -05:00
demodTray - > Add ( modemProps , 15 , wxEXPAND | wxALL , 0 ) ;
2015-11-15 13:52:54 -05:00
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > setup ( 1024 ) ;
2015-10-25 14:09:59 -04:00
demodSpectrumCanvas = new SpectrumCanvas ( demodPanel , attribList ) ;
2015-07-21 00:04:04 -04:00
demodSpectrumCanvas - > setView ( wxGetApp ( ) . getConfig ( ) - > getCenterFreq ( ) , 300000 ) ;
2015-01-06 19:15:27 -05:00
demodVisuals - > Add ( demodSpectrumCanvas , 3 , wxEXPAND | wxALL , 0 ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > attachOutput ( demodSpectrumCanvas - > getVisualDataQueue ( ) ) ;
2014-12-29 00:24:10 -05:00
demodVisuals - > AddSpacer ( 1 ) ;
2014-12-28 20:55:05 -05:00
2015-10-25 14:09:59 -04:00
demodWaterfallCanvas = new WaterfallCanvas ( demodPanel , attribList ) ;
2015-01-06 19:15:27 -05:00
demodWaterfallCanvas - > setup ( 1024 , 128 ) ;
2015-07-21 00:04:04 -04:00
demodWaterfallCanvas - > setView ( wxGetApp ( ) . getConfig ( ) - > getCenterFreq ( ) , 300000 ) ;
2014-12-29 00:24:10 -05:00
demodWaterfallCanvas - > attachSpectrumCanvas ( demodSpectrumCanvas ) ;
2015-12-01 00:59:11 -05:00
demodWaterfallCanvas - > setMinBandwidth ( 8000 ) ;
2015-01-01 21:10:54 -05:00
demodSpectrumCanvas - > attachWaterfallCanvas ( demodWaterfallCanvas ) ;
2015-01-06 19:15:27 -05:00
demodVisuals - > Add ( demodWaterfallCanvas , 6 , wxEXPAND | wxALL , 0 ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > attachOutput ( demodWaterfallCanvas - > getVisualDataQueue ( ) ) ;
2015-09-11 00:42:09 -04:00
demodWaterfallCanvas - > getVisualDataQueue ( ) - > set_max_num_items ( 3 ) ;
2014-12-28 20:55:05 -05:00
2015-11-28 23:03:07 -05:00
demodVisuals - > SetMinSize ( wxSize ( 128 , - 1 ) ) ;
2014-12-31 19:45:01 -05:00
demodTray - > Add ( demodVisuals , 30 , wxEXPAND | wxALL , 0 ) ;
2015-01-14 22:14:57 -05:00
demodTray - > AddSpacer ( 1 ) ;
2014-12-31 19:45:01 -05:00
2015-10-25 14:09:59 -04:00
demodSignalMeter = new MeterCanvas ( demodPanel , attribList ) ;
2015-11-21 15:12:20 -05:00
demodSignalMeter - > setMax ( DEMOD_SIGNAL_MAX ) ;
demodSignalMeter - > setMin ( DEMOD_SIGNAL_MIN ) ;
demodSignalMeter - > setLevel ( DEMOD_SIGNAL_MIN ) ;
demodSignalMeter - > setInputValue ( DEMOD_SIGNAL_MIN ) ;
2016-02-25 03:48:05 -05:00
demodSignalMeter - > setHelpTip ( " Current Signal Level. Click / Drag to set Squelch level. Right-Click to Auto-Zero Squelch " ) ;
2015-10-30 19:46:29 -04:00
demodSignalMeter - > SetMinSize ( wxSize ( 12 , 24 ) ) ;
2014-12-31 19:45:01 -05:00
demodTray - > Add ( demodSignalMeter , 1 , wxEXPAND | wxALL , 0 ) ;
2014-12-28 20:55:05 -05:00
2015-10-30 19:46:29 -04:00
2015-01-14 22:14:57 -05:00
demodTray - > AddSpacer ( 1 ) ;
2014-12-28 05:13:46 -05:00
2015-10-25 14:09:59 -04:00
scopeCanvas = new ScopeCanvas ( demodPanel , attribList ) ;
2015-08-24 01:31:37 -04:00
scopeCanvas - > setHelpTip ( " Audio Visuals, drag left/right to toggle Scope or Spectrum. " ) ;
2015-11-28 23:03:07 -05:00
scopeCanvas - > SetMinSize ( wxSize ( 128 , - 1 ) ) ;
2015-01-04 17:11:20 -05:00
demodScopeTray - > Add ( scopeCanvas , 8 , wxEXPAND | wxALL , 0 ) ;
2015-12-08 22:17:00 -05:00
wxGetApp ( ) . getScopeProcessor ( ) - > setup ( 1024 ) ;
2015-08-01 11:03:00 -04:00
wxGetApp ( ) . getScopeProcessor ( ) - > attachOutput ( scopeCanvas - > getInputQueue ( ) ) ;
2015-01-04 17:11:20 -05:00
2015-01-14 22:14:57 -05:00
demodScopeTray - > AddSpacer ( 1 ) ;
2015-01-04 17:11:20 -05:00
2016-02-15 17:43:10 -05:00
deltaLockButton = new ModeSelectorCanvas ( demodPanel , attribList ) ;
deltaLockButton - > addChoice ( 1 , " V " ) ;
deltaLockButton - > setPadding ( - 1 , - 1 ) ;
2016-06-01 19:42:34 -04:00
deltaLockButton - > setHighlightColor ( RGBA4f ( 0.8f , 0.8f , 0.2f ) ) ;
2016-02-15 17:43:10 -05:00
deltaLockButton - > setHelpTip ( " Delta Lock Toggle (V) - Enable to lock modem relative to center frequency. " ) ;
deltaLockButton - > setToggleMode ( true ) ;
deltaLockButton - > setSelection ( - 1 ) ;
deltaLockButton - > SetMinSize ( wxSize ( 20 , 28 ) ) ;
demodTunerTray - > Add ( deltaLockButton , 0 , wxEXPAND | wxALL , 0 ) ;
demodTunerTray - > AddSpacer ( 1 ) ;
2015-10-25 14:09:59 -04:00
demodTuner = new TuningCanvas ( demodPanel , attribList ) ;
2016-01-13 23:07:21 -05:00
demodTuner - > SetMinClientSize ( wxSize ( 200 , 28 ) ) ;
2016-02-15 17:43:10 -05:00
demodTunerTray - > Add ( demodTuner , 1 , wxEXPAND | wxALL , 0 ) ;
demodScopeTray - > Add ( demodTunerTray , 1 , wxEXPAND | wxALL , 0 ) ;
2015-01-04 17:11:20 -05:00
demodTray - > Add ( demodScopeTray , 30 , wxEXPAND | wxALL , 0 ) ;
2014-12-27 23:47:56 -05:00
2015-01-14 22:14:57 -05:00
demodTray - > AddSpacer ( 1 ) ;
2015-01-10 20:33:30 -05:00
2015-08-17 00:59:38 -04:00
wxBoxSizer * demodGainTray = new wxBoxSizer ( wxVERTICAL ) ;
2015-10-25 14:09:59 -04:00
demodGainMeter = new MeterCanvas ( demodPanel , attribList ) ;
2015-01-10 20:33:30 -05:00
demodGainMeter - > setMax ( 2.0 ) ;
demodGainMeter - > setHelpTip ( " Current Demodulator Gain Level. Click / Drag to set Gain level. " ) ;
2015-08-12 20:05:57 -04:00
demodGainMeter - > setShowUserInput ( false ) ;
2016-06-11 22:17:38 -04:00
demodGainMeter - > SetMinSize ( wxSize ( 13 , 24 ) ) ;
2015-08-17 00:59:38 -04:00
demodGainTray - > Add ( demodGainMeter , 8 , wxEXPAND | wxALL , 0 ) ;
2016-02-11 01:09:15 -05:00
demodGainTray - > AddSpacer ( 1 ) ;
soloModeButton = new ModeSelectorCanvas ( demodPanel , attribList ) ;
soloModeButton - > addChoice ( 1 , " S " ) ;
soloModeButton - > setPadding ( - 1 , - 1 ) ;
2016-06-01 19:42:34 -04:00
soloModeButton - > setHighlightColor ( RGBA4f ( 0.8f , 0.8f , 0.2f ) ) ;
2016-02-11 01:09:15 -05:00
soloModeButton - > setHelpTip ( " Solo Mode Toggle " ) ;
soloModeButton - > setToggleMode ( true ) ;
soloModeButton - > setSelection ( - 1 ) ;
soloModeButton - > SetMinSize ( wxSize ( 12 , 28 ) ) ;
demodGainTray - > Add ( soloModeButton , 1 , wxEXPAND | wxALL , 0 ) ;
2015-10-30 19:46:29 -04:00
2015-08-17 00:59:38 -04:00
demodGainTray - > AddSpacer ( 1 ) ;
2015-10-25 14:09:59 -04:00
demodMuteButton = new ModeSelectorCanvas ( demodPanel , attribList ) ;
2015-08-17 00:59:38 -04:00
demodMuteButton - > addChoice ( 1 , " M " ) ;
2015-08-19 17:06:06 -04:00
demodMuteButton - > setPadding ( - 1 , - 1 ) ;
2016-06-01 19:42:34 -04:00
demodMuteButton - > setHighlightColor ( RGBA4f ( 0.8f , 0.2f , 0.2f ) ) ;
2015-08-17 00:59:38 -04:00
demodMuteButton - > setHelpTip ( " Demodulator Mute Toggle " ) ;
demodMuteButton - > setToggleMode ( true ) ;
2015-08-31 20:26:17 -04:00
demodMuteButton - > setSelection ( - 1 ) ;
2016-02-11 01:09:15 -05:00
demodMuteButton - > SetMinSize ( wxSize ( 12 , 28 ) ) ;
2015-10-30 19:46:29 -04:00
2015-08-17 00:59:38 -04:00
demodGainTray - > Add ( demodMuteButton , 1 , wxEXPAND | wxALL , 0 ) ;
2015-01-10 20:33:30 -05:00
2015-08-17 00:59:38 -04:00
demodTray - > Add ( demodGainTray , 1 , wxEXPAND | wxALL , 0 ) ;
2015-10-25 14:09:59 -04:00
demodPanel - > SetSizer ( demodTray ) ;
// vbox->Add(demodTray, 12, wxEXPAND | wxALL, 0);
// vbox->AddSpacer(1);
2015-08-17 00:59:38 -04:00
2015-10-25 14:09:59 -04:00
mainVisSplitter = new wxSplitterWindow ( mainSplitter , wxID_VIS_SPLITTER , wxDefaultPosition , wxDefaultSize , wxSP_3DSASH | wxSP_LIVE_UPDATE ) ;
2016-01-13 23:07:21 -05:00
mainVisSplitter - > SetSashGravity ( 6.0 / 25.0 ) ;
2015-10-25 14:09:59 -04:00
mainVisSplitter - > SetMinimumPaneSize ( 1 ) ;
// mainVisSplitter->Connect( wxEVT_IDLE, wxIdleEventHandler( AppFrame::mainVisSplitterIdle ), NULL, this );
2015-08-03 01:38:38 -04:00
2015-10-25 14:09:59 -04:00
wxPanel * spectrumPanel = new wxPanel ( mainVisSplitter , wxID_ANY ) ;
2015-08-11 23:52:03 -04:00
wxBoxSizer * spectrumSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2015-10-25 14:09:59 -04:00
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getSpectrumProcessor ( ) - > setup ( 2048 ) ;
2015-10-25 14:09:59 -04:00
spectrumCanvas = new SpectrumCanvas ( spectrumPanel , attribList ) ;
2015-08-17 21:52:38 -04:00
spectrumCanvas - > setShowDb ( true ) ;
2015-10-25 14:09:59 -04:00
spectrumCanvas - > setScaleFactorEnabled ( true ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getSpectrumProcessor ( ) - > attachOutput ( spectrumCanvas - > getVisualDataQueue ( ) ) ;
2015-12-31 20:44:39 -05:00
wxBoxSizer * spectrumCtlTray = new wxBoxSizer ( wxVERTICAL ) ;
2015-08-11 23:52:03 -04:00
2015-12-31 20:44:39 -05:00
peakHoldButton = new ModeSelectorCanvas ( spectrumPanel , attribList ) ;
peakHoldButton - > addChoice ( 1 , " P " ) ;
peakHoldButton - > setPadding ( - 1 , - 1 ) ;
2016-06-01 19:42:34 -04:00
peakHoldButton - > setHighlightColor ( RGBA4f ( 0.2f , 0.8f , 0.2f ) ) ;
2015-12-31 20:44:39 -05:00
peakHoldButton - > setHelpTip ( " Peak Hold Toggle " ) ;
peakHoldButton - > setToggleMode ( true ) ;
peakHoldButton - > setSelection ( - 1 ) ;
peakHoldButton - > SetMinSize ( wxSize ( 12 , 24 ) ) ;
spectrumCtlTray - > Add ( peakHoldButton , 1 , wxEXPAND | wxALL , 0 ) ;
spectrumCtlTray - > AddSpacer ( 1 ) ;
2015-10-25 14:09:59 -04:00
spectrumAvgMeter = new MeterCanvas ( spectrumPanel , attribList ) ;
2015-08-13 20:39:31 -04:00
spectrumAvgMeter - > setHelpTip ( " Spectrum averaging speed, click or drag to adjust. " ) ;
2015-08-12 22:14:14 -04:00
spectrumAvgMeter - > setMax ( 1.0 ) ;
2016-06-01 19:42:34 -04:00
spectrumAvgMeter - > setLevel ( 0.65f ) ;
2015-08-12 20:05:57 -04:00
spectrumAvgMeter - > setShowUserInput ( false ) ;
2015-10-30 19:46:29 -04:00
spectrumAvgMeter - > SetMinSize ( wxSize ( 12 , 24 ) ) ;
2015-12-31 20:44:39 -05:00
spectrumCtlTray - > Add ( spectrumAvgMeter , 8 , wxEXPAND | wxALL , 0 ) ;
2015-08-12 20:05:57 -04:00
2015-08-11 23:52:03 -04:00
spectrumSizer - > Add ( spectrumCanvas , 63 , wxEXPAND | wxALL , 0 ) ;
spectrumSizer - > AddSpacer ( 1 ) ;
2015-12-31 20:44:39 -05:00
spectrumSizer - > Add ( spectrumCtlTray , 1 , wxEXPAND | wxALL , 0 ) ;
2015-10-25 14:09:59 -04:00
spectrumPanel - > SetSizer ( spectrumSizer ) ;
2015-08-11 23:52:03 -04:00
2015-10-25 14:09:59 -04:00
// vbox->Add(spectrumSizer, 5, wxEXPAND | wxALL, 0);
2015-08-03 01:38:38 -04:00
2015-10-25 14:09:59 -04:00
// vbox->AddSpacer(1);
2015-08-11 23:52:03 -04:00
2015-10-25 14:09:59 -04:00
wxPanel * waterfallPanel = new wxPanel ( mainVisSplitter , wxID_ANY ) ;
2015-08-11 23:52:03 -04:00
wxBoxSizer * wfSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2015-10-25 14:09:59 -04:00
waterfallCanvas = new WaterfallCanvas ( waterfallPanel , attribList ) ;
2015-01-03 17:07:39 -05:00
waterfallCanvas - > setup ( 2048 , 512 ) ;
2015-08-14 19:17:43 -04:00
waterfallDataThread = new FFTVisualDataThread ( ) ;
waterfallDataThread - > setInputQueue ( " IQDataInput " , wxGetApp ( ) . getWaterfallVisualQueue ( ) ) ;
waterfallDataThread - > setOutputQueue ( " FFTDataOutput " , waterfallCanvas - > getVisualDataQueue ( ) ) ;
2015-11-03 00:53:39 -05:00
waterfallDataThread - > getProcessor ( ) - > setHideDC ( true ) ;
2015-08-19 23:22:46 -04:00
t_FFTData = new std : : thread ( & FFTVisualDataThread : : threadMain , waterfallDataThread ) ;
2015-10-25 14:09:59 -04:00
waterfallSpeedMeter = new MeterCanvas ( waterfallPanel , attribList ) ;
2015-08-13 20:39:31 -04:00
waterfallSpeedMeter - > setHelpTip ( " Waterfall speed, click or drag to adjust (max 1024 lines per second) " ) ;
2015-08-11 23:52:03 -04:00
waterfallSpeedMeter - > setMax ( sqrt ( 1024 ) ) ;
2015-08-12 20:05:57 -04:00
waterfallSpeedMeter - > setLevel ( sqrt ( DEFAULT_WATERFALL_LPS ) ) ;
waterfallSpeedMeter - > setShowUserInput ( false ) ;
2015-10-30 19:46:29 -04:00
waterfallSpeedMeter - > SetMinSize ( wxSize ( 12 , 24 ) ) ;
2015-08-11 23:52:03 -04:00
wfSizer - > Add ( waterfallCanvas , 63 , wxEXPAND | wxALL , 0 ) ;
wfSizer - > AddSpacer ( 1 ) ;
wfSizer - > Add ( waterfallSpeedMeter , 1 , wxEXPAND | wxALL , 0 ) ;
2015-10-25 14:09:59 -04:00
waterfallPanel - > SetSizer ( wfSizer ) ;
2015-08-11 23:52:03 -04:00
2015-10-25 14:09:59 -04:00
// vbox->Add(wfSizer, 20, wxEXPAND | wxALL, 0);
2015-08-11 23:52:03 -04:00
2015-10-25 14:09:59 -04:00
mainVisSplitter - > SplitHorizontally ( spectrumPanel , waterfallPanel , 0 ) ;
mainSplitter - > SplitHorizontally ( demodPanel , mainVisSplitter ) ;
vbox - > Add ( mainSplitter , 1 , wxEXPAND | wxALL , 0 ) ;
2015-08-11 23:52:03 -04:00
// TODO: refactor these..
2014-12-29 00:24:10 -05:00
waterfallCanvas - > attachSpectrumCanvas ( spectrumCanvas ) ;
2015-01-01 21:10:54 -05:00
spectrumCanvas - > attachWaterfallCanvas ( waterfallCanvas ) ;
2015-08-11 23:52:03 -04:00
2015-07-29 18:34:58 -04:00
/*
2015-06-20 20:19:52 -04:00
vbox - > AddSpacer ( 1 ) ;
testCanvas = new UITestCanvas ( this , attribList ) ;
vbox - > Add ( testCanvas , 20 , wxEXPAND | wxALL , 0 ) ;
2015-07-29 18:34:58 -04:00
// */
2015-06-20 20:19:52 -04:00
2014-11-15 23:41:41 -05:00
this - > SetSizer ( vbox ) ;
2014-10-27 21:22:29 -04:00
2015-05-30 23:14:16 -04:00
// SetIcon(wxICON(sample));
2014-10-27 21:22:29 -04:00
2015-05-30 23:14:16 -04:00
// Make a menubar
2015-11-02 21:04:02 -05:00
menuBar = new wxMenuBar ;
2015-01-06 00:29:33 -05:00
wxMenu * menu = new wxMenu ;
2015-05-30 23:14:16 -04:00
2015-10-04 19:55:52 -04:00
menu - > Append ( wxID_SDR_DEVICES , " SDR Devices " ) ;
menu - > AppendSeparator ( ) ;
2016-02-28 23:16:56 -05:00
menu - > Append ( wxID_SDR_START_STOP , " Stop / Start Device " ) ;
menu - > AppendSeparator ( ) ;
2015-05-31 22:13:14 -04:00
menu - > Append ( wxID_OPEN , " &Open Session " ) ;
menu - > Append ( wxID_SAVE , " &Save Session " ) ;
menu - > Append ( wxID_SAVEAS , " Save Session &As.. " ) ;
menu - > AppendSeparator ( ) ;
menu - > Append ( wxID_RESET , " &Reset Session " ) ;
# ifndef __APPLE__
2016-02-28 22:44:17 -05:00
menu - > AppendSeparator ( ) ;
menu - > Append ( wxID_CLOSE ) ;
# else
if ( wxApp : : s_macAboutMenuItemId ! = wxID_NONE ) {
wxString aboutLabel ;
aboutLabel . Printf ( _ ( " About %s " ) , wxTheApp - > GetAppDisplayName ( ) ) ;
menu - > Append ( wxApp : : s_macAboutMenuItemId , aboutLabel ) ;
}
2015-05-31 22:13:14 -04:00
# endif
2016-02-28 22:44:17 -05:00
2015-05-31 22:13:14 -04:00
menuBar - > Append ( menu , wxT ( " &File " ) ) ;
2015-11-03 19:58:42 -05:00
settingsMenu = new wxMenu ;
menuBar - > Append ( settingsMenu , wxT ( " &Settings " ) ) ;
2015-05-31 22:13:14 -04:00
2015-01-06 00:29:33 -05:00
menu = new wxMenu ;
2014-12-31 19:45:01 -05:00
std : : vector < RtAudio : : DeviceInfo > : : iterator devices_i ;
2015-01-01 18:08:54 -05:00
std : : map < int , RtAudio : : DeviceInfo > : : iterator mdevices_i ;
2014-12-31 19:45:01 -05:00
AudioThread : : enumerateDevices ( devices ) ;
int i = 0 ;
for ( devices_i = devices . begin ( ) ; devices_i ! = devices . end ( ) ; devices_i + + ) {
if ( devices_i - > inputChannels ) {
2015-01-03 17:07:39 -05:00
inputDevices [ i ] = * devices_i ;
2014-12-31 19:45:01 -05:00
}
if ( devices_i - > outputChannels ) {
2015-01-03 17:07:39 -05:00
outputDevices [ i ] = * devices_i ;
2014-12-31 19:45:01 -05:00
}
i + + ;
}
2015-01-03 17:07:39 -05:00
for ( mdevices_i = outputDevices . begin ( ) ; mdevices_i ! = outputDevices . end ( ) ; mdevices_i + + ) {
2015-01-01 18:08:54 -05:00
wxMenuItem * itm = menu - > AppendRadioItem ( wxID_RT_AUDIO_DEVICE + mdevices_i - > first , mdevices_i - > second . name , wxT ( " Description? " ) ) ;
itm - > SetId ( wxID_RT_AUDIO_DEVICE + mdevices_i - > first ) ;
2014-12-31 19:45:01 -05:00
if ( mdevices_i - > second . isDefaultOutput ) {
itm - > Check ( true ) ;
}
2015-01-03 17:07:39 -05:00
outputDeviceMenuItems [ mdevices_i - > first ] = itm ;
2014-12-31 19:45:01 -05:00
}
2015-05-31 22:13:14 -04:00
menuBar - > Append ( menu , wxT ( " Audio &Output " ) ) ;
2015-01-01 03:48:32 -05:00
2015-01-11 03:09:59 -05:00
menu = new wxMenu ;
2015-07-15 00:32:36 -04:00
int themeId = wxGetApp ( ) . getConfig ( ) - > getTheme ( ) ;
menu - > AppendRadioItem ( wxID_THEME_DEFAULT , " Default " ) - > Check ( themeId = = COLOR_THEME_DEFAULT ) ;
menu - > AppendRadioItem ( wxID_THEME_RADAR , " RADAR " ) - > Check ( themeId = = COLOR_THEME_RADAR ) ;
menu - > AppendRadioItem ( wxID_THEME_BW , " Black & White " ) - > Check ( themeId = = COLOR_THEME_BW ) ;
menu - > AppendRadioItem ( wxID_THEME_SHARP , " Sharp " ) - > Check ( themeId = = COLOR_THEME_SHARP ) ;
menu - > AppendRadioItem ( wxID_THEME_RAD , " Rad " ) - > Check ( themeId = = COLOR_THEME_RAD ) ;
menu - > AppendRadioItem ( wxID_THEME_TOUCH , " Touch " ) - > Check ( themeId = = COLOR_THEME_TOUCH ) ;
menu - > AppendRadioItem ( wxID_THEME_HD , " HD " ) - > Check ( themeId = = COLOR_THEME_HD ) ;
2015-01-11 03:09:59 -05:00
menuBar - > Append ( menu , wxT ( " &Color Scheme " ) ) ;
2015-01-11 17:08:16 -05:00
menu = new wxMenu ;
2015-03-12 19:41:50 -04:00
2015-03-29 20:24:00 -04:00
# define NUM_RATES_DEFAULT 4
2016-01-28 15:49:31 -05:00
unsigned int desired_rates [ NUM_RATES_DEFAULT ] = { 48000 , 44100 , 96000 , 192000 } ;
2015-03-22 20:47:07 -04:00
for ( mdevices_i = outputDevices . begin ( ) ; mdevices_i ! = outputDevices . end ( ) ; mdevices_i + + ) {
2016-01-28 15:49:31 -05:00
unsigned int desired_rate = 0 ;
unsigned int desired_rank = NUM_RATES_DEFAULT + 1 ;
2015-03-29 20:24:00 -04:00
for ( std : : vector < unsigned int > : : iterator srate = mdevices_i - > second . sampleRates . begin ( ) ; srate ! = mdevices_i - > second . sampleRates . end ( ) ;
srate + + ) {
2016-01-28 15:49:31 -05:00
for ( unsigned int i = 0 ; i < NUM_RATES_DEFAULT ; i + + ) {
2015-03-29 20:24:00 -04:00
if ( desired_rates [ i ] = = ( * srate ) ) {
if ( desired_rank > i ) {
desired_rank = i ;
desired_rate = ( * srate ) ;
}
}
}
2015-03-22 20:47:07 -04:00
}
2015-03-29 20:24:00 -04:00
if ( desired_rank > NUM_RATES_DEFAULT ) {
desired_rate = mdevices_i - > second . sampleRates . back ( ) ;
}
2015-03-22 20:47:07 -04:00
AudioThread : : deviceSampleRate [ mdevices_i - > first ] = desired_rate ;
}
2015-03-12 19:41:50 -04:00
for ( mdevices_i = outputDevices . begin ( ) ; mdevices_i ! = outputDevices . end ( ) ; mdevices_i + + ) {
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i - > first ;
wxMenu * subMenu = new wxMenu ;
2015-03-29 20:24:00 -04:00
menu - > AppendSubMenu ( subMenu , mdevices_i - > second . name , wxT ( " Description? " ) ) ;
2015-03-12 19:41:50 -04:00
int j = 0 ;
2015-03-29 20:24:00 -04:00
for ( std : : vector < unsigned int > : : iterator srate = mdevices_i - > second . sampleRates . begin ( ) ; srate ! = mdevices_i - > second . sampleRates . end ( ) ;
srate + + ) {
2015-03-12 19:41:50 -04:00
std : : stringstream srateName ;
2015-03-29 20:24:00 -04:00
srateName < < ( ( float ) ( * srate ) / 1000.0f ) < < " kHz " ;
wxMenuItem * itm = subMenu - > AppendRadioItem ( menu_id + j , srateName . str ( ) , wxT ( " Description? " ) ) ;
2015-03-12 19:41:50 -04:00
2016-02-04 18:05:33 -05:00
if ( ( int ) ( * srate ) = = AudioThread : : deviceSampleRate [ mdevices_i - > first ] ) {
2015-03-12 19:41:50 -04:00
itm - > Check ( true ) ;
}
2015-03-29 20:24:00 -04:00
audioSampleRateMenuItems [ menu_id + j ] = itm ;
2015-03-12 19:41:50 -04:00
j + + ;
}
}
2015-11-02 21:04:02 -05:00
sampleRateMenu = new wxMenu ;
2015-12-07 21:02:47 -05:00
menuBar - > Append ( sampleRateMenu , wxT ( " Sample &Rate " ) ) ;
2015-11-02 21:04:02 -05:00
2015-12-07 21:02:47 -05:00
menuBar - > Append ( menu , wxT ( " Audio &Sample Rate " ) ) ;
2015-03-12 19:41:50 -04:00
2016-06-20 13:28:26 -04:00
//Add Display menu
2016-06-15 16:21:41 -04:00
displayMenu = new wxMenu ;
menuBar - > Append ( displayMenu , wxT ( " &Display " ) ) ;
2016-06-20 13:28:26 -04:00
int fontScale = wxGetApp ( ) . getConfig ( ) - > getFontScale ( ) ;
2016-06-23 22:07:37 -04:00
displayMenu - > AppendRadioItem ( wxID_DISPLAY_BASE , " Text Size: Normal " ) - > Check ( GLFont : : GLFONT_SCALE_NORMAL = = fontScale ) ;
displayMenu - > AppendRadioItem ( wxID_DISPLAY_BASE + 1 , " Text Size: 1.5x " ) - > Check ( GLFont : : GLFONT_SCALE_MEDIUM = = fontScale ) ;
displayMenu - > AppendRadioItem ( wxID_DISPLAY_BASE + 2 , " Text Size: 2.0x " ) - > Check ( GLFont : : GLFONT_SCALE_LARGE = = fontScale ) ;
2016-06-15 16:21:41 -04:00
2016-06-20 13:28:26 -04:00
GLFont : : setScale ( ( GLFont : : GLFontScale ) fontScale ) ;
2016-06-15 16:21:41 -04:00
2016-01-03 19:00:26 -05:00
# ifdef USE_HAMLIB
rigModel = wxGetApp ( ) . getConfig ( ) - > getRigModel ( ) ;
rigSerialRate = wxGetApp ( ) . getConfig ( ) - > getRigRate ( ) ;
rigPort = wxGetApp ( ) . getConfig ( ) - > getRigPort ( ) ;
2016-01-09 00:09:46 -05:00
2016-01-03 19:00:26 -05:00
rigMenu = new wxMenu ;
rigEnableMenuItem = rigMenu - > AppendCheckItem ( wxID_RIG_TOGGLE , wxT ( " Enable Rig " ) ) ;
2016-01-09 00:09:46 -05:00
rigMenu - > Append ( wxID_RIG_SDR_IF , wxT ( " SDR-IF " ) ) ;
2016-02-16 01:13:26 -05:00
rigControlMenuItem = rigMenu - > AppendCheckItem ( wxID_RIG_CONTROL , wxT ( " Control Rig " ) ) ;
rigControlMenuItem - > Check ( wxGetApp ( ) . getConfig ( ) - > getRigControlMode ( ) ) ;
2016-01-09 00:09:46 -05:00
2016-02-16 01:13:26 -05:00
rigFollowMenuItem = rigMenu - > AppendCheckItem ( wxID_RIG_FOLLOW , wxT ( " Follow Rig " ) ) ;
rigFollowMenuItem - > Check ( wxGetApp ( ) . getConfig ( ) - > getRigFollowMode ( ) ) ;
2016-02-29 23:14:23 -05:00
rigCenterLockMenuItem = rigMenu - > AppendCheckItem ( wxID_RIG_CENTERLOCK , wxT ( " Floating Center " ) ) ;
rigCenterLockMenuItem - > Check ( wxGetApp ( ) . getConfig ( ) - > getRigCenterLock ( ) ) ;
rigFollowModemMenuItem = rigMenu - > AppendCheckItem ( wxID_RIG_FOLLOW_MODEM , wxT ( " Track Modem " ) ) ;
rigFollowModemMenuItem - > Check ( wxGetApp ( ) . getConfig ( ) - > getRigFollowModem ( ) ) ;
2016-01-03 19:00:26 -05:00
wxMenu * rigModelMenu = new wxMenu ;
RigList & rl = RigThread : : enumerate ( ) ;
numRigs = rl . size ( ) ;
int modelMenuId = wxID_RIG_MODEL_BASE ;
for ( RigList : : const_iterator ri = rl . begin ( ) ; ri ! = rl . end ( ) ; ri + + ) {
std : : string modelString ( ( * ri ) - > mfg_name ) ;
modelString . append ( " " ) ;
modelString . append ( ( * ri ) - > model_name ) ;
rigModelMenuItems [ ( * ri ) - > rig_model ] = rigModelMenu - > AppendRadioItem ( modelMenuId , modelString , wxT ( " Description? " ) ) ;
if ( rigModel = = ( * ri ) - > rig_model ) {
2016-01-09 00:09:46 -05:00
rigModelMenuItems [ ( * ri ) - > rig_model ] - > Check ( true ) ;
2016-01-03 19:00:26 -05:00
}
modelMenuId + + ;
}
rigMenu - > AppendSubMenu ( rigModelMenu , wxT ( " Model " ) ) ;
wxMenu * rigSerialMenu = new wxMenu ;
rigSerialRates . push_back ( 1200 ) ;
rigSerialRates . push_back ( 2400 ) ;
rigSerialRates . push_back ( 4800 ) ;
rigSerialRates . push_back ( 9600 ) ;
rigSerialRates . push_back ( 19200 ) ;
rigSerialRates . push_back ( 38400 ) ;
rigSerialRates . push_back ( 57600 ) ;
rigSerialRates . push_back ( 115200 ) ;
rigSerialRates . push_back ( 128000 ) ;
rigSerialRates . push_back ( 256000 ) ;
int rateMenuId = wxID_RIG_SERIAL_BASE ;
for ( std : : vector < int > : : const_iterator rate_i = rigSerialRates . begin ( ) ; rate_i ! = rigSerialRates . end ( ) ; rate_i + + ) {
std : : string rateString ;
rateString . append ( std : : to_string ( ( * rate_i ) ) ) ;
rateString . append ( " baud " ) ;
rigSerialMenuItems [ ( * rate_i ) ] = rigSerialMenu - > AppendRadioItem ( rateMenuId , rateString , wxT ( " Description? " ) ) ;
if ( rigSerialRate = = ( * rate_i ) ) {
2016-01-09 00:09:46 -05:00
rigSerialMenuItems [ ( * rate_i ) ] - > Check ( true ) ;
2016-01-03 19:00:26 -05:00
}
rateMenuId + + ;
}
rigMenu - > AppendSubMenu ( rigSerialMenu , wxT ( " Serial Rate " ) ) ;
rigPortMenuItem = rigMenu - > Append ( wxID_RIG_PORT , wxT ( " Control Port " ) ) ;
menuBar - > Append ( rigMenu , wxT ( " &Rig Control " ) ) ;
# endif
2014-10-27 21:22:29 -04:00
SetMenuBar ( menuBar ) ;
CreateStatusBar ( ) ;
2015-07-15 00:32:36 -04:00
wxRect * win = wxGetApp ( ) . getConfig ( ) - > getWindow ( ) ;
if ( win ) {
this - > SetPosition ( win - > GetPosition ( ) ) ;
this - > SetClientSize ( win - > GetSize ( ) ) ;
} else {
SetClientSize ( 1280 , 600 ) ;
Centre ( ) ;
}
2015-07-16 18:57:03 -04:00
bool max = wxGetApp ( ) . getConfig ( ) - > getWindowMaximized ( ) ;
if ( max ) {
this - > Maximize ( ) ;
}
2015-07-18 21:49:53 -04:00
long long freqSnap = wxGetApp ( ) . getConfig ( ) - > getSnap ( ) ;
wxGetApp ( ) . setFrequencySnap ( freqSnap ) ;
2015-08-13 22:00:05 -04:00
float spectrumAvg = wxGetApp ( ) . getConfig ( ) - > getSpectrumAvgSpeed ( ) ;
spectrumAvgMeter - > setLevel ( spectrumAvg ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getSpectrumProcessor ( ) - > setFFTAverageRate ( spectrumAvg ) ;
2015-08-13 22:00:05 -04:00
int wflps = wxGetApp ( ) . getConfig ( ) - > getWaterfallLinesPerSec ( ) ;
waterfallSpeedMeter - > setLevel ( sqrt ( wflps ) ) ;
2015-08-14 19:17:43 -04:00
waterfallDataThread - > setLinesPerSecond ( wflps ) ;
2015-09-09 23:29:38 -04:00
waterfallCanvas - > setLinesPerSecond ( wflps ) ;
2015-07-15 00:32:36 -04:00
ThemeMgr : : mgr . setTheme ( wxGetApp ( ) . getConfig ( ) - > getTheme ( ) ) ;
2016-04-07 20:00:59 -04:00
2014-10-27 21:22:29 -04:00
Show ( ) ;
2015-03-08 17:31:43 -04:00
# ifdef _WIN32
2015-03-07 20:29:25 -05:00
SetIcon ( wxICON ( frame_icon ) ) ;
2015-03-08 17:31:43 -04:00
# endif
2014-11-25 00:35:06 -05:00
2015-01-10 12:27:03 -05:00
wxAcceleratorEntry entries [ 3 ] ;
entries [ 0 ] . Set ( wxACCEL_CTRL , ( int ) ' O ' , wxID_OPEN ) ;
entries [ 1 ] . Set ( wxACCEL_CTRL , ( int ) ' S ' , wxID_SAVE ) ;
entries [ 2 ] . Set ( wxACCEL_CTRL , ( int ) ' A ' , wxID_SAVEAS ) ;
wxAcceleratorTable accel ( 3 , entries ) ;
SetAcceleratorTable ( accel ) ;
2015-11-02 19:27:34 -05:00
deviceChanged . store ( false ) ;
devInfo = NULL ;
2015-10-05 19:59:17 -04:00
wxGetApp ( ) . deviceSelector ( ) ;
2014-10-27 21:22:29 -04:00
// static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
// wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
// ShowFullScreen(true);
2016-06-20 13:28:26 -04:00
//Force refresh of all
Refresh ( ) ;
2014-10-27 21:22:29 -04:00
}
2014-11-04 18:39:08 -05:00
AppFrame : : ~ AppFrame ( ) {
2015-08-14 19:17:43 -04:00
waterfallDataThread - > terminate ( ) ;
t_FFTData - > join ( ) ;
2014-11-11 20:25:16 -05:00
}
2015-10-20 23:00:10 -04:00
void AppFrame : : initDeviceParams ( SDRDeviceInfo * devInfo ) {
2015-11-02 19:27:34 -05:00
this - > devInfo = devInfo ;
deviceChanged . store ( true ) ;
}
2015-07-08 18:54:52 -04:00
2015-11-02 19:27:34 -05:00
void AppFrame : : updateDeviceParams ( ) {
if ( ! deviceChanged . load ( ) ) {
return ;
}
2015-07-08 01:07:39 -04:00
2016-02-15 15:07:57 -05:00
int i = 0 ;
SoapySDR : : Device * soapyDev = devInfo - > getSoapyDevice ( ) ;
2015-07-08 01:07:39 -04:00
2015-11-03 19:58:42 -05:00
// Build settings menu
wxMenu * newSettingsMenu = new wxMenu ;
2016-02-08 22:43:11 -05:00
showTipMenuItem = newSettingsMenu - > AppendCheckItem ( wxID_SET_TIPS , " Show Hover Tips " ) ;
2016-02-15 15:07:57 -05:00
showTipMenuItem - > Check ( wxGetApp ( ) . getConfig ( ) - > getShowTips ( ) ) ;
2016-03-31 21:32:50 -04:00
lowPerfMode = wxGetApp ( ) . getConfig ( ) - > getLowPerfMode ( ) ;
lowPerfMenuItem = newSettingsMenu - > AppendCheckItem ( wxID_LOW_PERF , " Reduce CPU Usage " ) ;
if ( lowPerfMode ) {
lowPerfMenuItem - > Check ( true ) ;
}
newSettingsMenu - > AppendSeparator ( ) ;
2015-11-03 19:58:42 -05:00
newSettingsMenu - > Append ( wxID_SET_FREQ_OFFSET , " Frequency Offset " ) ;
2016-02-15 15:07:57 -05:00
2016-01-31 15:11:54 -05:00
if ( devInfo - > hasCORR ( SOAPY_SDR_RX , 0 ) ) {
2015-11-03 19:58:42 -05:00
newSettingsMenu - > Append ( wxID_SET_PPM , " Device PPM " ) ;
2015-07-08 01:07:39 -04:00
}
2016-02-15 15:07:57 -05:00
if ( devInfo - > getDriver ( ) ! = " rtlsdr " ) {
iqSwapMenuItem = newSettingsMenu - > AppendCheckItem ( wxID_SET_IQSWAP , " I/Q Swap " ) ;
iqSwapMenuItem - > Check ( wxGetApp ( ) . getSDRThread ( ) - > getIQSwap ( ) ) ;
}
2016-02-28 21:11:29 -05:00
agcMenuItem = nullptr ;
if ( soapyDev - > listGains ( SOAPY_SDR_RX , 0 ) . size ( ) ) {
agcMenuItem = newSettingsMenu - > AppendCheckItem ( wxID_AGC_CONTROL , " Automatic Gain " ) ;
agcMenuItem - > Check ( wxGetApp ( ) . getAGCMode ( ) ) ;
2016-02-28 22:44:17 -05:00
} else if ( ! wxGetApp ( ) . getAGCMode ( ) ) {
wxGetApp ( ) . setAGCMode ( true ) ;
2016-02-28 21:11:29 -05:00
}
2015-11-03 19:58:42 -05:00
SoapySDR : : ArgInfoList : : const_iterator args_i ;
2016-02-02 19:27:08 -05:00
settingArgs = soapyDev - > getSettingInfo ( ) ;
2016-03-31 21:32:50 -04:00
if ( settingArgs . size ( ) ) {
newSettingsMenu - > AppendSeparator ( ) ;
}
2016-02-15 15:07:57 -05:00
2015-11-03 23:44:35 -05:00
for ( args_i = settingArgs . begin ( ) ; args_i ! = settingArgs . end ( ) ; args_i + + ) {
2015-11-03 19:58:42 -05:00
SoapySDR : : ArgInfo arg = ( * args_i ) ;
2016-02-02 19:27:08 -05:00
std : : string currentVal = soapyDev - > readSetting ( arg . key ) ;
2015-11-03 19:58:42 -05:00
if ( arg . type = = SoapySDR : : ArgInfo : : BOOL ) {
wxMenuItem * item = newSettingsMenu - > AppendCheckItem ( wxID_SETTINGS_BASE + i , arg . name , arg . description ) ;
2015-11-03 23:44:35 -05:00
item - > Check ( currentVal = = " true " ) ;
2015-11-03 19:58:42 -05:00
i + + ;
} else if ( arg . type = = SoapySDR : : ArgInfo : : INT ) {
2015-11-03 23:44:35 -05:00
newSettingsMenu - > Append ( wxID_SETTINGS_BASE + i , arg . name , arg . description ) ;
2015-11-03 19:58:42 -05:00
i + + ;
} else if ( arg . type = = SoapySDR : : ArgInfo : : FLOAT ) {
2015-11-03 23:44:35 -05:00
newSettingsMenu - > Append ( wxID_SETTINGS_BASE + i , arg . name , arg . description ) ;
2015-11-03 19:58:42 -05:00
i + + ;
} else if ( arg . type = = SoapySDR : : ArgInfo : : STRING ) {
if ( arg . options . size ( ) ) {
wxMenu * subMenu = new wxMenu ;
int j = 0 ;
for ( std : : vector < std : : string > : : iterator str_i = arg . options . begin ( ) ; str_i ! = arg . options . end ( ) ; str_i + + ) {
std : : string optName = ( * str_i ) ;
std : : string displayName = optName ;
if ( arg . optionNames . size ( ) ) {
displayName = arg . optionNames [ j ] ;
}
wxMenuItem * item = subMenu - > AppendRadioItem ( wxID_SETTINGS_BASE + i , displayName ) ;
2015-11-03 23:44:35 -05:00
if ( currentVal = = ( * str_i ) ) {
2016-01-09 00:09:46 -05:00
item - > Check ( true ) ;
2015-11-03 19:58:42 -05:00
}
j + + ;
2015-11-03 23:44:35 -05:00
i + + ;
2015-11-03 19:58:42 -05:00
}
newSettingsMenu - > AppendSubMenu ( subMenu , arg . name , arg . description ) ;
} else {
2015-11-03 23:44:35 -05:00
newSettingsMenu - > Append ( wxID_SETTINGS_BASE + i , arg . name , arg . description ) ;
2015-11-03 19:58:42 -05:00
i + + ;
}
}
}
2015-11-03 23:44:35 -05:00
settingsIdMax = wxID_SETTINGS_BASE + i ;
2015-11-03 19:58:42 -05:00
menuBar - > Replace ( 1 , newSettingsMenu , wxT ( " &Settings " ) ) ;
settingsMenu = newSettingsMenu ;
// Build sample rate menu
2016-01-31 15:11:54 -05:00
sampleRates = devInfo - > getSampleRates ( SOAPY_SDR_RX , 0 ) ;
2015-10-20 23:00:10 -04:00
sampleRateMenuItems . erase ( sampleRateMenuItems . begin ( ) , sampleRateMenuItems . end ( ) ) ;
2015-11-02 21:04:02 -05:00
wxMenu * newSampleRateMenu = new wxMenu ;
2015-10-20 23:00:10 -04:00
int ofs = 0 ;
long sampleRate = wxGetApp ( ) . getSampleRate ( ) ;
bool checked = false ;
for ( vector < long > : : iterator i = sampleRates . begin ( ) ; i ! = sampleRates . end ( ) ; i + + ) {
2015-11-02 21:04:02 -05:00
sampleRateMenuItems [ wxID_BANDWIDTH_BASE + ofs ] = newSampleRateMenu - > AppendRadioItem ( wxID_BANDWIDTH_BASE + ofs , frequencyToStr ( * i ) ) ;
2015-10-20 23:00:10 -04:00
if ( sampleRate = = ( * i ) ) {
sampleRateMenuItems [ wxID_BANDWIDTH_BASE + ofs ] - > Check ( true ) ;
checked = true ;
}
ofs + + ;
}
2015-11-02 21:04:02 -05:00
sampleRateMenuItems [ wxID_BANDWIDTH_MANUAL ] = newSampleRateMenu - > AppendRadioItem ( wxID_BANDWIDTH_MANUAL , wxT ( " Manual Entry " ) ) ;
2015-10-20 23:00:10 -04:00
if ( ! checked ) {
sampleRateMenuItems [ wxID_BANDWIDTH_MANUAL ] - > Check ( true ) ;
}
2015-11-02 21:04:02 -05:00
2015-12-07 21:02:47 -05:00
menuBar - > Replace ( 4 , newSampleRateMenu , wxT ( " Sample &Rate " ) ) ;
2015-11-02 21:04:02 -05:00
sampleRateMenu = newSampleRateMenu ;
2015-10-27 01:56:49 -04:00
if ( ! wxGetApp ( ) . getAGCMode ( ) ) {
gainSpacerItem - > Show ( true ) ;
gainSizerItem - > Show ( true ) ;
2016-01-31 15:11:54 -05:00
gainSizerItem - > SetMinSize ( devInfo - > getSoapyDevice ( ) - > listGains ( SOAPY_SDR_RX , 0 ) . size ( ) * 50 , 0 ) ;
2015-10-27 01:56:49 -04:00
demodTray - > Layout ( ) ;
gainCanvas - > updateGainUI ( ) ;
gainCanvas - > Refresh ( ) ;
gainCanvas - > Refresh ( ) ;
} else {
gainSpacerItem - > Show ( false ) ;
gainSizerItem - > Show ( false ) ;
demodTray - > Layout ( ) ;
2015-07-08 01:07:39 -04:00
}
2016-02-28 21:11:29 -05:00
2016-01-09 00:09:46 -05:00
# if USE_HAMLIB
2016-02-16 01:13:26 -05:00
if ( wxGetApp ( ) . getConfig ( ) - > getRigEnabled ( ) & & ! wxGetApp ( ) . rigIsActive ( ) ) {
enableRig ( ) ;
rigEnableMenuItem - > Check ( true ) ;
}
2016-01-09 00:09:46 -05:00
std : : string deviceId = devInfo - > getDeviceId ( ) ;
DeviceConfig * devConfig = wxGetApp ( ) . getConfig ( ) - > getDevice ( deviceId ) ;
if ( wxGetApp ( ) . rigIsActive ( ) ) {
rigSDRIF = devConfig - > getRigIF ( rigModel ) ;
if ( rigSDRIF ) {
wxGetApp ( ) . lockFrequency ( rigSDRIF ) ;
} else {
wxGetApp ( ) . unlockFrequency ( ) ;
}
}
# endif
2015-11-02 19:27:34 -05:00
deviceChanged . store ( false ) ;
2014-10-27 21:22:29 -04:00
}
2016-02-16 01:13:26 -05:00
# ifdef USE_HAMLIB
void AppFrame : : enableRig ( ) {
wxGetApp ( ) . stopRig ( ) ;
wxGetApp ( ) . initRig ( rigModel , rigPort , rigSerialRate ) ;
if ( devInfo ! = nullptr ) {
std : : string deviceId = devInfo - > getDeviceId ( ) ;
DeviceConfig * devConfig = wxGetApp ( ) . getConfig ( ) - > getDevice ( deviceId ) ;
rigSDRIF = devConfig - > getRigIF ( rigModel ) ;
if ( rigSDRIF ) {
wxGetApp ( ) . lockFrequency ( rigSDRIF ) ;
} else {
wxGetApp ( ) . unlockFrequency ( ) ;
}
} else {
wxGetApp ( ) . unlockFrequency ( ) ;
}
wxGetApp ( ) . getConfig ( ) - > setRigEnabled ( true ) ;
}
void AppFrame : : disableRig ( ) {
wxGetApp ( ) . stopRig ( ) ;
wxGetApp ( ) . unlockFrequency ( ) ;
wxGetApp ( ) . getConfig ( ) - > setRigEnabled ( false ) ;
}
# endif
2014-11-11 20:25:16 -05:00
2016-06-20 13:28:26 -04:00
2014-12-31 21:31:37 -05:00
void AppFrame : : OnMenu ( wxCommandEvent & event ) {
2016-06-20 13:28:26 -04:00
2016-01-28 15:49:31 -05:00
if ( event . GetId ( ) > = wxID_RT_AUDIO_DEVICE & & event . GetId ( ) < wxID_RT_AUDIO_DEVICE + ( int ) devices . size ( ) ) {
2014-12-31 21:31:37 -05:00
if ( activeDemodulator ) {
2015-01-01 18:08:54 -05:00
activeDemodulator - > setOutputDevice ( event . GetId ( ) - wxID_RT_AUDIO_DEVICE ) ;
2014-12-31 21:31:37 -05:00
activeDemodulator = NULL ;
}
2016-02-28 23:16:56 -05:00
}
# ifdef __APPLE__
else if ( event . GetId ( ) = = wxApp : : s_macAboutMenuItemId ) {
2016-02-28 22:44:17 -05:00
wxMessageDialog * aboutDlg = new wxMessageDialog ( NULL , wxT ( " CubicSDR v " CUBICSDR_VERSION " \n by Charles J. Cliffe (@ccliffe) \n www.cubicsdr.com " ) , wxT ( " CubicSDR v " CUBICSDR_VERSION ) , wxOK ) ;
aboutDlg - > ShowModal ( ) ;
2016-02-28 23:16:56 -05:00
}
# endif
else if ( event . GetId ( ) = = wxID_SDR_START_STOP ) {
if ( ! wxGetApp ( ) . getSDRThread ( ) - > isTerminated ( ) ) {
wxGetApp ( ) . stopDevice ( true ) ;
} else {
SDRDeviceInfo * dev = wxGetApp ( ) . getDevice ( ) ;
if ( dev ! = nullptr ) {
wxGetApp ( ) . setDevice ( dev ) ;
}
}
2016-03-31 21:32:50 -04:00
} else if ( event . GetId ( ) = = wxID_LOW_PERF ) {
lowPerfMode = lowPerfMenuItem - > IsChecked ( ) ;
wxGetApp ( ) . getConfig ( ) - > setLowPerfMode ( lowPerfMode ) ;
// long srate = wxGetApp().getSampleRate();
// if (srate > CHANNELIZER_RATE_MAX && lowPerfMode) {
// if (wxGetApp().getSpectrumProcessor()->getFFTSize() != 1024) {
// setMainWaterfallFFTSize(1024);
// }
// } else if (srate > CHANNELIZER_RATE_MAX) {
// if (wxGetApp().getSpectrumProcessor()->getFFTSize() != 2048) {
// setMainWaterfallFFTSize(2048);
// }
// }
2016-02-08 22:43:11 -05:00
} else if ( event . GetId ( ) = = wxID_SET_TIPS ) {
if ( wxGetApp ( ) . getConfig ( ) - > getShowTips ( ) ) {
wxGetApp ( ) . getConfig ( ) - > setShowTips ( false ) ;
} else {
wxGetApp ( ) . getConfig ( ) - > setShowTips ( true ) ;
}
2016-02-15 15:07:57 -05:00
} else if ( event . GetId ( ) = = wxID_SET_IQSWAP ) {
wxGetApp ( ) . getSDRThread ( ) - > setIQSwap ( ! wxGetApp ( ) . getSDRThread ( ) - > getIQSwap ( ) ) ;
2015-01-06 00:57:57 -05:00
} else if ( event . GetId ( ) = = wxID_SET_FREQ_OFFSET ) {
2015-01-08 23:57:58 -05:00
long ofs = wxGetNumberFromUser ( " Shift the displayed frequency by this amount. \n i.e. -125000000 for -125 MHz " , " Frequency (Hz) " ,
" Frequency Offset " , wxGetApp ( ) . getOffset ( ) , - 2000000000 , 2000000000 , this ) ;
2015-01-06 19:15:27 -05:00
if ( ofs ! = - 1 ) {
wxGetApp ( ) . setOffset ( ofs ) ;
}
2015-10-27 01:56:49 -04:00
} else if ( event . GetId ( ) = = wxID_AGC_CONTROL ) {
2015-10-30 19:29:56 -04:00
if ( wxGetApp ( ) . getDevice ( ) = = NULL ) {
2016-01-09 00:09:46 -05:00
agcMenuItem - > Check ( true ) ;
2015-10-30 19:29:56 -04:00
return ;
}
2015-10-27 01:56:49 -04:00
if ( ! wxGetApp ( ) . getAGCMode ( ) ) {
wxGetApp ( ) . setAGCMode ( true ) ;
gainSpacerItem - > Show ( false ) ;
gainSizerItem - > Show ( false ) ;
demodTray - > Layout ( ) ;
} else {
wxGetApp ( ) . setAGCMode ( false ) ;
gainSpacerItem - > Show ( true ) ;
gainSizerItem - > Show ( true ) ;
2016-01-31 15:11:54 -05:00
gainSizerItem - > SetMinSize ( wxGetApp ( ) . getDevice ( ) - > getSoapyDevice ( ) - > listGains ( SOAPY_SDR_RX , 0 ) . size ( ) * 40 , 0 ) ;
2015-10-27 01:56:49 -04:00
demodTray - > Layout ( ) ;
gainCanvas - > updateGainUI ( ) ;
gainCanvas - > Refresh ( ) ;
gainCanvas - > Refresh ( ) ;
}
2015-10-04 16:07:14 -04:00
} else if ( event . GetId ( ) = = wxID_SDR_DEVICES ) {
wxGetApp ( ) . deviceSelector ( ) ;
2015-04-13 21:18:45 -04:00
} else if ( event . GetId ( ) = = wxID_SET_PPM ) {
2015-04-22 23:08:43 -04:00
long ofs = wxGetNumberFromUser ( " Frequency correction for device in PPM. \n i.e. -51 for -51 PPM \n \n Note: you can adjust PPM interactively \n by holding ALT over the frequency tuning bar. \n " , " Parts per million (PPM) " ,
2015-04-13 21:18:45 -04:00
" Frequency Correction " , wxGetApp ( ) . getPPM ( ) , - 1000 , 1000 , this ) ;
wxGetApp ( ) . setPPM ( ofs ) ;
2015-01-08 23:57:58 -05:00
} else if ( event . GetId ( ) = = wxID_SAVE ) {
2015-01-10 12:27:03 -05:00
if ( ! currentSessionFile . empty ( ) ) {
saveSession ( currentSessionFile ) ;
} else {
wxFileDialog saveFileDialog ( this , _ ( " Save XML Session file " ) , " " , " " , " XML files (*.xml)|*.xml " , wxFD_SAVE | wxFD_OVERWRITE_PROMPT ) ;
if ( saveFileDialog . ShowModal ( ) = = wxID_CANCEL ) {
return ;
}
saveSession ( saveFileDialog . GetPath ( ) . ToStdString ( ) ) ;
}
2015-01-08 23:57:58 -05:00
} else if ( event . GetId ( ) = = wxID_OPEN ) {
2015-01-10 12:27:03 -05:00
wxFileDialog openFileDialog ( this , _ ( " Open XML Session file " ) , " " , " " , " XML files (*.xml)|*.xml " , wxFD_OPEN | wxFD_FILE_MUST_EXIST ) ;
if ( openFileDialog . ShowModal ( ) = = wxID_CANCEL ) {
return ;
}
loadSession ( openFileDialog . GetPath ( ) . ToStdString ( ) ) ;
2015-01-08 23:57:58 -05:00
} else if ( event . GetId ( ) = = wxID_SAVEAS ) {
2015-01-10 12:27:03 -05:00
wxFileDialog saveFileDialog ( this , _ ( " Save XML Session file " ) , " " , " " , " XML files (*.xml)|*.xml " , wxFD_SAVE | wxFD_OVERWRITE_PROMPT ) ;
if ( saveFileDialog . ShowModal ( ) = = wxID_CANCEL ) {
return ;
}
saveSession ( saveFileDialog . GetPath ( ) . ToStdString ( ) ) ;
} else if ( event . GetId ( ) = = wxID_RESET ) {
wxGetApp ( ) . getDemodMgr ( ) . terminateAll ( ) ;
2015-07-21 00:04:04 -04:00
wxGetApp ( ) . setFrequency ( 100000000 ) ;
2015-11-17 18:57:42 -05:00
wxGetApp ( ) . getDemodMgr ( ) . setLastDemodulatorType ( " FM " ) ;
2015-08-13 22:00:05 -04:00
demodModeSelector - > setSelection ( 1 ) ;
2015-08-19 17:06:06 -04:00
wxGetApp ( ) . getDemodMgr ( ) . setLastMuted ( false ) ;
2015-08-13 22:00:05 -04:00
wxGetApp ( ) . getDemodMgr ( ) . setLastBandwidth ( DEFAULT_DEMOD_BW ) ;
wxGetApp ( ) . getDemodMgr ( ) . setLastGain ( 1.0 ) ;
2015-11-21 15:12:20 -05:00
wxGetApp ( ) . getDemodMgr ( ) . setLastSquelchLevel ( - 100 ) ;
2015-08-13 22:00:05 -04:00
waterfallCanvas - > setBandwidth ( wxGetApp ( ) . getSampleRate ( ) ) ;
waterfallCanvas - > setCenterFrequency ( wxGetApp ( ) . getFrequency ( ) ) ;
spectrumCanvas - > setBandwidth ( wxGetApp ( ) . getSampleRate ( ) ) ;
spectrumCanvas - > setCenterFrequency ( wxGetApp ( ) . getFrequency ( ) ) ;
2015-08-14 19:17:43 -04:00
waterfallDataThread - > setLinesPerSecond ( DEFAULT_WATERFALL_LPS ) ;
2015-09-09 23:29:38 -04:00
waterfallCanvas - > setLinesPerSecond ( DEFAULT_WATERFALL_LPS ) ;
2015-08-13 22:00:05 -04:00
waterfallSpeedMeter - > setLevel ( sqrt ( DEFAULT_WATERFALL_LPS ) ) ;
2016-06-01 19:42:34 -04:00
wxGetApp ( ) . getSpectrumProcessor ( ) - > setFFTAverageRate ( 0.65f ) ;
spectrumAvgMeter - > setLevel ( 0.65f ) ;
2015-08-13 22:00:05 -04:00
demodModeSelector - > Refresh ( ) ;
demodTuner - > Refresh ( ) ;
2015-01-24 22:01:47 -05:00
SetTitle ( CUBICSDR_TITLE ) ;
2015-01-10 20:33:30 -05:00
currentSessionFile = " " ;
2015-11-10 02:13:15 -05:00
} else if ( event . GetId ( ) = = wxID_CLOSE | | event . GetId ( ) = = wxID_EXIT ) {
2015-01-08 23:57:58 -05:00
Close ( false ) ;
2015-01-11 03:09:59 -05:00
} else if ( event . GetId ( ) = = wxID_THEME_DEFAULT ) {
2015-01-14 22:14:57 -05:00
ThemeMgr : : mgr . setTheme ( COLOR_THEME_DEFAULT ) ;
2015-01-11 03:09:59 -05:00
} else if ( event . GetId ( ) = = wxID_THEME_SHARP ) {
2015-01-14 22:14:57 -05:00
ThemeMgr : : mgr . setTheme ( COLOR_THEME_SHARP ) ;
2015-01-11 03:09:59 -05:00
} else if ( event . GetId ( ) = = wxID_THEME_BW ) {
2015-01-14 22:14:57 -05:00
ThemeMgr : : mgr . setTheme ( COLOR_THEME_BW ) ;
2015-01-11 03:09:59 -05:00
} else if ( event . GetId ( ) = = wxID_THEME_RAD ) {
2015-01-14 22:14:57 -05:00
ThemeMgr : : mgr . setTheme ( COLOR_THEME_RAD ) ;
2015-01-11 03:09:59 -05:00
} else if ( event . GetId ( ) = = wxID_THEME_TOUCH ) {
2015-01-14 22:14:57 -05:00
ThemeMgr : : mgr . setTheme ( COLOR_THEME_TOUCH ) ;
2015-01-11 03:09:59 -05:00
} else if ( event . GetId ( ) = = wxID_THEME_HD ) {
2015-01-14 22:14:57 -05:00
ThemeMgr : : mgr . setTheme ( COLOR_THEME_HD ) ;
2015-01-11 03:09:59 -05:00
} else if ( event . GetId ( ) = = wxID_THEME_RADAR ) {
2015-01-14 22:14:57 -05:00
ThemeMgr : : mgr . setTheme ( COLOR_THEME_RADAR ) ;
2014-12-31 21:31:37 -05:00
}
2016-06-15 16:21:41 -04:00
//Display : font sizes
else if ( event . GetId ( ) = = wxID_DISPLAY_BASE ) {
GLFont : : setScale ( GLFont : : GLFONT_SCALE_NORMAL ) ;
2016-06-20 12:29:56 -04:00
//force all windows refresh
Refresh ( ) ;
2016-06-15 16:21:41 -04:00
}
else if ( event . GetId ( ) = = wxID_DISPLAY_BASE + 1 ) {
GLFont : : setScale ( GLFont : : GLFONT_SCALE_MEDIUM ) ;
2016-06-20 12:29:56 -04:00
//force all windows refresh
Refresh ( ) ;
2016-06-15 16:21:41 -04:00
}
else if ( event . GetId ( ) = = wxID_DISPLAY_BASE + 2 ) {
GLFont : : setScale ( GLFont : : GLFONT_SCALE_LARGE ) ;
2016-06-20 12:29:56 -04:00
//force all windows refresh
Refresh ( ) ;
2016-06-15 16:21:41 -04:00
}
2015-01-11 17:08:16 -05:00
2015-11-03 23:44:35 -05:00
if ( event . GetId ( ) > = wxID_SETTINGS_BASE & & event . GetId ( ) < settingsIdMax ) {
int setIdx = event . GetId ( ) - wxID_SETTINGS_BASE ;
int menuIdx = 0 ;
for ( std : : vector < SoapySDR : : ArgInfo > : : iterator arg_i = settingArgs . begin ( ) ; arg_i ! = settingArgs . end ( ) ; arg_i + + ) {
SoapySDR : : ArgInfo & arg = ( * arg_i ) ;
2016-01-28 15:49:31 -05:00
if ( arg . type = = SoapySDR : : ArgInfo : : STRING & & arg . options . size ( ) & & setIdx > = menuIdx & & setIdx < menuIdx + ( int ) arg . options . size ( ) ) {
2015-11-03 23:44:35 -05:00
int optIdx = setIdx - menuIdx ;
wxGetApp ( ) . getSDRThread ( ) - > writeSetting ( arg . key , arg . options [ optIdx ] ) ;
break ;
} else if ( arg . type = = SoapySDR : : ArgInfo : : STRING & & arg . options . size ( ) ) {
menuIdx + = arg . options . size ( ) ;
} else if ( menuIdx = = setIdx ) {
if ( arg . type = = SoapySDR : : ArgInfo : : BOOL ) {
wxGetApp ( ) . getSDRThread ( ) - > writeSetting ( arg . key , ( wxGetApp ( ) . getSDRThread ( ) - > readSetting ( arg . key ) = = " true " ) ? " false " : " true " ) ;
break ;
} else if ( arg . type = = SoapySDR : : ArgInfo : : STRING ) {
2016-01-02 21:42:35 -05:00
wxString stringVal = wxGetTextFromUser ( arg . description , arg . name , wxGetApp ( ) . getSDRThread ( ) - > readSetting ( arg . key ) ) ;
if ( stringVal . ToStdString ( ) ! = " " ) {
wxGetApp ( ) . getSDRThread ( ) - > writeSetting ( arg . key , stringVal . ToStdString ( ) ) ;
}
break ;
2015-11-03 23:44:35 -05:00
} else if ( arg . type = = SoapySDR : : ArgInfo : : INT ) {
int currentVal ;
try {
currentVal = std : : stoi ( wxGetApp ( ) . getSDRThread ( ) - > readSetting ( arg . key ) ) ;
} catch ( std : : invalid_argument e ) {
currentVal = 0 ;
}
int intVal = wxGetNumberFromUser ( arg . description , arg . units , arg . name , currentVal , arg . range . minimum ( ) , arg . range . maximum ( ) , this ) ;
if ( intVal ! = - 1 ) {
wxGetApp ( ) . getSDRThread ( ) - > writeSetting ( arg . key , std : : to_string ( intVal ) ) ;
}
break ;
} else if ( arg . type = = SoapySDR : : ArgInfo : : FLOAT ) {
wxString floatVal = wxGetTextFromUser ( arg . description , arg . name , wxGetApp ( ) . getSDRThread ( ) - > readSetting ( arg . key ) ) ;
try {
wxGetApp ( ) . getSDRThread ( ) - > writeSetting ( arg . key , floatVal . ToStdString ( ) ) ;
} catch ( std : : invalid_argument e ) {
// ...
}
break ;
} else {
menuIdx + + ;
}
} else {
menuIdx + + ;
}
}
}
2015-08-10 18:45:46 -04:00
if ( event . GetId ( ) > = wxID_THEME_DEFAULT & & event . GetId ( ) < = wxID_THEME_RADAR ) {
demodTuner - > Refresh ( ) ;
demodModeSelector - > Refresh ( ) ;
2015-10-27 01:56:49 -04:00
waterfallSpeedMeter - > Refresh ( ) ;
spectrumAvgMeter - > Refresh ( ) ;
gainCanvas - > setThemeColors ( ) ;
2015-08-10 18:45:46 -04:00
}
2015-01-11 17:08:16 -05:00
switch ( event . GetId ( ) ) {
2015-09-13 22:18:29 -04:00
case wxID_BANDWIDTH_MANUAL :
2015-10-21 17:39:44 -04:00
int rateHigh , rateLow ;
SDRDeviceInfo * dev = wxGetApp ( ) . getDevice ( ) ;
if ( dev = = NULL ) {
break ;
}
2016-01-31 15:11:54 -05:00
std : : vector < long > sampleRates = dev - > getSampleRates ( SOAPY_SDR_RX , 0 ) ;
2015-10-21 17:39:44 -04:00
rateLow = 2000000 ;
rateHigh = 30000000 ;
2016-01-31 15:11:54 -05:00
if ( sampleRates . size ( ) ) {
rateLow = sampleRates [ 0 ] ;
rateHigh = sampleRates [ sampleRates . size ( ) - 1 ] ;
2015-10-21 17:39:44 -04:00
}
long bw = wxGetNumberFromUser ( " \n " + dev - > getName ( ) + " \n \n "
+ " min: " + std : : to_string ( rateLow ) + " Hz "
+ " , max: " + std : : to_string ( rateHigh ) + " Hz \n " ,
" Sample Rate in Hz " ,
2015-12-07 21:02:47 -05:00
" Manual Sample Rate Entry " ,
2015-10-21 17:39:44 -04:00
wxGetApp ( ) . getSampleRate ( ) ,
rateLow ,
rateHigh ,
this ) ;
2015-09-13 22:18:29 -04:00
if ( bw ! = - 1 ) {
wxGetApp ( ) . setSampleRate ( bw ) ;
}
2015-06-11 17:18:36 -04:00
break ;
2015-01-11 17:08:16 -05:00
}
2015-11-03 00:53:39 -05:00
2016-01-28 15:49:31 -05:00
if ( event . GetId ( ) > = wxID_BANDWIDTH_BASE & & event . GetId ( ) < wxID_BANDWIDTH_BASE + ( int ) sampleRates . size ( ) ) {
2015-10-20 23:00:10 -04:00
wxGetApp ( ) . setSampleRate ( sampleRates [ event . GetId ( ) - wxID_BANDWIDTH_BASE ] ) ;
2015-01-12 00:40:43 -05:00
}
2015-10-20 23:00:10 -04:00
2015-03-12 19:41:50 -04:00
if ( event . GetId ( ) > = wxID_AUDIO_BANDWIDTH_BASE ) {
int evId = event . GetId ( ) ;
std : : vector < RtAudio : : DeviceInfo > : : iterator devices_i ;
std : : map < int , RtAudio : : DeviceInfo > : : iterator mdevices_i ;
int i = 0 ;
for ( mdevices_i = outputDevices . begin ( ) ; mdevices_i ! = outputDevices . end ( ) ; mdevices_i + + ) {
2015-03-29 20:24:00 -04:00
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i - > first ;
2015-03-12 19:41:50 -04:00
2015-03-29 20:24:00 -04:00
int j = 0 ;
for ( std : : vector < unsigned int > : : iterator srate = mdevices_i - > second . sampleRates . begin ( ) ; srate ! = mdevices_i - > second . sampleRates . end ( ) ;
srate + + ) {
2015-03-12 19:41:50 -04:00
2015-03-29 20:24:00 -04:00
if ( evId = = menu_id + j ) {
//audioSampleRateMenuItems[menu_id+j];
//std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl;
AudioThread : : setDeviceSampleRate ( mdevices_i - > first , * srate ) ;
}
2015-03-12 19:41:50 -04:00
2015-03-29 20:24:00 -04:00
j + + ;
}
i + + ;
}
2015-03-12 19:41:50 -04:00
}
2016-01-03 19:00:26 -05:00
# ifdef USE_HAMLIB
2016-01-09 00:09:46 -05:00
2016-01-03 19:00:26 -05:00
bool resetRig = false ;
if ( event . GetId ( ) > = wxID_RIG_MODEL_BASE & & event . GetId ( ) < wxID_RIG_MODEL_BASE + numRigs ) {
int rigIdx = event . GetId ( ) - wxID_RIG_MODEL_BASE ;
RigList & rl = RigThread : : enumerate ( ) ;
rigModel = rl [ rigIdx ] - > rig_model ;
2016-01-09 00:09:46 -05:00
if ( devInfo ! = nullptr ) {
std : : string deviceId = devInfo - > getDeviceId ( ) ;
DeviceConfig * devConfig = wxGetApp ( ) . getConfig ( ) - > getDevice ( deviceId ) ;
rigSDRIF = devConfig - > getRigIF ( rigModel ) ;
if ( rigSDRIF ) {
wxGetApp ( ) . lockFrequency ( rigSDRIF ) ;
} else {
wxGetApp ( ) . unlockFrequency ( ) ;
}
} else {
wxGetApp ( ) . unlockFrequency ( ) ;
}
2016-01-03 19:00:26 -05:00
resetRig = true ;
}
if ( event . GetId ( ) > = wxID_RIG_SERIAL_BASE & & event . GetId ( ) < wxID_RIG_SERIAL_BASE + rigSerialRates . size ( ) ) {
int serialIdx = event . GetId ( ) - wxID_RIG_SERIAL_BASE ;
rigSerialRate = rigSerialRates [ serialIdx ] ;
resetRig = true ;
}
if ( event . GetId ( ) = = wxID_RIG_PORT ) {
wxString stringVal = wxGetTextFromUser ( " Rig Serial / COM / Address " , " Rig Control Port " , rigPort ) ;
std : : string rigPortStr = stringVal . ToStdString ( ) ;
if ( rigPortStr ! = " " ) {
rigPort = rigPortStr ;
resetRig = true ;
}
}
if ( event . GetId ( ) = = wxID_RIG_TOGGLE ) {
resetRig = false ;
if ( ! wxGetApp ( ) . rigIsActive ( ) ) {
2016-02-16 01:13:26 -05:00
enableRig ( ) ;
2016-01-03 19:00:26 -05:00
} else {
2016-02-16 01:13:26 -05:00
disableRig ( ) ;
2016-01-09 00:09:46 -05:00
}
}
if ( event . GetId ( ) = = wxID_RIG_SDR_IF ) {
if ( devInfo ! = nullptr ) {
std : : string deviceId = devInfo - > getDeviceId ( ) ;
DeviceConfig * devConfig = wxGetApp ( ) . getConfig ( ) - > getDevice ( deviceId ) ;
long long freqRigIF = wxGetNumberFromUser ( " Rig SDR-IF Frequency " , " Frequency (Hz) " , " Frequency " , devConfig - > getRigIF ( rigModel ) , 0 , 2000000000 ) ;
if ( freqRigIF ! = - 1 ) {
rigSDRIF = freqRigIF ;
devConfig - > setRigIF ( rigModel , rigSDRIF ) ;
}
if ( rigSDRIF & & wxGetApp ( ) . rigIsActive ( ) ) {
wxGetApp ( ) . lockFrequency ( rigSDRIF ) ;
} else {
wxGetApp ( ) . unlockFrequency ( ) ;
}
2016-01-03 19:00:26 -05:00
}
}
2016-02-16 01:13:26 -05:00
if ( event . GetId ( ) = = wxID_RIG_CONTROL ) {
if ( wxGetApp ( ) . rigIsActive ( ) ) {
RigThread * rt = wxGetApp ( ) . getRigThread ( ) ;
rt - > setControlMode ( ! rt - > getControlMode ( ) ) ;
rigControlMenuItem - > Check ( rt - > getControlMode ( ) ) ;
wxGetApp ( ) . getConfig ( ) - > setRigControlMode ( rt - > getControlMode ( ) ) ;
} else {
wxGetApp ( ) . getConfig ( ) - > setRigControlMode ( rigControlMenuItem - > IsChecked ( ) ) ;
}
}
if ( event . GetId ( ) = = wxID_RIG_FOLLOW ) {
if ( wxGetApp ( ) . rigIsActive ( ) ) {
RigThread * rt = wxGetApp ( ) . getRigThread ( ) ;
rt - > setFollowMode ( ! rt - > getFollowMode ( ) ) ;
rigFollowMenuItem - > Check ( rt - > getFollowMode ( ) ) ;
wxGetApp ( ) . getConfig ( ) - > setRigFollowMode ( rt - > getFollowMode ( ) ) ;
} else {
wxGetApp ( ) . getConfig ( ) - > setRigFollowMode ( rigFollowMenuItem - > IsChecked ( ) ) ;
}
}
2016-02-29 23:14:23 -05:00
if ( event . GetId ( ) = = wxID_RIG_CENTERLOCK ) {
if ( wxGetApp ( ) . rigIsActive ( ) ) {
RigThread * rt = wxGetApp ( ) . getRigThread ( ) ;
rt - > setCenterLock ( ! rt - > getCenterLock ( ) ) ;
rigCenterLockMenuItem - > Check ( rt - > getCenterLock ( ) ) ;
wxGetApp ( ) . getConfig ( ) - > setRigCenterLock ( rt - > getCenterLock ( ) ) ;
} else {
wxGetApp ( ) . getConfig ( ) - > setRigCenterLock ( rigCenterLockMenuItem - > IsChecked ( ) ) ;
}
}
if ( event . GetId ( ) = = wxID_RIG_FOLLOW_MODEM ) {
if ( wxGetApp ( ) . rigIsActive ( ) ) {
RigThread * rt = wxGetApp ( ) . getRigThread ( ) ;
rt - > setFollowModem ( ! rt - > getFollowModem ( ) ) ;
rigFollowModemMenuItem - > Check ( rt - > getFollowModem ( ) ) ;
wxGetApp ( ) . getConfig ( ) - > setRigFollowModem ( rt - > getFollowModem ( ) ) ;
} else {
wxGetApp ( ) . getConfig ( ) - > setRigFollowModem ( rigFollowModemMenuItem - > IsChecked ( ) ) ;
}
}
2016-01-03 19:00:26 -05:00
if ( wxGetApp ( ) . rigIsActive ( ) & & resetRig ) {
wxGetApp ( ) . stopRig ( ) ;
wxGetApp ( ) . initRig ( rigModel , rigPort , rigSerialRate ) ;
}
# endif
2015-03-12 19:41:50 -04:00
2014-10-27 21:22:29 -04:00
}
2015-07-15 00:32:36 -04:00
void AppFrame : : OnClose ( wxCloseEvent & event ) {
2015-11-12 18:38:38 -05:00
wxGetApp ( ) . closeDeviceSelector ( ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > removeOutput ( demodSpectrumCanvas - > getVisualDataQueue ( ) ) ;
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > removeOutput ( demodWaterfallCanvas - > getVisualDataQueue ( ) ) ;
wxGetApp ( ) . getSpectrumProcessor ( ) - > removeOutput ( spectrumCanvas - > getVisualDataQueue ( ) ) ;
2015-07-15 00:32:36 -04:00
wxGetApp ( ) . getConfig ( ) - > setWindow ( this - > GetPosition ( ) , this - > GetClientSize ( ) ) ;
2015-07-16 18:57:03 -04:00
wxGetApp ( ) . getConfig ( ) - > setWindowMaximized ( this - > IsMaximized ( ) ) ;
2015-07-15 00:32:36 -04:00
wxGetApp ( ) . getConfig ( ) - > setTheme ( ThemeMgr : : mgr . getTheme ( ) ) ;
2016-06-20 13:28:26 -04:00
wxGetApp ( ) . getConfig ( ) - > setFontScale ( GLFont : : getScale ( ) ) ;
2015-07-18 21:49:53 -04:00
wxGetApp ( ) . getConfig ( ) - > setSnap ( wxGetApp ( ) . getFrequencySnap ( ) ) ;
2015-07-21 00:04:04 -04:00
wxGetApp ( ) . getConfig ( ) - > setCenterFreq ( wxGetApp ( ) . getFrequency ( ) ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getConfig ( ) - > setSpectrumAvgSpeed ( wxGetApp ( ) . getSpectrumProcessor ( ) - > getFFTAverageRate ( ) ) ;
2015-08-14 19:17:43 -04:00
wxGetApp ( ) . getConfig ( ) - > setWaterfallLinesPerSec ( waterfallDataThread - > getLinesPerSecond ( ) ) ;
2016-01-22 00:40:00 -05:00
wxGetApp ( ) . getConfig ( ) - > setManualDevices ( SDREnumerator : : getManuals ( ) ) ;
2016-01-03 19:00:26 -05:00
# ifdef USE_HAMLIB
2016-02-16 01:13:26 -05:00
wxGetApp ( ) . getConfig ( ) - > setRigEnabled ( rigEnableMenuItem - > IsChecked ( ) ) ;
2016-01-03 19:00:26 -05:00
wxGetApp ( ) . getConfig ( ) - > setRigModel ( rigModel ) ;
wxGetApp ( ) . getConfig ( ) - > setRigRate ( rigSerialRate ) ;
wxGetApp ( ) . getConfig ( ) - > setRigPort ( rigPort ) ;
2016-02-16 01:13:26 -05:00
wxGetApp ( ) . getConfig ( ) - > setRigFollowMode ( rigFollowMenuItem - > IsChecked ( ) ) ;
wxGetApp ( ) . getConfig ( ) - > setRigControlMode ( rigControlMenuItem - > IsChecked ( ) ) ;
2016-02-29 23:14:23 -05:00
wxGetApp ( ) . getConfig ( ) - > setRigCenterLock ( rigCenterLockMenuItem - > IsChecked ( ) ) ;
wxGetApp ( ) . getConfig ( ) - > setRigFollowModem ( rigFollowModemMenuItem - > IsChecked ( ) ) ;
2016-01-03 19:00:26 -05:00
# endif
2015-07-15 00:32:36 -04:00
wxGetApp ( ) . getConfig ( ) - > save ( ) ;
event . Skip ( ) ;
2014-12-31 22:38:59 -05:00
}
2014-10-27 21:22:29 -04:00
void AppFrame : : OnNewWindow ( wxCommandEvent & WXUNUSED ( event ) ) {
new AppFrame ( ) ;
}
2014-10-28 21:39:59 -04:00
2014-11-17 18:14:37 -05:00
void AppFrame : : OnThread ( wxCommandEvent & event ) {
2014-11-22 22:17:33 -05:00
event . Skip ( ) ;
2014-11-16 16:51:45 -05:00
}
2014-10-28 21:39:59 -04:00
void AppFrame : : OnIdle ( wxIdleEvent & event ) {
2014-12-28 05:13:46 -05:00
2015-11-02 19:27:34 -05:00
if ( deviceChanged . load ( ) ) {
updateDeviceParams ( ) ;
}
2014-12-28 05:13:46 -05:00
DemodulatorInstance * demod = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ;
2015-11-26 01:54:54 -05:00
if ( demod & & demod - > isModemInitialized ( ) ) {
2015-04-23 19:38:44 -04:00
if ( demod - > isTracking ( ) ) {
if ( spectrumCanvas - > getViewState ( ) ) {
long long diff = abs ( demod - > getFrequency ( ) - spectrumCanvas - > getCenterFrequency ( ) ) + ( demod - > getBandwidth ( ) / 2 ) + ( demod - > getBandwidth ( ) / 4 ) ;
if ( diff > spectrumCanvas - > getBandwidth ( ) / 2 ) {
2016-02-04 18:05:33 -05:00
if ( demod - > getBandwidth ( ) > ( int ) spectrumCanvas - > getBandwidth ( ) ) {
2015-04-23 19:38:44 -04:00
diff = abs ( demod - > getFrequency ( ) - spectrumCanvas - > getCenterFrequency ( ) ) ;
} else {
diff = diff - spectrumCanvas - > getBandwidth ( ) / 2 ;
}
spectrumCanvas - > moveCenterFrequency ( ( demod - > getFrequency ( ) < spectrumCanvas - > getCenterFrequency ( ) ) ? diff : - diff ) ;
demod - > setTracking ( false ) ;
}
} else {
demod - > setTracking ( false ) ;
}
}
2015-11-26 01:54:54 -05:00
if ( demod - > getBandwidth ( ) ! = wxGetApp ( ) . getDemodMgr ( ) . getLastBandwidth ( ) ) {
wxGetApp ( ) . getDemodMgr ( ) . setLastBandwidth ( demod - > getBandwidth ( ) ) ;
}
2015-04-23 19:38:44 -04:00
2014-12-31 19:45:01 -05:00
if ( demod ! = activeDemodulator ) {
demodSignalMeter - > setInputValue ( demod - > getSquelchLevel ( ) ) ;
2015-01-10 20:33:30 -05:00
demodGainMeter - > setInputValue ( demod - > getGain ( ) ) ;
2016-03-07 20:15:27 -05:00
wxGetApp ( ) . getDemodMgr ( ) . setLastGain ( demod - > getGain ( ) ) ;
2014-12-31 21:31:37 -05:00
int outputDevice = demod - > getOutputDevice ( ) ;
2015-01-03 17:07:39 -05:00
scopeCanvas - > setDeviceName ( outputDevices [ outputDevice ] . name ) ;
outputDeviceMenuItems [ outputDevice ] - > Check ( true ) ;
2015-11-17 18:57:42 -05:00
std : : string dType = demod - > getDemodulatorType ( ) ;
2015-01-06 00:29:33 -05:00
demodModeSelector - > setSelection ( dType ) ;
2015-11-15 13:52:54 -05:00
# ifdef ENABLE_DIGITAL_LAB
2015-06-09 11:00:05 -04:00
demodModeSelectorAdv - > setSelection ( dType ) ;
2015-11-15 13:52:54 -05:00
# endif
2016-02-15 17:43:10 -05:00
deltaLockButton - > setSelection ( demod - > isDeltaLock ( ) ? 1 : - 1 ) ;
2015-08-17 00:59:38 -04:00
demodMuteButton - > setSelection ( demod - > isMuted ( ) ? 1 : - 1 ) ;
2015-11-23 22:16:09 -05:00
modemPropertiesUpdated . store ( true ) ;
2015-12-07 20:19:03 -05:00
demodTuner - > setHalfBand ( dType = = " USB " | | dType = = " LSB " ) ;
2014-12-31 19:45:01 -05:00
}
2014-12-28 20:55:05 -05:00
if ( demodWaterfallCanvas - > getDragState ( ) = = WaterfallCanvas : : WF_DRAG_NONE ) {
2015-02-16 02:15:04 -05:00
long long centerFreq = demod - > getFrequency ( ) ;
2015-02-21 23:25:40 -05:00
unsigned int demodBw = ( unsigned int ) ceil ( ( float ) demod - > getBandwidth ( ) * 2.25 ) ;
2015-02-16 02:15:04 -05:00
2015-11-17 18:57:42 -05:00
if ( demod - > getDemodulatorType ( ) = = " USB " ) {
2015-02-16 02:15:04 -05:00
demodBw / = 2 ;
2015-03-29 20:24:00 -04:00
centerFreq + = demod - > getBandwidth ( ) / 4 ;
2014-12-28 20:55:05 -05:00
}
2015-02-16 02:15:04 -05:00
2015-11-17 18:57:42 -05:00
if ( demod - > getDemodulatorType ( ) = = " LSB " ) {
2015-02-16 02:15:04 -05:00
demodBw / = 2 ;
2015-03-29 20:24:00 -04:00
centerFreq - = demod - > getBandwidth ( ) / 4 ;
2015-01-06 00:29:33 -05:00
}
2015-01-11 17:08:16 -05:00
if ( demodBw > wxGetApp ( ) . getSampleRate ( ) / 2 ) {
demodBw = wxGetApp ( ) . getSampleRate ( ) / 2 ;
2014-12-28 20:55:05 -05:00
}
2015-02-21 23:25:40 -05:00
if ( demodBw < 20000 ) {
demodBw = 20000 ;
2014-12-28 20:55:05 -05:00
}
2015-02-16 02:15:04 -05:00
if ( centerFreq ! = demodWaterfallCanvas - > getCenterFrequency ( ) ) {
demodWaterfallCanvas - > setCenterFrequency ( centerFreq ) ;
demodSpectrumCanvas - > setCenterFrequency ( centerFreq ) ;
}
2015-11-17 18:57:42 -05:00
std : : string dSelection = demodModeSelector - > getSelectionLabel ( ) ;
2015-11-15 13:52:54 -05:00
# ifdef ENABLE_DIGITAL_LAB
2015-11-17 18:57:42 -05:00
std : : string dSelectionadv = demodModeSelectorAdv - > getSelectionLabel ( ) ;
2015-06-10 13:39:08 -04:00
2015-06-10 04:50:14 -04:00
// basic demodulators
2015-11-17 18:57:42 -05:00
if ( dSelection ! = " " & & dSelection ! = demod - > getDemodulatorType ( ) ) {
2015-02-16 02:15:04 -05:00
demod - > setDemodulatorType ( dSelection ) ;
2015-12-07 20:19:03 -05:00
demodTuner - > setHalfBand ( dSelection = = " USB " | | dSelection = = " LSB " ) ;
2015-06-09 11:00:05 -04:00
demodModeSelectorAdv - > setSelection ( - 1 ) ;
2015-11-15 13:52:54 -05:00
}
2015-06-10 04:50:14 -04:00
// advanced demodulators
2015-11-17 18:57:42 -05:00
else if ( dSelectionadv ! = " " & & dSelectionadv ! = demod - > getDemodulatorType ( ) ) {
2015-06-10 13:39:08 -04:00
demod - > setDemodulatorType ( dSelectionadv ) ;
2015-12-07 20:19:03 -05:00
demodTuner - > setHalfBand ( false ) ;
2015-06-10 13:39:08 -04:00
demodModeSelector - > setSelection ( - 1 ) ;
2015-02-16 02:15:04 -05:00
}
2015-11-15 13:52:54 -05:00
# else
// basic demodulators
2015-11-19 00:39:14 -05:00
if ( dSelection ! = " " & & dSelection ! = demod - > getDemodulatorType ( ) ) {
2015-11-15 13:52:54 -05:00
demod - > setDemodulatorType ( dSelection ) ;
2015-12-07 20:19:03 -05:00
demodTuner - > setHalfBand ( dSelection = = " USB " | | dSelection = = " LSB " ) ;
2015-11-15 13:52:54 -05:00
}
# endif
2015-06-10 13:39:08 -04:00
2015-08-17 00:59:38 -04:00
int muteMode = demodMuteButton - > getSelection ( ) ;
if ( demodMuteButton - > modeChanged ( ) ) {
if ( demod - > isMuted ( ) & & muteMode = = - 1 ) {
demod - > setMuted ( false ) ;
} else if ( ! demod - > isMuted ( ) & & muteMode = = 1 ) {
demod - > setMuted ( true ) ;
}
2015-08-19 17:06:06 -04:00
wxGetApp ( ) . getDemodMgr ( ) . setLastMuted ( demod - > isMuted ( ) ) ;
2015-08-17 00:59:38 -04:00
demodMuteButton - > clearModeChanged ( ) ;
} else {
if ( demod - > isMuted ( ) & & muteMode = = - 1 ) {
demodMuteButton - > setSelection ( 1 ) ;
2015-08-19 17:06:06 -04:00
wxGetApp ( ) . getDemodMgr ( ) . setLastMuted ( demod - > isMuted ( ) ) ;
2016-02-15 17:43:10 -05:00
demodMuteButton - > Refresh ( ) ;
2015-08-17 00:59:38 -04:00
} else if ( ! demod - > isMuted ( ) & & muteMode = = 1 ) {
demodMuteButton - > setSelection ( - 1 ) ;
2015-08-19 17:06:06 -04:00
wxGetApp ( ) . getDemodMgr ( ) . setLastMuted ( demod - > isMuted ( ) ) ;
2016-02-15 17:43:10 -05:00
demodMuteButton - > Refresh ( ) ;
}
}
int deltaMode = deltaLockButton - > getSelection ( ) ;
if ( deltaLockButton - > modeChanged ( ) ) {
if ( demod - > isDeltaLock ( ) & & deltaMode = = - 1 ) {
demod - > setDeltaLock ( false ) ;
} else if ( ! demod - > isDeltaLock ( ) & & deltaMode = = 1 ) {
demod - > setDeltaLockOfs ( demod - > getFrequency ( ) - wxGetApp ( ) . getFrequency ( ) ) ;
demod - > setDeltaLock ( true ) ;
}
wxGetApp ( ) . getDemodMgr ( ) . setLastDeltaLock ( demod - > isDeltaLock ( ) ) ;
deltaLockButton - > clearModeChanged ( ) ;
} else {
if ( demod - > isDeltaLock ( ) & & deltaMode = = - 1 ) {
deltaLockButton - > setSelection ( 1 ) ;
wxGetApp ( ) . getDemodMgr ( ) . setLastDeltaLock ( true ) ;
deltaLockButton - > Refresh ( ) ;
} else if ( ! demod - > isDeltaLock ( ) & & deltaMode = = 1 ) {
deltaLockButton - > setSelection ( - 1 ) ;
wxGetApp ( ) . getDemodMgr ( ) . setLastDeltaLock ( false ) ;
deltaLockButton - > Refresh ( ) ;
2015-08-17 00:59:38 -04:00
}
}
2016-02-11 01:09:15 -05:00
int soloMode = soloModeButton - > getSelection ( ) ;
if ( soloModeButton - > modeChanged ( ) ) {
if ( soloMode = = 1 ) {
wxGetApp ( ) . setSoloMode ( true ) ;
} else {
wxGetApp ( ) . setSoloMode ( false ) ;
}
soloModeButton - > clearModeChanged ( ) ;
} else {
if ( wxGetApp ( ) . getSoloMode ( ) ! = ( soloMode = = 1 ) ) {
soloModeButton - > setSelection ( wxGetApp ( ) . getSoloMode ( ) ? 1 : - 1 ) ;
soloModeButton - > Refresh ( ) ;
}
}
2015-01-03 17:07:39 -05:00
demodWaterfallCanvas - > setBandwidth ( demodBw ) ;
demodSpectrumCanvas - > setBandwidth ( demodBw ) ;
2014-12-28 05:13:46 -05:00
}
2014-12-31 19:45:01 -05:00
demodSignalMeter - > setLevel ( demod - > getSignalLevel ( ) ) ;
2015-01-10 20:33:30 -05:00
demodGainMeter - > setLevel ( demod - > getGain ( ) ) ;
2014-12-31 19:45:01 -05:00
if ( demodSignalMeter - > inputChanged ( ) ) {
demod - > setSquelchLevel ( demodSignalMeter - > getInputValue ( ) ) ;
}
2015-01-10 20:33:30 -05:00
if ( demodGainMeter - > inputChanged ( ) ) {
demod - > setGain ( demodGainMeter - > getInputValue ( ) ) ;
demodGainMeter - > setLevel ( demodGainMeter - > getInputValue ( ) ) ;
}
2014-12-31 19:45:01 -05:00
activeDemodulator = demod ;
2015-11-26 22:06:29 -05:00
} else if ( demod ) {
// Wait state for current demodulator modem to activate..
2015-02-02 20:10:55 -05:00
} else {
DemodulatorMgr * mgr = & wxGetApp ( ) . getDemodMgr ( ) ;
2015-11-17 18:57:42 -05:00
std : : string dSelection = demodModeSelector - > getSelectionLabel ( ) ;
2015-11-15 13:52:54 -05:00
# ifdef ENABLE_DIGITAL_LAB
2015-11-17 18:57:42 -05:00
std : : string dSelectionadv = demodModeSelectorAdv - > getSelectionLabel ( ) ;
2015-06-10 13:39:08 -04:00
2015-06-10 04:50:14 -04:00
// basic demodulators
2015-11-17 18:57:42 -05:00
if ( dSelection ! = " " & & dSelection ! = mgr - > getLastDemodulatorType ( ) ) {
2015-02-02 20:10:55 -05:00
mgr - > setLastDemodulatorType ( dSelection ) ;
2015-12-11 22:21:41 -05:00
mgr - > setLastBandwidth ( Modem : : getModemDefaultSampleRate ( dSelection ) ) ;
demodTuner - > setHalfBand ( dSelection = = " USB " | | dSelection = = " LSB " ) ;
2015-06-09 11:00:05 -04:00
demodModeSelectorAdv - > setSelection ( - 1 ) ;
2015-02-02 20:10:55 -05:00
}
2015-06-10 04:50:14 -04:00
// advanced demodulators
2015-11-17 18:57:42 -05:00
else if ( dSelectionadv ! = " " & & dSelectionadv ! = mgr - > getLastDemodulatorType ( ) ) {
2015-06-04 16:38:43 -04:00
mgr - > setLastDemodulatorType ( dSelectionadv ) ;
2015-12-11 22:21:41 -05:00
mgr - > setLastBandwidth ( Modem : : getModemDefaultSampleRate ( dSelectionadv ) ) ;
demodTuner - > setHalfBand ( false ) ;
2015-06-04 16:38:43 -04:00
demodModeSelector - > setSelection ( - 1 ) ;
2015-02-02 20:10:55 -05:00
}
2015-11-15 13:52:54 -05:00
# else
// basic demodulators
2015-11-19 00:39:14 -05:00
if ( dSelection ! = " " & & dSelection ! = mgr - > getLastDemodulatorType ( ) ) {
2015-11-15 13:52:54 -05:00
mgr - > setLastDemodulatorType ( dSelection ) ;
2015-12-14 19:31:18 -05:00
mgr - > setLastBandwidth ( Modem : : getModemDefaultSampleRate ( dSelection ) ) ;
2015-12-11 22:21:41 -05:00
demodTuner - > setHalfBand ( dSelection = = " USB " | | dSelection = = " LSB " ) ;
2015-11-15 13:52:54 -05:00
}
# endif
2015-02-02 20:10:55 -05:00
demodGainMeter - > setLevel ( mgr - > getLastGain ( ) ) ;
if ( demodSignalMeter - > inputChanged ( ) ) {
mgr - > setLastSquelchLevel ( demodSignalMeter - > getInputValue ( ) ) ;
}
if ( demodGainMeter - > inputChanged ( ) ) {
mgr - > setLastGain ( demodGainMeter - > getInputValue ( ) ) ;
demodGainMeter - > setLevel ( demodGainMeter - > getInputValue ( ) ) ;
}
2015-02-05 20:54:04 -05:00
2015-03-29 20:24:00 -04:00
if ( wxGetApp ( ) . getFrequency ( ) ! = demodWaterfallCanvas - > getCenterFrequency ( ) ) {
2015-02-05 20:54:04 -05:00
demodWaterfallCanvas - > setCenterFrequency ( wxGetApp ( ) . getFrequency ( ) ) ;
demodSpectrumCanvas - > setCenterFrequency ( wxGetApp ( ) . getFrequency ( ) ) ;
}
2015-03-31 17:51:56 -04:00
if ( spectrumCanvas - > getViewState ( ) & & abs ( wxGetApp ( ) . getFrequency ( ) - spectrumCanvas - > getCenterFrequency ( ) ) > ( wxGetApp ( ) . getSampleRate ( ) / 2 ) ) {
spectrumCanvas - > setCenterFrequency ( wxGetApp ( ) . getFrequency ( ) ) ;
waterfallCanvas - > setCenterFrequency ( wxGetApp ( ) . getFrequency ( ) ) ;
}
2015-08-19 17:06:06 -04:00
if ( demodMuteButton - > modeChanged ( ) ) {
int muteMode = demodMuteButton - > getSelection ( ) ;
if ( muteMode = = - 1 ) {
wxGetApp ( ) . getDemodMgr ( ) . setLastMuted ( false ) ;
} else if ( muteMode = = 1 ) {
wxGetApp ( ) . getDemodMgr ( ) . setLastMuted ( true ) ;
}
demodMuteButton - > clearModeChanged ( ) ;
}
2014-12-28 05:13:46 -05:00
}
2015-04-22 22:54:48 -04:00
scopeCanvas - > setPPMMode ( demodTuner - > isAltDown ( ) ) ;
2015-08-03 01:38:38 -04:00
2015-08-24 01:31:37 -04:00
scopeCanvas - > setShowDb ( spectrumCanvas - > getShowDb ( ) ) ;
wxGetApp ( ) . getScopeProcessor ( ) - > setScopeEnabled ( scopeCanvas - > scopeVisible ( ) ) ;
wxGetApp ( ) . getScopeProcessor ( ) - > setSpectrumEnabled ( scopeCanvas - > spectrumVisible ( ) ) ;
wxGetApp ( ) . getAudioVisualQueue ( ) - > set_max_num_items ( ( scopeCanvas - > scopeVisible ( ) ? 1 : 0 ) + ( scopeCanvas - > spectrumVisible ( ) ? 1 : 0 ) ) ;
2015-08-08 14:52:01 -04:00
wxGetApp ( ) . getScopeProcessor ( ) - > run ( ) ;
2015-08-12 22:14:14 -04:00
2015-08-16 18:12:12 -04:00
SpectrumVisualProcessor * proc = wxGetApp ( ) . getSpectrumProcessor ( ) ;
2015-10-21 19:50:53 -04:00
2015-08-12 22:14:14 -04:00
if ( spectrumAvgMeter - > inputChanged ( ) ) {
float val = spectrumAvgMeter - > getInputValue ( ) ;
2015-08-14 21:36:31 -04:00
if ( val < 0.01 ) {
2016-06-01 19:42:34 -04:00
val = 0.01f ;
2015-08-14 21:36:31 -04:00
}
2015-08-18 00:08:22 -04:00
if ( val > 0.99 ) {
2016-06-01 19:42:34 -04:00
val = 0.99f ;
2015-08-18 00:08:22 -04:00
}
2015-08-12 22:14:14 -04:00
spectrumAvgMeter - > setLevel ( val ) ;
proc - > setFFTAverageRate ( val ) ;
2015-08-13 20:39:31 -04:00
GetStatusBar ( ) - > SetStatusText ( wxString : : Format ( wxT ( " Spectrum averaging speed changed to %0.2f%%. " ) , val * 100.0 ) ) ;
2015-08-12 22:14:14 -04:00
}
2015-08-16 18:12:12 -04:00
SpectrumVisualProcessor * dproc = wxGetApp ( ) . getDemodSpectrumProcessor ( ) ;
2015-08-03 01:38:38 -04:00
2015-12-12 17:28:17 -05:00
dproc - > setView ( demodWaterfallCanvas - > getViewState ( ) , demodWaterfallCanvas - > getCenterFrequency ( ) , demodWaterfallCanvas - > getBandwidth ( ) ) ;
2015-08-08 13:26:53 -04:00
2015-08-14 19:17:43 -04:00
SpectrumVisualProcessor * wproc = waterfallDataThread - > getProcessor ( ) ;
2015-10-21 19:50:53 -04:00
2015-08-11 23:52:03 -04:00
if ( waterfallSpeedMeter - > inputChanged ( ) ) {
2015-08-12 20:05:57 -04:00
float val = waterfallSpeedMeter - > getInputValue ( ) ;
waterfallSpeedMeter - > setLevel ( val ) ;
2015-08-14 19:17:43 -04:00
waterfallDataThread - > setLinesPerSecond ( ( int ) ceil ( val * val ) ) ;
2015-09-09 23:29:38 -04:00
waterfallCanvas - > setLinesPerSecond ( ( int ) ceil ( val * val ) ) ;
2015-08-13 20:39:31 -04:00
GetStatusBar ( ) - > SetStatusText ( wxString : : Format ( wxT ( " Waterfall max speed changed to %d lines per second. " ) , ( int ) ceil ( val * val ) ) ) ;
2015-08-08 13:26:53 -04:00
}
2015-08-11 23:52:03 -04:00
2015-12-12 17:28:17 -05:00
wproc - > setView ( waterfallCanvas - > getViewState ( ) , waterfallCanvas - > getCenterFrequency ( ) , waterfallCanvas - > getBandwidth ( ) ) ;
2015-10-18 12:26:07 -04:00
wxGetApp ( ) . getSDRPostThread ( ) - > setIQVisualRange ( waterfallCanvas - > getCenterFrequency ( ) , waterfallCanvas - > getBandwidth ( ) ) ;
2015-08-11 00:50:43 -04:00
2015-12-12 17:28:17 -05:00
proc - > setView ( wproc - > isView ( ) , wproc - > getCenterFrequency ( ) , wproc - > getBandwidth ( ) ) ;
2015-11-26 01:54:54 -05:00
demod = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ;
2015-11-27 00:05:21 -05:00
if ( modemPropertiesUpdated . load ( ) & & demod & & demod - > isModemInitialized ( ) ) {
2015-11-26 01:54:54 -05:00
modemProps - > initProperties ( demod - > getModemArgs ( ) ) ;
2015-11-23 22:03:14 -05:00
modemPropertiesUpdated . store ( false ) ;
2015-11-24 23:00:43 -05:00
demodTray - > Layout ( ) ;
2015-11-28 23:03:07 -05:00
# if ENABLE_DIGITAL_LAB
if ( demod - > getModemType ( ) = = " digital " ) {
ModemDigitalOutputConsole * outp = ( ModemDigitalOutputConsole * ) demod - > getOutput ( ) ;
if ( ! outp - > getDialog ( ) ) {
outp - > setTitle ( demod - > getDemodulatorType ( ) + " : " + frequencyToStr ( demod - > getFrequency ( ) ) ) ;
outp - > setDialog ( new DigitalConsole ( this , outp ) ) ;
}
demod - > showOutput ( ) ;
}
# endif
2015-11-23 22:03:14 -05:00
}
2015-11-28 23:03:07 -05:00
2015-12-31 20:44:39 -05:00
int peakHoldMode = peakHoldButton - > getSelection ( ) ;
if ( peakHoldButton - > modeChanged ( ) ) {
wxGetApp ( ) . getSpectrumProcessor ( ) - > setPeakHold ( peakHoldMode = = 1 ) ;
2016-06-09 13:33:52 -04:00
//make the peak hold act on the current dmod also, like a zoomed-in version.
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > setPeakHold ( peakHoldMode = = 1 ) ;
2015-12-31 20:44:39 -05:00
peakHoldButton - > clearModeChanged ( ) ;
}
2016-02-15 13:04:18 -05:00
# if USE_HAMLIB
if ( rigEnableMenuItem - > IsChecked ( ) ) {
if ( ! wxGetApp ( ) . rigIsActive ( ) ) {
rigEnableMenuItem - > Check ( false ) ;
2016-02-16 01:13:26 -05:00
wxGetApp ( ) . getConfig ( ) - > setRigEnabled ( false ) ;
2016-02-15 13:04:18 -05:00
}
}
# endif
2016-05-30 19:25:46 -04:00
# ifdef _WIN32
2016-05-30 19:45:38 -04:00
if ( scopeCanvas - > HasFocus ( ) ) {
2016-05-30 19:25:46 -04:00
waterfallCanvas - > SetFocus ( ) ;
}
# endif
2015-08-14 20:41:52 -04:00
if ( ! this - > IsActive ( ) ) {
2016-03-31 21:32:50 -04:00
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 30 ) ) ;
2016-02-07 18:01:11 -05:00
} else {
2016-03-31 21:32:50 -04:00
if ( lowPerfMode ) {
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 30 ) ) ;
} else {
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1 ) ) ;
}
2015-08-13 20:39:31 -04:00
}
2016-01-03 19:00:26 -05:00
2015-08-12 18:07:06 -04:00
event . RequestMore ( ) ;
2014-10-28 21:39:59 -04:00
}
2015-01-09 17:17:56 -05:00
2015-10-25 14:09:59 -04:00
void AppFrame : : OnDoubleClickSash ( wxSplitterEvent & event )
{
wxWindow * a , * b ;
wxSplitterWindow * w = NULL ;
float g = 0.5 ;
if ( event . GetId ( ) = = wxID_MAIN_SPLITTER ) {
w = mainSplitter ;
2016-06-01 19:42:34 -04:00
g = 10.0f / 37.0f ;
2015-10-25 14:09:59 -04:00
} else if ( event . GetId ( ) = = wxID_VIS_SPLITTER ) {
w = mainVisSplitter ;
2016-06-01 19:42:34 -04:00
g = 6.0f / 25.0f ;
2015-10-25 14:09:59 -04:00
}
if ( w ! = NULL ) {
a = w - > GetWindow1 ( ) ;
b = w - > GetWindow2 ( ) ;
w - > Unsplit ( ) ;
w - > SetSashGravity ( g ) ;
wxSize s = w - > GetSize ( ) ;
w - > SplitHorizontally ( a , b , int ( float ( s . GetHeight ( ) ) * g ) ) ;
}
event . Veto ( ) ;
}
void AppFrame : : OnUnSplit ( wxSplitterEvent & event )
{
event . Veto ( ) ;
}
2016-06-20 13:28:26 -04:00
2015-01-09 17:17:56 -05:00
void AppFrame : : saveSession ( std : : string fileName ) {
DataTree s ( " cubicsdr_session " ) ;
2015-01-09 20:56:43 -05:00
DataNode * header = s . rootNode ( ) - > newChild ( " header " ) ;
* header - > newChild ( " version " ) = std : : string ( CUBICSDR_VERSION ) ;
* header - > newChild ( " center_freq " ) = wxGetApp ( ) . getFrequency ( ) ;
2016-01-10 15:08:08 -05:00
* header - > newChild ( " sample_rate " ) = wxGetApp ( ) . getSampleRate ( ) ;
2015-01-09 20:56:43 -05:00
DataNode * demods = s . rootNode ( ) - > newChild ( " demodulators " ) ;
2015-01-09 17:17:56 -05:00
std : : vector < DemodulatorInstance * > & instances = wxGetApp ( ) . getDemodMgr ( ) . getDemodulators ( ) ;
std : : vector < DemodulatorInstance * > : : iterator instance_i ;
for ( instance_i = instances . begin ( ) ; instance_i ! = instances . end ( ) ; instance_i + + ) {
2015-01-09 20:56:43 -05:00
DataNode * demod = demods - > newChild ( " demodulator " ) ;
* demod - > newChild ( " bandwidth " ) = ( * instance_i ) - > getBandwidth ( ) ;
* demod - > newChild ( " frequency " ) = ( * instance_i ) - > getFrequency ( ) ;
* demod - > newChild ( " type " ) = ( * instance_i ) - > getDemodulatorType ( ) ;
2016-06-12 09:31:55 -04:00
2016-06-12 22:49:13 -04:00
demod - > newChild ( " user_label " ) - > element ( ) - > set ( ( * instance_i ) - > getDemodulatorUserLabel ( ) ) ;
2016-06-12 09:31:55 -04:00
2015-01-09 20:56:43 -05:00
* demod - > newChild ( " squelch_level " ) = ( * instance_i ) - > getSquelchLevel ( ) ;
2015-01-10 12:27:03 -05:00
* demod - > newChild ( " squelch_enabled " ) = ( * instance_i ) - > isSquelchEnabled ( ) ? 1 : 0 ;
2015-01-09 20:56:43 -05:00
* demod - > newChild ( " output_device " ) = outputDevices [ ( * instance_i ) - > getOutputDevice ( ) ] . name ;
2015-01-10 20:33:30 -05:00
* demod - > newChild ( " gain " ) = ( * instance_i ) - > getGain ( ) ;
2015-08-17 00:59:38 -04:00
* demod - > newChild ( " muted " ) = ( * instance_i ) - > isMuted ( ) ? 1 : 0 ;
2016-02-15 17:43:10 -05:00
if ( ( * instance_i ) - > isDeltaLock ( ) ) {
* demod - > newChild ( " delta_lock " ) = ( * instance_i ) - > isDeltaLock ( ) ? 1 : 0 ;
* demod - > newChild ( " delta_ofs " ) = ( * instance_i ) - > getDeltaLockOfs ( ) ;
}
2016-01-11 19:30:56 -05:00
if ( ( * instance_i ) = = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ) {
* demod - > newChild ( " active " ) = 1 ;
}
2015-11-27 00:05:21 -05:00
ModemSettings saveSettings = ( * instance_i ) - > readModemSettings ( ) ;
if ( saveSettings . size ( ) ) {
DataNode * settingsNode = demod - > newChild ( " settings " ) ;
for ( ModemSettings : : const_iterator msi = saveSettings . begin ( ) ; msi ! = saveSettings . end ( ) ; msi + + ) {
* settingsNode - > newChild ( msi - > first . c_str ( ) ) = msi - > second ;
}
}
2016-06-20 13:28:26 -04:00
} //end for demodulators
2015-01-09 17:17:56 -05:00
s . SaveToFileXML ( fileName ) ;
2015-01-10 20:33:30 -05:00
currentSessionFile = fileName ;
2015-01-11 17:08:16 -05:00
std : : string filePart = fileName . substr ( fileName . find_last_of ( filePathSeparator ) + 1 ) ;
2015-01-10 20:33:30 -05:00
GetStatusBar ( ) - > SetStatusText ( wxString : : Format ( wxT ( " Saved session: %s " ) , currentSessionFile . c_str ( ) ) ) ;
SetTitle ( wxString : : Format ( wxT ( " %s: %s " ) , CUBICSDR_TITLE , filePart . c_str ( ) ) ) ;
2015-01-09 17:17:56 -05:00
}
bool AppFrame : : loadSession ( std : : string fileName ) {
2015-01-09 20:56:43 -05:00
DataTree l ;
if ( ! l . LoadFromFileXML ( fileName ) ) {
return false ;
}
2016-06-01 19:57:18 -04:00
wxGetApp ( ) . getDemodMgr ( ) . setActiveDemodulator ( nullptr , false ) ;
2015-01-10 12:27:03 -05:00
wxGetApp ( ) . getDemodMgr ( ) . terminateAll ( ) ;
2015-01-09 20:56:43 -05:00
try {
2016-06-02 19:25:52 -04:00
if ( ! l . rootNode ( ) - > hasAnother ( " header " ) ) {
return false ;
}
2015-01-09 20:56:43 -05:00
DataNode * header = l . rootNode ( ) - > getNext ( " header " ) ;
2016-06-02 19:25:52 -04:00
if ( header - > hasAnother ( " version " ) ) {
2016-06-02 17:56:31 -04:00
std : : string version ( * header - > getNext ( " version " ) ) ;
2016-06-02 19:25:52 -04:00
// std::cout << "Loading " << version << " session file" << std::endl;
}
2016-01-10 15:08:08 -05:00
2016-06-02 19:25:52 -04:00
if ( header - > hasAnother ( " center_freq " ) ) {
2016-06-02 17:56:31 -04:00
long long center_freq = * header - > getNext ( " center_freq " ) ;
2016-06-02 19:25:52 -04:00
// std::cout << "\tCenter Frequency: " << center_freq << std::endl;
2016-05-11 22:37:25 -04:00
2016-06-02 17:56:31 -04:00
wxGetApp ( ) . setFrequency ( center_freq ) ;
}
2016-05-11 22:37:25 -04:00
2016-01-10 15:08:08 -05:00
if ( header - > hasAnother ( " sample_rate " ) ) {
int sample_rate = * header - > getNext ( " sample_rate " ) ;
SDRDeviceInfo * dev = wxGetApp ( ) . getSDRThread ( ) - > getDevice ( ) ;
if ( dev ) {
2016-01-31 15:11:54 -05:00
// Try for a reasonable default sample rate.
sample_rate = dev - > getSampleRateNear ( SOAPY_SDR_RX , 0 , sample_rate ) ;
2016-01-10 15:08:08 -05:00
wxGetApp ( ) . setSampleRate ( sample_rate ) ;
deviceChanged . store ( true ) ;
} else {
wxGetApp ( ) . setSampleRate ( sample_rate ) ;
}
}
2015-01-09 20:56:43 -05:00
2016-06-02 19:25:52 -04:00
if ( l . rootNode ( ) - > hasAnother ( " demodulators " ) ) {
2016-06-02 17:56:31 -04:00
DataNode * demodulators = l . rootNode ( ) - > getNext ( " demodulators " ) ;
2015-01-09 20:56:43 -05:00
2016-06-02 17:56:31 -04:00
int numDemodulators = 0 ;
DemodulatorInstance * loadedDemod = NULL ;
DemodulatorInstance * newDemod = NULL ;
std : : vector < DemodulatorInstance * > demodsLoaded ;
while ( demodulators - > hasAnother ( " demodulator " ) ) {
DataNode * demod = demodulators - > getNext ( " demodulator " ) ;
2015-11-27 00:16:13 -05:00
2016-06-02 17:56:31 -04:00
if ( ! demod - > hasAnother ( " bandwidth " ) | | ! demod - > hasAnother ( " frequency " ) ) {
continue ;
}
2015-11-27 00:05:21 -05:00
2016-06-02 17:56:31 -04:00
long bandwidth = * demod - > getNext ( " bandwidth " ) ;
long long freq = * demod - > getNext ( " frequency " ) ;
float squelch_level = demod - > hasAnother ( " squelch_level " ) ? ( float ) * demod - > getNext ( " squelch_level " ) : 0 ;
int squelch_enabled = demod - > hasAnother ( " squelch_enabled " ) ? ( int ) * demod - > getNext ( " squelch_enabled " ) : 0 ;
int muted = demod - > hasAnother ( " muted " ) ? ( int ) * demod - > getNext ( " muted " ) : 0 ;
int delta_locked = demod - > hasAnother ( " delta_lock " ) ? ( int ) * demod - > getNext ( " delta_lock " ) : 0 ;
int delta_ofs = demod - > hasAnother ( " delta_ofs " ) ? ( int ) * demod - > getNext ( " delta_ofs " ) : 0 ;
std : : string output_device = demod - > hasAnother ( " output_device " ) ? string ( * ( demod - > getNext ( " output_device " ) ) ) : " " ;
float gain = demod - > hasAnother ( " gain " ) ? ( float ) * demod - > getNext ( " gain " ) : 1.0 ;
std : : string type = " FM " ;
2016-06-11 01:46:07 -04:00
2016-06-02 17:56:31 -04:00
DataNode * demodTypeNode = demod - > hasAnother ( " type " ) ? demod - > getNext ( " type " ) : nullptr ;
if ( demodTypeNode & & demodTypeNode - > element ( ) - > getDataType ( ) = = DATA_INT ) {
int legacyType = * demodTypeNode ;
int legacyStereo = demod - > hasAnother ( " stereo " ) ? ( int ) * demod - > getNext ( " stereo " ) : 0 ;
switch ( legacyType ) { // legacy demod ID
case 1 : type = legacyStereo ? " FMS " : " FM " ; break ;
case 2 : type = " AM " ; break ;
case 3 : type = " LSB " ; break ;
case 4 : type = " USB " ; break ;
case 5 : type = " DSB " ; break ;
case 6 : type = " ASK " ; break ;
case 7 : type = " APSK " ; break ;
case 8 : type = " BPSK " ; break ;
case 9 : type = " DPSK " ; break ;
case 10 : type = " PSK " ; break ;
case 11 : type = " OOK " ; break ;
case 12 : type = " ST " ; break ;
case 13 : type = " SQAM " ; break ;
case 14 : type = " QAM " ; break ;
case 15 : type = " QPSK " ; break ;
case 16 : type = " I/Q " ; break ;
default : type = " FM " ; break ;
2015-11-27 00:05:21 -05:00
}
2016-06-02 17:56:31 -04:00
} else if ( demodTypeNode & & demodTypeNode - > element ( ) - > getDataType ( ) = = DATA_STRING ) {
demodTypeNode - > element ( ) - > get ( type ) ;
}
2016-01-11 19:30:56 -05:00
2016-06-11 01:46:07 -04:00
//read the user label associated with the demodulator
2016-06-12 09:31:55 -04:00
std : : wstring user_label = L " " ;
2016-06-11 01:46:07 -04:00
DataNode * demodUserLabel = demod - > hasAnother ( " user_label " ) ? demod - > getNext ( " user_label " ) : nullptr ;
2016-06-11 07:15:01 -04:00
if ( demodUserLabel ) {
2016-06-13 15:31:17 -04:00
2016-06-12 22:49:13 -04:00
demodUserLabel - > element ( ) - > get ( user_label ) ;
2016-06-11 01:46:07 -04:00
}
2016-06-11 07:15:01 -04:00
2016-06-11 01:46:07 -04:00
2016-06-02 17:56:31 -04:00
ModemSettings mSettings ;
if ( demod - > hasAnother ( " settings " ) ) {
DataNode * modemSettings = demod - > getNext ( " settings " ) ;
for ( int msi = 0 , numSettings = modemSettings - > numChildren ( ) ; msi < numSettings ; msi + + ) {
DataNode * settingNode = modemSettings - > child ( msi ) ;
std : : string keyName = settingNode - > getName ( ) ;
std : : string strSettingValue = settingNode - > element ( ) - > toString ( ) ;
if ( keyName ! = " " & & strSettingValue ! = " " ) {
mSettings [ keyName ] = strSettingValue ;
2016-06-02 19:25:52 -04:00
}
}
2016-06-02 17:56:31 -04:00
}
2016-06-11 01:46:07 -04:00
2016-06-02 17:56:31 -04:00
newDemod = wxGetApp ( ) . getDemodMgr ( ) . newThread ( ) ;
2016-01-11 19:30:56 -05:00
2016-06-02 17:56:31 -04:00
if ( demod - > hasAnother ( " active " ) ) {
loadedDemod = newDemod ;
}
2015-01-10 12:27:03 -05:00
2016-06-02 17:56:31 -04:00
numDemodulators + + ;
newDemod - > setDemodulatorType ( type ) ;
2016-06-11 01:46:07 -04:00
newDemod - > setDemodulatorUserLabel ( user_label ) ;
2016-06-02 17:56:31 -04:00
newDemod - > writeModemSettings ( mSettings ) ;
newDemod - > setBandwidth ( bandwidth ) ;
newDemod - > setFrequency ( freq ) ;
newDemod - > setGain ( gain ) ;
newDemod - > updateLabel ( freq ) ;
newDemod - > setMuted ( muted ? true : false ) ;
if ( delta_locked ) {
newDemod - > setDeltaLock ( true ) ;
newDemod - > setDeltaLockOfs ( delta_ofs ) ;
}
if ( squelch_enabled ) {
newDemod - > setSquelchEnabled ( true ) ;
newDemod - > setSquelchLevel ( squelch_level ) ;
}
bool found_device = false ;
std : : map < int , RtAudio : : DeviceInfo > : : iterator i ;
for ( i = outputDevices . begin ( ) ; i ! = outputDevices . end ( ) ; i + + ) {
if ( i - > second . name = = output_device ) {
newDemod - > setOutputDevice ( i - > first ) ;
found_device = true ;
2016-06-02 19:25:52 -04:00
}
2016-06-02 17:56:31 -04:00
}
2015-01-10 12:27:03 -05:00
2016-06-02 19:25:52 -04:00
// if (!found_device) {
// std::cout << "\tWarning: named output device '" << output_device << "' was not found. Using default output.";
// }
2015-01-09 20:56:43 -05:00
2016-06-02 17:56:31 -04:00
newDemod - > run ( ) ;
newDemod - > setActive ( true ) ;
demodsLoaded . push_back ( newDemod ) ;
// wxGetApp().bindDemodulator(newDemod);
2016-06-02 19:25:52 -04:00
2016-06-02 19:45:34 -04:00
std : : cout < < " \t Added demodulator at frequency " < < newDemod - > getFrequency ( ) < < " type " < < type < < std : : endl ;
2016-06-02 19:25:52 -04:00
// std::cout << "\t\tBandwidth: " << bandwidth << std::endl;
// std::cout << "\t\tSquelch Level: " << squelch_level << std::endl;
// std::cout << "\t\tSquelch Enabled: " << (squelch_enabled ? "true" : "false") << std::endl;
// std::cout << "\t\tOutput Device: " << output_device << std::endl;
2016-06-02 17:56:31 -04:00
}
DemodulatorInstance * focusDemod = loadedDemod ? loadedDemod : newDemod ;
if ( focusDemod ) {
wxGetApp ( ) . bindDemodulators ( & demodsLoaded ) ;
wxGetApp ( ) . getDemodMgr ( ) . setActiveDemodulator ( focusDemod , false ) ;
}
2015-08-16 22:31:14 -04:00
}
2015-01-09 20:56:43 -05:00
} catch ( DataTypeMismatchException & e ) {
std : : cout < < e . what ( ) < < std : : endl ;
return false ;
}
2016-06-02 17:56:31 -04:00
2015-01-10 12:27:03 -05:00
currentSessionFile = fileName ;
2015-01-10 20:33:30 -05:00
2015-01-11 17:08:16 -05:00
std : : string filePart = fileName . substr ( fileName . find_last_of ( filePathSeparator ) + 1 ) ;
2015-01-10 20:33:30 -05:00
GetStatusBar ( ) - > SetStatusText ( wxString : : Format ( wxT ( " Loaded session file: %s " ) , currentSessionFile . c_str ( ) ) ) ;
SetTitle ( wxString : : Format ( wxT ( " %s: %s " ) , CUBICSDR_TITLE , filePart . c_str ( ) ) ) ;
2015-01-20 19:13:49 -05:00
return true ;
2015-01-09 17:17:56 -05:00
}
2015-10-25 00:07:01 -04:00
FFTVisualDataThread * AppFrame : : getWaterfallDataThread ( ) {
return waterfallDataThread ;
}
2015-11-23 22:03:14 -05:00
void AppFrame : : updateModemProperties ( ModemArgInfoList args ) {
newModemArgs = args ;
modemPropertiesUpdated . store ( true ) ;
}
2015-12-29 20:52:49 -05:00
void AppFrame : : setMainWaterfallFFTSize ( int fftSize ) {
wxGetApp ( ) . getSpectrumProcessor ( ) - > setFFTSize ( fftSize ) ;
spectrumCanvas - > setFFTSize ( fftSize ) ;
waterfallDataThread - > getProcessor ( ) - > setFFTSize ( fftSize ) ;
waterfallCanvas - > setFFTSize ( fftSize ) ;
}
2016-02-07 18:01:11 -05:00
2016-02-07 22:19:05 -05:00
void AppFrame : : refreshGainUI ( ) {
gainCanvas - > updateGainUI ( ) ;
gainCanvas - > Refresh ( ) ;
}
2016-05-30 00:17:08 -04:00
# ifdef _WIN32
2016-05-29 21:03:21 -04:00
bool AppFrame : : canFocus ( ) {
return ( ! wxGetApp ( ) . isDeviceSelectorOpen ( ) & & ( ! modemProps | | ! modemProps - > isMouseInView ( ) ) ) ;
}
2016-05-30 00:17:08 -04:00
# endif
2016-05-29 21:03:21 -04:00
2016-02-07 21:05:49 -05:00
FrequencyDialog : : FrequencyDialogTarget AppFrame : : getFrequencyDialogTarget ( ) {
FrequencyDialog : : FrequencyDialogTarget target = FrequencyDialog : : FrequencyDialogTarget : : FDIALOG_TARGET_DEFAULT ;
if ( waterfallSpeedMeter - > getMouseTracker ( ) - > mouseInView ( ) ) {
target = FrequencyDialog : : FrequencyDialogTarget : : FDIALOG_TARGET_WATERFALL_LPS ;
}
else if ( spectrumAvgMeter - > getMouseTracker ( ) - > mouseInView ( ) ) {
target = FrequencyDialog : : FrequencyDialogTarget : : FDIALOG_TARGET_SPECTRUM_AVG ;
2016-02-07 22:19:05 -05:00
}
else if ( demodTuner - > getMouseTracker ( ) - > mouseInView ( ) ) {
2016-02-07 21:05:49 -05:00
switch ( demodTuner - > getHoverState ( ) ) {
case TuningCanvas : : ActiveState : : TUNING_HOVER_BW :
target = FrequencyDialog : : FrequencyDialogTarget : : FDIALOG_TARGET_BANDWIDTH ;
break ;
case TuningCanvas : : ActiveState : : TUNING_HOVER_FREQ :
target = FrequencyDialog : : FrequencyDialogTarget : : FDIALOG_TARGET_FREQ ;
break ;
case TuningCanvas : : ActiveState : : TUNING_HOVER_CENTER :
default :
target = FrequencyDialog : : FrequencyDialogTarget : : FDIALOG_TARGET_DEFAULT ;
break ;
}
}
2016-02-07 22:19:05 -05:00
else if ( gainCanvas - > getMouseTracker ( ) - > mouseInView ( ) ) {
target = FrequencyDialog : : FrequencyDialogTarget : : FDIALOG_TARGET_GAIN ;
}
2016-02-07 21:05:49 -05:00
return target ;
}
2016-05-18 23:12:48 -04:00
void AppFrame : : gkNudgeLeft ( DemodulatorInstance * demod , int snap ) {
if ( demod ) {
demod - > setFrequency ( demod - > getFrequency ( ) - snap ) ;
demod - > updateLabel ( demod - > getFrequency ( ) ) ;
}
}
void AppFrame : : gkNudgeRight ( DemodulatorInstance * demod , int snap ) {
if ( demod ) {
demod - > setFrequency ( demod - > getFrequency ( ) + snap ) ;
demod - > updateLabel ( demod - > getFrequency ( ) ) ;
}
}
2016-02-07 18:01:11 -05:00
int AppFrame : : OnGlobalKeyDown ( wxKeyEvent & event ) {
if ( ! this - > IsActive ( ) ) {
return - 1 ;
}
2016-05-19 19:23:56 -04:00
if ( modemProps & & ( modemProps - > HasFocus ( ) | | modemProps - > isMouseInView ( ) ) ) {
return - 1 ;
}
2016-02-07 18:01:11 -05:00
2016-02-11 00:08:56 -05:00
DemodulatorInstance * demod = nullptr , * lastDemod = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ;
2016-02-12 20:38:05 -05:00
int snap = wxGetApp ( ) . getFrequencySnap ( ) ;
2016-02-11 00:08:56 -05:00
2016-02-14 06:10:42 -05:00
if ( event . ShiftDown ( ) ) {
if ( snap ! = 1 ) {
snap / = 2 ;
}
}
2016-05-18 23:12:48 -04:00
# ifdef wxHAS_RAW_KEY_CODES
switch ( event . GetRawKeyCode ( ) ) {
case 30 :
gkNudgeRight ( lastDemod , snap ) ;
return 1 ;
case 33 :
gkNudgeLeft ( lastDemod , snap ) ;
return 1 ;
}
# endif
2016-02-07 18:01:11 -05:00
switch ( event . GetKeyCode ( ) ) {
case WXK_UP :
case WXK_NUMPAD_UP :
case WXK_DOWN :
case WXK_NUMPAD_DOWN :
case WXK_LEFT :
case WXK_NUMPAD_LEFT :
case WXK_RIGHT :
case WXK_NUMPAD_RIGHT :
2016-02-12 20:38:05 -05:00
waterfallCanvas - > OnKeyDown ( event ) ; // TODO: Move the stuff from there to here
2016-02-08 23:40:09 -05:00
return 1 ;
2016-02-15 17:43:10 -05:00
case ' V ' :
return 1 ;
2016-02-12 20:38:05 -05:00
case ' ] ' :
2016-05-18 23:12:48 -04:00
gkNudgeRight ( lastDemod , snap ) ;
2016-02-12 20:38:05 -05:00
return 1 ;
case ' [ ' :
2016-05-18 23:12:48 -04:00
gkNudgeLeft ( lastDemod , snap ) ;
2016-02-12 20:38:05 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
case ' A ' :
case ' F ' :
case ' L ' :
case ' U ' :
2016-02-11 01:09:15 -05:00
case ' S ' :
2016-06-09 18:16:03 -04:00
case ' P ' :
2016-06-11 22:13:42 -04:00
case ' M ' :
2016-02-08 23:40:09 -05:00
return 1 ;
2016-02-07 19:32:05 -05:00
case ' 0 ' :
case ' 1 ' :
case ' 2 ' :
case ' 3 ' :
case ' 4 ' :
case ' 5 ' :
case ' 6 ' :
case ' 7 ' :
case ' 8 ' :
case ' 9 ' :
2016-02-07 21:05:49 -05:00
wxGetApp ( ) . showFrequencyInput ( getFrequencyDialogTarget ( ) , std : : to_string ( event . GetKeyCode ( ) - ' 0 ' ) ) ;
2016-02-08 23:40:09 -05:00
return 1 ;
2016-02-07 19:32:05 -05:00
break ;
2016-02-11 00:08:56 -05:00
case WXK_TAB :
lastDemod = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ;
if ( ! lastDemod ) {
break ;
}
if ( event . ShiftDown ( ) ) {
demod = wxGetApp ( ) . getDemodMgr ( ) . getPreviousDemodulator ( lastDemod ) ;
} else {
demod = wxGetApp ( ) . getDemodMgr ( ) . getNextDemodulator ( lastDemod ) ;
}
if ( demod ) {
wxGetApp ( ) . getDemodMgr ( ) . setActiveDemodulator ( nullptr ) ;
wxGetApp ( ) . getDemodMgr ( ) . setActiveDemodulator ( demod , false ) ;
}
2016-03-07 20:15:27 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
default :
break ;
}
if ( demodTuner - > getMouseTracker ( ) - > mouseInView ( ) ) {
demodTuner - > OnKeyDown ( event ) ;
} else if ( waterfallCanvas - > getMouseTracker ( ) - > mouseInView ( ) ) {
waterfallCanvas - > OnKeyDown ( event ) ;
}
2016-02-08 23:40:09 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
}
int AppFrame : : OnGlobalKeyUp ( wxKeyEvent & event ) {
if ( ! this - > IsActive ( ) ) {
return - 1 ;
}
2016-05-19 19:23:56 -04:00
if ( modemProps & & ( modemProps - > HasFocus ( ) | | modemProps - > isMouseInView ( ) ) ) {
return - 1 ;
}
2016-02-07 18:01:11 -05:00
2016-06-11 22:13:42 -04:00
DemodulatorInstance * activeDemod = wxGetApp ( ) . getDemodMgr ( ) . getActiveDemodulator ( ) ;
2016-02-15 17:43:10 -05:00
DemodulatorInstance * lastDemod = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ;
2016-05-18 23:12:48 -04:00
# ifdef wxHAS_RAW_KEY_CODES
switch ( event . GetRawKeyCode ( ) ) {
case 30 :
return 1 ;
case 33 :
return 1 ;
}
# endif
2016-02-07 18:01:11 -05:00
switch ( event . GetKeyCode ( ) ) {
case WXK_SPACE :
if ( ! demodTuner - > getMouseTracker ( ) - > mouseInView ( ) ) {
2016-02-07 21:05:49 -05:00
wxGetApp ( ) . showFrequencyInput ( getFrequencyDialogTarget ( ) ) ;
2016-02-08 23:40:09 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
}
break ;
case WXK_UP :
case WXK_NUMPAD_UP :
case WXK_DOWN :
case WXK_NUMPAD_DOWN :
case WXK_LEFT :
case WXK_NUMPAD_LEFT :
case WXK_RIGHT :
case WXK_NUMPAD_RIGHT :
waterfallCanvas - > OnKeyUp ( event ) ;
2016-02-08 23:40:09 -05:00
return 1 ;
2016-02-15 17:43:10 -05:00
case ' V ' :
2016-06-11 22:13:42 -04:00
if ( activeDemod ) {
lastDemod = activeDemod ;
2016-02-17 20:49:36 -05:00
}
2016-02-15 17:43:10 -05:00
if ( lastDemod & & lastDemod - > isDeltaLock ( ) ) {
lastDemod - > setDeltaLock ( false ) ;
} else if ( lastDemod ) {
lastDemod - > setDeltaLockOfs ( lastDemod - > getFrequency ( ) - wxGetApp ( ) . getFrequency ( ) ) ;
lastDemod - > setDeltaLock ( true ) ;
}
break ;
2016-02-07 18:01:11 -05:00
case ' A ' :
demodModeSelector - > setSelection ( " AM " ) ;
2016-02-11 01:09:15 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
break ;
case ' F ' :
if ( demodModeSelector - > getSelectionLabel ( ) = = " FM " ) {
demodModeSelector - > setSelection ( " FMS " ) ;
2016-05-11 23:05:56 -04:00
} else if ( demodModeSelector - > getSelectionLabel ( ) = = " FMS " ) {
demodModeSelector - > setSelection ( " NBFM " ) ;
} else if ( demodModeSelector - > getSelectionLabel ( ) = = " NBFM " ) {
2016-02-07 18:01:11 -05:00
demodModeSelector - > setSelection ( " FM " ) ;
}
2016-02-11 01:09:15 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
break ;
case ' L ' :
demodModeSelector - > setSelection ( " LSB " ) ;
2016-02-11 01:09:15 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
break ;
case ' U ' :
demodModeSelector - > setSelection ( " USB " ) ;
2016-02-11 01:09:15 -05:00
return 1 ;
break ;
case ' S ' :
wxGetApp ( ) . setSoloMode ( ! wxGetApp ( ) . getSoloMode ( ) ) ;
return 1 ;
2016-02-07 18:01:11 -05:00
break ;
2016-06-09 18:16:03 -04:00
case ' P ' :
wxGetApp ( ) . getSpectrumProcessor ( ) - > setPeakHold ( ! wxGetApp ( ) . getSpectrumProcessor ( ) - > getPeakHold ( ) ) ;
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > setPeakHold ( wxGetApp ( ) . getSpectrumProcessor ( ) - > getPeakHold ( ) ) ;
peakHoldButton - > setSelection ( wxGetApp ( ) . getSpectrumProcessor ( ) - > getPeakHold ( ) ? 1 : 0 ) ;
peakHoldButton - > clearModeChanged ( ) ;
break ;
2016-02-12 20:38:05 -05:00
case ' ] ' :
case ' [ ' :
return 1 ;
2016-06-11 22:13:42 -04:00
case ' M ' :
if ( activeDemod ) {
lastDemod = activeDemod ;
}
if ( lastDemod ) {
lastDemod - > setMuted ( ! lastDemod - > isMuted ( ) ) ;
}
break ;
2016-02-07 18:01:11 -05:00
default :
break ;
}
if ( demodTuner - > getMouseTracker ( ) - > mouseInView ( ) ) {
demodTuner - > OnKeyUp ( event ) ;
} else if ( waterfallCanvas - > getMouseTracker ( ) - > mouseInView ( ) ) {
waterfallCanvas - > OnKeyUp ( event ) ;
}
// TODO: Catch key-ups outside of original target
2016-02-08 23:40:09 -05:00
return 1 ;
2016-02-07 18:01:11 -05:00
}
2016-02-07 21:05:49 -05:00
void AppFrame : : setWaterfallLinesPerSecond ( int lps ) {
waterfallSpeedMeter - > setUserInputValue ( sqrt ( lps ) ) ;
}
void AppFrame : : setSpectrumAvgSpeed ( double avg ) {
spectrumAvgMeter - > setUserInputValue ( avg ) ;
}