Skip to content

Commit

Permalink
MORSE_CW demod, integer math and gen-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias Oenal authored and Elias Oenal committed Aug 30, 2013
1 parent b95660e commit 43cb771
Show file tree
Hide file tree
Showing 34 changed files with 768 additions and 247 deletions.
16 changes: 8 additions & 8 deletions demod_afsk12.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void afsk12_init(struct demod_state *s)

/* ---------------------------------------------------------------------- */

static void afsk12_demod(struct demod_state *s, float *buffer, int length)
static void afsk12_demod(struct demod_state *s, buffer_t buffer, int length)
{
float f;
unsigned char curbit;
Expand All @@ -84,15 +84,15 @@ static void afsk12_demod(struct demod_state *s, float *buffer, int length)
s->l1.afsk12.subsamp += length;
return;
}
buffer += numfill;
buffer.fbuffer += numfill;
length -= numfill;
s->l1.afsk12.subsamp = 0;
}
for (; length >= SUBSAMP; length -= SUBSAMP, buffer += SUBSAMP) {
f = fsqr(mac(buffer, corr_mark_i, CORRLEN)) +
fsqr(mac(buffer, corr_mark_q, CORRLEN)) -
fsqr(mac(buffer, corr_space_i, CORRLEN)) -
fsqr(mac(buffer, corr_space_q, CORRLEN));
for (; length >= SUBSAMP; 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)) -
fsqr(mac(buffer.fbuffer, corr_space_q, CORRLEN));
s->l1.afsk12.dcd_shreg <<= 1;
s->l1.afsk12.dcd_shreg |= (f > 0);
verbprintf(10, "%c", '0'+(s->l1.afsk12.dcd_shreg & 1));
Expand Down Expand Up @@ -122,7 +122,7 @@ static void afsk12_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_afsk1200 = {
"AFSK1200", FREQ_SAMP, CORRLEN, afsk12_init, afsk12_demod, NULL
"AFSK1200", true, FREQ_SAMP, CORRLEN, afsk12_init, afsk12_demod, NULL
};

/* ---------------------------------------------------------------------- */
14 changes: 7 additions & 7 deletions demod_afsk24.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ static void afsk24_init(struct demod_state *s)

/* ---------------------------------------------------------------------- */

