Skip to content

Commit

Permalink
Merge branch 'v2.0-dev' into ms-pulseaudio-divide-samples
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Dec 27, 2024
2 parents 63af42a + 93770ac commit 9b85492
Show file tree
Hide file tree
Showing 16 changed files with 1,173 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install codespell libpulse-dev libspeexdsp-dev libsamplerate0-dev sox git libwxgtk3.2-dev portaudio19-dev libhamlib-dev libasound2-dev libao-dev libgsm1-dev libsndfile-dev xvfb pipewire pulseaudio-utils pipewire-pulse wireplumber metacity dbus-x11 at-spi2-core rtkit
sudo apt-get install codespell libpulse-dev libspeexdsp-dev libsamplerate0-dev sox git libwxgtk3.2-dev portaudio19-dev libhamlib-dev libasound2-dev libao-dev libgsm1-dev libsndfile-dev xvfb pipewire pulseaudio-utils pipewire-pulse wireplumber metacity dbus-x11 at-spi2-core rtkit octave octave-signal
- name: Spellcheck codebase
shell: bash
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/cmake-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ jobs:
- name: Install packages
shell: bash
working-directory: ${{github.workspace}}
run: brew install automake libtool numpy sox
run: brew install automake libtool numpy sox octave

- name: Install octave-signal
shell: bash
working-directory: ${{github.workspace}}
run: |
# make sure gfortran is available
sudo ln -s /opt/homebrew/bin/gfortran-14 /opt/homebrew/bin/gfortran
ls /opt/homebrew/bin/gfortran*
#sudo mkdir /usr/local/gfortran
#ls /usr/local/Cellar
#sudo ln -s /usr/local/Cellar/gcc@14/*/lib/gcc/14 /usr/local/gfortran/lib
gfortran --version
octave-cli --eval "pkg install -forge control; pkg install -forge signal"
- name: Install virtual audio devices
shell: bash
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -731,4 +731,14 @@ DefineAudioTest(RADEV1)
DefineAudioTest(700D)
DefineAudioTest(700E)
DefineAudioTest(1600)

add_test(NAME rade_reporting_clean COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/test_rade_reporting.sh)
set_tests_properties(rade_reporting_clean PROPERTIES PASS_REGULAR_EXPRESSION "Reporting callsign ZZ0ZZZ @ SNR")

add_test(NAME rade_reporting_awgn COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/test_rade_reporting.sh ${CODEC2_BUILD_DIR} awgn)
set_tests_properties(rade_reporting_awgn PROPERTIES PASS_REGULAR_EXPRESSION "Reporting callsign ZZ0ZZZ @ SNR")

add_test(NAME rade_reporting_mpp COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/test_rade_reporting.sh ${CODEC2_BUILD_DIR} mpp)
set_tests_properties(rade_reporting_mpp PROPERTIES PASS_REGULAR_EXPRESSION "Reporting callsign ZZ0ZZZ @ SNR")

endif(UNITTEST)
2 changes: 2 additions & 0 deletions cmake/BuildCodec2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ set_target_properties(codec2 PROPERTIES
IMPORTED_IMPLIB "${BINARY_DIR}/src/libcodec2${CMAKE_IMPORT_LIBRARY_SUFFIX}"
)

set(CODEC2_BUILD_DIR ${BINARY_DIR})

if(BOOTSTRAP_LPCNET)
add_dependencies(build_codec2 build_lpcnetfreedv)
endif(BOOTSTRAP_LPCNET)
Expand Down
51 changes: 49 additions & 2 deletions src/freedv_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

using namespace std::placeholders;

#include <wx/string.h>
extern wxString utFreeDVMode;

