Skip to content

Commit

Permalink
Move voice keyer settings to separate config.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Jul 2, 2023
1 parent c4af569 commit 942d8eb
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 41 deletions.
21 changes: 21 additions & 0 deletions src/config/FreeDVConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ FreeDVConfiguration::FreeDVConfiguration()
, recFileFromModulatorPath("/File/recFileFromModulatorPath", _(""))
, recFileFromModulatorSecs("/File/recFileFromModulatorSecs", 60)
, playFileFromRadioPath("/File/playFileFromRadioPath", _(""))

, enableSpaceBarForPTT("/Rig/EnableSpacebarForPTT", true)

, voiceKeyerWaveFilePath("/VoiceKeyer/WaveFilePath", _(""))
, voiceKeyerWaveFile("/VoiceKeyer/WaveFile", _("voicekeyer.wav"))
, voiceKeyerRxPause("/VoiceKeyer/RxPause", 10)
, voiceKeyerRepeats("/VoiceKeyer/Repeats", 5)
{
// empty
}
Expand Down Expand Up @@ -84,6 +91,13 @@ void FreeDVConfiguration::load(wxConfigBase* config)
load_(config, recFileFromModulatorPath);
load_(config, recFileFromModulatorSecs);
load_(config, playFileFromRadioPath);

load_(config, enableSpaceBarForPTT);

load_(config, voiceKeyerWaveFilePath);
load_(config, voiceKeyerWaveFile);
load_(config, voiceKeyerRxPause);
load_(config, voiceKeyerRepeats);
}

void FreeDVConfiguration::save(wxConfigBase* config)
Expand Down Expand Up @@ -116,5 +130,12 @@ void FreeDVConfiguration::save(wxConfigBase* config)
save_(config, recFileFromModulatorSecs);
save_(config, playFileFromRadioPath);

save_(config, enableSpaceBarForPTT);

save_(config, voiceKeyerWaveFilePath);
save_(config, voiceKeyerWaveFile);
save_(config, voiceKeyerRxPause);
save_(config, voiceKeyerRepeats);

config->Flush();
}
7 changes: 7 additions & 0 deletions src/config/FreeDVConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ class FreeDVConfiguration : public WxWidgetsConfigStore
ConfigurationDataElement<unsigned int> recFileFromModulatorSecs;
ConfigurationDataElement<wxString> playFileFromRadioPath;

ConfigurationDataElement<bool> enableSpaceBarForPTT;

ConfigurationDataElement<wxString> voiceKeyerWaveFilePath;
ConfigurationDataElement<wxString> voiceKeyerWaveFile;
ConfigurationDataElement<int> voiceKeyerRxPause;
ConfigurationDataElement<int> voiceKeyerRepeats;

virtual void load(wxConfigBase* config) override;
virtual void save(wxConfigBase* config) override;
};
Expand Down
30 changes: 14 additions & 16 deletions src/dlg_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,15 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)
{
m_txtCtrlCallSign->SetValue(wxGetApp().appConfiguration.reportingConfiguration.reportingFreeTextString);

m_ckboxEnableSpacebarForPTT->SetValue(wxGetApp().m_boolEnableSpacebarForPTT);
m_ckboxEnableSpacebarForPTT->SetValue(wxGetApp().appConfiguration.enableSpaceBarForPTT);
m_ckboxUseAnalogModes->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.hamlibUseAnalogModes);
m_ckboxEnableFreqModeChanges->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.hamlibEnableFreqModeChanges);

/* Voice Keyer */

m_txtCtrlVoiceKeyerWaveFile->SetValue(wxGetApp().m_txtVoiceKeyerWaveFile);
m_txtCtrlVoiceKeyerRxPause->SetValue(wxString::Format(wxT("%i"), wxGetApp().m_intVoiceKeyerRxPause));
m_txtCtrlVoiceKeyerRepeats->SetValue(wxString::Format(wxT("%i"), wxGetApp().m_intVoiceKeyerRepeats));
m_txtCtrlVoiceKeyerWaveFile->SetValue(wxGetApp().appConfiguration.voiceKeyerWaveFile);
m_txtCtrlVoiceKeyerRxPause->SetValue(wxString::Format(wxT("%i"), wxGetApp().appConfiguration.voiceKeyerRxPause.get()));
m_txtCtrlVoiceKeyerRepeats->SetValue(wxString::Format(wxT("%i"), wxGetApp().appConfiguration.voiceKeyerRepeats.get()));

m_txtCtrlQuickRecordPath->SetValue(wxGetApp().m_txtQuickRecordPath);

Expand Down Expand Up @@ -746,8 +746,7 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)

if(inout == EXCHANGE_DATA_OUT)
{
wxGetApp().m_boolEnableSpacebarForPTT = m_ckboxEnableSpacebarForPTT->GetValue();
pConfig->Write(wxT("/Rig/EnableSpacebarForPTT"), wxGetApp().m_boolEnableSpacebarForPTT);
wxGetApp().appConfiguration.enableSpaceBarForPTT = m_ckboxEnableSpacebarForPTT->GetValue();

wxGetApp().appConfiguration.rigControlConfiguration.hamlibUseAnalogModes = m_ckboxUseAnalogModes->GetValue();

Expand All @@ -766,15 +765,13 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)