static void afsk24_demod(struct demod_state *s, float *buffer, int length)
static void afsk24_demod(struct demod_state *s, buffer_t buffer, int length)
{
float f;
unsigned char curbit;

for (; length > 0; length--, buffer++) {
f = fsqr(mac(buffer, corr_mark_i, CORRLEN)) +
fsqr(mac(buffer, corr_mark_q, CORRLEN)) -
fsqr(mac(buffer, corr_space_i, CORRLEN)) -
fsqr(mac(buffer, corr_space_q, CORRLEN));
for (; length > 0; length--, buffer.fbuffer++) {
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)) -
fsqr(mac(buffer.fbuffer, corr_space_q, CORRLEN));
s->l1.afsk24.dcd_shreg <<= 1;
s->l1.afsk24.dcd_shreg |= (f > 0);
verbprintf(10, "%c", '0'+(s->l1.afsk24.dcd_shreg & 1));
Expand Down Expand Up @@ -119,7 +119,7 @@ static void afsk24_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_afsk2400 = {
"AFSK2400", FREQ_SAMP, CORRLEN, afsk24_init, afsk24_demod, NULL
"AFSK2400", true, FREQ_SAMP, CORRLEN, afsk24_init, afsk24_demod, NULL
};

/* ---------------------------------------------------------------------- */
14 changes: 7 additions & 7 deletions demod_afsk24_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ static void afsk24_2_init(struct demod_state *s)

/* ---------------------------------------------------------------------- */

static void afsk24_2_demod(struct demod_state *s, float *buffer, int length)
static void afsk24_2_demod(struct demod_state *s, buffer_t buffer, int length)
{
float f;
unsigned char curbit;

for (; length > 0; length--, buffer++) {
f = fsqr(mac(buffer, corr_mark_i, CORRLEN)) +
fsqr(mac(buffer, corr_mark_q, CORRLEN)) -
fsqr(mac(buffer, corr_space_i, CORRLEN)) -
fsqr(mac(buffer, corr_space_q, CORRLEN));
for (; length > 0; length--, buffer.fbuffer++) {
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)) -
fsqr(mac(buffer.fbuffer, corr_space_q, CORRLEN));
s->l1.afsk24.dcd_shreg <<= 1;
s->l1.afsk24.dcd_shreg |= (f > 0);
verbprintf(10, "%c", '0'+(s->l1.afsk24.dcd_shreg & 1));
Expand Down Expand Up @@ -119,7 +119,7 @@ static void afsk24_2_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_afsk2400_2 = {
"AFSK2400_2", FREQ_SAMP, CORRLEN, afsk24_2_init, afsk24_2_demod, NULL
"AFSK2400_2", true, FREQ_SAMP, CORRLEN, afsk24_2_init, afsk24_2_demod, NULL
};

/* ---------------------------------------------------------------------- */
14 changes: 7 additions & 7 deletions demod_afsk24_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ static void afsk24_3_init(struct demod_state *s)

/* ---------------------------------------------------------------------- */

static void afsk24_3_demod(struct demod_state *s, float *buffer, int length)
static void afsk24_3_demod(struct demod_state *s, buffer_t buffer, int length)
{
float f;
unsigned char curbit;

for (; length > 0; length--, buffer++) {
f = fsqr(mac(buffer, corr_mark_i, CORRLEN)) +
fsqr(mac(buffer, corr_mark_q, CORRLEN)) -
fsqr(mac(buffer, corr_space_i, CORRLEN)) -
fsqr(mac(buffer, corr_space_q, CORRLEN));
for (; length > 0; length--, buffer.fbuffer++) {
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)) -
fsqr(mac(buffer.fbuffer, corr_space_q, CORRLEN));
s->l1.afsk24.dcd_shreg <<= 1;
s->l1.afsk24.dcd_shreg |= (f > 0);
verbprintf(10, "%c", '0'+(s->l1.afsk24.dcd_shreg & 1));
Expand Down Expand Up @@ -119,7 +119,7 @@ static void afsk24_3_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_afsk2400_3 = {
"AFSK2400_3", FREQ_SAMP, CORRLEN, afsk24_3_init, afsk24_3_demod, NULL
"AFSK2400_3", true, FREQ_SAMP, CORRLEN, afsk24_3_init, afsk24_3_demod, NULL
};

/* ---------------------------------------------------------------------- */
6 changes: 3 additions & 3 deletions demod_ccir.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ static void ccir_deinit(struct demod_state *s)
selcall_deinit(s);
}

static void ccir_demod(struct demod_state *s, float *buffer, int length)
static void ccir_demod(struct demod_state *s, buffer_t buffer, int length)
{
selcall_demod(s, buffer, length, ccir_freq, demod_ccir.name);
selcall_demod(s, buffer.fbuffer, length, ccir_freq, demod_ccir.name);
}

const struct demod_param demod_ccir = {
"CCIR", SAMPLE_RATE, 0, ccir_init, ccir_demod, ccir_deinit
"CCIR", true, SAMPLE_RATE, 0, ccir_init, ccir_demod, ccir_deinit
};


Expand Down
16 changes: 8 additions & 8 deletions demod_clipfsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void clipfsk_init(struct demod_state *s)

/* ---------------------------------------------------------------------- */

static void clipfsk_demod(struct demod_state *s, float *buffer, int length)
static void clipfsk_demod(struct demod_state *s, buffer_t buffer, int length)
{
float f;
unsigned char curbit;
Expand All @@ -83,15 +83,15 @@ static void clipfsk_demod(struct demod_state *s, float *buffer, int length)
s->l1.clipfsk.subsamp += length;
return;
}
buffer += numfill;
buffer.fbuffer += numfill;
length -= numfill;
s->l1.clipfsk.subsamp = 0;
}
for (; length >= SUBSAMP; length -= SUBSAMP, buffer += SUBSAMP) {
f = fsqr(mac(buffer, corr_mark_i, CORRLEN)) +
fsqr(mac(buffer, corr_mark_q, CORRLEN)) -
fsqr(mac(buffer, corr_space_i, CORRLEN)) -
fsqr(mac(buffer, corr_space_q, CORRLEN));
for (; length >= SUBSAMP; 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)) -
fsqr(mac(buffer.fbuffer, corr_space_q, CORRLEN));
s->l1.clipfsk.dcd_shreg <<= 1;
s->l1.clipfsk.dcd_shreg |= (f > 0);
verbprintf(10, "%c", '0'+(s->l1.clipfsk.dcd_shreg & 1));
Expand All @@ -118,7 +118,7 @@ static void clipfsk_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_clipfsk = {
"CLIPFSK", FREQ_SAMP, CORRLEN, clipfsk_init, clipfsk_demod, NULL
"CLIPFSK", true, FREQ_SAMP, CORRLEN, clipfsk_init, clipfsk_demod, NULL
};

/* ---------------------------------------------------------------------- */
8 changes: 4 additions & 4 deletions demod_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ static void scope_init(struct demod_state *s)

#define MEMSIZE sizeof(s->l1.scope.data)/sizeof(s->l1.scope.data[0])

static void scope_demod(struct demod_state *s, float *buffer, int length)
static void scope_demod(struct demod_state *s, buffer_t buffer, int length)
{
float *src, *dst;
int i, j;

if (s->l1.scope.dispnum == -1)
return;
if (length >= MEMSIZE) {
src = buffer+length-MEMSIZE;
src = buffer.fbuffer+length-MEMSIZE;
dst = s->l1.scope.data;
i = MEMSIZE;
} else {
i = MEMSIZE-length;
memmove(s->l1.scope.data, s->l1.scope.data+i,
i*sizeof(s->l1.scope.data[0]));
src = buffer;
src = buffer.fbuffer;
dst = s->l1.scope.data+i;
i = length;
}
Expand All @@ -81,7 +81,7 @@ static void scope_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_scope = {
"SCOPE", SAMPLING_RATE, 0, scope_init, scope_demod, NULL
"SCOPE", true, SAMPLING_RATE, 0, scope_init, scope_demod, NULL
};


Expand Down
8 changes: 4 additions & 4 deletions demod_dtmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ static inline int process_block(struct demod_state *s)

/* ---------------------------------------------------------------------- */

static void dtmf_demod(struct demod_state *s, float *buffer, int length)
static void dtmf_demod(struct demod_state *s, buffer_t buffer, int length)
{
float s_in;
int i;

for (; length > 0; length--, buffer++) {
s_in = *buffer;
for (; length > 0; length--, buffer.fbuffer++) {
s_in = *buffer.fbuffer;
s->l1.dtmf.energy[0] += fsqr(s_in);
for (i = 0; i < 8; i++) {
s->l1.dtmf.tenergy[0][i] += COS(s->l1.dtmf.ph[i]) * s_in;
Expand All @@ -145,7 +145,7 @@ static void dtmf_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_dtmf = {
"DTMF", SAMPLE_RATE, 0, dtmf_init, dtmf_demod, NULL
"DTMF", true, SAMPLE_RATE, 0, dtmf_init, dtmf_demod, NULL
};

/* ---------------------------------------------------------------------- */
6 changes: 3 additions & 3 deletions demod_dzvei.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ static void dzvei_deinit(struct demod_state *s)
selcall_deinit(s);
}

static void dzvei_demod(struct demod_state *s, float *buffer, int length)
static void dzvei_demod(struct demod_state *s, buffer_t buffer, int length)
{
selcall_demod(s, buffer, length, dzvei_freq, demod_dzvei.name);
selcall_demod(s, buffer.fbuffer, length, dzvei_freq, demod_dzvei.name);
}

const struct demod_param demod_dzvei = {
"DZVEI", SAMPLE_RATE, 0, dzvei_init, dzvei_demod, dzvei_deinit
"DZVEI", true, SAMPLE_RATE, 0, dzvei_init, dzvei_demod, dzvei_deinit
};


Expand Down
16 changes: 8 additions & 8 deletions demod_eas.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static void eas_frame(struct demod_state *s, char data)
}
}

static void eas_demod(struct demod_state *s, float *buffer, int length)
static void eas_demod(struct demod_state *s, buffer_t buffer, int length)
{
float f;
unsigned char curbit;
Expand All @@ -260,17 +260,17 @@ static void eas_demod(struct demod_state *s, float *buffer, int length)
s->l1.eas.subsamp += length;
return;
}
buffer += numfill;
buffer.fbuffer += numfill;
length -= numfill;
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 += SUBSAMP) {
f = fsqr(mac(buffer, eascorr_mark_i, CORRLEN)) +
fsqr(mac(buffer, eascorr_mark_q, CORRLEN)) -
fsqr(mac(buffer, eascorr_space_i, CORRLEN)) -
fsqr(mac(buffer, eascorr_space_q, CORRLEN));
for (; length >= SUBSAMP; 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)) -
fsqr(mac(buffer.fbuffer, eascorr_space_q, CORRLEN));
// f > 0 if a mark (wireline 1) is detected
// keep the last few correlator samples in s->l1.eas.dcd_shreg
// when we've synchronized to the bit transitions, the dcd_shreg
Expand Down Expand Up @@ -380,7 +380,7 @@ static void eas_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_eas = {
"EAS", FREQ_SAMP, CORRLEN, eas_init, eas_demod, NULL
"EAS", true, FREQ_SAMP, CORRLEN, eas_init, eas_demod, NULL
};

/* ---------------------------------------------------------------------- */
6 changes: 3 additions & 3 deletions demod_eea.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ static void eea_deinit(struct demod_state *s)
selcall_deinit(s);
}

static void eea_demod(struct demod_state *s, float *buffer, int length)
static void eea_demod(struct demod_state *s, buffer_t buffer, int length)
{
selcall_demod(s, buffer, length, eea_freq, demod_eea.name);
selcall_demod(s, buffer.fbuffer, length, eea_freq, demod_eea.name);
}

const struct demod_param demod_eea = {
"EEA", SAMPLE_RATE, 0, eea_init, eea_demod, eea_deinit
"EEA", true, SAMPLE_RATE, 0, eea_init, eea_demod, eea_deinit
};


Expand Down
6 changes: 3 additions & 3 deletions demod_eia.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ static void eia_deinit(struct demod_state *s)
selcall_deinit(s);
}

