aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnetz
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/cnetz
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/cnetz')
-rw-r--r--src/cnetz/cnetz.c10
-rw-r--r--src/cnetz/cnetz.h2
-rw-r--r--src/cnetz/dsp.c6
-rw-r--r--src/cnetz/main.c20
4 files changed, 21 insertions, 17 deletions
diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c
index ca0e941..f0a4ec5 100644
--- a/src/cnetz/cnetz.c
+++ b/src/cnetz/cnetz.c
@@ -161,7 +161,7 @@ double cnetz_kanal2freq(int kanal, int unterband)
if (unterband)
freq -= 10.0;
- return freq;
+ return freq * 1e6;
}
const char *cnetz_state_name(enum cnetz_state state)
@@ -215,7 +215,7 @@ int cnetz_init(void)
static void cnetz_go_idle(cnetz_t *cnetz);
/* Create transceiver instance and link to a list. */
-int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev, int samplerate, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback)
+int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *audiodev, int samplerate, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback)
{
sender_t *sender;
cnetz_t *cnetz;
@@ -258,7 +258,7 @@ int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev
for (sender = sender_head; sender; sender = sender->next) {
cnetz = (cnetz_t *)sender;
- if (!!strcmp(sender->sounddev, sounddev)) {
+ if (!!strcmp(sender->audiodev, audiodev)) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "To be able to sync multiple channels, all channels must be on the same sound device!\n");
return -EINVAL;
}
@@ -274,7 +274,7 @@ int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev
/* init general part of transceiver */
/* do not enable emphasis, since it is done by cnetz code, not by common sender code */
- rc = sender_create(&cnetz->sender, kanal, sounddev, samplerate, rx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
+ rc = sender_create(&cnetz->sender, kanal, cnetz_kanal2freq(kanal, 0), cnetz_kanal2freq(kanal, 1), audiodev, samplerate, rx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;
@@ -443,7 +443,7 @@ void call_rx_audio(int callref, int16_t *samples, int count)
if (cnetz->dsp_mode == DSP_MODE_SPK_V) {
/* store as is, since we convert rate when processing FSK frames */
- jitter_save(&cnetz->sender.audio, samples, count);
+ jitter_save(&cnetz->sender.dejitter, samples, count);
}
}
diff --git a/src/cnetz/cnetz.h b/src/cnetz/cnetz.h
index 8691ac4..5897735 100644
--- a/src/cnetz/cnetz.h
+++ b/src/cnetz/cnetz.h
@@ -123,7 +123,7 @@ int cnetz_channel_by_short_name(const char *short_name);
const char *chan_type_short_name(enum cnetz_chan_type chan_type);
const char *chan_type_long_name(enum cnetz_chan_type chan_type);
int cnetz_init(void);
-int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev, int samplerate, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback);
+int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *audiodev, int samplerate, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback);
void cnetz_destroy(sender_t *sender);
void cnetz_sync_frame(cnetz_t *cnetz, double sync, int ts);
int cnetz_meldeaufruf(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest);
diff --git a/src/cnetz/dsp.c b/src/cnetz/dsp.c
index 0b78b92..a35e8c8 100644
--- a/src/cnetz/dsp.c
+++ b/src/cnetz/dsp.c
@@ -137,8 +137,8 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], do
scrambler_setup(&cnetz->scrambler_rx, (double)cnetz->sender.samplerate / 1.1);
/* reinit jitter buffer for 8000 kHz */
- jitter_destroy(&cnetz->sender.audio);
- rc = jitter_create(&cnetz->sender.audio, 8000 / 5);
+ jitter_destroy(&cnetz->sender.dejitter);
+ rc = jitter_create(&cnetz->sender.dejitter, 8000 / 5);
if (rc < 0)
goto error;
@@ -702,7 +702,7 @@ again:
for (i = 0; i < copy; i++) {
if (*spl == -32768) {
/* marker found to insert new chunk of audio */
- jitter_load(&cnetz->sender.audio, speech_buffer, 100);
+ jitter_load(&cnetz->sender.dejitter, speech_buffer, 100);
/* 1. compress dynamics */
compress_audio(&cnetz->cstate, speech_buffer, 100);
/* 2. upsample */
diff --git a/src/cnetz/main.c b/src/cnetz/main.c
index efe3148..ddb8216 100644
--- a/src/cnetz/main.c
+++ b/src/cnetz/main.c
@@ -217,9 +217,9 @@ int main(int argc, char *argv[])
printf("No channel (\"Kanal\") is specified, I suggest channel %d.\n\n", CNETZ_OGK_KANAL);
mandatory = 1;
}
- 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);
}
@@ -248,7 +248,7 @@ 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;
}
}
scrambler_init();
@@ -261,7 +261,7 @@ int main(int argc, char *argv[])
}
init_coding();
cnetz_init();
- rc = call_init(station_id, call_sounddev, samplerate, latency, 7, loopback);
+ rc = call_init(station_id, call_audiodev, samplerate, latency, 7, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create call control instance. Quitting!\n");
goto fail;
@@ -302,15 +302,19 @@ int main(int argc, char *argv[])
/* create transceiver instance */
for (i = 0; i < num_kanal; i++) {
- rc = cnetz_create(kanal[i], chan_type[i], sounddev[i], samplerate, rx_gain, auth, ms_power, (i == 0) ? measure_speed : 0, clock_speed, polarity, noise, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback);
+ rc = cnetz_create(kanal[i], chan_type[i], audiodev[i], samplerate, rx_gain, auth, ms_power, (i == 0) ? measure_speed : 0, clock_speed, polarity, noise, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail;
}
- printf("Base station on channel %d ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], cnetz_kanal2freq(kanal[i], 0), cnetz_kanal2freq(kanal[i], 1));
+ if ((kanal[i] & 1)) {
+ printf("Base station on channel %d ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], cnetz_kanal2freq(kanal[i], 0) / 1e6, cnetz_kanal2freq(kanal[i], 1) / 1e6);
+ } else {
+ printf("Base station on channel %d ready, please tune transmitter to %.4f MHz and receiver to %.4f MHz.\n", kanal[i], cnetz_kanal2freq(kanal[i], 0) / 1e6, cnetz_kanal2freq(kanal[i], 1) / 1e6);
+ }
}
- main_loop(&quit, latency, interval, NULL);
+ main_common(&quit, latency, interval, NULL);
fail:
/* cleanup functions */