Skip to content

Commit

Permalink
Reconstruct voice FEC on incoming network audio.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed May 25, 2016
1 parent afb4b5d commit 8432199
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 18 additions & 3 deletions YSFControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ m_holdoffTimer(1000U, 0U, 500U),
m_rfFrames(0U),
m_netFrames(0U),
m_rfErrs(0U),
m_rfBits(0U),
m_rfBits(1U),
m_netErrs(0U),
m_netBits(1U),
m_rfSource(NULL),
m_rfDest(NULL),
m_netSource(NULL),
Expand Down Expand Up @@ -379,6 +381,8 @@ void CYSFControl::writeNetwork()
m_netPayload.reset();
m_netState = RS_NET_AUDIO;
m_netFrames = 0U;
m_netErrs = 0U;
m_netBits = 1U;
} else {
bool changed = false;

Expand Down Expand Up @@ -411,6 +415,7 @@ void CYSFControl::writeNetwork()
unsigned char dt = fich.getDT();
unsigned char fn = fich.getFN();
unsigned char fi = fich.getFI();
unsigned char ft = fich.getFT();

// Set the downlink callsign
switch (fi) {
Expand All @@ -423,17 +428,27 @@ void CYSFControl::writeNetwork()
switch (dt) {
case YSF_DT_VD_MODE1:
m_netPayload.processVDMode1Data(data + 35U, fn);
m_netErrs += m_netPayload.processVDMode1Audio(data + 35U);
m_netBits += 235U;
break;

case YSF_DT_VD_MODE2:
m_netPayload.processVDMode2Data(data + 35U, fn);
// Temporarily disable the repition FEC code
// m_netErrs += m_netPayload.processVDMode2Audio(data + 35U);
// m_netBits += 135U;
break;

case YSF_DT_DATA_FR_MODE:
m_netPayload.processDataFRModeData(data + 35U, fn);
break;

case YSF_DT_VOICE_FR_MODE:
if (fn != 0U || ft != 1U) {
// The first packet after the header is odd, don't try and regenerate it
m_netErrs += m_netPayload.processVoiceFRModeAudio(data + 35U);
m_netBits += 720U;
}
break;

default:
Expand All @@ -453,7 +468,7 @@ void CYSFControl::writeNetwork()
writeQueueNet(data + 33U);

if (end) {
LogMessage("YSF, received network end of transmission, %.1f seconds", float(m_netFrames) / 10.0F);
LogMessage("YSF, received network end of transmission, %.1f seconds, BER: %.1f%%", float(m_netFrames) / 10.0F, float(m_netErrs * 100U) / float(m_netBits));
writeEndNet();
}
}
Expand All @@ -474,7 +489,7 @@ void CYSFControl::clock(unsigned int ms)
m_networkWatchdog.clock(ms);

if (m_networkWatchdog.hasExpired()) {
LogMessage("YSF, network watchdog has expired, %.1f seconds", float(m_netFrames) / 10.0F);
LogMessage("YSF, network watchdog has expired, %.1f seconds, BER: %.1f%%", float(m_netFrames) / 10.0F, float(m_netErrs * 100U) / float(m_netBits));
writeEndNet();
}
}
Expand Down
2 changes: 2 additions & 0 deletions YSFControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class CYSFControl {
unsigned int m_netFrames;
unsigned int m_rfErrs;
unsigned int m_rfBits;
unsigned int m_netErrs;
unsigned int m_netBits;
unsigned char* m_rfSource;
unsigned char* m_rfDest;
unsigned char* m_netSource;
Expand Down

0 comments on commit 8432199

Please sign in to comment.