static void eia_demod(struct demod_state *s, float *buffer, int length)
static void eia_demod(struct demod_state *s, buffer_t buffer, int length)
{
selcall_demod(s, buffer, length, eia_freq, demod_eia.name);
selcall_demod(s, buffer.fbuffer, length, eia_freq, demod_eia.name);
}

const struct demod_param demod_eia = {
"EIA", SAMPLE_RATE, 0, eia_init, eia_demod, eia_deinit
"EIA", true, SAMPLE_RATE, 0, eia_init, eia_demod, eia_deinit
};


Expand Down
8 changes: 4 additions & 4 deletions demod_fsk96.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ static void fsk96_init(struct demod_state *s)

/* ---------------------------------------------------------------------- */

static void fsk96_demod(struct demod_state *s, float *buffer, int length)
static void fsk96_demod(struct demod_state *s, buffer_t buffer, int length)
{
float f;
unsigned char curbit;
int i;
unsigned int descx;

for (; length > 0; length--, buffer++) {
for (; length > 0; length--, buffer.fbuffer++) {
for (i = 0; i < UPSAMP; i++) {
f = mac(buffer, inp_filt[i], FILTLEN);
f = mac(buffer.fbuffer, inp_filt[i], FILTLEN);
s->l1.fsk96.dcd_shreg <<= 1;
s->l1.fsk96.dcd_shreg |= (f > 0);
verbprintf(10, "%c", '0'+(s->l1.fsk96.dcd_shreg & 1));
Expand Down Expand Up @@ -122,7 +122,7 @@ static void fsk96_demod(struct demod_state *s, float *buffer, int length)
/* ---------------------------------------------------------------------- */

const struct demod_param demod_fsk9600 = {
"FSK9600", FREQ_SAMP, FILTLEN, fsk96_init, fsk96_demod, NULL
"FSK9600", true, FREQ_SAMP, FILTLEN, fsk96_init, fsk96_demod, NULL
};

/* ---------------------------------------------------------------------- */
Loading

0 comments on commit 43cb771

Please sign in to comment.