/* Voice Keyer */

wxGetApp().m_txtVoiceKeyerWaveFile = m_txtCtrlVoiceKeyerWaveFile->GetValue();
pConfig->Write(wxT("/VoiceKeyer/WaveFile"), wxGetApp().m_txtVoiceKeyerWaveFile);
wxGetApp().appConfiguration.voiceKeyerWaveFile = m_txtCtrlVoiceKeyerWaveFile->GetValue();

long tmp;
m_txtCtrlVoiceKeyerRxPause->GetValue().ToLong(&tmp); if (tmp < 0) tmp = 0; wxGetApp().m_intVoiceKeyerRxPause = (int)tmp;
pConfig->Write(wxT("/VoiceKeyer/RxPause"), wxGetApp().m_intVoiceKeyerRxPause);
m_txtCtrlVoiceKeyerRxPause->GetValue().ToLong(&tmp); if (tmp < 0) tmp = 0; wxGetApp().appConfiguration.voiceKeyerRxPause = (int)tmp;
m_txtCtrlVoiceKeyerRepeats->GetValue().ToLong(&tmp);
if (tmp < 0) {tmp = 0;} if (tmp > 100) {tmp = 100;}
wxGetApp().m_intVoiceKeyerRepeats = (int)tmp;
pConfig->Write(wxT("/VoiceKeyer/Repeats"), wxGetApp().m_intVoiceKeyerRepeats);
wxGetApp().appConfiguration.voiceKeyerRepeats = (int)tmp;

