-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from luarvique/master
Fixed subsampling in AFSK12, CLIPFSK, EAS, FMSFSK, UFSK12 decoders
- Loading branch information
Showing
5 changed files
with
46 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
* | ||
* Copyright (C) 1996 | ||
* Thomas Sailer ([email protected], [email protected]) | ||
* Copyright (C) 2024 | ||
* Marat Fayzullin ([email protected]) | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -79,16 +81,15 @@ static void afsk12_demod(struct demod_state *s, buffer_t buffer, int length) | |
unsigned char curbit; | ||
|
||
if (s->l1.afsk12.subsamp) { | ||
int numfill = SUBSAMP - s->l1.afsk12.subsamp; | ||
if (length < numfill) { | ||
s->l1.afsk12.subsamp += length; | ||
if (length <= (int)s->l1.afsk12.subsamp) { | ||
s->l1.afsk12.subsamp -= length; | ||
return; | ||
} | ||
buffer.fbuffer += numfill; | ||
length -= numfill; | ||
buffer.fbuffer += s->l1.afsk12.subsamp; | ||
length -= s->l1.afsk12.subsamp; | ||
s->l1.afsk12.subsamp = 0; | ||
} | ||
for (; length >= SUBSAMP; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
for (; length > 0; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
f = fsqr(mac(buffer.fbuffer, corr_mark_i, CORRLEN)) + | ||
fsqr(mac(buffer.fbuffer, corr_mark_q, CORRLEN)) - | ||
fsqr(mac(buffer.fbuffer, corr_space_i, CORRLEN)) - | ||
|
@@ -116,7 +117,7 @@ static void afsk12_demod(struct demod_state *s, buffer_t buffer, int length) | |
hdlc_rxbit(s, curbit); | ||
} | ||
} | ||
s->l1.afsk12.subsamp = length; | ||
s->l1.afsk12.subsamp = -length; | ||
} | ||
|
||
/* ---------------------------------------------------------------------- */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
* | ||
* Copyright (C) 2000 | ||
* A. Maitland Bottoms <[email protected]> | ||
* Copyright (C) 2024 | ||
* Marat Fayzullin <[email protected]> | ||
* | ||
* Licensed under same terms and based upon the | ||
* demod_afsk12.c -- 1200 baud AFSK demodulator | ||
|
@@ -253,20 +255,19 @@ static void eas_demod(struct demod_state *s, buffer_t buffer, int length) | |
float f; | ||
unsigned char curbit; | ||
float dll_gain; | ||
|
||
if (s->l1.eas.subsamp) { | ||
int numfill = SUBSAMP - s->l1.eas.subsamp; | ||
if (length < numfill) { | ||
s->l1.eas.subsamp += length; | ||
if (length <= (int)s->l1.eas.subsamp) { | ||
s->l1.eas.subsamp -= length; | ||
return; | ||
} | ||
buffer.fbuffer += numfill; | ||
length -= numfill; | ||
buffer.fbuffer += s->l1.eas.subsamp; | ||
length -= s->l1.eas.subsamp; | ||
s->l1.eas.subsamp = 0; | ||
} | ||
// We use a sliding window correlator which advances by SUBSAMP | ||
// each time. One correlator sample is output for each SUBSAMP symbols | ||
for (; length >= SUBSAMP; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
for (; length > 0; length -= SUBSAMP, buffer.fbuffer += SUBSAMP) { | ||
f = fsqr(mac(buffer.fbuffer, eascorr_mark_i, CORRLEN)) + | ||
fsqr(mac(buffer.fbuffer, eascorr_mark_q, CORRLEN)) - | ||
fsqr(mac(buffer.fbuffer, eascorr_space_i, CORRLEN)) - | ||
|
@@ -286,14 +287,13 @@ static void eas_demod(struct demod_state *s, buffer_t buffer, int length) | |
{ | ||
s->l1.eas.dcd_integrator -= 1; | ||
} | ||
|
||
verbprintf(9, "%c", '0'+(s->l1.afsk12.dcd_shreg & 1)); | ||
|
||
|
||
|
||
/* | ||
* check if transition occurred on time | ||
*/ | ||
|
||
if (s->l2.eas.state != EAS_L2_IDLE) | ||
dll_gain = DLL_GAIN_SYNC; | ||
else | ||
|
@@ -313,7 +313,6 @@ static void eas_demod(struct demod_state *s, buffer_t buffer, int length) | |
else | ||
{ | ||
// after center; check for increment | ||
|
||
if (s->l1.eas.sphase < (0x10000u - SPHASEINC/2)) | ||
{ | ||
s->l1.eas.sphase += MIN((int)((0x10000u - s->l1.eas.sphase)* | ||
|
@@ -325,20 +324,20 @@ static void eas_demod(struct demod_state *s, buffer_t buffer, int length) | |
} | ||
|
||
s->l1.eas.sphase += SPHASEINC; | ||
|
||
if (s->l1.eas.sphase >= 0x10000u) { | ||
// end of bit period. | ||
s->l1.eas.sphase = 1; //was &= 0xffffu; | ||
s->l1.eas.lasts >>= 1; | ||
|
||
// if at least half of the values in the integrator are 1, | ||
// declare a 1 received | ||
s->l1.afsk12.lasts |= ((s->l1.eas.dcd_integrator >= 0) << 7) & 0x80u; | ||
|
||
curbit = (s->l1.eas.lasts >> 7) & 0x1u; | ||
verbprintf(9, " "); | ||
verbprintf(7, "%c", '0'+curbit); | ||
|
||
// check for sync sequence | ||
// do not resync when we're reading a message! | ||
if (s->l1.eas.lasts == PREAMBLE | ||
|
@@ -369,12 +368,11 @@ static void eas_demod(struct demod_state *s, buffer_t buffer, int length) | |
s->l1.eas.byte_counter = 0; | ||
} | ||
} | ||
|
||
|
||
|
||
verbprintf(9, "\n"); | ||
} | ||
} | ||
s->l1.eas.subsamp = length; | ||
s->l1.eas.subsamp = -length; | ||
} | ||
|
||
/* ---------------------------------------------------------------------- */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters