From: drowe67 Date: Mon, 14 Sep 2015 08:08:37 +0000 (+0000) Subject: voice keyer doing the right things, haven't tested sync detection state yet X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=83c75a868601e32a70d6113b8cf56968c28e4b53;p=freetel-svn-tracking.git voice keyer doing the right things, haven't tested sync detection state yet git-svn-id: https://svn.code.sf.net/p/freetel/code@2325 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/freedv-dev/src/dlg_ptt.cpp b/freedv-dev/src/dlg_ptt.cpp index 8964587a..f9a88ce6 100644 --- a/freedv-dev/src/dlg_ptt.cpp +++ b/freedv-dev/src/dlg_ptt.cpp @@ -62,19 +62,19 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title, wxStaticText *m_staticText28b = new wxStaticText(this, wxID_ANY, _("Wave File: "), wxDefaultPosition, wxDefaultSize, 0); staticBoxSizer28a->Add(m_staticText28b, 0, wxALIGN_CENTER_VERTICAL, 5); - m_txtCtrlVoiceKeyerWaveFile = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200,-1), 0); + m_txtCtrlVoiceKeyerWaveFile = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400,-1), 0); m_txtCtrlVoiceKeyerWaveFile->SetToolTip(_("Wave file to play for Voice Keyer")); staticBoxSizer28a->Add(m_txtCtrlVoiceKeyerWaveFile, 0, 0, 5); wxStaticText *m_staticText28c = new wxStaticText(this, wxID_ANY, _(" Rx Pause: "), wxDefaultPosition, wxDefaultSize, 0); staticBoxSizer28a->Add(m_staticText28c, 0, wxALIGN_CENTER_VERTICAL , 5); - m_txtCtrlVoiceKeyerRxPause = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + m_txtCtrlVoiceKeyerRxPause = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(40,-1), 0); m_txtCtrlVoiceKeyerRxPause->SetToolTip(_("How long to wait in Rx mode before repeat")); staticBoxSizer28a->Add(m_txtCtrlVoiceKeyerRxPause, 0, 0, 5); wxStaticText *m_staticText28d = new wxStaticText(this, wxID_ANY, _(" Repeats: "), wxDefaultPosition, wxDefaultSize, 0); staticBoxSizer28a->Add(m_staticText28d, 0, wxALIGN_CENTER_VERTICAL, 5); - m_txtCtrlVoiceKeyerRepeats = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + m_txtCtrlVoiceKeyerRepeats = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(40,-1), 0); m_txtCtrlVoiceKeyerRepeats->SetToolTip(_("How long to wait in Rx mode before repeat")); staticBoxSizer28a->Add(m_txtCtrlVoiceKeyerRepeats, 0, 0, 5); diff --git a/freedv-dev/src/fdmdv2_main.cpp b/freedv-dev/src/fdmdv2_main.cpp index 3dc38c90..515f6127 100644 --- a/freedv-dev/src/fdmdv2_main.cpp +++ b/freedv-dev/src/fdmdv2_main.cpp @@ -446,6 +446,7 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) //m_togTxID->Disable(); m_togBtnAnalog->Disable(); m_btnTogPTT->Disable(); + m_togBtnVoiceKeyer->Disable(); //m_togBtnALC->Disable(); // squelch settings @@ -1386,6 +1387,7 @@ int MainApp::FilterEvent(wxEvent& event) frame->m_btnTogPTT->SetValue(true); frame->togglePTT(); + frame->VoiceKeyerProcessEvent(VK_SPACE_BAR); return true; // absorb space so we don't toggle control with focus (e.g. Start) @@ -1477,7 +1479,7 @@ void MainFrame::togglePTT(void) { + space bar turns keyer off + 5 secs of valid sync turns it off - [ ] complete state machine and builds OK + [X] complete state machine and builds OK [ ] file select dialog [ ] test all states [ ] restore size @@ -1485,7 +1487,7 @@ void MainFrame::togglePTT(void) { void MainFrame::OnTogBtnVoiceKeyerClick (wxCommandEvent& event) { - VoiceKeyerStartTx(); + VoiceKeyerProcessEvent(VK_START); event.Skip(); } @@ -1502,7 +1504,7 @@ int MainFrame::VoiceKeyerStartTx(void) g_sfPlayFile = sf_open(wxGetApp().m_txtVoiceKeyerWaveFile, SFM_READ, &sfInfo); if(g_sfPlayFile == NULL) { wxString strErr = sf_strerror(NULL); - wxMessageBox(strErr, wxT("Couldn't open voice keyer wave file"), wxOK); + wxMessageBox(strErr, wxT("Couldn't open:") + wxGetApp().m_txtVoiceKeyerWaveFile, wxOK); m_togBtnVoiceKeyer->SetValue(false); next_state = VK_IDLE; } @@ -1522,20 +1524,21 @@ int MainFrame::VoiceKeyerStartTx(void) void MainFrame::VoiceKeyerProcessEvent(int vk_event) { int next_state = vk_state; - switch(vk_state) { + switch(vk_state) { - case VK_IDLE: + 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; + fprintf(stderr, "vk_rx_pause: %d vk_repeats: %d\n", vk_rx_pause, vk_repeats); vk_repeat_counter = 0; next_state = VoiceKeyerStartTx(); } break; - case VK_TX: + case VK_TX: // In this state we are transmitting and playing a wave file // to Mic In @@ -1554,13 +1557,15 @@ void MainFrame::VoiceKeyerProcessEvent(int vk_event) { m_togBtnVoiceKeyer->SetValue(false); next_state = VK_IDLE; } - vk_rx_time = 0.0; - next_state = VK_RX; + else { + vk_rx_time = 0.0; + next_state = VK_RX; + } } break; - case VK_RX: + case VK_RX: // in this state we are receiving and waiting for // delay timer or valid sync @@ -1583,7 +1588,7 @@ void MainFrame::VoiceKeyerProcessEvent(int vk_event) { } break; - case VK_SYNC_WAIT: + case VK_SYNC_WAIT: // In this state we wait for valid sync to last // VK_SYNC_WAIT_TIME seconds @@ -1618,9 +1623,10 @@ void MainFrame::VoiceKeyerProcessEvent(int vk_event) { m_btnTogPTT->SetValue(false); togglePTT(); m_togBtnVoiceKeyer->SetValue(false); next_state = VK_IDLE; - } + } - fprintf(stderr, "VoiceKeyerProcessEvent: vk_state: %d vk_event: %d next_state: %d\n", vk_state, vk_event, next_state); + if ((vk_event != VK_DT) || (vk_state != next_state)) + fprintf(stderr, "VoiceKeyerProcessEvent: vk_state: %d vk_event: %d next_state: %d vk_repeat_counter: %d\n", vk_state, vk_event, next_state, vk_repeat_counter); vk_state = next_state; } @@ -2271,6 +2277,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event) m_togBtnAnalog->Enable(); m_togBtnOnOff->SetLabel(wxT("Stop")); m_btnTogPTT->Enable(); + m_togBtnVoiceKeyer->Enable(); m_rb1600->Disable(); m_rb700b->Disable(); @@ -2412,6 +2419,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event) //m_togTxID->Disable(); m_togBtnAnalog->Disable(); m_btnTogPTT->Disable(); + m_togBtnVoiceKeyer->Disable(); m_togBtnOnOff->SetLabel(wxT("Start")); m_rb1600->Enable(); m_rb700b->Enable(); @@ -3768,6 +3776,18 @@ int MainFrame::PollUDP(void) } sprintf(reply,"ok\n"); } + if (bufstr.StartsWith(_("ptton"), &itemToSet)) { + // note: if options dialog is open this will get overwritten + m_btnTogPTT->SetValue(true); + togglePTT(); + sprintf(reply,"ok\n"); + } + if (bufstr.StartsWith(_("pttoff"), &itemToSet)) { + // note: if options dialog is open this will get overwritten + m_btnTogPTT->SetValue(false); + togglePTT(); + sprintf(reply,"ok\n"); + } } else { diff --git a/freedv-dev/src/fdmdv2_main.h b/freedv-dev/src/fdmdv2_main.h index 34773f8a..d5910b27 100644 --- a/freedv-dev/src/fdmdv2_main.h +++ b/freedv-dev/src/fdmdv2_main.h @@ -451,6 +451,8 @@ class MainFrame : public TopFrame int PollUDP(); bool m_schedule_restore; + void VoiceKeyerProcessEvent(int vk_event); + protected: #ifdef _WIN32 @@ -530,7 +532,6 @@ class MainFrame : public TopFrame void OnIdle(wxIdleEvent &evt); #endif - void VoiceKeyerProcessEvent(int vk_event); int VoiceKeyerStartTx(void); private: diff --git a/freedv-dev/src/topFrame.cpp b/freedv-dev/src/topFrame.cpp index 9a1298b7..1bd7d4e8 100644 --- a/freedv-dev/src/topFrame.cpp +++ b/freedv-dev/src/topFrame.cpp @@ -499,7 +499,7 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const m_togBtnOnOff->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnOnOff), NULL, this); m_togBtnSplit->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnSplitClick), NULL, this); m_togBtnAnalog->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnAnalogClick), NULL, this); - m_togBtnAnalog->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this); + m_togBtnVoiceKeyer->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this); #ifdef ALC m_togBtnALC->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnALCClick), NULL, this); #endif @@ -554,7 +554,7 @@ TopFrame::~TopFrame() m_togBtnOnOff->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnOnOff), NULL, this); m_togBtnSplit->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnSplitClick), NULL, this); m_togBtnAnalog->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnAnalogClick), NULL, this); - m_togBtnAnalog->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this); + m_togBtnVoiceKeyer->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this); #ifdef ALC m_togBtnALC->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnALCClick), NULL, this); #endif