From 71e73a4cc4d82b2490b63bf00bb4345f0a2cfdc0 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 2 Jun 2019 06:41:35 +0930 Subject: [PATCH 1/7] added git hash to package name --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e2961460..6332a937f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,7 +499,7 @@ if(WIN32) endif() if(FREEDV_VERSION_SUFFIX) #set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${FREEDV_VERSION_SUFFIX}") - set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${FREEDV_VERSION_SUFFIX}-${DATE_RESULT}") + set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${FREEDV_VERSION_SUFFIX}-${DATE_RESULT}-${FREEDV_HASH}") message(STATUS "package name = ${CPACK_PACKAGE_VERSION_PATCH}") endif() # There is a bug in NSI that does not handle full unix paths properly. Make From bed6fc0052921c41a053ca873d4d427de71bc6f6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 2 Jun 2019 12:02:56 +0930 Subject: [PATCH 2/7] resolved conflict --- src/dlg_audiooptions.cpp | 341 +++++++++++--------------------------- src/dlg_audiooptions.h | 20 +-- src/fdmdv2_main.cpp | 134 +++++---------- src/fdmdv2_main.h | 8 +- src/fdmdv2_pa_wrapper.cpp | 58 +------ src/fdmdv2_pa_wrapper.h | 15 +- 6 files changed, 156 insertions(+), 420 deletions(-) diff --git a/src/dlg_audiooptions.cpp b/src/dlg_audiooptions.cpp index 1fc6d8c27..2e1ee1109 100644 --- a/src/dlg_audiooptions.cpp +++ b/src/dlg_audiooptions.cpp @@ -33,16 +33,10 @@ #define TEST_DT 0.1 // time between plot updates in seconds #define TEST_WAVEFORM_PLOT_BUF ((int)(DT*400)) -int AudioOptsDialog::displayConfigErrorCount = 0; - void AudioOptsDialog::Pa_Init(void) { m_isPaInitialized = false; - // The ALSA lib spits out a bunch of messages that are of no help to the average user - // Temporarily turn them off - freopen("/dev/null", "w", stderr); - if((pa_err = Pa_Initialize()) == paNoError) { m_isPaInitialized = true; @@ -52,7 +46,6 @@ void AudioOptsDialog::Pa_Init(void) wxMessageBox(wxT("Port Audio failed to initialize"), wxT("Pa_Initialize"), wxOK); return; } - freopen("/dev/tty", "w", stderr); } @@ -401,110 +394,35 @@ void AudioOptsDialog::OnInitDialog( wxInitDialogEvent& event ) } //------------------------------------------------------------------------- -// setTextCtrlIfDevNameValid() +// OnInitDialog() // // helper function to look up name of devNum, and if it exists write // name to textCtrl. Used to trap dissapearing devices. //------------------------------------------------------------------------- -std::string AudioOptsDialog::setTextCtrlIfDevNameValid(wxTextCtrl *textCtrl, wxListCtrl *listCtrl, std::string &audioDevName) +int AudioOptsDialog::setTextCtrlIfDevNumValid(wxTextCtrl *textCtrl, wxListCtrl *listCtrl, int devNum) { - int i; - std::string devName = ""; - int found_devNum = -1; - std::string foundDevName; + int i, aDevNum, found_devNum; // ignore last list entry as it is the "none" entry - for(i=0; iGetItemCount()-1; i++) { - devName = listCtrl->GetItemText(i, 0); - //wxPrintf("setTextCtrlIfDevNameValid first pass, audioDevName: %s devName: %s\n", audioDevName, devName); - if (devName == audioDevName) { - found_devNum = i; - foundDevName = devName; - //wxPrintf("setTextCtrlIfDevNameValid, found complete name\n"); - break; // weird, this break doesn't pop us out of 'for' loop - } - } - if (found_devNum == -1) { - // It could be that the user swapped out audio devices prior to last saving configuration, - // in which case, the (hw:n,m) string could be different. If a substring with the name excluding - // (hw:n,m) is found, then use it. The generic "USB Audio Codec" is often assigned to more than - // one device, in which case, it can't be used. - int numberOfCodecDevices = CountNumberOfCodecDevices(listCtrl); - - for (i = 0; i < listCtrl->GetItemCount()-1; i++) { - devName = listCtrl->GetItemText(i, 0); - - // Get the names up to, but not including the "hw(..." string - // Also exclude Window's "n - " that can occur at beginning - std::string audioDevNameSubstr = stripAudioDevName(audioDevName); - std::string devNameSubstr = stripAudioDevName(devName); - - if(audioDevNameSubstr == devNameSubstr) { - if((audioDevName.find("USB Audio Codec") == std::string::npos) - || ( numberOfCodecDevices == 1)) { - found_devNum = i; - foundDevName = devName; - } - } + found_devNum = 0; + for(i=0; iGetItemCount()-1; i++) { + aDevNum = wxAtoi(listCtrl->GetItemText(i, 1)); + //printf("aDevNum: %d devNum: %d\n", aDevNum, devNum); + if (aDevNum == devNum) { + found_devNum = 1; + textCtrl->SetValue(listCtrl->GetItemText(i, 0) + " (" + wxString::Format(wxT("%i"),devNum) + ")"); + printf("setting focus of %d\n", i); + listCtrl->SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); } } - if (found_devNum != -1) { - textCtrl->SetValue(foundDevName); - listCtrl->SetItemState(found_devNum, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); - } else { + if (found_devNum) + return devNum; + else { textCtrl->SetValue("none"); - foundDevName = ""; - } - - return foundDevName; -} - -//------------------------------------------------------------------------- -// stripAudioDevName() -//------------------------------------------------------------------------- -std::string AudioOptsDialog::stripAudioDevName(std::string & devName) -{ - // Get the names up to, but not including the "hw(..." string - // Also exclude Window's "n - " that can occur at beginning - - // Drop everything after "- (hw" that is, stuff like "- (hw:1,0) - size_t posEnd = devName.find("(hw"); - std::string strippedDevName = devName.substr(0, posEnd); - - // for Windows, get rid of"n-", example, "microphone (5- USB..." becomes "microphone (USB - // If you find a dash, then get rid of the dash and the char/number - size_t posStart = strippedDevName.find("-"); - if (posStart != std::string::npos) - { - strippedDevName.erase(posStart -1, 3 ); - } - - // Windows returns variable length names when same usb dev plugged into different - // usb ports!!! - strippedDevName.resize(27); - - return strippedDevName; -} - -//------------------------------------------------------------------------- -// CountNumberOfCodecDevices() -//------------------------------------------------------------------------- -int AudioOptsDialog::CountNumberOfCodecDevices(wxListCtrl *listCtrl) -{ - int numberOfCodecDevices = 0; - std::string devName; - int i; - - for(i=0; iGetItemCount()-1; i++) { - devName = listCtrl->GetItemText(i, 0); - - if(devName.find("USB Audio CODEC") != std::string::npos) - ++numberOfCodecDevices; + return -1; } - - return numberOfCodecDevices; } //------------------------------------------------------------------------- @@ -517,107 +435,70 @@ int AudioOptsDialog::ExchangeData(int inout) // Map sound card device numbers to tx/rx device numbers depending // on number of sound cards in use - wxPrintf("EXCHANGE_DATA_IN:\n"); - wxPrintf(" g_nSoundCards: %d\n", g_nSoundCards); - wxPrintf(" g_soundCard1InDeviceName: %s\n", g_soundCard1InDeviceName); - wxPrintf(" g_soundCard1OutDeviceName: %s\n", g_soundCard1OutDeviceName); - wxPrintf(" g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate); - wxPrintf(" g_soundCard2InDeviceName: %s\n", g_soundCard2InDeviceName); - wxPrintf(" g_soundCard2OutDeviceName: %s\n", g_soundCard2OutDeviceName); - wxPrintf(" g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate); + printf("EXCHANGE_DATA_IN:\n"); + printf(" g_nSoundCards: %d\n", g_nSoundCards); + printf(" g_soundCard1InDeviceNum: %d\n", g_soundCard1InDeviceNum); + printf(" g_soundCard1OutDeviceNum: %d\n", g_soundCard1OutDeviceNum); + printf(" g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate); + printf(" g_soundCard2InDeviceNum: %d\n", g_soundCard2InDeviceNum); + printf(" g_soundCard2OutDeviceNum: %d\n", g_soundCard2OutDeviceNum); + printf(" g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate); if (g_nSoundCards == 0) { - m_textCtrlRxIn ->SetValue("none"); rxInAudioDeviceName = ""; - m_textCtrlRxOut->SetValue("none"); rxOutAudioDeviceName = ""; - m_textCtrlTxIn ->SetValue("none"); txInAudioDeviceName = ""; - m_textCtrlTxOut->SetValue("none"); txOutAudioDeviceName = ""; + m_textCtrlRxIn ->SetValue("none"); rxInAudioDeviceNum = -1; + m_textCtrlRxOut->SetValue("none"); rxOutAudioDeviceNum = -1; + m_textCtrlTxIn ->SetValue("none"); txInAudioDeviceNum = -1; + m_textCtrlTxOut->SetValue("none"); txOutAudioDeviceNum = -1; } if (g_nSoundCards == 1) { - rxInAudioDeviceName = setTextCtrlIfDevNameValid(m_textCtrlRxIn, - m_listCtrlRxInDevices, - g_soundCard1InDeviceName); + rxInAudioDeviceNum = setTextCtrlIfDevNumValid(m_textCtrlRxIn, + m_listCtrlRxInDevices, + g_soundCard1InDeviceNum); - rxOutAudioDeviceName = setTextCtrlIfDevNameValid(m_textCtrlRxOut, + rxOutAudioDeviceNum = setTextCtrlIfDevNumValid(m_textCtrlRxOut, m_listCtrlRxOutDevices, - g_soundCard1OutDeviceName); + g_soundCard1OutDeviceNum); - if ((rxInAudioDeviceName != "") && (rxOutAudioDeviceName != "")) { + if ((rxInAudioDeviceNum != -1) && (rxInAudioDeviceNum != -1)) { m_cbSampleRateRxIn->SetValue(wxString::Format(wxT("%i"),g_soundCard1SampleRate)); m_cbSampleRateRxOut->SetValue(wxString::Format(wxT("%i"),g_soundCard1SampleRate)); } - else - { - m_cbSampleRateRxIn->SetValue(wxT("None")); - m_cbSampleRateRxOut->SetValue(wxT("None")); - wxMessageBox(wxT("Unable to match previously configured audio input/output devices with " - "current hardware configuration."), wxT("Audio Config Issue"), wxOK); - } - m_textCtrlTxIn ->SetValue("none"); txInAudioDeviceName = ""; - m_textCtrlTxOut->SetValue("none"); txOutAudioDeviceName = ""; + m_textCtrlTxIn ->SetValue("none"); txInAudioDeviceNum = -1; + m_textCtrlTxOut->SetValue("none"); txOutAudioDeviceNum = -1; } if (g_nSoundCards == 2) { - bool audioCardsOk = true; - rxInAudioDeviceName = setTextCtrlIfDevNameValid(m_textCtrlRxIn, + + rxInAudioDeviceNum = setTextCtrlIfDevNumValid(m_textCtrlRxIn, m_listCtrlRxInDevices, - g_soundCard1InDeviceName); + g_soundCard1InDeviceNum); - rxOutAudioDeviceName = setTextCtrlIfDevNameValid(m_textCtrlRxOut, + rxOutAudioDeviceNum = setTextCtrlIfDevNumValid(m_textCtrlRxOut, m_listCtrlRxOutDevices, - g_soundCard2OutDeviceName); + g_soundCard2OutDeviceNum); - txInAudioDeviceName = setTextCtrlIfDevNameValid(m_textCtrlTxIn, + txInAudioDeviceNum = setTextCtrlIfDevNumValid(m_textCtrlTxIn, m_listCtrlTxInDevices, - g_soundCard2InDeviceName); + g_soundCard2InDeviceNum); - txOutAudioDeviceName = setTextCtrlIfDevNameValid(m_textCtrlTxOut, + txOutAudioDeviceNum = setTextCtrlIfDevNumValid(m_textCtrlTxOut, m_listCtrlTxOutDevices, - g_soundCard1OutDeviceName); - - if ((rxInAudioDeviceName != "") && (txOutAudioDeviceName != "")) { - // Reset the global devices names in case there was an acceptable name change - // e.g. (hw:0,0) becomes (hw:1,0) - g_soundCard1InDeviceName = rxInAudioDeviceName; - g_soundCard1OutDeviceName = txOutAudioDeviceName; + g_soundCard1OutDeviceNum); + if ((rxInAudioDeviceNum != -1) && (txOutAudioDeviceNum != -1)) { m_cbSampleRateRxIn->SetValue(wxString::Format(wxT("%i"),g_soundCard1SampleRate)); m_cbSampleRateTxOut->SetValue(wxString::Format(wxT("%i"),g_soundCard1SampleRate)); } - else { - // While there *may* have been two sound cards, one could have been pulled out. - audioCardsOk = false; - m_cbSampleRateRxIn->SetValue(wxT("None")); - m_cbSampleRateTxOut->SetValue(wxT("None")); - } - - if ((txInAudioDeviceName != "") && (rxOutAudioDeviceName != "")) { - // Reset the global devices names in case there was an acceptable name change - g_soundCard2InDeviceName = txInAudioDeviceName; - g_soundCard2OutDeviceName = rxOutAudioDeviceName; + if ((txInAudioDeviceNum != -1) && (rxOutAudioDeviceNum != -1)) { m_cbSampleRateTxIn->SetValue(wxString::Format(wxT("%i"),g_soundCard2SampleRate)); m_cbSampleRateRxOut->SetValue(wxString::Format(wxT("%i"),g_soundCard2SampleRate)); } - else { - // While there *may* have been two sound cards, one could have been pulled out. - audioCardsOk = false; - m_cbSampleRateTxIn->SetValue(wxT("None")); - m_cbSampleRateRxOut->SetValue(wxT("None")); - } - - if(!audioCardsOk && displayConfigErrorCount < 1) - { - // This message should only be displayed once, and usually that occurs at startup if the - // user had inadverently removed hwd that was connected to FreeDV - wxMessageBox(wxT("Unable to match previously configured audio input/output devices with " - "current hardware configuration."), wxT("Audio Config Issue"), wxOK); - ++displayConfigErrorCount; - } } - wxPrintf(" rxInAudioDeviceName: %s\n rxOutAudioDeviceName: %s\n txInAudioDeviceName: %s\n txOutAudioDeviceName: %s\n", - rxInAudioDeviceName, rxOutAudioDeviceName, txInAudioDeviceName, txOutAudioDeviceName); + printf(" rxInAudioDeviceNum: %d\n rxOutAudioDeviceNum: %d\n txInAudioDeviceNum: %d\n txOutAudioDeviceNum: %d\n", + rxInAudioDeviceNum, rxOutAudioDeviceNum, txInAudioDeviceNum, txOutAudioDeviceNum); } if(inout == EXCHANGE_DATA_OUT) @@ -627,8 +508,8 @@ int AudioOptsDialog::ExchangeData(int inout) wxString sampleRate1, sampleRate2; printf("EXCHANGE_DATA_OUT:\n"); - wxPrintf(" rxInAudioDeviceName: %s\n rxOutAudioDeviceName: %s\n txInAudioDeviceName: %s\n txOutAudioDeviceName: %s\n", - rxInAudioDeviceName, rxOutAudioDeviceName, txInAudioDeviceName, txOutAudioDeviceName); + printf(" rxInAudioDeviceNum: %d\n rxOutAudioDeviceNum: %d\n txInAudioDeviceNum: %d\n txOutAudioDeviceNum: %d\n", + rxInAudioDeviceNum, rxOutAudioDeviceNum, txInAudioDeviceNum, txOutAudioDeviceNum); // --------------------------------------------------------------- // check we have a valid 1 or 2 sound card configuration @@ -636,8 +517,8 @@ int AudioOptsDialog::ExchangeData(int inout) // one sound card config, tx device numbers should be set to -1 - if ((rxInAudioDeviceName != "") && (rxOutAudioDeviceName != "") && - (txInAudioDeviceName == "") && (txOutAudioDeviceName == "")) { + if ((rxInAudioDeviceNum != -1) && (rxOutAudioDeviceNum != -1) && + (txInAudioDeviceNum == -1) && (txOutAudioDeviceNum == -1)) { valid_one_card_config = 1; @@ -653,19 +534,19 @@ int AudioOptsDialog::ExchangeData(int inout) // two card configuration - if ((rxInAudioDeviceName != "") && (rxOutAudioDeviceName != "") && - (txInAudioDeviceName != "") && (txOutAudioDeviceName != "")) { + if ((rxInAudioDeviceNum != -1) && (rxOutAudioDeviceNum != -1) && + (txInAudioDeviceNum != -1) && (txOutAudioDeviceNum != -1)) { valid_two_card_config = 1; // Check we haven't doubled up on sound devices - if (rxInAudioDeviceName == txInAudioDeviceName) { + if (rxInAudioDeviceNum == txInAudioDeviceNum) { wxMessageBox(wxT("You must use different devices for From Radio and From Microphone"), wxT(""), wxOK); return -1; } - if (rxOutAudioDeviceName == txOutAudioDeviceName) { + if (rxOutAudioDeviceNum == txOutAudioDeviceNum) { wxMessageBox(wxT("You must use different devices for To Radio and To Speaker/Headphones"), wxT(""), wxOK); return -1; } @@ -706,43 +587,43 @@ int AudioOptsDialog::ExchangeData(int inout) // Tx/Rx oriented as in this dialog. // --------------------------------------------------------------- g_nSoundCards = 0; - g_soundCard1InDeviceName = g_soundCard1OutDeviceName = g_soundCard2InDeviceName = g_soundCard2OutDeviceName =""; + g_soundCard1InDeviceNum = g_soundCard1OutDeviceNum = g_soundCard2InDeviceNum = g_soundCard2OutDeviceNum = -1; if (valid_one_card_config) { // Only callback 1 used g_nSoundCards = 1; - g_soundCard1InDeviceName = rxInAudioDeviceName; - g_soundCard1OutDeviceName = rxOutAudioDeviceName; + g_soundCard1InDeviceNum = rxInAudioDeviceNum; + g_soundCard1OutDeviceNum = rxOutAudioDeviceNum; g_soundCard1SampleRate = wxAtoi(sampleRate1); } if (valid_two_card_config) { g_nSoundCards = 2; - g_soundCard1InDeviceName = rxInAudioDeviceName; - g_soundCard1OutDeviceName = txOutAudioDeviceName; + g_soundCard1InDeviceNum = rxInAudioDeviceNum; + g_soundCard1OutDeviceNum = txOutAudioDeviceNum; g_soundCard1SampleRate = wxAtoi(sampleRate1); - g_soundCard2InDeviceName = txInAudioDeviceName; - g_soundCard2OutDeviceName = rxOutAudioDeviceName; + g_soundCard2InDeviceNum = txInAudioDeviceNum; + g_soundCard2OutDeviceNum = rxOutAudioDeviceNum; g_soundCard2SampleRate = wxAtoi(sampleRate2); } - wxPrintf(" g_nSoundCards: %d\n", g_nSoundCards); - wxPrintf(" g_soundCard1InDeviceName: %s\n", g_soundCard1InDeviceName); - wxPrintf(" g_soundCard1OutDeviceName: %s\n", g_soundCard1OutDeviceName); - wxPrintf(" g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate); - wxPrintf(" g_soundCard2InDeviceName: %s\n", g_soundCard2InDeviceName); - wxPrintf(" g_soundCard2OutDeviceName: %s\n", g_soundCard2OutDeviceName); - wxPrintf(" g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate); + printf(" g_nSoundCards: %d\n", g_nSoundCards); + printf(" g_soundCard1InDeviceNum: %d\n", g_soundCard1InDeviceNum); + printf(" g_soundCard1OutDeviceNum: %d\n", g_soundCard1OutDeviceNum); + printf(" g_soundCard1SampleRate: %d\n", g_soundCard1SampleRate); + printf(" g_soundCard2InDeviceNum: %d\n", g_soundCard2InDeviceNum); + printf(" g_soundCard2OutDeviceNum: %d\n", g_soundCard2OutDeviceNum); + printf(" g_soundCard2SampleRate: %d\n", g_soundCard2SampleRate); wxConfigBase *pConfig = wxConfigBase::Get(); - pConfig->Write(wxT("/Audio/soundCard1InDeviceName"), wxString(g_soundCard1InDeviceName)); - pConfig->Write(wxT("/Audio/soundCard1OutDeviceName"), wxString(g_soundCard1OutDeviceName)); + pConfig->Write(wxT("/Audio/soundCard1InDeviceNum"), g_soundCard1InDeviceNum); + pConfig->Write(wxT("/Audio/soundCard1OutDeviceNum"), g_soundCard1OutDeviceNum); pConfig->Write(wxT("/Audio/soundCard1SampleRate"), g_soundCard1SampleRate ); - pConfig->Write(wxT("/Audio/soundCard2InDeviceName"), wxString(g_soundCard2InDeviceName)); - pConfig->Write(wxT("/Audio/soundCard2OutDeviceName"), wxString(g_soundCard2OutDeviceName)); + pConfig->Write(wxT("/Audio/soundCard2InDeviceNum"), g_soundCard2InDeviceNum); + pConfig->Write(wxT("/Audio/soundCard2OutDeviceNum"), g_soundCard2OutDeviceNum); pConfig->Write(wxT("/Audio/soundCard2SampleRate"), g_soundCard2SampleRate ); pConfig->Flush(); @@ -809,7 +690,7 @@ int AudioOptsDialog:: buildListOfSupportedSampleRates(wxComboBox *cbSampleRate, if( err == paFormatIsSupported ) { str.Printf("%i", (int)standardSampleRates[i]); cbSampleRate->AppendString(str); - wxPrintf("Supported rates: %i\n", (int)standardSampleRates[i]); + printf("%i ", (int)standardSampleRates[i]); numSampleRates++; } } @@ -915,27 +796,15 @@ void AudioOptsDialog::populateParams(AudioInfoDisplay ai) if( ((in_out == AUDIO_IN) && (deviceInfo->maxInputChannels > 0)) || ((in_out == AUDIO_OUT) && (deviceInfo->maxOutputChannels > 0))) { - wxString devName = deviceInfo->name; - wxString apiName = Pa_GetHostApiInfo(deviceInfo->hostApi)->name; - // Don't display Windows Direct Sound devices, as it clutters up the list of - // available devices. - if (apiName.Contains(wxT("Direct"))) - continue; - - // Don't display spdif devices or surround - if(devName.Contains(wxT("spdif")) || devName.Contains(wxT("surround"))) - continue; - col = 0; - buf.Printf(wxT("%s"), devName); + buf.Printf(wxT("%s"), deviceInfo->name); idx = ctrl->InsertItem(ctrl->GetItemCount(), buf); col++; buf.Printf(wxT("%d"), devn); ctrl->SetItem(idx, col++, buf); - - buf.Printf(wxT("%s"), apiName); + buf.Printf(wxT("%s"), Pa_GetHostApiInfo(deviceInfo->hostApi)->name); ctrl->SetItem(idx, col++, buf); buf.Printf(wxT("%i"), (int)deviceInfo->defaultSampleRate); @@ -971,23 +840,22 @@ void AudioOptsDialog::populateParams(AudioInfoDisplay ai) //------------------------------------------------------------------------- void AudioOptsDialog::OnDeviceSelect(wxComboBox *cbSampleRate, wxTextCtrl *textCtrl, - std::string & audioDevName, + int *devNum, wxListCtrl *listCtrlDevices, int index, int in_out) { - int devNum; + wxString devName = listCtrlDevices->GetItemText(index, 0); if (devName.IsSameAs("none")) { - audioDevName = ""; - textCtrl->SetValue("none"); + *devNum = -1; + textCtrl->SetValue("none"); } else { - // Report the selected name back to the caller - audioDevName = devName; - textCtrl->SetValue(devName); - devNum = wxAtoi(listCtrlDevices->GetItemText(index, 1)); - int numSampleRates = buildListOfSupportedSampleRates(cbSampleRate, devNum, in_out); + *devNum = wxAtoi(listCtrlDevices->GetItemText(index, 1)); + textCtrl->SetValue(devName + " (" + wxString::Format(wxT("%i"),*devNum) + ")"); + + int numSampleRates = buildListOfSupportedSampleRates(cbSampleRate, *devNum, in_out); if (numSampleRates) { wxString defSampleRate = listCtrlDevices->GetItemText(index, 3); cbSampleRate->SetValue(defSampleRate); @@ -1005,7 +873,7 @@ void AudioOptsDialog::OnRxInDeviceSelect(wxListEvent& evt) { OnDeviceSelect(m_cbSampleRateRxIn, m_textCtrlRxIn, - rxInAudioDeviceName, + &rxInAudioDeviceNum, m_listCtrlRxInDevices, evt.GetIndex(), AUDIO_IN); @@ -1018,7 +886,7 @@ void AudioOptsDialog::OnRxOutDeviceSelect(wxListEvent& evt) { OnDeviceSelect(m_cbSampleRateRxOut, m_textCtrlRxOut, - rxOutAudioDeviceName, + &rxOutAudioDeviceNum, m_listCtrlRxOutDevices, evt.GetIndex(), AUDIO_OUT); @@ -1031,7 +899,7 @@ void AudioOptsDialog::OnTxInDeviceSelect(wxListEvent& evt) { OnDeviceSelect(m_cbSampleRateTxIn, m_textCtrlTxIn, - txInAudioDeviceName, + &txInAudioDeviceNum, m_listCtrlTxInDevices, evt.GetIndex(), AUDIO_IN); @@ -1044,7 +912,7 @@ void AudioOptsDialog::OnTxOutDeviceSelect(wxListEvent& evt) { OnDeviceSelect(m_cbSampleRateTxOut, m_textCtrlTxOut, - txOutAudioDeviceName, + &txOutAudioDeviceNum, m_listCtrlTxOutDevices, evt.GetIndex(), AUDIO_OUT); @@ -1057,7 +925,7 @@ void AudioOptsDialog::OnTxOutDeviceSelect(wxListEvent& evt) // synchronous portaudio functions, so the GUI will not respond until after test sample has been // taken //------------------------------------------------------------------------- -void AudioOptsDialog::plotDeviceInputForAFewSecs(const std::string & soundCardName, PlotScalar *plotScalar) { +void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotScalar) { PaStreamParameters inputParameters; const PaDeviceInfo *deviceInfo = NULL; PaStream *stream = NULL; @@ -1069,8 +937,6 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(const std::string & soundCardNa SRC_STATE *src; FIFO *fifo; - PaDeviceIndex devNum = PortAudioWrap::getDeviceIndex(soundCardName); - // a basic sanity check numDevices = Pa_GetDeviceCount(); if (devNum >= numDevices) @@ -1178,7 +1044,7 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(const std::string & soundCardNa // synchronous portaudio functions, so the GUI will not respond until after test sample has been // taken. Also plots a pretty picture like the record versions //------------------------------------------------------------------------- -void AudioOptsDialog::plotDeviceOutputForAFewSecs(const std::string &soundCardName, PlotScalar *plotScalar) { +void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotScalar) { PaStreamParameters outputParameters; const PaDeviceInfo *deviceInfo = NULL; PaStream *stream = NULL; @@ -1190,19 +1056,6 @@ void AudioOptsDialog::plotDeviceOutputForAFewSecs(const std::string &soundCardNa SRC_STATE *src; FIFO *fifo; - - // Clear the plot - short plotSamples[TEST_WAVEFORM_PLOT_BUF*2]; - memset(plotSamples, 0, TEST_WAVEFORM_PLOT_BUF*2 * sizeof(short)); - for(int i = 0; i < (TEST_WAVEFORM_PLOT_TIME * TEST_WAVEFORM_PLOT_FS); i += TEST_WAVEFORM_PLOT_BUF) - plotScalar->add_new_short_samples(0, plotSamples, TEST_WAVEFORM_PLOT_BUF, 32767); - - plotScalar->Refresh(); - plotScalar->Update(); - - - PaDeviceIndex devNum = PortAudioWrap::getDeviceIndex(soundCardName); - // a basic sanity check numDevices = Pa_GetDeviceCount(); if (devNum >= numDevices) @@ -1264,7 +1117,7 @@ void AudioOptsDialog::plotDeviceOutputForAFewSecs(const std::string &soundCardNa while(sampleCount < (TEST_WAVEFORM_PLOT_TIME * TEST_WAVEFORM_PLOT_FS)) { for(j=0; jShow(); g_parent =frame; - AudioOptsDialog *dlg = new AudioOptsDialog(NULL); - dlg->ExchangeData(EXCHANGE_DATA_IN); - delete dlg; - - return true; } @@ -451,54 +441,20 @@ MainFrame::MainFrame(wxString plugInName, wxWindow *parent) : TopFrame(plugInNam wxGetApp().m_framesPerBuffer = pConfig->Read(wxT("/Audio/framesPerBuffer"), (int)PA_FPB); wxGetApp().m_fifoSize_ms = pConfig->Read(wxT("/Audio/fifoSize_ms"), (int)FIFO_SIZE); - // Legacy FreeDV would use sound card device numbers in the config file, but these numbers - // are not static within the OS. Newer FreeDV uses device names instead. - g_soundCard1InDeviceNum = pConfig->Read(wxT("/Audio/soundCard1InDeviceNum"), paNoDevice); - g_soundCard1OutDeviceNum = pConfig->Read(wxT("/Audio/soundCard1OutDeviceNum"), paNoDevice); - g_soundCard1SampleRate = pConfig->Read(wxT("/Audio/soundCard1SampleRate"), -1); + g_soundCard1InDeviceNum = pConfig->Read(wxT("/Audio/soundCard1InDeviceNum"), -1); + g_soundCard1OutDeviceNum = pConfig->Read(wxT("/Audio/soundCard1OutDeviceNum"), -1); + g_soundCard1SampleRate = pConfig->Read(wxT("/Audio/soundCard1SampleRate"), -1); - g_soundCard2InDeviceNum = pConfig->Read(wxT("/Audio/soundCard2InDeviceNum"), paNoDevice); - g_soundCard2OutDeviceNum = pConfig->Read(wxT("/Audio/soundCard2OutDeviceNum"), paNoDevice); - g_soundCard2SampleRate = pConfig->Read(wxT("/Audio/soundCard2SampleRate"), -1); - - g_soundCard1InDeviceName = pConfig->Read(wxT("/Audio/soundCard1InDeviceName"), wxT("")); - g_soundCard1OutDeviceName = pConfig->Read(wxT("/Audio/soundCard1OutDeviceName"), wxT("")); - - g_soundCard2InDeviceName = pConfig->Read(wxT("/Audio/soundCard2InDeviceName"), wxT("")); - g_soundCard2OutDeviceName = pConfig->Read(wxT("/Audio/soundCard2OutDeviceName"), wxT("")); - - // Temporarily initialize port audio so we can attempt to get device names based on - // previous device numbers. Temp redirect stderr so ALSA lib doesn't clutter term output - - freopen("/dev/null", "w", stderr); - - if(Pa_Initialize()) - { - wxMessageBox(wxT("Port Audio failed to initialize"), wxT("Pa_Initialize"), wxOK); - } - freopen("/dev/tty", "w", stderr); - - // In the event the user's config file uses legacy device numbers and not strings, use - // device numbers if they, and not the strings, are available. Save names instead later. - if ((g_soundCard1InDeviceNum != -1) && (g_soundCard1InDeviceName == "")) - g_soundCard1InDeviceName = PortAudioWrap::getDeviceNameStr(g_soundCard1InDeviceNum); - - if ((g_soundCard1OutDeviceNum != -1) && (g_soundCard1OutDeviceName == "")) - g_soundCard1OutDeviceName = PortAudioWrap::getDeviceNameStr(g_soundCard1OutDeviceNum); - - if ((g_soundCard2InDeviceNum != -1) && (g_soundCard2InDeviceName == "")) - g_soundCard2InDeviceName = PortAudioWrap::getDeviceNameStr(g_soundCard2InDeviceNum); - - if ((g_soundCard2OutDeviceNum != -1) && (g_soundCard2OutDeviceName == "")) - g_soundCard2OutDeviceName = PortAudioWrap::getDeviceNameStr(g_soundCard2OutDeviceNum); + g_soundCard2InDeviceNum = pConfig->Read(wxT("/Audio/soundCard2InDeviceNum"), -1); + g_soundCard2OutDeviceNum = pConfig->Read(wxT("/Audio/soundCard2OutDeviceNum"), -1); + g_soundCard2SampleRate = pConfig->Read(wxT("/Audio/soundCard2SampleRate"), -1); g_nSoundCards = 0; - if ((g_soundCard1InDeviceName != "") && (g_soundCard1OutDeviceName != "")) { + if ((g_soundCard1InDeviceNum > -1) && (g_soundCard1OutDeviceNum > -1)) { g_nSoundCards = 1; - if ((g_soundCard2InDeviceName != "") && (g_soundCard2OutDeviceName != "")) + if ((g_soundCard2InDeviceNum > -1) && (g_soundCard2OutDeviceNum > -1)) g_nSoundCards = 2; } - Pa_Terminate(); wxGetApp().m_playFileToMicInPath = pConfig->Read("/File/playFileToMicInPath", wxT("")); wxGetApp().m_recFileFromRadioPath = pConfig->Read("/File/recFileFromRadioPath", wxT("")); @@ -744,7 +700,6 @@ MainFrame::MainFrame(wxString plugInName, wxWindow *parent) : TopFrame(plugInNam wxGetApp().m_txRxThreadHighPriority = true; g_dump_timing = g_dump_fifo_state = 0; - UDPInit(); } @@ -813,12 +768,12 @@ MainFrame::~MainFrame() pConfig->Write(wxT("/Audio/framesPerBuffer"), wxGetApp().m_framesPerBuffer); pConfig->Write(wxT("/Audio/fifoSize_ms"), wxGetApp().m_fifoSize_ms); - pConfig->Write(wxT("/Audio/soundCard1InDeviceName"), wxString(g_soundCard1InDeviceName)); - pConfig->Write(wxT("/Audio/soundCard1OutDeviceName"), wxString(g_soundCard1OutDeviceName)); + pConfig->Write(wxT("/Audio/soundCard1InDeviceNum"), g_soundCard1InDeviceNum); + pConfig->Write(wxT("/Audio/soundCard1OutDeviceNum"), g_soundCard1OutDeviceNum); pConfig->Write(wxT("/Audio/soundCard1SampleRate"), g_soundCard1SampleRate ); - pConfig->Write(wxT("/Audio/soundCard2InDeviceName"), wxString(g_soundCard2InDeviceName)); - pConfig->Write(wxT("/Audio/soundCard2OutDeviceName"), wxString(g_soundCard2OutDeviceName)); + pConfig->Write(wxT("/Audio/soundCard2InDeviceNum"), g_soundCard2InDeviceNum); + pConfig->Write(wxT("/Audio/soundCard2OutDeviceNum"), g_soundCard2OutDeviceNum); pConfig->Write(wxT("/Audio/soundCard2SampleRate"), g_soundCard2SampleRate ); pConfig->Write(wxT("/VoiceKeyer/WaveFilePath"), wxGetApp().m_txtVoiceKeyerWaveFilePath); @@ -2654,6 +2609,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event) // // Start Running ------------------------------------------------- // + // modify some button states when running m_togBtnOnOff->SetLabel(wxT("Stop")); @@ -3074,12 +3030,11 @@ void MainFrame::startRxStream() } m_rxInPa = new PortAudioWrap(); - - if(g_soundCard1InDeviceName != g_soundCard1OutDeviceName) + if(g_soundCard1InDeviceNum != g_soundCard1OutDeviceNum) two_rx=true; - if(g_soundCard2InDeviceName != g_soundCard2OutDeviceName) + if(g_soundCard2InDeviceNum != g_soundCard2OutDeviceNum) two_tx=true; - + //fprintf(stderr, "two_rx: %d two_tx: %d\n", two_rx, two_tx); if(two_rx) m_rxOutPa = new PortAudioWrap(); @@ -3097,26 +3052,25 @@ void MainFrame::startRxStream() // Init Sound card 1 ---------------------------------------------- // sanity check on sound card device numbers - if( !PortAudioWrap::isSoundCardNameValid(g_soundCard1InDeviceName) - || !PortAudioWrap::isSoundCardNameValid(g_soundCard1OutDeviceName)) { + + if ((m_rxInPa->getDeviceCount() <= g_soundCard1InDeviceNum) || + (m_rxOutPa->getDeviceCount() <= g_soundCard1OutDeviceNum)) { wxMessageBox(wxT("Sound Card 1 not present"), wxT("Error"), wxOK); delete m_rxInPa; if(two_rx) - delete m_rxOutPa; + delete m_rxOutPa; m_RxRunning = false; return; - } - // work out how many input channels this device supports. - PaDeviceIndex soundCard1InDeviceNum = PortAudioWrap::getDeviceIndex(g_soundCard1InDeviceName); - deviceInfo1 = Pa_GetDeviceInfo(soundCard1InDeviceNum); + + deviceInfo1 = Pa_GetDeviceInfo(g_soundCard1InDeviceNum); if (deviceInfo1 == NULL) { wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card 1"), wxT("Error"), wxOK); delete m_rxInPa; if(two_rx) - delete m_rxOutPa; + delete m_rxOutPa; m_RxRunning = false; return; } @@ -3125,17 +3079,14 @@ void MainFrame::startRxStream() else inputChannels1 = 2; - PaDeviceIndex soundCard1OutDeviceNum = PortAudioWrap::getDeviceIndex(g_soundCard1OutDeviceName); - if(two_rx) { - initPortAudioDevice(m_rxInPa, soundCard1InDeviceNum, paNoDevice, 1, + initPortAudioDevice(m_rxInPa, g_soundCard1InDeviceNum, paNoDevice, 1, g_soundCard1SampleRate, inputChannels1); - - initPortAudioDevice(m_rxOutPa, paNoDevice, soundCard1OutDeviceNum, 1, + initPortAudioDevice(m_rxOutPa, paNoDevice, g_soundCard1OutDeviceNum, 1, g_soundCard1SampleRate, inputChannels1); } else - initPortAudioDevice(m_rxInPa, soundCard1InDeviceNum, soundCard1OutDeviceNum, 1, + initPortAudioDevice(m_rxInPa, g_soundCard1InDeviceNum, g_soundCard1OutDeviceNum, 1, g_soundCard1SampleRate, inputChannels1); // Init Sound Card 2 ------------------------------------------------ @@ -3151,11 +3102,11 @@ void MainFrame::startRxStream() // sanity check on sound card device numbers //printf("m_txInPa->getDeviceCount(): %d\n", m_txInPa->getDeviceCount()); - //wxPrintf("g_soundCard2InDeviceName: %s\n", g_soundCard2InDeviceName); - //wxPrintf("g_soundCard2OutDeviceName: %s\n", g_soundCard2OutDeviceName); + //printf("g_soundCard2InDeviceNum: %d\n", g_soundCard2InDeviceNum); + //printf("g_soundCard2OutDeviceNum: %d\n", g_soundCard2OutDeviceNum); - if( !PortAudioWrap::isSoundCardNameValid(g_soundCard2InDeviceName) - || !PortAudioWrap::isSoundCardNameValid(g_soundCard2OutDeviceName)) { + if ((m_txInPa->getDeviceCount() <= g_soundCard2InDeviceNum) || + (m_txOutPa->getDeviceCount() <= g_soundCard2OutDeviceNum)) { wxMessageBox(wxT("Sound Card 2 not present"), wxT("Error"), wxOK); delete m_rxInPa; if(two_rx) @@ -3167,16 +3118,15 @@ void MainFrame::startRxStream() return; } - PaDeviceIndex soundCard2InDeviceNum = PortAudioWrap::getDeviceIndex(g_soundCard2InDeviceName); - deviceInfo2 = Pa_GetDeviceInfo(soundCard2InDeviceNum); + deviceInfo2 = Pa_GetDeviceInfo(g_soundCard2InDeviceNum); if (deviceInfo2 == NULL) { wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card 1"), wxT("Error"), wxOK); delete m_rxInPa; if(two_rx) - delete m_rxOutPa; + delete m_rxOutPa; delete m_txInPa; if(two_tx) - delete m_txOutPa; + delete m_txOutPa; m_RxRunning = false; return; } @@ -3185,17 +3135,15 @@ void MainFrame::startRxStream() else inputChannels2 = 2; - PaDeviceIndex soundCard2OutDeviceNum = PortAudioWrap::getDeviceIndex(g_soundCard2OutDeviceName); - if(two_tx) { - initPortAudioDevice(m_txInPa, soundCard2InDeviceNum, paNoDevice, 2, - g_soundCard2SampleRate, inputChannels2); - initPortAudioDevice(m_txOutPa, paNoDevice, soundCard2OutDeviceNum, 2, - g_soundCard2SampleRate, inputChannels2); - } - else - initPortAudioDevice(m_txInPa, soundCard2InDeviceNum, soundCard2OutDeviceNum, 2, - g_soundCard2SampleRate, inputChannels2); + initPortAudioDevice(m_txInPa, g_soundCard2InDeviceNum, paNoDevice, 2, + g_soundCard2SampleRate, inputChannels2); + initPortAudioDevice(m_txOutPa, paNoDevice, g_soundCard2OutDeviceNum, 2, + g_soundCard2SampleRate, inputChannels2); + } + else + initPortAudioDevice(m_txInPa, g_soundCard2InDeviceNum, g_soundCard2OutDeviceNum, 2, + g_soundCard2SampleRate, inputChannels2); } // Init call back data structure ---------------------------------------------- diff --git a/src/fdmdv2_main.h b/src/fdmdv2_main.h index c0416e1b2..3e866468d 100644 --- a/src/fdmdv2_main.h +++ b/src/fdmdv2_main.h @@ -47,7 +47,6 @@ #include #include #include -#include #include @@ -120,12 +119,7 @@ extern int g_soundCard2InDeviceNum; extern int g_soundCard2OutDeviceNum; extern int g_soundCard2SampleRate; -extern std::string g_soundCard1InDeviceName; -extern std::string g_soundCard1OutDeviceName; -extern std::string g_soundCard2InDeviceName; -extern std::string g_soundCard2OutDeviceName; - -// Voice Keyer Constants +// Voice Keyer Constants #define VK_SYNC_WAIT_TIME 5.0 diff --git a/src/fdmdv2_pa_wrapper.cpp b/src/fdmdv2_pa_wrapper.cpp index a9e4758d5..95eee5cb3 100644 --- a/src/fdmdv2_pa_wrapper.cpp +++ b/src/fdmdv2_pa_wrapper.cpp @@ -335,58 +335,6 @@ PaError PortAudioWrap::setOutputDevice(PaDeviceIndex index) PaError PortAudioWrap::setCallback(PaStreamCallback *callback) { m_pStreamCallback = callback; - return paNoError; -} - -//---------------------------------------------------------------- -// isSoundCardNameValid() -//---------------------------------------------------------------- -bool PortAudioWrap::isSoundCardNameValid(const wxString & soundCardName) -{ - // If getDeviceIndex returns anything but paNoDevice, then the name is a - // valid sound card name - return (getDeviceIndex(soundCardName) != paNoDevice); -} - -//---------------------------------------------------------------- -// getDeviceIndex() -//---------------------------------------------------------------- -PaDeviceIndex PortAudioWrap::getDeviceIndex(const wxString & soundCardName) -{ - PaDeviceIndex index = paNoDevice; - const PaDeviceInfo * deviceInfo; - - int numDevices = Pa_GetDeviceCount(); - - for (int devNum = 0; devNum < numDevices; devNum++) { - deviceInfo = Pa_GetDeviceInfo(devNum); - if (deviceInfo == NULL) { - //printf("PortAudioWrap::getDeviceIndex, call to Pa_GetDeviceInfo(%d) failed!\n", devNum); - continue; - } - else if (wxString::FromAscii(deviceInfo->name) == soundCardName) { - index = (PaDeviceIndex)devNum; - break; - } - } - - return index; -} - -//---------------------------------------------------------------- -// getDeviceNameStr() -//---------------------------------------------------------------- -wxString PortAudioWrap::getDeviceNameStr(PaDeviceIndex devNum) -{ - const PaDeviceInfo * deviceInfo; - wxString devName = wxT(""); - - deviceInfo = Pa_GetDeviceInfo(devNum); - if (deviceInfo == NULL) { - wxPrintf("PortAudioWrap::getDeviceNameStr, call to Pa_GetDeviceInfo(%d) failed!\n", devNum); - } - else - devName = wxString::FromAscii(deviceInfo->name); - - return devName; -} + return paNoError; +} + diff --git a/src/fdmdv2_pa_wrapper.h b/src/fdmdv2_pa_wrapper.h index 41cc8cb10..b666beb5b 100644 --- a/src/fdmdv2_pa_wrapper.h +++ b/src/fdmdv2_pa_wrapper.h @@ -63,15 +63,12 @@ class PortAudioWrap PaError setFramesPerBuffer(unsigned long size); PaError setSampleRate(unsigned long size); - - PaError setStreamFlags(PaStreamFlags flags); - PaError setCallback(PaStreamCallback *m_pStreamCallback); - static bool isSoundCardNameValid(const wxString & soundCardName); - static PaDeviceIndex getDeviceIndex(const wxString & soundCardName); - static wxString getDeviceNameStr(PaDeviceIndex devNum); - PaError setStreamCallback(PaStream *stream, PaStreamCallback* callback) { m_pStreamCallback = callback; return 0;} - PaError setStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback* m_pStreamFinishedCallback); - + + PaError setStreamFlags(PaStreamFlags flags); + PaError setCallback(PaStreamCallback *m_pStreamCallback); + PaError setStreamCallback(PaStream *stream, PaStreamCallback* callback) { m_pStreamCallback = callback; return 0;} + PaError setStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback* m_pStreamFinishedCallback); + void setInputBuffer(const PaStreamParameters& inputBuffer) {this->m_inputBuffer = inputBuffer;} PaError setInputDevice(PaDeviceIndex dev); PaError setInputChannelCount(int count); From a5c81cfda95932c3d4c11ce349ff2c6f7d4bc46a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 3 Jun 2019 06:57:46 +0930 Subject: [PATCH 3/7] script to build old windows versions, with zip file output. Useful for testing --- build_windows_old.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 build_windows_old.sh diff --git a/build_windows_old.sh b/build_windows_old.sh new file mode 100755 index 000000000..35bd3124a --- /dev/null +++ b/build_windows_old.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# build_windows_old.sh +# +# Script that cross compiles freedv-gui for Windows on Fedora +# Linux. Git pulls older versions of freedv-gui for test/debug purposes, +# then constructs a zip file for testing. Zips files are convenient +# when testing several versions, as everything is self contained. +# +# usage: ./build_old.sh githash + +export FREEDVGUIDIR=${PWD} +export CODEC2DIR=$FREEDVGUIDIR/codec2 +export LPCNETDIR=$FREEDVGUIDIR/LPCNet +#git checkout $1 +#mkdir -p build_win && cd build_win && rm -Rf * +#make VERBOSE=1 +git checkout dr-debug-vac-3 +#git checkout $1 +cd $FREEDVGUIDIR/build_win +rm -Rf * +# old cmake line +mingw64-cmake -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/build_win -DLPCNET_BUILD_DIR=$LPCNETDIR/build_win .. +make +make package +cd $FREEDVGUIDIR +export zipdir=freedv-gui-$1 +mkdir -p $zipdir +cp -f `find build_win/_CPack_Packages -name *.dll` $zipdir +cp -f `find codec2/build_win/ -name *.dll` $zipdir +cp -f `find LPCNet/build_win/ -name *.dll` $zipdir +cp build_win/src/freedv.exe $zipdir +zip -r $zipdir'.zip' $zipdir From 0fd987f273be8814420ab1ba5b5811b24d0cf797 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 4 Jun 2019 06:36:38 +0930 Subject: [PATCH 4/7] added 32 bit capability to windows build script --- README.md | 33 ++++++++++++++------------------- build_windows.sh | 27 ++++++++++++++++++--------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 4b57dd770..763e3c55c 100644 --- a/README.md +++ b/README.md @@ -57,36 +57,31 @@ Enable Freetel specific packages not currently in Fedora proper: mingw{32,64}-portaudio mingw{32,64}-libsndfile mingw{32,64}-libsamplerate.noarch ``` -Bootstrap codec2 and LPCNet: -This assumes all git checkouts are from your home directory. +Clone freedv-gui: ``` - $ git clone https://github.com/drowe67/codec2.git - $ cd codec2 && mkdir build_win && cd build_win - $ mingw64-cmake ../ - $ make $ cd - $ git clone https://github.com/drowe67/LPCNet.git - $ cd LPCNet && mkdir build_win && cd build_win - $ mingw64-cmake ../ -DCODEC2_BUILD_DIR=~/codec2/build_win - $ make - $ cd ~/codec2/build_win - $ mingw64-cmake ../ -DLPCNET_BUILD_DIR=~/LPCNet/build_win - $ make + $ git clone https://github.com/drowe67/freedv-gui.git ``` Building FreeDV for 64 Bit windows: ``` - $ cd - $ git clone https://github.com/drowe67/freedv-gui.git - $ cd freedv-gui && mkdir build_wins && cd build_win - $ mingw64-cmake ../ -DCODEC2_BUILD_DIR=~/codec2/build_win -D LPCNET_BUILD_DIR=~/LPCNet/build_win - $ make + $ cd ~/freedv-gui + $ ./build_windows.sh + $ cd build_win64 + $ make package +``` + +**OR** Building FreeDV for 32 Bit windows: +``` + $ cd ~/freedv-gui + $ CMAKE=mingw32-cmake ./build_windows.sh + $ cd build_win32 $ make package ``` ### Testing Windows Build -Conveniently, it is possible to run Windows executable using Wine on Fedora: +Conveniently, it is possible to run Windows executables using Wine on Fedora: Testing LPCNet: ``` diff --git a/build_windows.sh b/build_windows.sh index ac3287074..4e7131c6d 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -5,6 +5,15 @@ # Linux. Git pulls codec2 and LPCNet repos so they are available for # parallel development. +# override this at the command line for a 32 bit build +# $ CMAKE=mingw32-cmake ./build_windows.sh +: ${CMAKE=mingw64-cmake} + +if [ $CMAKE = "mingw64-cmake" ]; then + BUILD_DIR=build_win64 +else + BUILD_DIR=build_win32 +fi export FREEDVGUIDIR=${PWD} export CODEC2DIR=$FREEDVGUIDIR/codec2 export LPCNETDIR=$FREEDVGUIDIR/LPCNet @@ -13,32 +22,32 @@ export LPCNETDIR=$FREEDVGUIDIR/LPCNet cd $FREEDVGUIDIR git clone https://github.com/drowe67/codec2.git cd codec2 && git checkout master && git pull -mkdir -p build_win && cd build_win && rm -Rf * -mingw64-cmake .. && make +mkdir -p $BUILD_DIR && cd $BUILD_DIR && rm -Rf * +$CMAKE .. && make # OK, build and test LPCNet cd $FREEDVGUIDIR git clone https://github.com/drowe67/LPCNet.git cd $LPCNETDIR && git checkout master && git pull -mkdir -p build_win && cd build_win && rm -Rf * -mingw64-cmake -DCODEC2_BUILD_DIR=$CODEC2DIR/build_win .. +mkdir -p $BUILD_DIR && cd $BUILD_DIR && rm -Rf * +$CMAKE -DCODEC2_BUILD_DIR=$CODEC2DIR/$BUILD_DIR .. make # sanity check test #cd src && ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null # Re-build codec2 with LPCNet and test FreeDV 2020 support -cd $CODEC2DIR/build_win && rm -Rf * -mingw64-cmake -DLPCNET_BUILD_DIR=$LPCNETDIR/build_win .. +cd $CODEC2DIR/$BUILD_DIR && rm -Rf * +$CMAKE -DLPCNET_BUILD_DIR=$LPCNETDIR/$BUILD_DIR .. make VERBOSE=1 # sanity check test #cd src -#export LD_LIBRARY_PATH=$LPCNETDIR/build_win/src +#export LD_LIBRARY_PATH=$LPCNETDIR/$BUILD_DIR/src #./freedv_tx 2020 $LPCNETDIR/wav/wia.wav - | ./freedv_rx 2020 - /dev/null # Finally, build freedv-gui cd $FREEDVGUIDIR && git pull -mkdir -p build_win && cd build_win && rm -Rf * -mingw64-cmake -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/build_win -DLPCNET_BUILD_DIR=$LPCNETDIR/build_win .. +mkdir -p $BUILD_DIR && cd $BUILD_DIR && rm -Rf * +$CMAKE -DCMAKE_BUILD_TYPE=Debug -DCODEC2_BUILD_DIR=$CODEC2DIR/$BUILD_DIR -DLPCNET_BUILD_DIR=$LPCNETDIR/$BUILD_DIR .. make VERBOSE=1 From aa2dbfaca9d6a9d7ba4be494ca6d23f38b57de59 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 4 Jun 2019 06:50:43 +0930 Subject: [PATCH 5/7] fixed merge conflict with user manual --- USER_MANUAL.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/USER_MANUAL.md b/USER_MANUAL.md index ff9976a4f..564348442 100644 --- a/USER_MANUAL.md +++ b/USER_MANUAL.md @@ -229,6 +229,17 @@ for another program? 4. Contact the digital voice mailing list. Be specific about your hardware, what you have tried, and the exact nature of the problem. +### FreeDV 2020 mode is greyed out + +You must have a modern CPU with AVX support to run FreeDV 2020. A +Microsoft utlity called **coreinfo** can be used to determine if your +CPU supports AVX. + +### I installed a new version and FreeDV stopped working + +You may need to clean out the previous confirguration. Try +Tools-Restore Defaults. + ## Voice Keyer Voice Keyer Button on Front Page, and Options-PTT dialog. From 00cfc3245902910288c77d298452ee189034f370 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 4 Jun 2019 20:14:46 +0930 Subject: [PATCH 6/7] set up different size 20ms buffer for rx side processing to support different modem/speech sample rates --- src/fdmdv2_main.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/fdmdv2_main.cpp b/src/fdmdv2_main.cpp index f223c7712..446631e9c 100644 --- a/src/fdmdv2_main.cpp +++ b/src/fdmdv2_main.cpp @@ -139,7 +139,8 @@ float g_TxFreqOffsetHz; COMP g_TxFreqOffsetPhaseRect; // buffer sizes dependent upon sample rate -int g_bufferSize; +int g_modemInbufferSize; +int g_speechOutbufferSize; // experimental mutex to make sound card callbacks mutually exclusive // TODO: review code and see if we need this any more, as fifos should @@ -2721,8 +2722,10 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event) assert(g_pfreedv != NULL); - // Set buffer size. - g_bufferSize = (int)(FRAME_DURATION * freedv_get_speech_sample_rate(g_pfreedv)); + // Set processing buffer sizes, these are FRAME_DURATION (20ms) chunks of modem and speech that are a useful size for the + // various operations we do before and after passing to the freedv_api layer. + g_modemInbufferSize = (int)(FRAME_DURATION * freedv_get_modem_sample_rate(g_pfreedv)); + g_speechOutbufferSize = (int)(FRAME_DURATION * freedv_get_speech_sample_rate(g_pfreedv)); // init Codec 2 LPC Post Filter (FreeDV 1600) @@ -3729,9 +3732,9 @@ void txRxProcessing() // (20ms), number of samples is scaled for the sound card sample // rate, so we get the right number of samples for the output // decoded audio - - int nsam = g_soundCard1SampleRate * (float)g_bufferSize/freedv_get_speech_sample_rate(g_pfreedv); - assert(nsam <= N48); + + int nsam = g_soundCard1SampleRate * (float)g_modemInbufferSize/freedv_samplerate; + assert(nsam <= 10*N48); while ((codec2_fifo_read(cbData->infifo1, insound_card, nsam) == 0) && ((g_half_duplex && !g_tx) || !g_half_duplex)) { /* convert sound card sample rate FreeDV input sample rate */ @@ -3858,22 +3861,22 @@ void txRxProcessing() // this will typically be decoded output speech, and is // (currently at least) fixed at a sample rate of 8 kHz - memset(outfreedv, 0, sizeof(short)*g_bufferSize); + memset(outfreedv, 0, sizeof(short)*g_speechOutbufferSize); //fprintf(stderr, "rxoutfifo free: %d used: %d\n", codec2_fifo_free(cbData->rxoutfifo), codec2_fifo_used(cbData->rxoutfifo)); - codec2_fifo_read(cbData->rxoutfifo, outfreedv, g_bufferSize); + codec2_fifo_read(cbData->rxoutfifo, outfreedv, g_speechOutbufferSize); } // Optional Spk Out EQ Filtering, need mutex as filter can change at run time from another thread g_mutexProtectingCallbackData.Lock(); if (cbData->spkOutEQEnable) { - sox_biquad_filter(cbData->sbqSpkOutBass, outfreedv, outfreedv, g_bufferSize); - sox_biquad_filter(cbData->sbqSpkOutTreble, outfreedv, outfreedv, g_bufferSize); - sox_biquad_filter(cbData->sbqSpkOutMid, outfreedv, outfreedv, g_bufferSize); + sox_biquad_filter(cbData->sbqSpkOutBass, outfreedv, outfreedv, g_speechOutbufferSize); + sox_biquad_filter(cbData->sbqSpkOutTreble, outfreedv, outfreedv, g_speechOutbufferSize); + sox_biquad_filter(cbData->sbqSpkOutMid, outfreedv, outfreedv, g_speechOutbufferSize); } g_mutexProtectingCallbackData.Unlock(); - resample_for_plot(g_plotSpeechOutFifo, outfreedv, g_bufferSize, freedv_get_speech_sample_rate(g_pfreedv)); + resample_for_plot(g_plotSpeechOutFifo, outfreedv, g_speechOutbufferSize, freedv_get_speech_sample_rate(g_pfreedv)); // resample to output sound card rate @@ -3886,12 +3889,12 @@ void txRxProcessing() codec2_fifo_write(cbData->outfifo1, outsound_card, nout); } else { - nout = resample(cbData->outsrc2, outsound_card, outfreedv, g_soundCard1SampleRate, freedv_get_speech_sample_rate(g_pfreedv), N48, g_bufferSize); + nout = resample(cbData->outsrc2, outsound_card, outfreedv, g_soundCard1SampleRate, freedv_get_speech_sample_rate(g_pfreedv), N48, g_speechOutbufferSize); codec2_fifo_write(cbData->outfifo1, outsound_card, nout); } } else { - nout = resample(cbData->outsrc2, outsound_card, outfreedv, g_soundCard2SampleRate, freedv_get_speech_sample_rate(g_pfreedv), N48, g_bufferSize); + nout = resample(cbData->outsrc2, outsound_card, outfreedv, g_soundCard2SampleRate, freedv_get_speech_sample_rate(g_pfreedv), N48, g_speechOutbufferSize); codec2_fifo_write(cbData->outfifo2, outsound_card, nout); } } @@ -3939,7 +3942,7 @@ void txRxProcessing() memset(insound_card, 0, nsam_in_48*sizeof(short)); codec2_fifo_read(cbData->infifo2, insound_card, nsam_in_48); - nout = resample(cbData->insrc2, infreedv, insound_card, freedv_get_speech_sample_rate(g_pfreedv), g_soundCard2SampleRate, 10*g_bufferSize, nsam_in_48); + nout = resample(cbData->insrc2, infreedv, insound_card, freedv_get_speech_sample_rate(g_pfreedv), g_soundCard2SampleRate, 10*N48, nsam_in_48); // optionally use file for mic input signal if (g_playFileToMicIn && (g_sfPlayFile != NULL)) { From 437dbb65a3a4f25a2f5205aa0f008394dbf520d9 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 4 Jun 2019 20:24:44 +0930 Subject: [PATCH 7/7] horus demod working --- src/fdmdv2_main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fdmdv2_main.cpp b/src/fdmdv2_main.cpp index 446631e9c..783480962 100644 --- a/src/fdmdv2_main.cpp +++ b/src/fdmdv2_main.cpp @@ -3876,7 +3876,10 @@ void txRxProcessing() } g_mutexProtectingCallbackData.Unlock(); - resample_for_plot(g_plotSpeechOutFifo, outfreedv, g_speechOutbufferSize, freedv_get_speech_sample_rate(g_pfreedv)); + if (g_mode == -1) + resample_for_plot(g_plotSpeechOutFifo, outfreedv, g_speechOutbufferSize, freedv_samplerate); + else + resample_for_plot(g_plotSpeechOutFifo, outfreedv, g_speechOutbufferSize, freedv_get_speech_sample_rate(g_pfreedv)); // resample to output sound card rate