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-17 22:58:56 -05:00
# include "DemodulatorMgr.h"
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"
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 )
2014-10-27 21:22:29 -04:00
wxEND_EVENT_TABLE ( )
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 ) ;
wxBoxSizer * demodTray = new wxBoxSizer ( wxHORIZONTAL ) ;
2015-01-04 17:11:20 -05:00
wxBoxSizer * demodScopeTray = new wxBoxSizer ( wxVERTICAL ) ;
2014-12-27 23:47:56 -05:00
2015-09-08 21:32:15 -04:00
int attribList [ ] = { WX_GL_RGBA , WX_GL_DOUBLEBUFFER , 0 } ;
2015-02-09 20:49:21 -05:00
demodModeSelector = new ModeSelectorCanvas ( this , attribList ) ;
2015-01-10 12:27:03 -05:00
demodModeSelector - > addChoice ( DEMOD_TYPE_FM , " FM " ) ;
demodModeSelector - > addChoice ( DEMOD_TYPE_AM , " AM " ) ;
demodModeSelector - > addChoice ( DEMOD_TYPE_LSB , " LSB " ) ;
demodModeSelector - > addChoice ( DEMOD_TYPE_USB , " USB " ) ;
demodModeSelector - > addChoice ( DEMOD_TYPE_DSB , " DSB " ) ;
2015-06-27 23:23:43 -04:00
demodModeSelector - > addChoice ( DEMOD_TYPE_RAW , " I/Q " ) ;
2015-02-02 20:10:55 -05:00
demodModeSelector - > setSelection ( DEMOD_TYPE_FM ) ;
2015-04-02 21:16:03 -04:00
demodModeSelector - > setHelpTip ( " Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band. " ) ;
2015-01-05 19:12:16 -05:00
demodTray - > Add ( demodModeSelector , 2 , wxEXPAND | wxALL , 0 ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getDemodSpectrumProcessor ( ) - > setup ( 1024 ) ;
2015-02-09 20:49:21 -05:00
demodSpectrumCanvas = new SpectrumCanvas ( this , 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-02-09 20:49:21 -05:00
demodWaterfallCanvas = new WaterfallCanvas ( this , 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-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
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-02-09 20:49:21 -05:00
demodSignalMeter = new MeterCanvas ( this , attribList ) ;
2014-12-31 19:45:01 -05:00
demodSignalMeter - > setMax ( 0.5 ) ;
2015-01-04 13:20:31 -05:00
demodSignalMeter - > setHelpTip ( " Current Signal Level. Click / Drag to set Squelch level. " ) ;
2014-12-31 19:45:01 -05:00
demodTray - > Add ( demodSignalMeter , 1 , wxEXPAND | wxALL , 0 ) ;
2014-12-28 20:55:05 -05:00
2015-01-14 22:14:57 -05:00
demodTray - > AddSpacer ( 1 ) ;
2014-12-28 05:13:46 -05:00
2015-02-09 20:49:21 -05:00
scopeCanvas = new ScopeCanvas ( this , attribList ) ;
2015-08-24 01:31:37 -04:00
scopeCanvas - > setHelpTip ( " Audio Visuals, drag left/right to toggle Scope or Spectrum. " ) ;
2015-01-04 17:11:20 -05:00
demodScopeTray - > Add ( scopeCanvas , 8 , wxEXPAND | wxALL , 0 ) ;
2015-08-24 01:31:37 -04:00
wxGetApp ( ) . getScopeProcessor ( ) - > setup ( 2048 ) ;
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
2015-02-09 20:49:21 -05:00
demodTuner = new TuningCanvas ( this , attribList ) ;
2015-01-04 17:11:20 -05:00
demodTuner - > setHelpTip ( " Testing tuner " ) ;
demodScopeTray - > Add ( demodTuner , 1 , wxEXPAND | wxALL , 0 ) ;
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-02-09 20:49:21 -05:00
demodGainMeter = new MeterCanvas ( this , 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 ) ;
2015-08-17 00:59:38 -04:00
demodGainTray - > Add ( demodGainMeter , 8 , wxEXPAND | wxALL , 0 ) ;
demodGainTray - > AddSpacer ( 1 ) ;
demodMuteButton = new ModeSelectorCanvas ( this , attribList ) ;
demodMuteButton - > addChoice ( 1 , " M " ) ;
2015-08-19 17:06:06 -04:00
demodMuteButton - > setPadding ( - 1 , - 1 ) ;
demodMuteButton - > setHighlightColor ( RGBA4f ( 0.8 , 0.2 , 0.2 ) ) ;
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 ) ;
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-01-06 19:15:27 -05:00
vbox - > Add ( demodTray , 12 , wxEXPAND | wxALL , 0 ) ;
2015-01-14 22:14:57 -05:00
vbox - > AddSpacer ( 1 ) ;
2015-08-03 01:38:38 -04:00
2015-08-11 23:52:03 -04:00
wxBoxSizer * spectrumSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getSpectrumProcessor ( ) - > setup ( 2048 ) ;
2015-02-09 20:49:21 -05:00
spectrumCanvas = new SpectrumCanvas ( this , attribList ) ;
2015-08-17 21:52:38 -04:00
spectrumCanvas - > setShowDb ( true ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getSpectrumProcessor ( ) - > attachOutput ( spectrumCanvas - > getVisualDataQueue ( ) ) ;
2015-08-11 23:52:03 -04:00
spectrumAvgMeter = new MeterCanvas ( this , 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 ) ;
spectrumAvgMeter - > setLevel ( 0.65 ) ;
2015-08-12 20:05:57 -04:00
spectrumAvgMeter - > setShowUserInput ( false ) ;
2015-08-11 23:52:03 -04:00
spectrumSizer - > Add ( spectrumCanvas , 63 , wxEXPAND | wxALL , 0 ) ;
spectrumSizer - > AddSpacer ( 1 ) ;
spectrumSizer - > Add ( spectrumAvgMeter , 1 , wxEXPAND | wxALL , 0 ) ;
vbox - > Add ( spectrumSizer , 5 , wxEXPAND | wxALL , 0 ) ;
vbox - > AddSpacer ( 1 ) ;
wxBoxSizer * wfSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2015-08-03 01:38:38 -04:00
2015-02-09 20:49:21 -05:00
waterfallCanvas = new WaterfallCanvas ( this , 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-08-19 23:22:46 -04:00
t_FFTData = new std : : thread ( & FFTVisualDataThread : : threadMain , waterfallDataThread ) ;
2015-08-11 23:52:03 -04:00
waterfallSpeedMeter = new MeterCanvas ( this , 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-08-11 23:52:03 -04:00
wfSizer - > Add ( waterfallCanvas , 63 , wxEXPAND | wxALL , 0 ) ;
wfSizer - > AddSpacer ( 1 ) ;
wfSizer - > Add ( waterfallSpeedMeter , 1 , wxEXPAND | wxALL , 0 ) ;
vbox - > Add ( wfSizer , 20 , wxEXPAND | wxALL , 0 ) ;
// TODO: refactor these..
waterfallCanvas - > attachSpectrumCanvas ( spectrumCanvas ) ;
spectrumCanvas - > attachWaterfallCanvas ( waterfallCanvas ) ;
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
// waterfallCanvas->SetFocusFromKbd();
2014-12-10 21:22:13 -05:00
waterfallCanvas - > SetFocus ( ) ;
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-01-06 00:29:33 -05:00
wxMenuBar * menuBar = new wxMenuBar ;
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 ( ) ;
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__
menu - > AppendSeparator ( ) ;
menu - > Append ( wxID_CLOSE ) ;
# endif
menuBar - > Append ( menu , wxT ( " &File " ) ) ;
menu = new wxMenu ;
menu - > Append ( wxID_SET_FREQ_OFFSET , " Frequency Offset " ) ;
menu - > Append ( wxID_SET_PPM , " Device PPM " ) ;
iqSwapMenuItem = menu - > AppendCheckItem ( wxID_SET_SWAP_IQ , " Swap I/Q " ) ;
2015-05-30 23:14:16 -04:00
2015-05-31 22:13:14 -04:00
wxMenu * dsMenu = new wxMenu ;
2015-07-08 01:07:39 -04:00
directSamplingMenuItems [ 0 ] = dsMenu - > AppendRadioItem ( wxID_SET_DS_OFF , " Off " ) ;
directSamplingMenuItems [ 1 ] = dsMenu - > AppendRadioItem ( wxID_SET_DS_I , " I-ADC " ) ;
directSamplingMenuItems [ 2 ] = dsMenu - > AppendRadioItem ( wxID_SET_DS_Q , " Q-ADC " ) ;
2015-05-30 23:14:16 -04:00
2015-05-31 22:13:14 -04:00
menu - > AppendSubMenu ( dsMenu , " Direct Sampling " ) ;
2015-01-06 00:29:33 -05:00
2015-05-31 22:13:14 -04:00
menuBar - > Append ( menu , wxT ( " &Settings " ) ) ;
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-06-11 17:18:36 -04:00
sampleRateMenuItems [ wxID_BANDWIDTH_250K ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_250K , " 250k " ) ;
2015-01-11 19:44:02 -05:00
sampleRateMenuItems [ wxID_BANDWIDTH_1000M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_1000M , " 1.0M " ) ;
2015-06-11 17:18:36 -04:00
sampleRateMenuItems [ wxID_BANDWIDTH_1500M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_1024M , " 1.024M " ) ;
sampleRateMenuItems [ wxID_BANDWIDTH_1024M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_1500M , " 1.5M " ) ;
sampleRateMenuItems [ wxID_BANDWIDTH_1800M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_1800M , " 1.8M " ) ;
sampleRateMenuItems [ wxID_BANDWIDTH_1920M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_1920M , " 1.92M " ) ;
2015-01-11 19:44:02 -05:00
sampleRateMenuItems [ wxID_BANDWIDTH_2000M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_2000M , " 2.0M " ) ;
2015-06-11 17:18:36 -04:00
sampleRateMenuItems [ wxID_BANDWIDTH_2048M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_2048M , " 2.048M " ) ;
2015-05-11 20:25:31 -04:00
sampleRateMenuItems [ wxID_BANDWIDTH_2160M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_2160M , " 2.16M " ) ;
2015-06-11 17:18:36 -04:00
sampleRateMenuItems [ wxID_BANDWIDTH_2400M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_2400M , " 2.4M " ) ;
sampleRateMenuItems [ wxID_BANDWIDTH_2560M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_2560M , " 2.56M " ) ;
2015-01-11 19:44:02 -05:00
sampleRateMenuItems [ wxID_BANDWIDTH_2880M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_2880M , " 2.88M " ) ;
2015-06-11 17:18:36 -04:00
// sampleRateMenuItems[wxID_BANDWIDTH_3000M] = menu->AppendRadioItem(wxID_BANDWIDTH_3000M, "3.0M");
2015-01-11 19:44:02 -05:00
sampleRateMenuItems [ wxID_BANDWIDTH_3200M ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_3200M , " 3.2M " ) ;
2015-09-13 22:18:29 -04:00
sampleRateMenuItems [ wxID_BANDWIDTH_MANUAL ] = menu - > AppendRadioItem ( wxID_BANDWIDTH_MANUAL , " Manual Entry " ) ;
2015-01-11 19:44:02 -05:00
2015-08-13 20:39:31 -04:00
sampleRateMenuItems [ wxID_BANDWIDTH_2400M ] - > Check ( true ) ;
2015-01-11 17:08:16 -05:00
menuBar - > Append ( menu , wxT ( " &Input Bandwidth " ) ) ;
2015-01-11 03:09:59 -05:00
2015-10-05 19:59:17 -04:00
// std::vector<SDRDeviceInfo *> *devs = wxGetApp().getDevices();
// std::vector<SDRDeviceInfo *>::iterator devs_i;
2015-01-12 00:40:43 -05:00
2015-10-03 21:35:11 -04:00
// if (devs->size() > 1) {
//
// menu = new wxMenu;
//
// int p = 0;
// for (devs_i = devs->begin(); devs_i != devs->end(); devs_i++) {
// std::string devName = (*devs_i)->getName();
// if ((*devs_i)->isAvailable()) {
// devName.append(": ");
// devName.append((*devs_i)->getProduct());
// devName.append(" [");
// devName.append((*devs_i)->getSerial());
// devName.append("]");
// } else {
// devName.append(" (In Use?)");
// }
//
// menu->AppendRadioItem(wxID_DEVICE_ID + p, devName); //->Check(wxGetApp().getDevice() == p);
// p++;
// }
//
// menuBar->Append(menu, wxT("Input &Device"));
// }
2015-01-12 00:40:43 -05:00
2015-03-12 19:41:50 -04:00
menu = new wxMenu ;
2015-03-29 20:24:00 -04:00
# define NUM_RATES_DEFAULT 4
2015-03-22 20:47:07 -04:00
int desired_rates [ NUM_RATES_DEFAULT ] = { 48000 , 44100 , 96000 , 192000 } ;
for ( mdevices_i = outputDevices . begin ( ) ; mdevices_i ! = outputDevices . end ( ) ; mdevices_i + + ) {
2015-03-29 20:24:00 -04:00
int desired_rate = 0 ;
int desired_rank = NUM_RATES_DEFAULT + 1 ;
for ( std : : vector < unsigned int > : : iterator srate = mdevices_i - > second . sampleRates . begin ( ) ; srate ! = mdevices_i - > second . sampleRates . end ( ) ;
srate + + ) {
for ( i = 0 ; i < NUM_RATES_DEFAULT ; i + + ) {
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
2015-03-22 20:47:07 -04:00
if ( ( * 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 + + ;
}
}
menuBar - > Append ( menu , wxT ( " Audio &Bandwidth " ) ) ;
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 ( ) ) ;
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-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);
}
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-07-08 18:54:52 -04:00
void AppFrame : : initDeviceParams ( std : : string deviceId ) {
DeviceConfig * devConfig = wxGetApp ( ) . getConfig ( ) - > getDevice ( deviceId ) ;
2015-07-08 01:07:39 -04:00
int dsMode = devConfig - > getDirectSampling ( ) ;
if ( dsMode > 0 & & dsMode < = 2 ) {
directSamplingMenuItems [ devConfig - > getDirectSampling ( ) ] - > Check ( ) ;
}
if ( devConfig - > getIQSwap ( ) ) {
iqSwapMenuItem - > Check ( ) ;
}
2014-10-27 21:22:29 -04:00
}
2014-11-11 20:25:16 -05:00
2014-12-31 21:31:37 -05:00
void AppFrame : : OnMenu ( wxCommandEvent & event ) {
2015-01-01 18:08:54 -05:00
if ( event . GetId ( ) > = wxID_RT_AUDIO_DEVICE & & event . GetId ( ) < wxID_RT_AUDIO_DEVICE + 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 ;
}
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-07-19 12:56:54 -04:00
wxGetApp ( ) . saveConfig ( ) ;
2015-01-06 19:15:27 -05:00
}
2015-05-30 23:14:16 -04:00
} else if ( event . GetId ( ) = = wxID_SET_DS_OFF ) {
wxGetApp ( ) . setDirectSampling ( 0 ) ;
2015-07-19 12:56:54 -04:00
wxGetApp ( ) . saveConfig ( ) ;
2015-05-30 23:14:16 -04:00
} else if ( event . GetId ( ) = = wxID_SET_DS_I ) {
wxGetApp ( ) . setDirectSampling ( 1 ) ;
2015-07-19 12:56:54 -04:00
wxGetApp ( ) . saveConfig ( ) ;
2015-05-30 23:14:16 -04:00
} else if ( event . GetId ( ) = = wxID_SET_DS_Q ) {
wxGetApp ( ) . setDirectSampling ( 2 ) ;
2015-07-19 12:56:54 -04:00
wxGetApp ( ) . saveConfig ( ) ;
2015-05-31 22:13:14 -04:00
} else if ( event . GetId ( ) = = wxID_SET_SWAP_IQ ) {
bool swap_state = ! wxGetApp ( ) . getSwapIQ ( ) ;
wxGetApp ( ) . setSwapIQ ( swap_state ) ;
2015-07-19 12:56:54 -04:00
wxGetApp ( ) . saveConfig ( ) ;
2015-05-31 22:13:14 -04:00
iqSwapMenuItem - > Check ( swap_state ) ;
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-04-22 22:54:48 -04:00
wxGetApp ( ) . saveConfig ( ) ;
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-08-13 22:00:05 -04:00
wxGetApp ( ) . getDemodMgr ( ) . setLastDemodulatorType ( DEMOD_TYPE_FM ) ;
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 ( ) . setLastStereo ( false ) ;
wxGetApp ( ) . getDemodMgr ( ) . setLastBandwidth ( DEFAULT_DEMOD_BW ) ;
wxGetApp ( ) . getDemodMgr ( ) . setLastGain ( 1.0 ) ;
wxGetApp ( ) . getDemodMgr ( ) . setLastSquelchLevel ( 0 ) ;
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 ) ) ;
2015-08-16 18:12:12 -04:00
wxGetApp ( ) . getSpectrumProcessor ( ) - > setFFTAverageRate ( 0.65 ) ;
2015-08-13 22:00:05 -04:00
spectrumAvgMeter - > setLevel ( 0.65 ) ;
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-01-08 23:57:58 -05:00
} else if ( event . GetId ( ) = = wxID_EXIT ) {
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
}
2015-01-11 17:08:16 -05:00
2015-08-10 18:45:46 -04:00
if ( event . GetId ( ) > = wxID_THEME_DEFAULT & & event . GetId ( ) < = wxID_THEME_RADAR ) {
demodTuner - > Refresh ( ) ;
demodModeSelector - > Refresh ( ) ;
}
2015-01-11 17:08:16 -05:00
switch ( event . GetId ( ) ) {
2015-06-11 17:18:36 -04:00
case wxID_BANDWIDTH_250K :
wxGetApp ( ) . setSampleRate ( 250000 ) ;
break ;
case wxID_BANDWIDTH_1000M :
wxGetApp ( ) . setSampleRate ( 1000000 ) ;
break ;
case wxID_BANDWIDTH_1024M :
wxGetApp ( ) . setSampleRate ( 1024000 ) ;
break ;
case wxID_BANDWIDTH_1500M :
wxGetApp ( ) . setSampleRate ( 1500000 ) ;
break ;
case wxID_BANDWIDTH_1800M :
wxGetApp ( ) . setSampleRate ( 1800000 ) ;
break ;
case wxID_BANDWIDTH_1920M :
wxGetApp ( ) . setSampleRate ( 1920000 ) ;
break ;
case wxID_BANDWIDTH_2000M :
wxGetApp ( ) . setSampleRate ( 2000000 ) ;
break ;
case wxID_BANDWIDTH_2048M :
wxGetApp ( ) . setSampleRate ( 2048000 ) ;
break ;
case wxID_BANDWIDTH_2160M :
wxGetApp ( ) . setSampleRate ( 2160000 ) ;
break ;
case wxID_BANDWIDTH_2400M :
wxGetApp ( ) . setSampleRate ( 2400000 ) ;
break ;
case wxID_BANDWIDTH_2560M :
wxGetApp ( ) . setSampleRate ( 2560000 ) ;
break ;
case wxID_BANDWIDTH_2880M :
wxGetApp ( ) . setSampleRate ( 2880000 ) ;
break ;
// case wxID_BANDWIDTH_3000M:
// wxGetApp().setSampleRate(3000000);
// break;
case wxID_BANDWIDTH_3200M :
wxGetApp ( ) . setSampleRate ( 3200000 ) ;
break ;
2015-09-13 22:18:29 -04:00
case wxID_BANDWIDTH_MANUAL :
2015-10-04 16:07:14 -04:00
long bw = wxGetNumberFromUser ( " Set the bandwidth manually " , " Sample Rate (Hz), i.e. 2560000 for 2.56M " ,
" Manual Bandwidth Entry " , wxGetApp ( ) . getSampleRate ( ) , 250000 , 25000000 , this ) ;
2015-09-13 22:18:29 -04:00
if ( bw ! = - 1 ) {
wxGetApp ( ) . setSampleRate ( bw ) ;
}
break ;
2015-01-11 17:08:16 -05:00
}
2015-01-12 00:40:43 -05:00
2015-10-04 16:07:14 -04:00
// std::vector<SDRDeviceInfo *> *devs = wxGetApp().getDevices();
// if (event.GetId() >= wxID_DEVICE_ID && event.GetId() <= wxID_DEVICE_ID + devs->size()) {
// int devId = event.GetId() - wxID_DEVICE_ID;
// wxGetApp().setDevice(devId);
//
// SDRDeviceInfo *dev = (*wxGetApp().getDevices())[devId];
// DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
//
// int dsMode = devConfig->getDirectSampling();
//
// if (dsMode >= 0 && dsMode <= 2) {
// directSamplingMenuItems[devConfig->getDirectSampling()]->Check();
// }
//
// iqSwapMenuItem->Check(devConfig->getIQSwap());
// }
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
}
2014-10-27 21:22:29 -04:00
}
2015-07-15 00:32:36 -04:00
void AppFrame : : OnClose ( wxCloseEvent & event ) {
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 ( ) ) ;
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 ( ) ) ;
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
DemodulatorInstance * demod = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ;
if ( demod ) {
2015-04-23 19:38:44 -04:00
DemodulatorInstance * demod = wxGetApp ( ) . getDemodMgr ( ) . getLastActiveDemodulator ( ) ;
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 ) {
if ( demod - > getBandwidth ( ) > spectrumCanvas - > getBandwidth ( ) ) {
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 ) ;
}
}
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 ( ) ) ;
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-01-01 18:08:54 -05:00
int dType = demod - > getDemodulatorType ( ) ;
2015-01-06 00:29:33 -05:00
demodModeSelector - > setSelection ( dType ) ;
2015-08-17 00:59:38 -04:00
demodMuteButton - > setSelection ( demod - > isMuted ( ) ? 1 : - 1 ) ;
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
if ( demod - > getDemodulatorType ( ) = = DEMOD_TYPE_USB ) {
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
if ( demod - > getDemodulatorType ( ) = = DEMOD_TYPE_LSB ) {
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 ) ;
}
int dSelection = demodModeSelector - > getSelection ( ) ;
if ( dSelection ! = - 1 & & dSelection ! = demod - > getDemodulatorType ( ) ) {
demod - > setDemodulatorType ( dSelection ) ;
}
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 ( ) ) ;
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 ( ) ) ;
2015-08-17 00:59:38 -04:00
}
}
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-02-02 20:10:55 -05:00
} else {
DemodulatorMgr * mgr = & wxGetApp ( ) . getDemodMgr ( ) ;
int dSelection = demodModeSelector - > getSelection ( ) ;
if ( dSelection ! = - 1 & & dSelection ! = mgr - > getLastDemodulatorType ( ) ) {
mgr - > setLastDemodulatorType ( dSelection ) ;
}
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-08 18:37:40 -04:00
if ( demodTuner - > getMouseTracker ( ) - > mouseInView ( ) ) {
if ( ! demodTuner - > HasFocus ( ) ) {
demodTuner - > SetFocus ( ) ;
}
2015-10-10 01:13:48 -04:00
} else if ( ! wxGetApp ( ) . isDeviceSelectorOpen ( ) ) {
if ( ! waterfallCanvas - > HasFocus ( ) ) {
waterfallCanvas - > SetFocus ( ) ;
}
2015-01-06 00:29:33 -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-03 01:38:38 -04:00
wxGetApp ( ) . getSpectrumDistributor ( ) - > run ( ) ;
2015-08-12 22:14:14 -04:00
2015-08-16 18:12:12 -04:00
SpectrumVisualProcessor * proc = wxGetApp ( ) . getSpectrumProcessor ( ) ;
2015-08-03 01:38:38 -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 ) {
val = 0.01 ;
}
2015-08-18 00:08:22 -04:00
if ( val > 0.99 ) {
val = 0.99 ;
}
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 19:47:49 -04:00
proc - > setView ( waterfallCanvas - > getViewState ( ) ) ;
proc - > setBandwidth ( waterfallCanvas - > getBandwidth ( ) ) ;
proc - > setCenterFrequency ( waterfallCanvas - > getCenterFrequency ( ) ) ;
2015-08-03 01:38:38 -04:00
2015-08-16 18:12:12 -04:00
SpectrumVisualProcessor * dproc = wxGetApp ( ) . getDemodSpectrumProcessor ( ) ;
2015-08-03 01:38:38 -04:00
dproc - > setView ( demodWaterfallCanvas - > getViewState ( ) ) ;
dproc - > setBandwidth ( demodWaterfallCanvas - > getBandwidth ( ) ) ;
dproc - > setCenterFrequency ( demodWaterfallCanvas - > getCenterFrequency ( ) ) ;
2015-08-08 13:26:53 -04:00
2015-08-14 19:17:43 -04:00
SpectrumVisualProcessor * wproc = waterfallDataThread - > getProcessor ( ) ;
2015-08-11 00:50:43 -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-11 23:52:03 -04:00
}
2015-08-11 00:50:43 -04:00
wproc - > setView ( waterfallCanvas - > getViewState ( ) ) ;
wproc - > setBandwidth ( waterfallCanvas - > getBandwidth ( ) ) ;
wproc - > setCenterFrequency ( waterfallCanvas - > getCenterFrequency ( ) ) ;
2015-09-10 01:26:05 -04:00
// waterfallCanvas->processInputQueue();
2015-09-08 21:32:15 -04:00
// waterfallCanvas->Refresh();
2015-09-10 01:26:05 -04:00
// demodWaterfallCanvas->processInputQueue();
2015-09-08 21:32:15 -04:00
// demodWaterfallCanvas->Refresh();
2015-08-16 19:47:49 -04:00
2015-08-14 20:41:52 -04:00
if ( ! this - > IsActive ( ) ) {
2015-08-14 21:20:07 -04:00
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 25 ) ) ;
2015-08-13 20:39:31 -04:00
}
2015-08-13 18:03:06 -04: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
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 ( ) ;
2015-01-09 17:17:56 -05:00
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 ( ) ;
* demod - > newChild ( " squelch_level " ) = ( * instance_i ) - > getSquelchLevel ( ) ;
2015-01-10 12:27:03 -05:00
* demod - > newChild ( " squelch_enabled " ) = ( * instance_i ) - > isSquelchEnabled ( ) ? 1 : 0 ;
* demod - > newChild ( " stereo " ) = ( * instance_i ) - > isStereo ( ) ? 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 ;
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 ;
}
2015-01-10 12:27:03 -05:00
wxGetApp ( ) . getDemodMgr ( ) . terminateAll ( ) ;
2015-01-09 20:56:43 -05:00
try {
DataNode * header = l . rootNode ( ) - > getNext ( " header " ) ;
2015-01-10 11:00:03 -05:00
std : : string version ( * header - > getNext ( " version " ) ) ;
2015-01-09 20:56:43 -05:00
long long center_freq = * header - > getNext ( " center_freq " ) ;
std : : cout < < " Loading " < < version < < " session file " < < std : : endl ;
std : : cout < < " \t Center Frequency: " < < center_freq < < std : : endl ;
2015-01-10 12:27:03 -05:00
wxGetApp ( ) . setFrequency ( center_freq ) ;
2015-01-09 20:56:43 -05:00
DataNode * demodulators = l . rootNode ( ) - > getNext ( " demodulators " ) ;
2015-08-16 22:31:14 -04:00
int numDemodulators = 0 ;
DemodulatorInstance * loadedDemod = NULL ;
2015-01-09 20:56:43 -05:00
while ( demodulators - > hasAnother ( " demodulator " ) ) {
DataNode * demod = demodulators - > getNext ( " demodulator " ) ;
if ( ! demod - > hasAnother ( " bandwidth " ) | | ! demod - > hasAnother ( " frequency " ) ) {
continue ;
}
long bandwidth = * demod - > getNext ( " bandwidth " ) ;
long long freq = * demod - > getNext ( " frequency " ) ;
2015-01-10 12:27:03 -05:00
int type = demod - > hasAnother ( " type " ) ? * demod - > getNext ( " type " ) : DEMOD_TYPE_FM ;
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 stereo = demod - > hasAnother ( " stereo " ) ? ( int ) * demod - > getNext ( " stereo " ) : 0 ;
2015-08-17 00:59:38 -04:00
int muted = demod - > hasAnother ( " muted " ) ? ( int ) * demod - > getNext ( " muted " ) : 0 ;
2015-01-10 12:27:03 -05:00
std : : string output_device = demod - > hasAnother ( " output_device " ) ? string ( * ( demod - > getNext ( " output_device " ) ) ) : " " ;
2015-01-10 20:33:30 -05:00
float gain = demod - > hasAnother ( " gain " ) ? ( float ) * demod - > getNext ( " gain " ) : 1.0 ;
2015-01-10 12:27:03 -05:00
DemodulatorInstance * newDemod = wxGetApp ( ) . getDemodMgr ( ) . newThread ( ) ;
2015-08-16 22:31:14 -04:00
loadedDemod = newDemod ;
numDemodulators + + ;
2015-01-10 12:27:03 -05:00
newDemod - > setDemodulatorType ( type ) ;
newDemod - > setBandwidth ( bandwidth ) ;
newDemod - > setFrequency ( freq ) ;
2015-01-10 20:33:30 -05:00
newDemod - > setGain ( gain ) ;
2015-01-10 12:27:03 -05:00
newDemod - > updateLabel ( freq ) ;
2015-08-17 00:59:38 -04:00
newDemod - > setMuted ( muted ? true : false ) ;
2015-01-10 12:27:03 -05:00
if ( squelch_enabled ) {
newDemod - > setSquelchEnabled ( true ) ;
newDemod - > setSquelchLevel ( squelch_level ) ;
}
if ( stereo ) {
newDemod - > setStereo ( true ) ;
}
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 ;
}
}
if ( ! found_device ) {
std : : cout < < " \t Warning: named output device ' " < < output_device < < " ' was not found. Using default output. " ;
}
newDemod - > run ( ) ;
2015-07-08 19:25:22 -04:00
newDemod - > setActive ( false ) ;
2015-01-10 12:27:03 -05:00
wxGetApp ( ) . bindDemodulator ( newDemod ) ;
2015-01-09 20:56:43 -05:00
2015-01-10 12:27:03 -05:00
std : : cout < < " \t Added demodulator at frequency " < < freq < < " type " < < type < < std : : endl ;
2015-01-09 20:56:43 -05:00
std : : cout < < " \t \t Bandwidth: " < < bandwidth < < std : : endl ;
std : : cout < < " \t \t Squelch Level: " < < squelch_level < < std : : endl ;
2015-01-10 12:27:03 -05:00
std : : cout < < " \t \t Squelch Enabled: " < < ( squelch_enabled ? " true " : " false " ) < < std : : endl ;
std : : cout < < " \t \t Stereo: " < < ( stereo ? " true " : " false " ) < < std : : endl ;
2015-01-09 20:56:43 -05:00
std : : cout < < " \t \t Output Device: " < < output_device < < std : : endl ;
}
2015-08-16 22:31:14 -04:00
if ( ( numDemodulators = = 1 ) & & loadedDemod ) {
loadedDemod - > setActive ( true ) ;
loadedDemod - > setFollow ( true ) ;
loadedDemod - > setTracking ( true ) ;
wxGetApp ( ) . getDemodMgr ( ) . setActiveDemodulator ( loadedDemod ) ;
}
2015-01-09 20:56:43 -05:00
} catch ( DataInvalidChildException & e ) {
std : : cout < < e . what ( ) < < std : : endl ;
return false ;
} catch ( DataTypeMismatchException & e ) {
std : : cout < < e . what ( ) < < std : : endl ;
return false ;
}
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
}