static const char* GetCurrentModeStrImpl_(int mode)
{
switch(mode)
Expand Down Expand Up @@ -75,7 +78,8 @@ FreeDVInterface::FreeDVInterface() :
rade_(nullptr),
lpcnetEncState_(nullptr),
radeTxStep_(nullptr),
sync_(0)
sync_(0),
radeTextPtr_(nullptr)
{
// empty
}
Expand Down Expand Up @@ -105,6 +109,19 @@ void FreeDVInterface::OnReliableTextRx_(reliable_text_t rt, const char* txt_ptr,
reliable_text_reset(rt);
}

void FreeDVInterface::OnRadeTextRx_(rade_text_t rt, const char* txt_ptr, int length, void* state)
{
log_info("FreeDVInterface::OnRadeTextRx_: received %s", txt_ptr);

FreeDVInterface* obj = (FreeDVInterface*)state;
assert(obj != nullptr);

{
std::unique_lock<std::mutex> lock(obj->reliableTextMutex_);
obj->receivedReliableText_ = txt_ptr;
}
}

float FreeDVInterface::GetMinimumSNR_(int mode)
{
switch(mode)
Expand Down Expand Up @@ -155,6 +172,20 @@ void FreeDVInterface::start(int txMode, int fifoSizeMs, bool singleRxThread, boo
rade_ = rade_open(modelFile, RADE_USE_C_ENCODER | RADE_USE_C_DECODER | (wxGetApp().appConfiguration.debugVerbose ? 0 : RADE_VERBOSE_0));
assert(rade_ != nullptr);

if (usingReliableText)
{
log_info("creating RADE text object");
radeTextPtr_ = rade_text_create();
assert(radeTextPtr_ != nullptr);

rade_text_set_rx_callback(radeTextPtr_, &FreeDVInterface::OnRadeTextRx_, this);

if (utFreeDVMode != "")
{
rade_text_enable_stats_output(radeTextPtr_, true);
}
}

float zeros[320] = {0};
float in_features[5*NB_TOTAL_FEATURES] = {0};
fargan_init(&fargan_);
Expand Down Expand Up @@ -242,6 +273,12 @@ void FreeDVInterface::stop()
reliable_text_destroy(reliableTextObj);
}
reliableText_.clear();

if (radeTextPtr_ != nullptr)
{
rade_text_destroy(radeTextPtr_);
radeTextPtr_ = nullptr;
}

for (auto& dv : dvObjects_)
{
Expand Down Expand Up @@ -649,6 +686,16 @@ const char* FreeDVInterface::getReliableText()

void FreeDVInterface::setReliableText(const char* callsign)
{
// Special case for RADE.
if (rade_ != nullptr && radeTextPtr_ != nullptr)
{
log_info("generating RADE text string");
int nsyms = rade_n_eoo_bits(rade_);
float eooSyms[nsyms];
rade_text_generate_tx_string(radeTextPtr_, callsign, strlen(callsign), eooSyms, nsyms);
rade_tx_set_eoo_bits(rade_, eooSyms);
}

for (auto& rt : reliableText_)
{
reliable_text_set_string(rt, callsign, strlen(callsign));
Expand Down Expand Up @@ -721,7 +768,7 @@ IPipelineStep* FreeDVInterface::createReceivePipeline(
if (txMode_ >= FREEDV_MODE_RADE)
{
// special handling for RADE
parallelSteps.push_back(new RADEReceiveStep(rade_, &fargan_));
parallelSteps.push_back(new RADEReceiveStep(rade_, &fargan_, radeTextPtr_));

state->preProcessFn = [&](ParallelStep*) { return 0; };
state->postProcessFn = std::bind(&FreeDVInterface::postProcessRxFn_, this, _1); //[&](ParallelStep*) { return 0; };
Expand Down
3 changes: 3 additions & 0 deletions src/freedv_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

// RADE required include files
#include "rade_api.h"
#include "pipeline/rade_text.h"

// TBD - need to wrap in "extern C" to avoid linker errors
extern "C"
Expand Down Expand Up @@ -154,6 +155,7 @@ class FreeDVInterface

static void FreeDVTextRxFn_(void *callback_state, char c);
static void OnReliableTextRx_(reliable_text_t rt, const char* txt_ptr, int length, void* state);
static void OnRadeTextRx_(rade_text_t rt, const char* txt_ptr, int length, void* state);

static float GetMinimumSNR_(int mode);

Expand Down Expand Up @@ -192,6 +194,7 @@ class FreeDVInterface
LPCNetEncState *lpcnetEncState_;
RADETransmitStep *radeTxStep_;
int sync_;
rade_text_t radeTextPtr_;

int preProcessRxFn_(ParallelStep* ps);
int postProcessRxFn_(ParallelStep* ps);
Expand Down
18 changes: 13 additions & 5 deletions src/gui/dialogs/freedv_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ extern FreeDVInterface freedvInterface;
#define NUM_COLS (LAST_UPDATE_DATE_COL + 1)
#endif // defined(WIN32)
#define RX_ONLY_STATUS "RX Only"
#define RX_COLORING_TIMEOUT_SEC (20)
#define RX_COLORING_LONG_TIMEOUT_SEC (20)
#define RX_COLORING_SHORT_TIMEOUT_SEC (2)
#define MSG_COLORING_TIMEOUT_SEC (5)
#define STATUS_MESSAGE_MRU_MAX_SIZE (10)
#define MESSAGE_COLUMN_ID (6)
Expand Down Expand Up @@ -756,9 +757,14 @@ void FreeDVReporterDialog::OnTimer(wxTimerEvent& event)
auto reportData = allReporterData_[*sidPtr];

bool isTransmitting = reportData->transmitting;
bool isReceiving =
bool isReceivingValidCallsign =
reportData->lastRxDate.IsValid() &&
reportData->lastRxDate.ToUTC().IsEqualUpTo(curDate, wxTimeSpan(0, 0, RX_COLORING_TIMEOUT_SEC));
reportData->lastRxCallsign != "" &&
reportData->lastRxDate.ToUTC().IsEqualUpTo(curDate, wxTimeSpan(0, 0, RX_COLORING_LONG_TIMEOUT_SEC));
bool isReceivingNotValidCallsign =
reportData->lastRxDate.IsValid() &&
reportData->lastRxCallsign == "" &&
reportData->lastRxDate.ToUTC().IsEqualUpTo(curDate, wxTimeSpan(0, 0, RX_COLORING_SHORT_TIMEOUT_SEC));
bool isMessaging =
reportData->lastUpdateUserMessage.IsValid() &&
reportData->lastUpdateUserMessage.ToUTC().IsEqualUpTo(curDate, wxTimeSpan(0, 0, MSG_COLORING_TIMEOUT_SEC));
Expand All @@ -777,7 +783,7 @@ void FreeDVReporterDialog::OnTimer(wxTimerEvent& event)
backgroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterTxRowBackgroundColor);
foregroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterTxRowForegroundColor);
}
else if (isReceiving)
else if (isReceivingValidCallsign || isReceivingNotValidCallsign)
{
backgroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterRxRowBackgroundColor);
foregroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterRxRowForegroundColor);
Expand Down Expand Up @@ -2027,7 +2033,9 @@ void FreeDVReporterDialog::addOrUpdateListIfNotFiltered_(ReporterData* data, std
backgroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterTxRowBackgroundColor);
foregroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterTxRowForegroundColor);
}
else if (data->lastRxDate.IsValid() && data->lastRxDate.ToUTC().IsEqualUpTo(curDate, wxTimeSpan(0, 0, RX_COLORING_TIMEOUT_SEC)))
else if (data->lastRxDate.IsValid() &&
((data->lastRxDate.ToUTC().IsEqualUpTo(curDate, wxTimeSpan(0, 0, RX_COLORING_SHORT_TIMEOUT_SEC)) && data->lastRxCallsign == "") ||
(data->lastRxDate.ToUTC().IsEqualUpTo(curDate, wxTimeSpan(0, 0, RX_COLORING_LONG_TIMEOUT_SEC)) && data->lastRxCallsign != "")))
{
backgroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterRxRowBackgroundColor);
foregroundColor = wxColour(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterRxRowForegroundColor);
Expand Down
Loading

0 comments on commit 9b85492

Please sign in to comment.