start/stop transitions

* add code to soften the start/stop transitions for all
    modems
This commit is contained in:
David Freese 2020-01-29 14:35:20 -06:00
parent f4dd622c55
commit 93b75e79d9
5 changed files with 45 additions and 6 deletions

View file

@ -1015,6 +1015,7 @@ void rtty::flush_stream()
FSKbuf[i] = 0.0;
}
sig_stop = true;
if (progdefaults.PseudoFSK)
ModulateStereo(outbuf, FSKbuf, symbollen * 6);
else
@ -1088,6 +1089,7 @@ int rtty::tx_process()
if (progStatus.nanoFSK_online) {
if (preamble) {
start_deadman();
sig_start = true;
for (int i = 0; i < progdefaults.TTY_LTRS; i++)
nano_send_char(-1);
preamble = false;
@ -1173,6 +1175,7 @@ int rtty::tx_process()
}
if (preamble) {
sig_start = true;
for (int i = 0; i < progdefaults.TTY_LTRS; i++)
send_char(LETTERS);
preamble = false;

View file

@ -55,6 +55,8 @@ protected:
int samplerate;
bool reverse;
int sigsearch;
bool sig_start;
bool sig_stop;
double bandwidth;
double freqerr;
@ -98,7 +100,7 @@ protected:
bool CW_EOT;
public:
modem();
virtual ~modem(){};
virtual ~modem(){}
// these processes must be declared in the derived class
virtual void init();

View file

@ -1084,7 +1084,7 @@ int mfsk::tx_process()
switch (txstate) {
case TX_STATE_PREAMBLE:
clearbits();
sig_start = true;
if (mode != MODE_MFSK64L && mode != MODE_MFSK128L )
for (int i = 0; i < preamble / 3; i++)
sendbit(0);
@ -1092,6 +1092,7 @@ int mfsk::tx_process()
txstate = TX_STATE_START;
break;
case TX_STATE_START:
sig_start = true;
sendchar('\r');
sendchar(2); // STX
sendchar('\r');
@ -1130,6 +1131,7 @@ int mfsk::tx_process()
case TX_STATE_FLUSH:
sendchar('\r');
sendchar(4); // EOT
sig_stop = true;
sendchar('\r');
flushtx(preamble);
rxstate = RX_STATE_DATA;

View file

@ -2098,6 +2098,7 @@ void psk::tx_char(unsigned char c)
void psk::tx_flush()
{
sig_start = false;
if (_pskr) {
ovhd_symbols = ((numcarriers - symbols) % numcarriers);
//VK2ETA replace with a more effective flushing sequence (avoids cutting the last characters in low s/n)
@ -2105,23 +2106,28 @@ void psk::tx_flush()
for (int i = 0; i < dcdbits / 2; i++) {
tx_bit(1);
if (i == dcdbits/2 - 1) sig_stop = true;
tx_bit(1);
}
// QPSK - flush the encoder
} else if (_qpsk) {
for (int i = 0; i < dcdbits; i++)
for (int i = 0; i < dcdbits; i++) {
if (i == dcdbits - 1) sig_stop = true;
tx_bit(0);
}
// FEC enabled: Sens the NULL character in MFSk varicode as the flush / post-amble sequence
} else if (!_disablefec && (_xpsk || _8psk || _16psk) ) {
for (int i=0; i<flushlength; i++) {
if (i == flushlength - 1) sig_stop = true;
tx_char(0); // Send <NUL> to clear bit accumulators on both Tx and Rx ends.
}
// FEC disabled: use unmodulated carrier (bpsk-like single tone)
} else if (_disablefec && ( _xpsk || _8psk || _16psk) ) {
for (int i=0; i<symbits; i++) {
if (i == symbits - 1) sig_stop = true;
tx_char(0); // Send <NUL> to clear bit accumulators on both Tx and Rx ends.
}
@ -2130,13 +2136,17 @@ void psk::tx_flush()
else if (_8psk) symbol = 4;
else symbol = 2; // xpsk
for (int i = 0; i <= 96; i++) // DCD window is only 32-bits wide. Send 3-times
for (int i = 0; i <= 96; i++) { // DCD window is only 32-bits wide. Send 3-times
if (i == 95) sig_stop = true;
tx_symbol(symbol);
}
// Standard BPSK postamble
} else {
for (int i = 0; i < dcdbits; i++)
for (int i = 0; i < dcdbits; i++) {
if (i == dcdbits - 1) sig_stop = true;
tx_symbol(2); // 0 degrees
}
}
for (int i = 0; i < 2048; i++) outbuf[i] = 0;
transmit(outbuf, 2048);
@ -2159,7 +2169,9 @@ int psk::tx_process()
if (mode != MODE_PSK63F)
clearbits();
// FEC prep the encoder with one/zero sequences of bits
for (int i = 0; i < preamble; i += 2) {
sig_start = true;
sig_stop = false;
for (int i = 0; i < preamble/2; i++) {
tx_bit(1);
tx_bit(0);
}
@ -2175,6 +2187,8 @@ int psk::tx_process()
if (preamble > 96) preamble = 96;
if (_disablefec) {
// Send continuous symbol 0: Usual PSK 2-tone preamble
sig_start = true;
sig_stop = false;
for (int i = 0; i < preamble; i++ )
tx_symbol(0);
tx_char(0);
@ -2186,6 +2200,8 @@ int psk::tx_process()
_disablefec = false;
// FEC prep the encoder with encoded sequence of double-zeros
// sends a single centered preamble tone for FEC modes
sig_start = true;
sig_stop = false;
for (int i = 0; i < preamble; i += 2) {
tx_bit(0);
tx_bit(0);
@ -2196,6 +2212,8 @@ int psk::tx_process()
}
} else {
// Standard BPSK/QPSK preamble
sig_start = true;
sig_stop = false;
for (int i = 0; i < preamble; i++) {
tx_symbol(0); // send phase reversals
}

View file

@ -276,6 +276,7 @@ modem::modem()
bandwidth = 0.0;
CW_EOT = false;
sig_start = sig_stop = false;
}
// modem types CW and RTTY do not use the base init()
@ -520,6 +521,19 @@ void modem::ModulateXmtr(double *buffer, int len)
tx_sample_count += len;
if (sig_start) {
int num = len / 2;
for (int i = 0; i < num; i++)
buffer[i] *= (0.5 * (1.0 - cos (M_PI * i / num)));
sig_start = false;
}
if (sig_stop) {
int num = len / 2;
for (int i = 0; i < num; i++)
buffer[len - i - 1] *= (0.5 * (1.0 - cos (M_PI * i / num)));
sig_stop = false;
}
if (progdefaults.PTTrightchannel) {
for (int i = 0; i < len; i++)
PTTchannel[i] = PTTnco();