wxGetApp().m_txtQuickRecordPath = m_txtCtrlQuickRecordPath->GetValue();
pConfig->Write(wxT("/QuickRecord/SavePath"), wxGetApp().m_txtQuickRecordPath);
Expand Down Expand Up @@ -926,7 +923,7 @@ void OptionsDlg::OnChooseVoiceKeyerWaveFile(wxCommandEvent& event) {
wxFileDialog openFileDialog(
this,
wxT("Voice Keyer wave file"),
wxGetApp().m_txtVoiceKeyerWaveFilePath,
wxGetApp().appConfiguration.voiceKeyerWaveFilePath,
wxEmptyString,
wxT("WAV files (*.wav)|*.wav"),
wxFD_OPEN
Expand All @@ -936,9 +933,10 @@ void OptionsDlg::OnChooseVoiceKeyerWaveFile(wxCommandEvent& event) {
}

wxString fileName, extension;
wxGetApp().m_txtVoiceKeyerWaveFile = openFileDialog.GetPath();
wxFileName::SplitPath(wxGetApp().m_txtVoiceKeyerWaveFile, &wxGetApp().m_txtVoiceKeyerWaveFilePath, &fileName, &extension);
m_txtCtrlVoiceKeyerWaveFile->SetValue(wxGetApp().m_txtVoiceKeyerWaveFile);
wxGetApp().appConfiguration.voiceKeyerWaveFile = openFileDialog.GetPath();
wxString tmpString = wxGetApp().appConfiguration.voiceKeyerWaveFilePath;
wxFileName::SplitPath(wxGetApp().appConfiguration.voiceKeyerWaveFile, &tmpString, &fileName, &extension);
m_txtCtrlVoiceKeyerWaveFile->SetValue(wxGetApp().appConfiguration.voiceKeyerWaveFile);
}

void OptionsDlg::OnChooseQuickRecordPath(wxCommandEvent& event) {
Expand Down
14 changes: 1 addition & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,10 @@ void MainFrame::loadConfiguration_()
m_txtTxLevelNum->SetLabel(fmtString);

// PTT -------------------------------------------------------------------
wxGetApp().m_boolEnableSpacebarForPTT = pConfig->ReadBool("/Rig/EnableSpacebarForPTT", true);
wxGetApp().m_boolHalfDuplex = pConfig->ReadBool(wxT("/Rig/HalfDuplex"), true);
wxGetApp().m_boolMultipleRx = pConfig->ReadBool(wxT("/Rig/MultipleRx"), true);
wxGetApp().m_boolSingleRxThread = pConfig->ReadBool(wxT("/Rig/SingleRxThread"), true);

wxGetApp().m_txtVoiceKeyerWaveFilePath = pConfig->Read(wxT("/VoiceKeyer/WaveFilePath"), wxT(""));
wxGetApp().m_txtVoiceKeyerWaveFile = pConfig->Read(wxT("/VoiceKeyer/WaveFile"), wxT("voicekeyer.wav"));
wxGetApp().m_intVoiceKeyerRxPause = pConfig->Read(wxT("/VoiceKeyer/RxPause"), 10);
wxGetApp().m_intVoiceKeyerRepeats = pConfig->Read(wxT("/VoiceKeyer/Repeats"), 5);

auto wxStandardPathObj = wxStandardPaths::Get();
auto documentsDir = wxStandardPathObj.GetDocumentsDir();
wxGetApp().m_txtQuickRecordPath = pConfig->Read(wxT("/QuickRecord/SavePath"), documentsDir);
Expand Down Expand Up @@ -826,15 +820,9 @@ MainFrame::~MainFrame()
wxGetApp().appConfiguration.squelchLevel = (int)(g_SquelchLevel*2.0);

wxGetApp().appConfiguration.transmitLevel = g_txLevel;

pConfig->Write(wxT("/VoiceKeyer/WaveFilePath"), wxGetApp().m_txtVoiceKeyerWaveFilePath);
pConfig->Write(wxT("/VoiceKeyer/WaveFile"), wxGetApp().m_txtVoiceKeyerWaveFile);
pConfig->Write(wxT("/VoiceKeyer/RxPause"), wxGetApp().m_intVoiceKeyerRxPause);
pConfig->Write(wxT("/VoiceKeyer/Repeats"), wxGetApp().m_intVoiceKeyerRepeats);


pConfig->Write(wxT("/QuickRecord/SavePath"), wxGetApp().m_txtQuickRecordPath);

pConfig->Write(wxT("/Rig/EnableSpacebarForPTT"), wxGetApp().m_boolEnableSpacebarForPTT);
pConfig->Write(wxT("/Rig/HalfDuplex"), wxGetApp().m_boolHalfDuplex);
pConfig->Write(wxT("/Rig/MultipleRx"), wxGetApp().m_boolMultipleRx);
pConfig->Write(wxT("/Rig/SingleRxThread"), wxGetApp().m_boolSingleRxThread);
Expand Down
6 changes: 0 additions & 6 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,8 @@ class MainApp : public wxApp
bool m_boolMultipleRx;
bool m_boolSingleRxThread;

wxString m_txtVoiceKeyerWaveFilePath;
wxString m_txtVoiceKeyerWaveFile;
int m_intVoiceKeyerRxPause;
int m_intVoiceKeyerRepeats;

wxString m_txtQuickRecordPath;

bool m_boolEnableSpacebarForPTT;
unsigned int m_intHamlibRig;
Hamlib *m_hamlib;

Expand Down
2 changes: 1 addition & 1 deletion src/ongui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ int MainApp::FilterEvent(wxEvent& event)
// only use space to toggle PTT if we are running and no modal dialogs (like options) up
//fprintf(stderr,"frame->m_RxRunning: %d g_modal: %d\n",
// frame->m_RxRunning, g_modal);
if (frame->m_RxRunning && !g_modal && wxGetApp().m_boolEnableSpacebarForPTT) {
if (frame->m_RxRunning && !g_modal && wxGetApp().appConfiguration.enableSpaceBarForPTT) {

// space bar controls rx/rx if keyer not running
if (frame->vk_state == VK_IDLE) {
Expand Down
10 changes: 5 additions & 5 deletions src/voicekeyer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ int MainFrame::VoiceKeyerStartTx(void)
SF_INFO sfInfo;
sfInfo.format = 0;

SNDFILE* tmpPlayFile = sf_open(wxGetApp().m_txtVoiceKeyerWaveFile.mb_str(), SFM_READ, &sfInfo);
SNDFILE* tmpPlayFile = sf_open(wxGetApp().appConfiguration.voiceKeyerWaveFile->mb_str(), SFM_READ, &sfInfo);
if(tmpPlayFile == NULL) {
wxString strErr = sf_strerror(NULL);
wxMessageBox(strErr, wxT("Couldn't open:") + wxGetApp().m_txtVoiceKeyerWaveFile, wxOK);
wxMessageBox(strErr, wxT("Couldn't open:") + wxGetApp().appConfiguration.voiceKeyerWaveFile, wxOK);
m_togBtnVoiceKeyer->SetValue(false);
next_state = VK_IDLE;
}
else {
g_sfTxFs = sfInfo.samplerate;
g_sfPlayFile = tmpPlayFile;

SetStatusText(wxT("Voice Keyer: Playing file ") + wxGetApp().m_txtVoiceKeyerWaveFile + wxT(" to mic input") , 0);
SetStatusText(wxT("Voice Keyer: Playing file ") + wxGetApp().appConfiguration.voiceKeyerWaveFile + wxT(" to mic input") , 0);
g_loopPlayFileToMicIn = false;
g_playFileToMicIn = true;

Expand All @@ -62,8 +62,8 @@ void MainFrame::VoiceKeyerProcessEvent(int vk_event) {
case VK_IDLE:
if (vk_event == VK_START) {
// sample these puppies at start just in case they are changed while VK running
vk_rx_pause = wxGetApp().m_intVoiceKeyerRxPause;
vk_repeats = wxGetApp().m_intVoiceKeyerRepeats;
vk_rx_pause = wxGetApp().appConfiguration.voiceKeyerRxPause;
vk_repeats = wxGetApp().appConfiguration.voiceKeyerRepeats;
if (g_verbose) fprintf(stderr, "vk_rx_pause: %d vk_repeats: %d\n", vk_rx_pause, vk_repeats);

vk_repeat_counter = 0;
Expand Down

0 comments on commit 942d8eb

Please sign in to comment.