Prepare for NMT: Fixes and improvements at common code

This commit is contained in:
Andreas Eversberg
2016-03-11 06:59:05 +01:00
parent 287b914b56
commit 0dc81fe210
16 changed files with 137 additions and 105 deletions

View File

@@ -7,7 +7,7 @@ bnetz_SOURCES = \
bnetz.c \
dsp.c \
image.c \
ansage-27.c \
ansage.c \
main.c
bnetz_LDADD = \
$(COMMON_LA) \

View File

@@ -1,3 +0,0 @@
void init_ansage_27(void);

View File

@@ -1,5 +1,5 @@
#include <stdint.h>
#include "ansage-27.h"
#include "ansage.h"
static int16_t pattern[] = {
0xffd1, 0x0011, 0x0031, 0x002d, 0x0016, 0x000d, 0x002f, 0xffea,
@@ -4991,13 +4991,15 @@ static int16_t pattern[] = {
0x0006, 0x000e, 0xfffd, 0x000b, 0xfffc, 0x000b, 0x000e, 0xfffb,
};
extern int16_t *ansage_27_spl;
extern int ansage_27_size;
extern int16_t *outoforder_spl;
extern int outoforder_size;
extern int outoforder_max;
void init_ansage_27(void)
void init_ansage(void)
{
ansage_27_spl = pattern;
ansage_27_size = sizeof(pattern) / sizeof(pattern[0]);
outoforder_spl = pattern;
outoforder_size = sizeof(pattern) / sizeof(pattern[0]);
outoforder_max = outoforder_size;
}

3
src/bnetz/ansage.h Normal file
View File

@@ -0,0 +1,3 @@
void init_ansage(void);

View File

@@ -84,13 +84,13 @@ int dsp_init_sender(bnetz_t *bnetz)
PDEBUG(DFSK, DEBUG_DEBUG, "Using %d samples per bit duration.\n", bnetz->samples_per_bit);
bnetz->fsk_filter_step = bnetz->sender.samplerate * FILTER_STEP;
PDEBUG(DFSK, DEBUG_DEBUG, "Using %d samples per filter step.\n", bnetz->fsk_filter_step);
spl = calloc(16, bnetz->samples_per_bit << 1);
spl = calloc(16, bnetz->samples_per_bit * sizeof(*spl));
if (!spl) {
PDEBUG(DFSK, DEBUG_ERROR, "No memory!\n");
return -ENOMEM;
}
bnetz->telegramm_spl = spl;
spl = calloc(1, bnetz->samples_per_bit << 1);
spl = calloc(1, bnetz->samples_per_bit * sizeof(*spl));
if (!spl) {
PDEBUG(DFSK, DEBUG_ERROR, "No memory!\n");
return -ENOMEM;
@@ -204,7 +204,7 @@ char *show_level(int value)
/* Filter one chunk of audio an detect tone, quality and loss of signal.
* The chunk is a window of 10ms. This window slides over audio stream
* and is processed every 1ms. (one step) */
void fsk_decode_step(bnetz_t *bnetz, int pos)
static inline void fsk_decode_step(bnetz_t *bnetz, int pos)
{
double level, result[2], softbit, quality;
int max;

View File

@@ -29,10 +29,12 @@
#include "../common/call.h"
#include "../common/mncc_sock.h"
#include "../common/main.h"
#include "../common/freiton.h"
#include "../common/besetztton.h"
#include "bnetz.h"
#include "dsp.h"
#include "image.h"
#include "ansage-27.h"
#include "ansage.h"
int gfs = 2;
const char *pilot = "tone";
@@ -40,7 +42,7 @@ double lossdetect = 0;
void print_help(const char *arg0)
{
print_help_common(arg0);
print_help_common(arg0, "");
/* - - */
printf(" -g --gfs <gruppenfreisignal>\n");
printf(" Gruppenfreisignal\" 1..9 | 19 | 10..18 (default = '%d')\n", gfs);
@@ -109,6 +111,11 @@ int main(int argc, char *argv[])
int skip_args;
const char *station_id = "";
/* init common tones */
init_freiton();
init_besetzton();
init_ansage();
skip_args = handle_options(argc, argv);
argc -= skip_args;
argv += skip_args;
@@ -138,10 +145,9 @@ int main(int argc, char *argv[])
return -1;
}
}
init_ansage_27();
dsp_init();
bnetz_init();
rc = call_init(station_id, call_sounddev, samplerate, latency, loopback);
rc = call_init(station_id, call_sounddev, samplerate, latency, 5, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create call control instance. Quitting!\n");
goto fail;