m_panelFreqOffset->add_new_sample(g_stats.foff);
m_panelFreqOffset->Refresh();
- // SNR text box and guage ------------------------------------------------------------
+ // SNR text box and gauge ------------------------------------------------------------
// LP filter g_stats.snr_est some more to stabilise the
// display. g_stats.snr_est already has some low pass filtering
if (snr_limited > 20.0) snr_limited = 20.0;
m_gaugeSNR->SetValue((int)(snr_limited));
+ // Level Guage -----------------------------------------------------------------------
+
+ float tooHighThresh;
+ if (!g_tx && m_RxRunning) {
+ // receive mode - display From Radio peaks
+
+ // peak from this DT sampling period
+ int maxDemodIn = 0;
+ for(int i=0; i<WAVEFORM_PLOT_BUF; i++)
+ if (maxDemodIn < abs(demodInPlotSamples[i]))
+ maxDemodIn = abs(demodInPlotSamples[i]);
+
+ // peak from last second
+ if (maxDemodIn > m_maxLevel)
+ m_maxLevel = maxDemodIn;
+
+ tooHighThresh = FROM_RADIO_MAX;
+ }
+ else {
+ // transmit mode - display From Mic peaks
+
+ // peak from this DT sampling period
+ int maxSpeechIn = 0;
+ for(int i=0; i<WAVEFORM_PLOT_BUF; i++)
+ if (maxSpeechIn < abs(speechInPlotSamples[i]))
+ maxSpeechIn = abs(speechInPlotSamples[i]);
+
+ // peak from last second
+ if (maxSpeechIn > m_maxLevel)
+ m_maxLevel = maxSpeechIn;
+
+ tooHighThresh = FROM_MIC_MAX;
+ }
+
+ // Peak Readng meter: updates peaks immediately, then slowly decays
+
+ int maxScaled = (int)(100.0 * ((float)m_maxLevel/32767.0));
+ m_gaugeLevel->SetValue(maxScaled);
+ if (((float)maxScaled/100) > tooHighThresh)
+ m_textLevel->SetLabel("Too High");
+ else
+ m_textLevel->SetLabel("");
+
+ m_maxLevel *= LEVEL_BETA;
+
// sync LED (Colours don't work on Windows)
if (g_State) {
else {
// rx-> tx transition, swap to Mic In page to monitor speech
m_auiNbookCtrl->ChangeSelection(4); // is there a way to avoid hard coding this?
- }
+ }
g_tx = m_btnTogTX->GetValue();
+ // reset level gauge
+ m_maxLevel = 0;
+ m_textLevel->SetLabel(wxT(""));
+ m_gaugeLevel->SetValue(0);
+
event.Skip();
}
//for(int i=0; i<nout; i++)
// printf("%d", varicode[i]);
//printf("\n");
- int ret = fifo_write(g_txDataInFifo, varicode, nout);
+ fifo_write(g_txDataInFifo, varicode, nout);
//printf("MainFrame::OnTogBtnTxID, sending: %s nout: %d ret: %d\n", txid2, nout, ret);
}
long secs;
if (secsString.ToLong(&secs)) {
wxGetApp().m_recFileFromRadioSecs = (unsigned int)secs;
- printf(" secondsToRecord: %d\n", (unsigned int)secs);
+ //printf(" secondsToRecord: %d\n", (unsigned int)secs);
g_recFromRadioSamples = FS*(unsigned int)secs;
- printf("g_recFromRadioSamples: %d\n", g_recFromRadioSamples);
+ //printf("g_recFromRadioSamples: %d\n", g_recFromRadioSamples);
}
else {
wxMessageBox(wxT("Invalid number of Seconds"), wxT("Record File From Radio"), wxOK);
m_txIDTimerTics = 0.0;
m_txtCtrlRx->SetValue(wxT(""));
+ m_maxLevel = 0;
+ m_textLevel->SetLabel(wxT(""));
+ m_gaugeLevel->SetValue(0);
+
//printf("g_stats.snr: %f\n", g_stats.snr_est);
// attempt to start sound cards and tx/rx processing
// portaudio struct so can't return any errors. So no need to trap
// any errors in this function.
- printf("indDevice: %d outDevice: %d\n", inDevice, outDevice);
// init input params
pa->setInputDevice(inDevice);
pa->setInputChannelCount(inputChannels); // stereo input
- printf("maxInputChannels: %d\n", inputChannels);
pa->setInputSampleFormat(PA_SAMPLE_TYPE);
pa->setInputLatency(pa->getInputDefaultLowLatency());
pa->setInputHostApiStreamInfo(NULL);
*/
pa->setFramesPerBuffer(wxGetApp().m_framesPerBuffer);
- printf("framesPerBuffer: %d\n", wxGetApp().m_framesPerBuffer);
pa->setSampleRate(sampleRate);
pa->setStreamFlags(paClipOff);
}
wxMutexLocker lock(g_mutexProtectingCallbackData);
- if (statusFlags)
- printf("cb1 statusFlags: 0x%x\n", (int)statusFlags);
+ //if (statusFlags)
+ // printf("cb1 statusFlags: 0x%x\n", (int)statusFlags);
//
// RX side processing --------------------------------------------
data_flag_index = codec2_get_spare_bit_index(c2);
assert(data_flag_index != -1); // not supported for all rates
- // if there is low speech energy and data to send, then send data frame
+ // potential bug: this should really track background noise level
+ // e.g. look at minimum frame energy. OW a high backfround level might
+ // mean no data....
if ((peak < SILENCE_THRESHOLD) && fifo_used(g_txDataInFifo)) {
//printf("sending data ...\n");
wxMutexLocker lock(g_mutexProtectingCallbackData);
- if (statusFlags)
- printf("cb2 statusFlags: 0x%x\n", (int)statusFlags);
+ // if (statusFlags)
+ // printf("cb2 statusFlags: 0x%x\n", (int)statusFlags);
// assemble a mono buffer (just use left channel) and write to FIFO
//------------------------------
wxStaticBoxSizer* levelSizer;
levelSizer = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Level")), wxVERTICAL);
+
+ m_textLevel = new wxStaticText(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(50,-1), wxALIGN_CENTRE);
+ m_textLevel->SetForegroundColour(wxColour(255,0,0));
+ levelSizer->Add(m_textLevel, 0, wxALIGN_LEFT, 1);
+
m_gaugeLevel = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(15,135), wxGA_SMOOTH|wxGA_VERTICAL);
- m_gaugeLevel->SetToolTip(_("Display signal level."));
+ m_gaugeLevel->SetToolTip(_("Peak of From Radio in Rx, or peak of From Mic in Tx mode. If Red you should reduce your levels"));
levelSizer->Add(m_gaugeLevel, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
+
leftSizer->Add(levelSizer, 2, wxALIGN_CENTER|wxALL|wxEXPAND, 1);
bSizer1->Add(leftSizer, 0, wxALL|wxEXPAND, 5);
bSizer15 = new wxBoxSizer(wxVERTICAL);
m_txtCtrlTx = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
+ m_txtCtrlTx->SetToolTip(_("Text in this box wll be sent when TxID button is pressed"));
bSizer15->Add(m_txtCtrlTx, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5);
m_txtCtrlRx = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_MULTILINE);
bSizer15->Add(m_txtCtrlRx, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5);
+ m_txtCtrlRx->SetToolTip(_("Text will be received here when RxID button is pressed"));
lowerSizer->Add(bSizer15, 1, wxEXPAND, 5);
wxBoxSizer* bSizer141;