aboutsummaryrefslogtreecommitdiffstats
path: root/src/bnetz
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-01-04 14:14:02 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-02-18 21:00:45 +0100
commit9ff8c3bb25422e100801f90c17b9c21118920cfd (patch)
tree5715f3cc08893ed86dfc2514c93797d12e24d461 /src/bnetz
parentd54d3ac2654844c7b8e4ee67752941c9037d5f42 (diff)
Rework on audio interface
Sound instance is now called audio instance and uses funcation pointers. This gives a clean interface to be exchanged with other technologies, linke SDR.
Diffstat (limited to 'src/bnetz')
-rw-r--r--src/bnetz/bnetz.c8
-rw-r--r--src/bnetz/bnetz.h2
-rw-r--r--src/bnetz/dsp.c2
-rw-r--r--src/bnetz/main.c18
4 files changed, 15 insertions, 15 deletions
diff --git a/src/bnetz/bnetz.c b/src/bnetz/bnetz.c
index 9bb4b8b..6b8a6d9 100644
--- a/src/bnetz/bnetz.c
+++ b/src/bnetz/bnetz.c
@@ -106,7 +106,7 @@ double bnetz_kanal2freq(int kanal, int unterband)
if (unterband)
freq -= 4.600;
- return freq;
+ return freq * 1e6;
}
/* switch pilot signal (tone or file) */
@@ -141,7 +141,7 @@ static void bnetz_timeout(struct timer *timer);
static void bnetz_go_idle(bnetz_t *bnetz);
/* Create transceiver instance and link to a list. */
-int bnetz_create(int kanal, const char *sounddev, int samplerate, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_factor, const char *pilot)
+int bnetz_create(int kanal, const char *audiodev, int samplerate, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_factor, const char *pilot)
{
bnetz_t *bnetz;
enum pilot_signal pilot_signal = PILOT_SIGNAL_NONE;
@@ -202,7 +202,7 @@ error_pilot:
PDEBUG(DBNETZ, DEBUG_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %d 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate);
/* init general part of transceiver */
- rc = sender_create(&bnetz->sender, kanal, sounddev, samplerate, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, loss_factor, pilot_signal);
+ rc = sender_create(&bnetz->sender, kanal, bnetz_kanal2freq(kanal, 0), bnetz_kanal2freq(kanal, 1), audiodev, samplerate, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, loss_factor, pilot_signal);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;
@@ -823,7 +823,7 @@ void call_rx_audio(int callref, int16_t *samples, int count)
if (bnetz->dsp_mode == DSP_MODE_AUDIO) {
int16_t up[(int)((double)count * bnetz->sender.srstate.factor + 0.5) + 10];
count = samplerate_upsample(&bnetz->sender.srstate, samples, count, up);
- jitter_save(&bnetz->sender.audio, up, count);
+ jitter_save(&bnetz->sender.dejitter, up, count);
}
}
diff --git a/src/bnetz/bnetz.h b/src/bnetz/bnetz.h
index 444a5a2..10f5a6d 100644
--- a/src/bnetz/bnetz.h
+++ b/src/bnetz/bnetz.h
@@ -100,7 +100,7 @@ typedef struct bnetz {
double bnetz_kanal2freq(int kanal, int unterband);
int bnetz_init(void);
-int bnetz_create(int kanal, const char *sounddev, int samplerate, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_factor, const char *pilot);
+int bnetz_create(int kanal, const char *audiodev, int samplerate, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_factor, const char *pilot);
void bnetz_destroy(sender_t *sender);
void bnetz_loss_indication(bnetz_t *bnetz);
void bnetz_receive_tone(bnetz_t *bnetz, int bit);
diff --git a/src/bnetz/dsp.c b/src/bnetz/dsp.c
index d91780f..2e2a7f1 100644
--- a/src/bnetz/dsp.c
+++ b/src/bnetz/dsp.c
@@ -388,7 +388,7 @@ again:
memset(samples, 0, length * sizeof(*samples));
break;
case DSP_MODE_AUDIO:
- jitter_load(&bnetz->sender.audio, samples, length);
+ jitter_load(&bnetz->sender.dejitter, samples, length);
break;
case DSP_MODE_0:
fsk_tone(bnetz, samples, length, 0);
diff --git a/src/bnetz/main.c b/src/bnetz/main.c
index 6f5a73b..7322ca3 100644
--- a/src/bnetz/main.c
+++ b/src/bnetz/main.c
@@ -153,9 +153,9 @@ int main(int argc, char *argv[])
print_help(argv[-skip_args]);
return 0;
}
- if (num_kanal == 1 && num_sounddev == 0)
- num_sounddev = 1; /* use defualt */
- if (num_kanal != num_sounddev) {
+ if (num_kanal == 1 && num_audiodev == 0)
+ num_audiodev = 1; /* use defualt */
+ if (num_kanal != num_audiodev) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0);
}
@@ -174,12 +174,12 @@ int main(int argc, char *argv[])
rc = mncc_init("/tmp/bsc_mncc");
if (rc < 0) {
fprintf(stderr, "Failed to setup MNCC socket. Quitting!\n");
- return -1;
+ goto fail;
}
}
dsp_init();
bnetz_init();
- rc = call_init(station_id, call_sounddev, samplerate, latency, 5, loopback);
+ rc = call_init(station_id, call_audiodev, samplerate, latency, 5, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create call control instance. Quitting!\n");
goto fail;
@@ -187,16 +187,16 @@ int main(int argc, char *argv[])
/* create transceiver instance */
for (i = 0; i < num_kanal; i++) {
- rc = bnetz_create(kanal[i], sounddev[i], samplerate, rx_gain, gfs, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, (double)lossdetect / 100.0, pilot[i]);
+ rc = bnetz_create(kanal[i], audiodev[i], samplerate, rx_gain, gfs, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, (double)lossdetect / 100.0, pilot[i]);
if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail;
}
- printf("Base station for channel %d ready, please tune transmitter to %.3f MHz and receiver " "to %.3f MHz.\n", kanal[i], bnetz_kanal2freq(kanal[i], 0), bnetz_kanal2freq(kanal[i], 1));
- printf("To call phone, switch transmitter (using pilot signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0));
+ printf("Base station for channel %d ready, please tune transmitter to %.3f MHz and receiver " "to %.3f MHz.\n", kanal[i], bnetz_kanal2freq(kanal[i], 0) / 1e6, bnetz_kanal2freq(kanal[i], 1) / 1e6);
+ printf("To call phone, switch transmitter (using pilot signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0) / 1e6);
}
- main_loop(&quit, latency, interval, NULL);
+ main_common(&quit, latency, interval, NULL);
fail:
/* cleanup functions */