NXDN: New Frame Sync Fine Tuning;

Tweak lmix, lmax, qsort indexing values based on sync pattern length;
This commit is contained in:
lwvmobile
2026-02-13 14:55:00 -05:00
parent d3303aea28
commit 9f03ad123d

View File

@@ -379,8 +379,19 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
lbuf2[i] = lbuf[i];
}
qsort (lbuf2, t_max, sizeof (int), comp);
lmin = (lbuf2[1] + lbuf2[2] + lbuf2[3]) / 3;
lmax = (lbuf2[t_max - 3] + lbuf2[t_max - 2] + lbuf2[t_max - 1]) / 3;
//on shorter sync patterns, we need to look at the edges since we don't have many to pull from
if (t_max < 13)
{
lmin = (lbuf2[0] + lbuf2[1] + lbuf2[2]) / 3;
lmax = (lbuf2[t_max - 3] + lbuf2[t_max - 2] + lbuf2[t_max - 1]) / 3;
}
//on longer sync patterns, we can get more towards the middle and eliminate outlier values
else
{
lmin = (lbuf2[2] + lbuf2[3] + lbuf2[4]) / 3;
lmax = (lbuf2[t_max - 5] + lbuf2[t_max - 4] + lbuf2[t_max - 3]) / 3;
}
if (state->rf_mod == 1)
{
@@ -1155,6 +1166,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
)
{
//debug
// fprintf (stderr, " %s ", synctest10);
if (state->lastsynctype == 28)
{
state->offset = synctest_pos;
@@ -1177,6 +1191,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
)
{
//debug
// fprintf (stderr, " %s ", synctest10);
if (state->lastsynctype == 29)
{
state->offset = synctest_pos;
@@ -1196,19 +1213,19 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
strncpy (synctest10, (synctest_p - 9), 10); //FSW only
if (
(strcmp (synctest10, "3131331131") == 0 ) //this seems to be the most common 'correct' pattern on Type-C
|| (strcmp (synctest10, "3331331131") == 0 ) //this one hits on new sync but gives a bad lich code
|| (strcmp (synctest10, "3131331111") == 0 )
|| (strcmp (synctest10, "3331331111") == 0 )
|| (strcmp (synctest10, "3131311131") == 0 ) //First few FSW on NXDN48 Type-C seems to hit this for some reason
|| (strcmp (synctest10, "3331331131") == 0 ) //this seems to be the most common 'correct' pattern on Conventional
)
{
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
//debug
// fprintf (stderr, " %s ", synctest10);
if (state->lastsynctype == 28)
{
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
state->last_cc_sync_time = time(NULL);
return (28);
}
@@ -1222,20 +1239,20 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{
strncpy (synctest10, (synctest_p - 9), 10); //FSW only
if (
(strcmp (synctest10, "1313113313") == 0 )
|| (strcmp (synctest10, "1113113313") == 0 )
|| (strcmp (synctest10, "1313113333") == 0 )
|| (strcmp (synctest10, "1113113333") == 0 )
|| (strcmp (synctest10, "1313133313") == 0 )
)
(strcmp (synctest10, "1313113313") == 0 ) //this seems to be the most common 'correct' pattern on Type-C
|| (strcmp (synctest10, "1113113313") == 0 ) //this seems to be the most common 'correct' pattern on Conventional
)
{
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
//debug
// fprintf (stderr, " %s ", synctest10);
if (state->lastsynctype == 29)
{
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
state->last_cc_sync_time = time(NULL);
return (29);
}