Refactor global variables for signal processing

These are:
	device, sample rate, buffer, latency
Called now:
	dsp_device, dsp_samplerate, dsp_buffer, dsp_latency
Call audio device:
	call_device, call_samplerate, call_buffer
This commit is contained in:
Andreas Eversberg 2021-09-18 11:43:01 +02:00
parent de685b3cb6
commit 6fa74a1296
57 changed files with 379 additions and 368 deletions

View File

@ -348,7 +348,7 @@ Find out what band and channels your phone supports. Then get a list of all avai
<p> <p>
Assume the phone supports VHF Low band, so we select channel 'YK' with the command line option '-k YK', or select any other channel your phone supports. Assume the phone supports VHF Low band, so we select channel 'YK' with the command line option '-k YK', or select any other channel your phone supports.
In order to have a low latency, you must add '-b 5' to the command line option. In order to have a low latency, you must add '-b 5 -i 0.1' to the command line option.
Then tune the transmitter to the indicated channel and receiver to the other indicated channel. Then tune the transmitter to the indicated channel and receiver to the other indicated channel.
Transmit with a normal loud speech volume, but not too loud. Transmit with a normal loud speech volume, but not too loud.
The actual level is not yet relevant. The actual level is not yet relevant.
@ -356,7 +356,7 @@ The actual level is not yet relevant.
<pre> <pre>
# src/imts/imts -k YK -b 5 # src/imts/imts -k YK -b 5 -i 0.1
... ...
imts.c:381 info : Entering IDLE state on channel YK, sending 2000 Hz tone. imts.c:381 info : Entering IDLE state on channel YK, sending 2000 Hz tone.
imts.c:336 notice : Created channel #YK imts.c:336 notice : Created channel #YK
@ -382,7 +382,7 @@ If the phone transmits, your base station should respond to the seize sequence b
<pre> <pre>
# src/imts/imts -k YK -b 5 # src/imts/imts -k YK -b 5 -i 0.1
... ...
imts.c:381 info : Entering IDLE state on channel YK, sending 2000 Hz tone. imts.c:381 info : Entering IDLE state on channel YK, sending 2000 Hz tone.
imts.c:336 notice : Created channel #YK imts.c:336 notice : Created channel #YK

View File

@ -491,7 +491,7 @@ static amps_t *search_pc(void)
} }
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback) int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback)
{ {
sender_t *sender; sender_t *sender;
amps_t *amps; amps_t *amps;
@ -562,7 +562,7 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *au
PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %s of band %s (sample rate %d).\n", kanal, band, samplerate); PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %s of band %s (sample rate %d).\n", kanal, band, samplerate);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&amps->sender, kanal, amps_channel2freq(atoi(kanal), 0), amps_channel2freq(atoi(kanal), 1), audiodev, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&amps->sender, kanal, amps_channel2freq(atoi(kanal), 0), amps_channel2freq(atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n"); PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error; goto error;

View File

@ -174,7 +174,7 @@ const char *amps_min12number(uint32_t min1);
void amps_number2min(const char *number, uint32_t *min1, uint16_t *min2); void amps_number2min(const char *number, uint32_t *min1, uint16_t *min2);
const char *amps_min2number(uint32_t min1, uint16_t min2); const char *amps_min2number(uint32_t min1, uint16_t min2);
const char *amps_scm(uint8_t scm); const char *amps_scm(uint8_t scm);
int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback); int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback);
void amps_destroy(sender_t *sender); void amps_destroy(sender_t *sender);
void amps_go_idle(amps_t *amps); void amps_go_idle(amps_t *amps);
void amps_rx_signaling_tone(amps_t *amps, int tone, double quality); void amps_rx_signaling_tone(amps_t *amps, int tone, double quality);

View File

@ -235,7 +235,7 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
int i; int i;
/* override default */ /* override default */
samplerate = 96000; dsp_samplerate = 96000;
main_mobile_init(); main_mobile_init();
@ -269,10 +269,10 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
return 0; return 0;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
/* set channel types for more than 1 channel */ /* set channel types for more than 1 channel */
if (num_kanal > 1 && num_chan_type == 0) { if (num_kanal > 1 && num_chan_type == 0) {
chan_type[0] = CHAN_TYPE_CC_PC; chan_type[0] = CHAN_TYPE_CC_PC;
@ -281,9 +281,9 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
num_chan_type = num_kanal; num_chan_type = num_kanal;
} }
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -320,8 +320,8 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
} }
if (bis && latency > 5) { if (bis && dsp_buffer > 5) {
fprintf(stderr, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--latency 5).\n"); fprintf(stderr, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--buffer 5).\n");
exit(0); exit(0);
} }
@ -381,7 +381,7 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
amps_si si; amps_si si;
init_sysinfo(&si, ms_power, ms_power, dtx, dcc, sid >> 1, regh, regr, pureg, pdreg, locaid, regincr, bis); init_sysinfo(&si, ms_power, ms_power, dtx, dcc, sid >> 1, regh, regr, pureg, pdreg, locaid, regincr, bis);
rc = amps_create(kanal[i], chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, &si, sid, scc, polarity, tolerant, loopback); rc = amps_create(kanal[i], chan_type[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, &si, sid, scc, polarity, tolerant, loopback);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail; goto fail;
@ -392,7 +392,7 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
printf("Base station on channel %s ready (%s), please tune transmitter to %.4f MHz and receiver to %.4f MHz. (%.3f MHz offset)\n", kanal[i], chan_type_long_name(chan_type[i]), amps_channel2freq(atoi(kanal[i]), 0) / 1e6, amps_channel2freq(atoi(kanal[i]), 1) / 1e6, amps_channel2freq(atoi(kanal[i]), 2) / 1e6); printf("Base station on channel %s ready (%s), please tune transmitter to %.4f MHz and receiver to %.4f MHz. (%.3f MHz offset)\n", kanal[i], chan_type_long_name(chan_type[i]), amps_channel2freq(atoi(kanal[i]), 0) / 1e6, amps_channel2freq(atoi(kanal[i]), 1) / 1e6, amps_channel2freq(atoi(kanal[i]), 2) / 1e6);
} }
main_mobile(name, &quit, latency, interval, NULL, station_id, 10); main_mobile(name, &quit, NULL, station_id, 10);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -183,7 +183,7 @@ static void anetz_timeout(struct timer *timer);
static void anetz_go_idle(anetz_t *anetz); static void anetz_go_idle(anetz_t *anetz);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int anetz_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, double page_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *operator) int anetz_create(const char *kanal, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, double page_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *operator)
{ {
anetz_t *anetz; anetz_t *anetz;
int rc; int rc;
@ -204,7 +204,7 @@ int anetz_create(const char *kanal, const char *audiodev, int use_sdr, int sampl
PDEBUG(DANETZ, DEBUG_DEBUG, "Creating 'A-Netz' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate); PDEBUG(DANETZ, DEBUG_DEBUG, "Creating 'A-Netz' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&anetz->sender, kanal, anetz_kanal2freq(atoi(kanal), 0), anetz_kanal2freq(atoi(kanal), 1), audiodev, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&anetz->sender, kanal, anetz_kanal2freq(atoi(kanal), 0), anetz_kanal2freq(atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n"); PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
goto error; goto error;

View File

@ -54,7 +54,7 @@ typedef struct anetz {
double anetz_kanal2freq(int kanal, int unterband); double anetz_kanal2freq(int kanal, int unterband);
int anetz_init(void); int anetz_init(void);
int anetz_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, double page_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *operator); int anetz_create(const char *kanal, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, double page_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *operator);
void anetz_destroy(sender_t *sender); void anetz_destroy(sender_t *sender);
void anetz_loss_indication(anetz_t *anetz, double loss_time); void anetz_loss_indication(anetz_t *anetz, double loss_time);
void anetz_receive_tone(anetz_t *anetz, int bit); void anetz_receive_tone(anetz_t *anetz, int bit);

View File

@ -161,14 +161,14 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -180,7 +180,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = anetz_create(kanal[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, page_gain, page_sequence, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, operator); rc = anetz_create(kanal[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, page_gain, page_sequence, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, operator);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail; goto fail;
@ -188,7 +188,7 @@ int main(int argc, char *argv[])
printf("Base station on channel %s ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz. (%.3f MHz offset)\n", kanal[i], anetz_kanal2freq(atoi(kanal[i]), 0) / 1e6, anetz_kanal2freq(atoi(kanal[i]), 1) / 1e6, anetz_kanal2freq(atoi(kanal[i]), 2) / 1e6); printf("Base station on channel %s ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz. (%.3f MHz offset)\n", kanal[i], anetz_kanal2freq(atoi(kanal[i]), 0) / 1e6, anetz_kanal2freq(atoi(kanal[i]), 1) / 1e6, anetz_kanal2freq(atoi(kanal[i]), 2) / 1e6);
} }
main_mobile("anetz", &quit, latency, interval, NULL, station_id, 5); main_mobile("anetz", &quit, NULL, station_id, 5);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -154,7 +154,7 @@ static void bnetz_timeout(struct timer *timer);
static void bnetz_go_idle(bnetz_t *bnetz); static void bnetz_go_idle(bnetz_t *bnetz);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int bnetz_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *paging, int metering) int bnetz_create(const char *kanal, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *paging, int metering)
{ {
bnetz_t *bnetz; bnetz_t *bnetz;
enum paging_signal paging_signal = PAGING_SIGNAL_NONE; enum paging_signal paging_signal = PAGING_SIGNAL_NONE;
@ -220,7 +220,7 @@ error_paging:
PDEBUG(DBNETZ, DEBUG_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %s 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate); PDEBUG(DBNETZ, DEBUG_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %s 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&bnetz->sender, kanal, bnetz_kanal2freq(atoi(kanal), 0), bnetz_kanal2freq(atoi(kanal), 1), audiodev, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, paging_signal); rc = sender_create(&bnetz->sender, kanal, bnetz_kanal2freq(atoi(kanal), 0), bnetz_kanal2freq(atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, paging_signal);
if (rc < 0) { if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n"); PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error; goto error;

View File

@ -113,7 +113,7 @@ typedef struct bnetz {
double bnetz_kanal2freq(int kanal, int unterband); double bnetz_kanal2freq(int kanal, int unterband);
int bnetz_init(void); int bnetz_init(void);
int bnetz_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *paging, int metering); int bnetz_create(const char *kanal, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *paging, int metering);
void bnetz_destroy(sender_t *sender); void bnetz_destroy(sender_t *sender);
void bnetz_loss_indication(bnetz_t *bnetz, double loss_time); void bnetz_loss_indication(bnetz_t *bnetz, double loss_time);
void bnetz_receive_tone(bnetz_t *bnetz, int bit); void bnetz_receive_tone(bnetz_t *bnetz, int bit);

View File

@ -42,10 +42,10 @@
char start_digit = 's'; char start_digit = 's';
const char *station_id = "50993"; const char *station_id = "50993";
const char *dialing; const char *dialing;
const char *audiodev = "hw:0,0"; const char *dsp_audiodev = "hw:0,0";
int samplerate = 48000; int dsp_samplerate = 48000;
const char *write_tx_wave = NULL; const char *write_tx_wave = NULL;
int latency = 50; int dsp_buffer = 50;
/* states */ /* states */
enum tx_mode { enum tx_mode {
@ -58,7 +58,6 @@ char funkwahl[128];
int digit_pos = 0; int digit_pos = 0;
const char *tx_telegramm = NULL; const char *tx_telegramm = NULL;
int tx_telegramm_pos = 0; int tx_telegramm_pos = 0;
int latspl;
/* instances */ /* instances */
fsk_mod_t fsk_mod; fsk_mod_t fsk_mod;
@ -90,10 +89,10 @@ static void print_help(const char *arg0)
printf(" 5 Digits of ID of mobile station (default = '%s')\n", station_id); printf(" 5 Digits of ID of mobile station (default = '%s')\n", station_id);
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
printf(" -a --audio-device hw:<card>,<device>\n"); printf(" -a --audio-device hw:<card>,<device>\n");
printf(" Sound card and device number (default = '%s')\n", audiodev); printf(" Sound card and device number (default = '%s')\n", dsp_audiodev);
#endif #endif
printf(" -s --samplerate <rate>\n"); printf(" -s --samplerate <rate>\n");
printf(" Sample rate of sound device (default = '%d')\n", samplerate); printf(" Sample rate of sound device (default = '%d')\n", dsp_samplerate);
printf(" -w --write-tx-wave <file>\n"); printf(" -w --write-tx-wave <file>\n");
printf(" Write audio to given wave file also.\n"); printf(" Write audio to given wave file also.\n");
printf(" -g --gebuehenimpuls\n"); printf(" -g --gebuehenimpuls\n");
@ -128,10 +127,10 @@ static int handle_options(int short_option, int __attribute__((unused)) argi, ch
station_id = options_strdup(argv[argi]); station_id = options_strdup(argv[argi]);
break; break;
case 'a': case 'a':
audiodev = options_strdup(argv[argi]); dsp_audiodev = options_strdup(argv[argi]);
break; break;
case 's': case 's':
samplerate = atoi(argv[argi]); dsp_samplerate = atoi(argv[argi]);
break; break;
case 'w': case 'w':
write_tx_wave = options_strdup(argv[argi]); write_tx_wave = options_strdup(argv[argi]);
@ -216,7 +215,7 @@ again:
case TX_MODE_SILENCE: case TX_MODE_SILENCE:
memset(samples, 0, length * sizeof(*samples)); memset(samples, 0, length * sizeof(*samples));
tx_silence_count += length; tx_silence_count += length;
if (tx_silence_count >= (int)((double)samplerate * MAX_PAUSE)) { if (tx_silence_count >= (int)((double)dsp_samplerate * MAX_PAUSE)) {
if (funkwahl[digit_pos]) if (funkwahl[digit_pos])
tx_mode = TX_MODE_FSK; tx_mode = TX_MODE_FSK;
else else
@ -239,18 +238,18 @@ again:
/* loop that gets audio from encoder and forwards it to sound card. /* loop that gets audio from encoder and forwards it to sound card.
* alternatively a sound file is written. * alternatively a sound file is written.
*/ */
static void process_signal(void) static void process_signal(int buffer_size)
{ {
sample_t buff[latspl], *samples[1] = { buff }; sample_t buff[buffer_size], *samples[1] = { buff };
uint8_t pbuff[latspl], *power[1] = { pbuff }; uint8_t pbuff[buffer_size], *power[1] = { pbuff };
int count; int count;
int __attribute__((unused)) rc; int __attribute__((unused)) rc;
while (tx_mode != TX_MODE_DONE) { while (tx_mode != TX_MODE_DONE) {
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
count = sound_get_tosend(audio, latspl); count = sound_get_tosend(audio, buffer_size);
#else #else
count = samplerate / 1000; count = dsp_samplerate / 1000;
#endif #endif
if (count < 0) { if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count); PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
@ -282,13 +281,14 @@ int main(int argc, char *argv[])
{ {
int i; int i;
int rc, argi; int rc, argi;
int buffer_size;
/* init */ /* init */
bnetz_init_telegramm(); bnetz_init_telegramm();
memset(&fsk_mod, 0, sizeof(fsk_mod)); memset(&fsk_mod, 0, sizeof(fsk_mod));
/* latency of send buffer in samples */ /* size of send buffer in samples */
latspl = samplerate * latency / 1000; buffer_size = dsp_samplerate * dsp_buffer / 1000;
/* handle options / config file */ /* handle options / config file */
add_options(); add_options();
@ -339,14 +339,14 @@ int main(int argc, char *argv[])
sprintf(funkwahl, "wwww%c%s%se%c%s%se", start_digit, station_id, dialing + 1, start_digit, station_id, dialing + 1); sprintf(funkwahl, "wwww%c%s%se%c%s%se", start_digit, station_id, dialing + 1, start_digit, station_id, dialing + 1);
/* init fsk */ /* init fsk */
if (fsk_mod_init(&fsk_mod, NULL, fsk_send_bit, samplerate, BIT_RATE, F0, F1, 1.0, 0, 0) < 0) { if (fsk_mod_init(&fsk_mod, NULL, fsk_send_bit, dsp_samplerate, BIT_RATE, F0, F1, 1.0, 0, 0) < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "FSK init failed!\n"); PDEBUG(DDSP, DEBUG_ERROR, "FSK init failed!\n");
goto exit; goto exit;
} }
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* init sound */ /* init sound */
audio = sound_open(audiodev, NULL, NULL, NULL, 1, 0.0, samplerate, latspl, 1.0, 4000.0, 2.0); audio = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 4000.0, 2.0);
if (!audio) { if (!audio) {
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n"); PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n");
goto exit; goto exit;
@ -355,7 +355,7 @@ int main(int argc, char *argv[])
/* open wave */ /* open wave */
if (write_tx_wave) { if (write_tx_wave) {
rc = wave_create_record(&wave_tx_rec, write_tx_wave, samplerate, 1, 1.0); rc = wave_create_record(&wave_tx_rec, write_tx_wave, dsp_samplerate, 1, 1.0);
if (rc < 0) { if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n"); PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
goto exit; goto exit;
@ -375,7 +375,7 @@ int main(int argc, char *argv[])
PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n"); PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n");
process_signal(); process_signal(buffer_size);
exit: exit:
/* close wave */ /* close wave */

View File

@ -160,14 +160,14 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /*deviceuse default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -193,7 +193,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = bnetz_create(kanal[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, gfs, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, paging, metering); rc = bnetz_create(kanal[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, gfs, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, paging, metering);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail; goto fail;
@ -202,7 +202,7 @@ int main(int argc, char *argv[])
printf("To call phone, switch transmitter (using paging signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0) / 1e6); printf("To call phone, switch transmitter (using paging signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0) / 1e6);
} }
main_mobile("bnetz", &quit, latency, interval, NULL, station_id, 5); main_mobile("bnetz", &quit, NULL, station_id, 5);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -264,7 +264,7 @@ int cnetz_init(void)
} }
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int cnetz_create(const char *kanal, enum cnetz_chan_type chan_type, const char *audiodev, int use_sdr, enum demod_type demod, int samplerate, double rx_gain, double tx_gain, int challenge_valid, uint64_t challenge, int response_valid, uint64_t response, int warteschlange, int metering, double speech_deviation, int ms_power, int measure_speed, double clock_speed[2], int polarity, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback) int cnetz_create(const char *kanal, enum cnetz_chan_type chan_type, const char *device, int use_sdr, enum demod_type demod, int samplerate, double rx_gain, double tx_gain, int challenge_valid, uint64_t challenge, int response_valid, uint64_t response, int warteschlange, int metering, double speech_deviation, int ms_power, int measure_speed, double clock_speed[2], int polarity, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback)
{ {
sender_t *sender; sender_t *sender;
cnetz_t *cnetz; cnetz_t *cnetz;
@ -304,7 +304,7 @@ int cnetz_create(const char *kanal, enum cnetz_chan_type chan_type, const char *
for (sender = sender_head; sender; sender = sender->next) { for (sender = sender_head; sender; sender = sender->next) {
cnetz = (cnetz_t *)sender; cnetz = (cnetz_t *)sender;
if (!!strcmp(sender->audiodev, audiodev)) { if (!!strcmp(sender->device, device)) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "To be able to sync multiple channels, all channels must be on the same sound device!\n"); PDEBUG(DCNETZ, DEBUG_NOTICE, "To be able to sync multiple channels, all channels must be on the same sound device!\n");
return -EINVAL; return -EINVAL;
} }
@ -320,7 +320,7 @@ int cnetz_create(const char *kanal, enum cnetz_chan_type chan_type, const char *
/* init general part of transceiver */ /* init general part of transceiver */
/* do not enable emphasis, since it is done by cnetz code, not by common sender code */ /* do not enable emphasis, since it is done by cnetz code, not by common sender code */
rc = sender_create(&cnetz->sender, kanal, cnetz_kanal2freq(atoi(kanal), 0), cnetz_kanal2freq(atoi(kanal), 1), audiodev, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&cnetz->sender, kanal, cnetz_kanal2freq(atoi(kanal), 0), cnetz_kanal2freq(atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n"); PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error; goto error;

View File

@ -139,7 +139,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_short_name(enum cnetz_chan_type chan_type);
const char *chan_type_long_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_init(void);
int cnetz_create(const char *kanal, enum cnetz_chan_type chan_type, const char *audiodev, int use_sdr, enum demod_type demod, int samplerate, double rx_gain, double tx_gain, int challenge_valid, uint64_t challenge, int response_valid, uint64_t response, int warteschlange, int metering, double speech_deviation, int ms_power, int measure_speed, double clock_speed[2], int polarity, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback); int cnetz_create(const char *kanal, enum cnetz_chan_type chan_type, const char *device, int use_sdr, enum demod_type demod, int samplerate, double rx_gain, double tx_gain, int challenge_valid, uint64_t challenge, int response_valid, uint64_t response, int warteschlange, int metering, double speech_deviation, int ms_power, int measure_speed, double clock_speed[2], int polarity, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback);
void cnetz_destroy(sender_t *sender); void cnetz_destroy(sender_t *sender);
void cnetz_go_idle(cnetz_t *cnetz); void cnetz_go_idle(cnetz_t *cnetz);
void cnetz_sync_frame(cnetz_t *cnetz, double sync, int ts); void cnetz_sync_frame(cnetz_t *cnetz, double sync, int ts);

View File

@ -516,10 +516,10 @@ int main(int argc, char *argv[])
mandatory = 1; mandatory = 1;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
/* set channel types for more than 1 channel */ /* set channel types for more than 1 channel */
if (num_kanal > 1 && num_chan_type == 0) { if (num_kanal > 1 && num_chan_type == 0) {
chan_type[0] = CHAN_TYPE_OGK; chan_type[0] = CHAN_TYPE_OGK;
@ -528,9 +528,9 @@ int main(int argc, char *argv[])
num_chan_type = num_kanal; num_chan_type = num_kanal;
} }
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -633,7 +633,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = cnetz_create(kanal[i], chan_type[i], audiodev[i], use_sdr, demod, samplerate, rx_gain, tx_gain, challenge_valid, challenge, response_valid, response, warteschlange, metering, speech_deviation, ms_power, (i == 0) ? measure_speed : 0, clock_speed, polarity, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback); rc = cnetz_create(kanal[i], chan_type[i], dsp_device[i], use_sdr, demod, dsp_samplerate, rx_gain, tx_gain, challenge_valid, challenge, response_valid, response, warteschlange, metering, speech_deviation, ms_power, (i == 0) ? measure_speed : 0, clock_speed, polarity, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail; goto fail;
@ -645,7 +645,7 @@ int main(int argc, char *argv[])
} }
} }
main_mobile("cnetz", &quit, latency, interval, NULL, station_id, 7); main_mobile("cnetz", &quit, NULL, station_id, 7);
fail: fail:
flush_db(); flush_db();

View File

@ -1381,7 +1381,7 @@ error:
} }
/* open audio device of one or two datenlo_t instance */ /* open audio device of one or two datenlo_t instance */
int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int latency, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave) int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int buffer, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave)
{ {
int channels = 1; int channels = 1;
int rc; int rc;
@ -1390,12 +1390,12 @@ int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int latency,
if (datenklo->slave) if (datenklo->slave)
channels = 2; channels = 2;
/* latency of send buffer in samples */ /* size of send buffer in samples */
datenklo->latspl = datenklo->samplerate * latency / 1000; datenklo->buffer_size = datenklo->samplerate * buffer / 1000;
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* init sound */ /* init sound */
datenklo->audio = sound_open(audiodev, NULL, NULL, NULL, channels, 0.0, datenklo->samplerate, datenklo->latspl, 1.0, 4000.0, 2.0); datenklo->audio = sound_open(audiodev, NULL, NULL, NULL, channels, 0.0, datenklo->samplerate, datenklo->buffer_size, 1.0, 1.0, 4000.0, 2.0);
if (!datenklo->audio) { if (!datenklo->audio) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "No sound device!\n"); PDEBUG(DDATENKLO, DEBUG_ERROR, "No sound device!\n");
return -EIO; return -EIO;
@ -1484,8 +1484,8 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
if (datenklo->slave) if (datenklo->slave)
num_chan = 2; num_chan = 2;
sample_t buff[num_chan][datenklo->latspl], *samples[num_chan]; sample_t buff[num_chan][datenklo->buffer_size], *samples[num_chan];
uint8_t pbuff[num_chan][datenklo->latspl], *power[num_chan]; uint8_t pbuff[num_chan][datenklo->buffer_size], *power[num_chan];
for (i = 0; i < num_chan; i++) { for (i = 0; i < num_chan; i++) {
samples[i] = buff[i]; samples[i] = buff[i];
power[i] = pbuff[i]; power[i] = pbuff[i];
@ -1524,7 +1524,7 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
process_timer(); process_timer();
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
count = sound_read(datenklo->audio, samples, datenklo->latspl, num_chan, rf_level_db); count = sound_read(datenklo->audio, samples, datenklo->buffer_size, num_chan, rf_level_db);
if (count < 0) { if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to read RX data from audio device (rc = %d)\n", count); PDEBUG(DDSP, DEBUG_ERROR, "Failed to read RX data from audio device (rc = %d)\n", count);
if (count == -EPIPE) { if (count == -EPIPE) {
@ -1556,7 +1556,7 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
} }
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
count = sound_get_tosend(datenklo->audio, datenklo->latspl); count = sound_get_tosend(datenklo->audio, datenklo->buffer_size);
#else #else
count = samplerate / 1000; count = samplerate / 1000;
#endif #endif
@ -1576,7 +1576,7 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
} }
if (loopback) { if (loopback) {
/* copy buffer to preserve original audio for later use */ /* copy buffer to preserve original audio for later use */
sample_t lbuff[num_chan][datenklo->latspl]; sample_t lbuff[num_chan][datenklo->buffer_size];
memcpy(lbuff, buff, sizeof(lbuff)); memcpy(lbuff, buff, sizeof(lbuff));
if (loopback == 2 && num_chan == 2) { if (loopback == 2 && num_chan == 2) {
/* swap */ /* swap */

View File

@ -19,7 +19,7 @@ typedef struct datenklo {
double force_tx_baud, force_rx_baud; /* override IOCTL */ double force_tx_baud, force_rx_baud; /* override IOCTL */
int tx_back, rx_back; /* set if back channel is used for path */ int tx_back, rx_back; /* set if back channel is used for path */
int samplerate; /* audio sample rate */ int samplerate; /* audio sample rate */
int latspl; /* latenc */ int buffer_size; /* audio buffer size */
int loopback; /* loopback mode */ int loopback; /* loopback mode */
/* states */ /* states */
@ -86,7 +86,7 @@ typedef struct datenklo {
void datenklo_main(datenklo_t *datenklo, int loopback); void datenklo_main(datenklo_t *datenklo, int loopback);
int datenklo_init(datenklo_t *datenklo, const char *dev_name, enum am791x_type am791x_type, uint8_t mc, int auto_rts, double force_tx_baud, double force_rx_baud, int samplerate, int loopback); int datenklo_init(datenklo_t *datenklo, const char *dev_name, enum am791x_type am791x_type, uint8_t mc, int auto_rts, double force_tx_baud, double force_rx_baud, int samplerate, int loopback);
int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int latency, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave); int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int buffer, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave);
void datenklo_exit(datenklo_t *datenklo); void datenklo_exit(datenklo_t *datenklo);
void datenklo_init_global(void); void datenklo_init_global(void);

View File

@ -61,8 +61,8 @@ static int tx_baudrate[MAX_DEVICES] = { 0 }, rx_baudrate[MAX_DEVICES] = { 0 };
static int num_ttydev = 0; static int num_ttydev = 0;
static const char *ttydev[MAX_DEVICES] = { "/dev/ttyDATENKLO0" }; static const char *ttydev[MAX_DEVICES] = { "/dev/ttyDATENKLO0" };
static const char *audiodev = "hw:0,0"; static const char *audiodev = "hw:0,0";
static int samplerate = 48000; static int dsp_samplerate = 48000;
static int latency = 50; static int dsp_buffer = 50;
static int stereo = 0; static int stereo = 0;
static int loopback = 0; static int loopback = 0;
static int fast_math = 0; static int fast_math = 0;
@ -102,9 +102,9 @@ void print_help(const char *arg0)
printf(" -a --audio-device hw:<card>,<device>\n"); printf(" -a --audio-device hw:<card>,<device>\n");
printf(" Sound card and device number (default = '%s')\n", audiodev); printf(" Sound card and device number (default = '%s')\n", audiodev);
printf(" -s --samplerate <rate>\n"); printf(" -s --samplerate <rate>\n");
printf(" Sample rate of sound device (default = '%d')\n", samplerate); printf(" Sample rate of sound device (default = '%d')\n", dsp_samplerate);
printf(" -b --buffer <ms>\n"); printf(" -b --buffer <ms>\n");
printf(" How many milliseconds are processed in advance (default = '%d')\n", latency); printf(" How many milliseconds are processed in advance (default = '%d')\n", dsp_buffer);
printf(" -l --loopback <type>\n"); printf(" -l --loopback <type>\n");
printf(" Perform audio loopback to test modem.\n"); printf(" Perform audio loopback to test modem.\n");
printf(" type 1: Audio from transmitter is fed into receiver (analog loopback)\n"); printf(" type 1: Audio from transmitter is fed into receiver (analog loopback)\n");
@ -208,10 +208,10 @@ static int handle_options(int short_option, int argi, char **argv)
audiodev = options_strdup(argv[argi]); audiodev = options_strdup(argv[argi]);
break; break;
case 's': case 's':
samplerate = atoi(argv[argi]); dsp_samplerate = atoi(argv[argi]);
break; break;
case 'b': case 'b':
latency = atoi(argv[argi]); dsp_buffer = atoi(argv[argi]);
break; break;
case 'l': case 'l':
loopback = atoi(argv[argi]); loopback = atoi(argv[argi]);
@ -298,7 +298,7 @@ int main(int argc, char *argv[])
/* increment last name */ /* increment last name */
if (i && ttydev[i] == NULL) if (i && ttydev[i] == NULL)
ttydev[i] = inc_dev_name(ttydev[i - 1]); ttydev[i] = inc_dev_name(ttydev[i - 1]);
rc = datenklo_init(&datenklo[i], ttydev[i], am791x_type, mc[i], auto_rts, tx_baudrate[i], rx_baudrate[i], samplerate, loopback); rc = datenklo_init(&datenklo[i], ttydev[i], am791x_type, mc[i], auto_rts, tx_baudrate[i], rx_baudrate[i], dsp_samplerate, loopback);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Datenklo\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Datenklo\" instance. Quitting!\n");
goto fail; goto fail;
@ -308,7 +308,7 @@ int main(int argc, char *argv[])
printf("Datenklo on device '/dev/%s' ready. (using sound device '%s')\n", ttydev[i], audiodev); printf("Datenklo on device '/dev/%s' ready. (using sound device '%s')\n", ttydev[i], audiodev);
} }
rc = datenklo_open_audio(&datenklo[0], audiodev, latency, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave); rc = datenklo_open_audio(&datenklo[0], audiodev, dsp_buffer, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to initialize audio. Quitting!\n"); fprintf(stderr, "Failed to initialize audio. Quitting!\n");
goto fail; goto fail;

View File

@ -237,7 +237,7 @@ void euro_exit(void)
static void call_timeout(struct timer *timer); static void call_timeout(struct timer *timer);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int euro_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int fm, int tx, int rx, int repeat, int degraded, int random, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback) int euro_create(const char *kanal, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int fm, int tx, int rx, int repeat, int degraded, int random, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback)
{ {
euro_t *euro; euro_t *euro;
int rc; int rc;
@ -261,7 +261,7 @@ int euro_create(const char *kanal, const char *audiodev, int use_sdr, int sample
PDEBUG(DEURO, DEBUG_DEBUG, "Creating 'Eurosignal' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate); PDEBUG(DEURO, DEBUG_DEBUG, "Creating 'Eurosignal' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&euro->sender, kanal, euro_kanal2freq(kanal, fm), euro_kanal2freq(kanal, fm), audiodev, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&euro->sender, kanal, euro_kanal2freq(kanal, fm), euro_kanal2freq(kanal, fm), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DEURO, DEBUG_ERROR, "Failed to init transceiver process!\n"); PDEBUG(DEURO, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error; goto error;

View File

@ -82,7 +82,7 @@ double euro_kanal2freq(const char *kanal, int fm);
void euro_list_channels(void); void euro_list_channels(void);
int euro_init(void); int euro_init(void);
void euro_exit(void); void euro_exit(void);
int euro_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int fm, int tx, int rx, int repeat, int degraded, int random, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback); int euro_create(const char *kanal, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int fm, int tx, int rx, int repeat, int degraded, int random, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback);
void euro_destroy(sender_t *sender); void euro_destroy(sender_t *sender);
void euro_get_id(euro_t *euro, char *id); void euro_get_id(euro_t *euro, char *id);
void euro_receive_id(euro_t *euro, char *id); void euro_receive_id(euro_t *euro, char *id);

View File

@ -208,21 +208,21 @@ int main(int argc, char *argv[])
goto fail; goto fail;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
/* inits */ /* inits */
fm_init(fast_math); fm_init(fast_math);
dsp_init(samplerate); dsp_init(dsp_samplerate);
euro_init(); euro_init();
/* TX is default */ /* TX is default */
@ -231,7 +231,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = euro_create(kanal[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, fm, tx, rx, repeat, degraded, random_id, scan_from, scan_to, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback); rc = euro_create(kanal[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, fm, tx, rx, repeat, degraded, random_id, scan_from, scan_to, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail; goto fail;
@ -239,7 +239,7 @@ int main(int argc, char *argv[])
printf("Base station for channel %s ready, please tune transmitter and/or receiver to %.4f MHz\n", kanal[i], euro_kanal2freq(kanal[i], fm) / 1e6); printf("Base station for channel %s ready, please tune transmitter and/or receiver to %.4f MHz\n", kanal[i], euro_kanal2freq(kanal[i], fm) / 1e6);
} }
main_mobile("eurosignal", &quit, latency, interval, NULL, station_id, 6); main_mobile("eurosignal", &quit, NULL, station_id, 6);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -195,9 +195,9 @@ int main(int argc, char *argv[])
} }
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
return -EINVAL; return -EINVAL;
} }
@ -231,7 +231,7 @@ int main(int argc, char *argv[])
fm_init(fast_math); fm_init(fast_math);
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = fuvst_create(kanal[i], chan_type[i], audiodev[i], samplerate, rx_gain, tx_gain, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, ignore_link_monitor, sio, uele_pc, fuko_pc); rc = fuvst_create(kanal[i], chan_type[i], dsp_device[i], dsp_samplerate, rx_gain, tx_gain, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, ignore_link_monitor, sio, uele_pc, fuko_pc);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Kanal\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Kanal\" instance. Quitting!\n");
goto fail; goto fail;
@ -270,7 +270,7 @@ int main(int argc, char *argv[])
if (config_loaded) if (config_loaded)
printf("BS-Config: %s\n", config_name); printf("BS-Config: %s\n", config_name);
main_mobile("fuvst", &quit, latency, interval, NULL, station_id, 7); main_mobile("fuvst", &quit, NULL, station_id, 7);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -198,17 +198,17 @@ int main(int argc, char *argv[])
goto fail; goto fail;
} }
if (num_audiodev <= 1) if (num_device <= 1)
audiodev[1] = audiodev[0]; dsp_device[1] = dsp_device[0];
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
PDEBUG(DCNETZ, DEBUG_DEBUG, "Creating 'Sniffer' instance for 'Kanal' = %s (sample rate %d).\n", kanal[i], samplerate); PDEBUG(DCNETZ, DEBUG_DEBUG, "Creating 'Sniffer' instance for 'Kanal' = %s (sample rate %d).\n", kanal[i], dsp_samplerate);
sniffer = calloc(1, sizeof(sniffer_t)); sniffer = calloc(1, sizeof(sniffer_t));
if (!sniffer) { if (!sniffer) {
PDEBUG(DCNETZ, DEBUG_ERROR, "No memory!\n"); PDEBUG(DCNETZ, DEBUG_ERROR, "No memory!\n");
goto fail; goto fail;
} }
rc = sender_create(&sniffer->sender, kanal[i], 131, 131, audiodev[i], 0, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&sniffer->sender, kanal[i], 131, 131, dsp_device[i], 0, dsp_samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Sniffer\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Sniffer\" instance. Quitting!\n");
goto fail; goto fail;
@ -220,12 +220,12 @@ int main(int argc, char *argv[])
sender_set_fm(&sniffer->sender, 1.0, 4000.0, 1.0, 1.0); sender_set_fm(&sniffer->sender, 1.0, 4000.0, 1.0, 1.0);
rc = v27_modem_init(&sniffer->modem, sniffer, send_bit, receive_bit, samplerate, 1); rc = v27_modem_init(&sniffer->modem, sniffer, send_bit, receive_bit, dsp_samplerate, 1);
if (rc < 0) if (rc < 0)
goto fail; goto fail;
} }
main_mobile(NULL, &quit, latency, interval, NULL, NULL, 0); main_mobile(NULL, &quit, NULL, NULL, 0);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -35,10 +35,10 @@
/* presets */ /* presets */
const char *station_id = "6681739"; const char *station_id = "6681739";
const char *dialing; const char *dialing;
const char *audiodev = "hw:0,0"; const char *dsp_audiodev = "hw:0,0";
int samplerate = 48000; int dsp_samplerate = 48000;
const char *write_tx_wave = NULL; const char *write_tx_wave = NULL;
int latency = 50; int dsp_buffer = 50;
#define TONE_DONE -1 #define TONE_DONE -1
#define TONE_SILENCE 0 #define TONE_SILENCE 0
@ -53,7 +53,6 @@ static struct dial_string {
int length; int length;
} dial_string[2048]; } dial_string[2048];
static int dial_pos = 0; static int dial_pos = 0;
static int latspl;
/* instances */ /* instances */
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
@ -82,10 +81,10 @@ static void print_help(const char *arg0)
printf(" 7 Digits of ID of mobile station (default = '%s')\n", station_id); printf(" 7 Digits of ID of mobile station (default = '%s')\n", station_id);
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
printf(" -a --audio-device hw:<card>,<device>\n"); printf(" -a --audio-device hw:<card>,<device>\n");
printf(" Sound card and device number (default = '%s')\n", audiodev); printf(" Sound card and device number (default = '%s')\n", dsp_audiodev);
#endif #endif
printf(" -s --samplerate <rate>\n"); printf(" -s --samplerate <rate>\n");
printf(" Sample rate of sound device (default = '%d')\n", samplerate); printf(" Sample rate of sound device (default = '%d')\n", dsp_samplerate);
printf(" -w --write-tx-wave <file>\n"); printf(" -w --write-tx-wave <file>\n");
printf(" Write audio to given wave file also.\n"); printf(" Write audio to given wave file also.\n");
} }
@ -109,10 +108,10 @@ static int handle_options(int short_option, int __attribute__((unused)) argi, ch
station_id = options_strdup(argv[argi]); station_id = options_strdup(argv[argi]);
break; break;
case 'a': case 'a':
audiodev = options_strdup(argv[argi]); dsp_audiodev = options_strdup(argv[argi]);
break; break;
case 's': case 's':
samplerate = atoi(argv[argi]); dsp_samplerate = atoi(argv[argi]);
break; break;
case 'w': case 'w':
write_tx_wave = options_strdup(argv[argi]); write_tx_wave = options_strdup(argv[argi]);
@ -148,7 +147,7 @@ again:
default: default:
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
samples[i] = cos(2.0 * M_PI * (double)dial_string[dial_pos].tone * phase); samples[i] = cos(2.0 * M_PI * (double)dial_string[dial_pos].tone * phase);
phase += 1.0 / samplerate; phase += 1.0 / dsp_samplerate;
} }
} }
@ -173,18 +172,18 @@ again:
/* loop that gets audio from encoder and forwards it to sound card. /* loop that gets audio from encoder and forwards it to sound card.
* alternatively a sound file is written. * alternatively a sound file is written.
*/ */
static void process_signal(void) static void process_signal(int buffer_size)
{ {
sample_t buff[latspl], *samples[1] = { buff }; sample_t buff[buffer_size], *samples[1] = { buff };
uint8_t pbuff[latspl], *power[1] = { pbuff }; uint8_t pbuff[buffer_size], *power[1] = { pbuff };
int count; int count;
int __attribute__((unused)) rc; int __attribute__((unused)) rc;
while (dial_string[dial_pos].tone != TONE_DONE) { while (dial_string[dial_pos].tone != TONE_DONE) {
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
count = sound_get_tosend(audio, latspl); count = sound_get_tosend(audio, buffer_size);
#else #else
count = samplerate / 1000; count = dsp_samplerate / 1000;
#endif #endif
if (count < 0) { if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count); PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
@ -215,12 +214,13 @@ static void process_signal(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int i, d, p, pulses, tone = 0; int i, d, p, pulses, tone = 0;
int buffer_size;
int rc, argi; int rc, argi;
memset(dial_string, 0, sizeof(dial_string)); memset(dial_string, 0, sizeof(dial_string));
/* latency of send buffer in samples */ /* size of send buffer in samples */
latspl = samplerate * latency / 1000; buffer_size = dsp_samplerate * dsp_buffer / 1000;
/* handle options / config file */ /* handle options / config file */
add_options(); add_options();
@ -248,7 +248,7 @@ int main(int argc, char *argv[])
dialing = argv[argi]; dialing = argv[argi];
d = 0; d = 0;
dial_string[d].tone = TONE_SILENCE; dial_string[d++].length = 0.600 * (double)samplerate; /* pause */ dial_string[d].tone = TONE_SILENCE; dial_string[d++].length = 0.600 * (double)dsp_samplerate; /* pause */
if (!!strcasecmp(dialing, "disconnect")) { if (!!strcasecmp(dialing, "disconnect")) {
/* check for valid phone number */ /* check for valid phone number */
if (strlen(dialing) > 64) { if (strlen(dialing) > 64) {
@ -262,11 +262,11 @@ int main(int argc, char *argv[])
} }
} }
dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.350 * (double)samplerate; /* off-hook */ dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.350 * (double)dsp_samplerate; /* off-hook */
dial_string[d].console = 's'; dial_string[d].console = 's';
dial_string[d].tone = TONE_CONNECT; dial_string[d++].length = 0.050 * (double)samplerate; /* seize */ dial_string[d].tone = TONE_CONNECT; dial_string[d++].length = 0.050 * (double)dsp_samplerate; /* seize */
dial_string[d].console = '-'; dial_string[d].console = '-';
dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 1.000 * (double)samplerate; /* pause */ dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 1.000 * (double)dsp_samplerate; /* pause */
for (i = 0; station_id[i]; i++) { for (i = 0; station_id[i]; i++) {
pulses = station_id[i] - '0'; pulses = station_id[i] - '0';
if (pulses == 0) if (pulses == 0)
@ -277,37 +277,37 @@ int main(int argc, char *argv[])
tone = TONE_SILENCE; tone = TONE_SILENCE;
else else
tone = TONE_GUARD; tone = TONE_GUARD;
dial_string[d].tone = TONE_CONNECT; dial_string[d++].length = 0.025 * (double)samplerate; /* mark */ dial_string[d].tone = TONE_CONNECT; dial_string[d++].length = 0.025 * (double)dsp_samplerate; /* mark */
dial_string[d].tone = tone; dial_string[d++].length = 0.025 * (double)samplerate; /* space */ dial_string[d].tone = tone; dial_string[d++].length = 0.025 * (double)dsp_samplerate; /* space */
} }
dial_string[d].tone = tone; dial_string[d++].length = 0.190 * (double)samplerate; /* after digit */ dial_string[d].tone = tone; dial_string[d++].length = 0.190 * (double)dsp_samplerate; /* after digit */
} }
dial_string[d].console = '-'; dial_string[d].console = '-';
dial_string[d].tone = TONE_SILENCE; dial_string[d++].length = 2.000 * (double)samplerate; /* pause */ dial_string[d].tone = TONE_SILENCE; dial_string[d++].length = 2.000 * (double)dsp_samplerate; /* pause */
for (i = 0; dialing[i]; i++) { for (i = 0; dialing[i]; i++) {
pulses = dialing[i] - '0'; pulses = dialing[i] - '0';
if (pulses == 0) if (pulses == 0)
pulses = 10; pulses = 10;
dial_string[d].console = dialing[i]; dial_string[d].console = dialing[i];
for (p = 1; p <= pulses; p++) { for (p = 1; p <= pulses; p++) {
dial_string[d].tone = TONE_CONNECT; dial_string[d++].length = 0.060 * (double)samplerate; /* mark */ dial_string[d].tone = TONE_CONNECT; dial_string[d++].length = 0.060 * (double)dsp_samplerate; /* mark */
dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.040 * (double)samplerate; /* space */ dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.040 * (double)dsp_samplerate; /* space */
} }
dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.400 * (double)samplerate; /* after digit */ dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.400 * (double)dsp_samplerate; /* after digit */
} }
dial_string[d].console = '\n'; dial_string[d].console = '\n';
} else { } else {
for (i = 0; i < 750; i += 50) { for (i = 0; i < 750; i += 50) {
dial_string[d].tone = TONE_DISCONNECT; dial_string[d++].length = 0.025 * (double)samplerate; /* mark */ dial_string[d].tone = TONE_DISCONNECT; dial_string[d++].length = 0.025 * (double)dsp_samplerate; /* mark */
dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.025 * (double)samplerate; /* space */ dial_string[d].tone = TONE_GUARD; dial_string[d++].length = 0.025 * (double)dsp_samplerate; /* space */
} }
} }
dial_string[d].tone = TONE_SILENCE; dial_string[d++].length = 0.600 * (double)samplerate; /* pause */ dial_string[d].tone = TONE_SILENCE; dial_string[d++].length = 0.600 * (double)dsp_samplerate; /* pause */
dial_string[d].tone = TONE_DONE; dial_string[d++].length = 0; /* end */ dial_string[d].tone = TONE_DONE; dial_string[d++].length = 0; /* end */
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* init sound */ /* init sound */
audio = sound_open(audiodev, NULL, NULL, NULL, 1, 0.0, samplerate, latspl, 1.0, 4000.0, 2.0); audio = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, dsp_buffer, 1.0, 1.0, 4000.0, 2.0);
if (!audio) { if (!audio) {
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n"); PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n");
goto exit; goto exit;
@ -316,7 +316,7 @@ int main(int argc, char *argv[])
/* open wave */ /* open wave */
if (write_tx_wave) { if (write_tx_wave) {
rc = wave_create_record(&wave_tx_rec, write_tx_wave, samplerate, 1, 1.0); rc = wave_create_record(&wave_tx_rec, write_tx_wave, dsp_samplerate, 1, 1.0);
if (rc < 0) { if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n"); PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
goto exit; goto exit;
@ -336,7 +336,7 @@ int main(int argc, char *argv[])
PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n"); PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n");
process_signal(); process_signal(buffer_size);
exit: exit:
/* close wave */ /* close wave */

View File

@ -274,7 +274,7 @@ static void imts_paging(imts_t *imts, const char *dial_string, int loopback);
static void imts_detector_test(imts_t *imts, double length_1, double length_2, double length_3); static void imts_detector_test(imts_t *imts, double length_1, double length_2, double length_3);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int imts_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int ptt, int station_length, double fast_seize, enum mode mode, const char *operator, double length_1, double length_2, double length_3) int imts_create(const char *kanal, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int ptt, int station_length, double fast_seize, enum mode mode, const char *operator, double length_1, double length_2, double length_3)
{ {
imts_t *imts; imts_t *imts;
int rc; int rc;
@ -317,7 +317,7 @@ int imts_create(const char *kanal, const char *audiodev, int use_sdr, int sample
/* init general part of transceiver */ /* init general part of transceiver */
/* do not enable emphasis, since it is done by imts code, not by common sender code */ /* do not enable emphasis, since it is done by imts code, not by common sender code */
rc = sender_create(&imts->sender, kanal, imts_channel2freq(kanal, 0), imts_channel2freq(kanal, 1), audiodev, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&imts->sender, kanal, imts_channel2freq(kanal, 0), imts_channel2freq(kanal, 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DIMTS, DEBUG_ERROR, "Failed to init 'Sender' processing!\n"); PDEBUG(DIMTS, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
goto error; goto error;

View File

@ -129,7 +129,7 @@ typedef struct imts {
void imts_list_channels(void); void imts_list_channels(void);
double imts_channel2freq(const char *kanal, int uplink); double imts_channel2freq(const char *kanal, int uplink);
int imts_init(void); int imts_init(void);
int imts_create(const char *channel, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int ptt, int station_length, double fast_seize, enum mode mode, const char *operator, double length_1, double length_2, double length_3); int imts_create(const char *channel, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int ptt, int station_length, double fast_seize, enum mode mode, const char *operator, double length_1, double length_2, double length_3);
void imts_destroy(sender_t *sender); void imts_destroy(sender_t *sender);
void imts_loss_indication(imts_t *imts, double loss_time); void imts_loss_indication(imts_t *imts, double loss_time);
void imts_signal_indication(imts_t *imts); void imts_signal_indication(imts_t *imts);

View File

@ -50,7 +50,7 @@ static double detector_test_length_3 = 0.0;
void print_help(const char *arg0) void print_help(const char *arg0)
{ {
main_mobile_print_help(arg0, "-b 5 "); main_mobile_print_help(arg0, "-b 5 -i 0.1 ");
/* - - */ /* - - */
printf(" -S --squelch <dB> | auto\n"); printf(" -S --squelch <dB> | auto\n");
printf(" Use given RF level to detect loss of signal. When the signal gets lost\n"); printf(" Use given RF level to detect loss of signal. When the signal gets lost\n");
@ -199,14 +199,14 @@ int main(int argc, char *argv[])
goto fail; goto fail;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -226,10 +226,10 @@ int main(int argc, char *argv[])
fprintf(stderr, "*******************************************************************************\n"); fprintf(stderr, "*******************************************************************************\n");
} }
if (mode == MODE_IMTS && !fast_seize && latency > 5 && loopback == 0) { if (mode == MODE_IMTS && !fast_seize && dsp_buffer > 5 && loopback == 0) {
fprintf(stderr, "*******************************************************************************\n"); fprintf(stderr, "*******************************************************************************\n");
fprintf(stderr, "It is required to have a low latency in order to respond to phone's seizure\n"); fprintf(stderr, "It is required to have a low latency in order to respond to phone's seizure\n");
fprintf(stderr, "fast enough! Please reduce buffer size to 5 ms via option: '-b 5'\n"); fprintf(stderr, "fast enough! Please reduce buffer size to 5 ms via option: '-b 5 -i 0.1'\n");
fprintf(stderr, "If this causes buffer underruns, use the 'Fast Seize' mode, see help.\n"); fprintf(stderr, "If this causes buffer underruns, use the 'Fast Seize' mode, see help.\n");
fprintf(stderr, "*******************************************************************************\n"); fprintf(stderr, "*******************************************************************************\n");
exit(0); exit(0);
@ -266,7 +266,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = imts_create(kanal[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, ptt, station_length, fast_seize, mode, operator, detector_test_length_1, detector_test_length_2, detector_test_length_3); rc = imts_create(kanal[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, ptt, station_length, fast_seize, mode, operator, detector_test_length_1, detector_test_length_2, detector_test_length_3);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n"); fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail; goto fail;
@ -274,7 +274,7 @@ int main(int argc, char *argv[])
printf("Base station on channel %s ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz. (%.3f MHz offset)\n", kanal[i], imts_channel2freq(kanal[i], 0) / 1e6, imts_channel2freq(kanal[i], 1) / 1e6, imts_channel2freq(kanal[i], 2) / 1e6); printf("Base station on channel %s ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz. (%.3f MHz offset)\n", kanal[i], imts_channel2freq(kanal[i], 0) / 1e6, imts_channel2freq(kanal[i], 1) / 1e6, imts_channel2freq(kanal[i], 2) / 1e6);
} }
main_mobile((mode == MODE_IMTS) ? "imts" : "mts", &quit, latency, interval, NULL, station_id, station_length); main_mobile((mode == MODE_IMTS) ? "imts" : "mts", &quit, NULL, station_id, station_length);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -209,7 +209,7 @@ static void jolly_speech_timeout(struct timer *timer);
static void jolly_go_idle(jolly_t *jolly); static void jolly_go_idle(jolly_t *jolly);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int jolly_create(const char *kanal, double dl_freq, double ul_freq, double step, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int nbfm, int repeater) int jolly_create(const char *kanal, double dl_freq, double ul_freq, double step, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int nbfm, int repeater)
{ {
jolly_t *jolly; jolly_t *jolly;
int rc; int rc;
@ -226,7 +226,7 @@ int jolly_create(const char *kanal, double dl_freq, double ul_freq, double step,
ul_freq = ul_freq * 1e6 + step * 1e3 * (double)atoi(kanal); ul_freq = ul_freq * 1e6 + step * 1e3 * (double)atoi(kanal);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&jolly->sender, kanal, dl_freq, ul_freq, audiodev, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&jolly->sender, kanal, dl_freq, ul_freq, device, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DJOLLY, DEBUG_ERROR, "Failed to init 'Sender' processing!\n"); PDEBUG(DJOLLY, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
goto error; goto error;

View File

@ -50,7 +50,7 @@ typedef struct jolly {
int delay_max; /* number of samples in delay buffer */ int delay_max; /* number of samples in delay buffer */
} jolly_t; } jolly_t;
int jolly_create(const char *kanal, double dl_freq, double ul_freq, double step, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int nbfm, int repeater); int jolly_create(const char *kanal, double dl_freq, double ul_freq, double step, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, int nbfm, int repeater);
void jolly_destroy(sender_t *sender); void jolly_destroy(sender_t *sender);
void speech_finished(jolly_t *jolly); void speech_finished(jolly_t *jolly);
void jolly_receive_dtmf(void *priv, char digit, dtmf_meas_t *meas); void jolly_receive_dtmf(void *priv, char digit, dtmf_meas_t *meas);

View File

@ -154,14 +154,14 @@ int main(int argc, char *argv[])
mandatory = 1; mandatory = 1;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -185,12 +185,12 @@ int main(int argc, char *argv[])
/* inits */ /* inits */
fm_init(fast_math); fm_init(fast_math);
init_voice(samplerate); init_voice(dsp_samplerate);
dsp_init(); dsp_init();
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = jolly_create(kanal[i], dl_freq, ul_freq, step, audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, nbfm, repeater); rc = jolly_create(kanal[i], dl_freq, ul_freq, step, dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db, nbfm, repeater);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create transceiver instance. Quitting!\n"); fprintf(stderr, "Failed to create transceiver instance. Quitting!\n");
goto fail; goto fail;
@ -198,7 +198,7 @@ int main(int argc, char *argv[])
printf("base station on channel %s ready, please tune transmitter to %.4f MHz and receiver to %.4f MHz. (%.4f MHz offset)\n", kanal[i], dl_freq + step / 1e3 * (double)atoi(kanal[i]), ul_freq + step / 1e3 * (double)atoi(kanal[i]), ul_freq - dl_freq); printf("base station on channel %s ready, please tune transmitter to %.4f MHz and receiver to %.4f MHz. (%.4f MHz offset)\n", kanal[i], dl_freq + step / 1e3 * (double)atoi(kanal[i]), ul_freq + step / 1e3 * (double)atoi(kanal[i]), ul_freq - dl_freq);
} }
main_mobile("jollycom", &quit, latency, interval, NULL, station_id, 4); main_mobile("jollycom", &quit, NULL, station_id, 4);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -71,7 +71,7 @@ typedef struct console {
char audiodev[64]; /* headphone interface, if used */ char audiodev[64]; /* headphone interface, if used */
int samplerate; /* sample rate of headphone interface */ int samplerate; /* sample rate of headphone interface */
void *sound; /* headphone interface */ void *sound; /* headphone interface */
int latspl; /* sample latency at headphone interface */ int buffer_size; /* sample buffer size at headphone interface */
samplerate_t srstate; /* patterns/announcement upsampling */ samplerate_t srstate; /* patterns/announcement upsampling */
jitter_t dejitter; /* headphone audio dejittering */ jitter_t dejitter; /* headphone audio dejittering */
int test_audio_pos; /* position for test tone toward mobile */ int test_audio_pos; /* position for test tone toward mobile */
@ -358,7 +358,7 @@ static void _print_console_text(void)
printf("\033[0;39m"); printf("\033[0;39m");
} }
int console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int num_digits, int loopback, int echo_test, const char *digits) int console_init(const char *station_id, const char *audiodev, int samplerate, int buffer, int num_digits, int loopback, int echo_test, const char *digits)
{ {
int rc = 0; int rc = 0;
@ -372,7 +372,7 @@ int console_init(const char *station_id, const char *audiodev, int samplerate, i
strncpy(console.station_id, station_id, sizeof(console.station_id) - 1); strncpy(console.station_id, station_id, sizeof(console.station_id) - 1);
strncpy(console.audiodev, audiodev, sizeof(console.audiodev) - 1); strncpy(console.audiodev, audiodev, sizeof(console.audiodev) - 1);
console.samplerate = samplerate; console.samplerate = samplerate;
console.latspl = latency * samplerate / 1000; console.buffer_size = buffer * samplerate / 1000;
console.num_digits = num_digits; console.num_digits = num_digits;
console.loopback = loopback; console.loopback = loopback;
console.echo_test = echo_test; console.echo_test = echo_test;
@ -400,7 +400,7 @@ error:
return rc; return rc;
} }
int console_open_audio(int __attribute__((unused)) latspl) int console_open_audio(int __attribute__((unused)) buffer_size, double __attribute__((unused)) interval)
{ {
if (!console.audiodev[0]) if (!console.audiodev[0])
return 0; return 0;
@ -408,7 +408,7 @@ int console_open_audio(int __attribute__((unused)) latspl)
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* open sound device for call control */ /* open sound device for call control */
/* use factor 1.4 of speech level for complete range of sound card */ /* use factor 1.4 of speech level for complete range of sound card */
console.sound = sound_open(console.audiodev, NULL, NULL, NULL, 1, 0.0, console.samplerate, latspl, 1.4, 4000.0, 2.0); console.sound = sound_open(console.audiodev, NULL, NULL, NULL, 1, 0.0, console.samplerate, buffer_size, interval, 1.4, 4000.0, 2.0);
if (!console.sound) { if (!console.sound) {
PDEBUG(DSENDER, DEBUG_ERROR, "No sound device!\n"); PDEBUG(DSENDER, DEBUG_ERROR, "No sound device!\n");
return -EIO; return -EIO;
@ -547,12 +547,12 @@ void process_console(int c)
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* handle audio, if sound device is used */ /* handle audio, if sound device is used */
sample_t samples[console.latspl + 10], *samples_list[1]; sample_t samples[console.buffer_size + 10], *samples_list[1];
uint8_t *power_list[1]; uint8_t *power_list[1];
int count; int count;
int rc; int rc;
count = sound_get_tosend(console.sound, console.latspl); count = sound_get_tosend(console.sound, console.buffer_size);
if (count < 0) { if (count < 0) {
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to get samples in buffer (rc = %d)!\n", count); PDEBUG(DSENDER, DEBUG_ERROR, "Failed to get samples in buffer (rc = %d)!\n", count);
if (count == -EPIPE) if (count == -EPIPE)
@ -572,7 +572,7 @@ void process_console(int c)
} }
} }
samples_list[0] = samples; samples_list[0] = samples;
count = sound_read(console.sound, samples_list, console.latspl, 1, NULL); count = sound_read(console.sound, samples_list, console.buffer_size, 1, NULL);
if (count < 0) { if (count < 0) {
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to read from sound device (rc = %d)!\n", count); PDEBUG(DSENDER, DEBUG_ERROR, "Failed to read from sound device (rc = %d)!\n", count);
if (count == -EPIPE) if (count == -EPIPE)

View File

@ -1,8 +1,8 @@
void console_msg(osmo_cc_call_t *call, osmo_cc_msg_t *msg); void console_msg(osmo_cc_call_t *call, osmo_cc_msg_t *msg);
int console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int dial_digits, int loopback, int echo_test, const char *digits); int console_init(const char *station_id, const char *audiodev, int samplerate, int buffer, int dial_digits, int loopback, int echo_test, const char *digits);
void console_cleanup(void); void console_cleanup(void);
int console_open_audio(int latspl); int console_open_audio(int buffer_size, double interval);
int console_start_audio(void); int console_start_audio(void);
void console_process(int c); void console_process(int c);
void process_console(int c); void process_console(int c);

View File

@ -50,15 +50,16 @@ static int got_init = 0;
/* common mobile settings */ /* common mobile settings */
int num_kanal = 0; int num_kanal = 0;
const char *kanal[MAX_SENDER]; const char *kanal[MAX_SENDER];
int num_audiodev = 0; int num_device = 0;
const char *audiodev[MAX_SENDER] = { "hw:0,0" }; const char *dsp_device[MAX_SENDER] = { "hw:0,0" };
int allow_sdr = 1; int allow_sdr = 1;
int use_sdr = 0; int use_sdr = 0;
static const char *call_audiodev = ""; int dsp_samplerate = 48000;
int samplerate = 48000; double dsp_interval = 1.0;
int dsp_buffer = 50;
static const char *call_device = "";
static int call_samplerate = 48000; static int call_samplerate = 48000;
int interval = 1; static int call_buffer = 50;
int latency = 50;
int uses_emphasis = 1; int uses_emphasis = 1;
int do_pre_emphasis = 0; int do_pre_emphasis = 0;
int do_de_emphasis = 0; int do_de_emphasis = 0;
@ -106,16 +107,17 @@ void main_mobile_print_help(const char *arg0, const char *ext_usage)
printf(" -k --channel <channel>\n"); printf(" -k --channel <channel>\n");
printf(" Channel (German = Kanal) number of \"Sender\" (German = Transceiver)\n"); printf(" Channel (German = Kanal) number of \"Sender\" (German = Transceiver)\n");
printf(" -a --audio-device hw:<card>,<device>\n"); printf(" -a --audio-device hw:<card>,<device>\n");
printf(" Sound card and device number (default = '%s')\n", audiodev[0]); printf(" Sound card and device number (default = '%s')\n", dsp_device[0]);
printf(" Don't set it for SDR!\n"); printf(" Don't set it for SDR!\n");
printf(" -s --samplerate <rate>\n"); printf(" -s --samplerate <rate>\n");
printf(" Sample rate of sound device (default = '%d')\n", samplerate); printf(" Sample rate of sound device (default = '%d')\n", dsp_samplerate);
printf(" -i --interval 1..25\n"); printf(" -i --interval 0.1..25\n");
printf(" Interval of processing loop in ms (default = '%d' ms)\n", interval); printf(" Interval of processing loop in ms (default = '%.1f' ms)\n", dsp_interval);
printf(" Use 25 to drastically reduce CPU usage. In case of buffer underrun,\n"); printf(" Use 10 to drastically reduce CPU usage. In case of buffer underrun,\n");
printf(" increase latency accordingly.\n"); printf(" increase buffer accordingly.\n");
printf(" -b --buffer <ms>\n"); printf(" -b --buffer <ms>\n");
printf(" How many milliseconds are processed in advance (default = '%d')\n", latency); printf(" How many milliseconds are processed in advance (default = '%d')\n", dsp_buffer);
printf(" A buffer below 10 ms requires low interval like 0.1 ms.\n");
if (uses_emphasis) { if (uses_emphasis) {
printf(" -p --pre-emphasis\n"); printf(" -p --pre-emphasis\n");
printf(" Enable pre-emphasis, if you directly connect to the oscillator of the\n"); printf(" Enable pre-emphasis, if you directly connect to the oscillator of the\n");
@ -134,9 +136,11 @@ void main_mobile_print_help(const char *arg0, const char *ext_usage)
printf(" Use echo test, to send back audio from mobile phone's microphone to\n"); printf(" Use echo test, to send back audio from mobile phone's microphone to\n");
printf(" the speaker. (German: 'Blasprobe').\n"); printf(" the speaker. (German: 'Blasprobe').\n");
printf(" -c --call-device hw:<card>,<device>\n"); printf(" -c --call-device hw:<card>,<device>\n");
printf(" Sound card and device number for headset (default = '%s')\n", call_audiodev); printf(" Sound card and device number for headset (default = '%s')\n", call_device);
printf(" --call-samplerate <rate>\n"); printf(" --call-samplerate <rate>\n");
printf(" Sample rate of sound device for headset (default = '%d')\n", call_samplerate); printf(" Sample rate of sound device for headset (default = '%d')\n", call_samplerate);
printf(" --call-buffer <ms>\n");
printf(" How many milliseconds are processed in advance (default = '%d')\n", call_buffer);
printf(" -x --osmocc-cross\n"); printf(" -x --osmocc-cross\n");
printf(" Enable built-in call forwarding between mobiles. Be sure to have\n"); printf(" Enable built-in call forwarding between mobiles. Be sure to have\n");
printf(" at least one control channel and two voice channels. Alternatively\n"); printf(" at least one control channel and two voice channels. Alternatively\n");
@ -198,7 +202,8 @@ void main_mobile_print_hotkeys(void)
#define OPT_READ_RX_WAVE 1006 #define OPT_READ_RX_WAVE 1006
#define OPT_READ_TX_WAVE 1007 #define OPT_READ_TX_WAVE 1007
#define OPT_CALL_SAMPLERATE 1008 #define OPT_CALL_SAMPLERATE 1008
#define OPT_FAST_MATH 1009 #define OPT_CALL_BUFFER 1009
#define OPT_FAST_MATH 1010
#define OPT_LIMESDR 1100 #define OPT_LIMESDR 1100
#define OPT_LIMESDR_MINI 1101 #define OPT_LIMESDR_MINI 1101
@ -222,6 +227,7 @@ void main_mobile_add_options(void)
option_add(OPT_OSMO_CC, "cc", 1); option_add(OPT_OSMO_CC, "cc", 1);
option_add('c', "call-device", 1); option_add('c', "call-device", 1);
option_add(OPT_CALL_SAMPLERATE, "call-samplerate", 1); option_add(OPT_CALL_SAMPLERATE, "call-samplerate", 1);
option_add(OPT_CALL_BUFFER, "call-buffer", 1);
option_add('t', "tones", 1); option_add('t', "tones", 1);
option_add('l', "loopback", 1); option_add('l', "loopback", 1);
option_add('r', "realtime", 1); option_add('r', "realtime", 1);
@ -264,20 +270,20 @@ int main_mobile_handle_options(int short_option, int argi, char **argv)
OPT_ARRAY(num_kanal, kanal, argv[argi]) OPT_ARRAY(num_kanal, kanal, argv[argi])
break; break;
case 'a': case 'a':
OPT_ARRAY(num_audiodev, audiodev, options_strdup(argv[argi])) OPT_ARRAY(num_device, dsp_device, options_strdup(argv[argi]))
break; break;
case 's': case 's':
samplerate = atoi(argv[argi]); dsp_samplerate = atoi(argv[argi]);
break; break;
case 'i': case 'i':
interval = atoi(argv[argi]); dsp_interval = atof(argv[argi]);
if (interval < 1) if (dsp_interval < 0.1)
interval = 1; dsp_interval = 0.1;
if (interval > 25) if (dsp_interval > 10)
interval = 25; dsp_interval = 10;
break; break;
case 'b': case 'b':
latency = atoi(argv[argi]); dsp_buffer = atoi(argv[argi]);
break; break;
case 'p': case 'p':
if (!uses_emphasis) { if (!uses_emphasis) {
@ -321,11 +327,14 @@ int main_mobile_handle_options(int short_option, int argi, char **argv)
cc_argv[cc_argc++] = options_strdup(argv[argi]); cc_argv[cc_argc++] = options_strdup(argv[argi]);
break; break;
case 'c': case 'c':
call_audiodev = options_strdup(argv[argi]); call_device = options_strdup(argv[argi]);
break; break;
case OPT_CALL_SAMPLERATE: case OPT_CALL_SAMPLERATE:
call_samplerate = atoi(argv[argi]); call_samplerate = atoi(argv[argi]);
break; break;
case OPT_CALL_BUFFER:
call_buffer = atoi(argv[argi]);
break;
case 't': case 't':
send_patterns = atoi(argv[argi]); send_patterns = atoi(argv[argi]);
break; break;
@ -431,9 +440,9 @@ static int get_char()
} }
/* Loop through all transceiver instances of one network. */ /* Loop through all transceiver instances of one network. */
void main_mobile(const char *name, int *quit, int latency, int interval, void (*myhandler)(void), const char *station_id, int station_id_digits) void main_mobile(const char *name, int *quit, void (*myhandler)(void), const char *station_id, int station_id_digits)
{ {
int latspl; int buffer_size;
sender_t *sender; sender_t *sender;
double last_time_call = 0, begin_time, now, sleep; double last_time_call = 0, begin_time, now, sleep;
struct termios term, term_orig; struct termios term, term_orig;
@ -445,8 +454,8 @@ void main_mobile(const char *name, int *quit, int latency, int interval, void (*
abort(); abort();
} }
/* latency of send buffer in samples */ /* size of dsp buffer in samples */
latspl = samplerate * latency / 1000; buffer_size = dsp_samplerate * dsp_buffer / 1000;
/* check OSMO-CC support */ /* check OSMO-CC support */
if (use_osmocc_cross && num_kanal == 1) { if (use_osmocc_cross && num_kanal == 1) {
@ -457,15 +466,15 @@ void main_mobile(const char *name, int *quit, int latency, int interval, void (*
fprintf(stderr, "You selected OSMO-CC socket interface and built-in call forwarding, but only one can be selected.\n"); fprintf(stderr, "You selected OSMO-CC socket interface and built-in call forwarding, but only one can be selected.\n");
return; return;
} }
if (echo_test && call_audiodev[0]) { if (echo_test && call_device[0]) {
fprintf(stderr, "You selected call device (headset) and echo test, but only one can be selected.\n"); fprintf(stderr, "You selected call device (headset) and echo test, but only one can be selected.\n");
return; return;
} }
if (use_osmocc_sock && call_audiodev[0]) { if (use_osmocc_sock && call_device[0]) {
fprintf(stderr, "You selected OSMO-CC socket interface, but it cannot be used with call device (headset).\n"); fprintf(stderr, "You selected OSMO-CC socket interface, but it cannot be used with call device (headset).\n");
return; return;
} }
if (use_osmocc_cross && call_audiodev[0]) { if (use_osmocc_cross && call_device[0]) {
fprintf(stderr, "You selected built-in call forwarding, but it cannot be used with call device (headset).\n"); fprintf(stderr, "You selected built-in call forwarding, but it cannot be used with call device (headset).\n");
return; return;
} }
@ -488,7 +497,7 @@ void main_mobile(const char *name, int *quit, int latency, int interval, void (*
/* init OSMO-CC */ /* init OSMO-CC */
if (!use_osmocc_sock) if (!use_osmocc_sock)
console_init(station_id, call_audiodev, call_samplerate, latency, station_id_digits, loopback, echo_test, console_digits); console_init(station_id, call_device, call_samplerate, call_buffer, station_id_digits, loopback, echo_test, console_digits);
/* init call control instance */ /* init call control instance */
rc = call_init(name, (use_osmocc_sock) ? send_patterns : 0, release_on_disconnect, use_osmocc_sock, cc_argc, cc_argv); rc = call_init(name, (use_osmocc_sock) ? send_patterns : 0, release_on_disconnect, use_osmocc_sock, cc_argc, cc_argv);
@ -498,15 +507,15 @@ void main_mobile(const char *name, int *quit, int latency, int interval, void (*
} }
#ifdef HAVE_SDR #ifdef HAVE_SDR
rc = sdr_configure(samplerate); rc = sdr_configure(dsp_samplerate);
if (rc < 0) if (rc < 0)
return; return;
#endif #endif
/* open audio */ /* open audio */
if (sender_open_audio(latspl)) if (sender_open_audio(buffer_size, dsp_interval))
return; return;
if (console_open_audio(latspl)) if (console_open_audio(buffer_size, dsp_interval))
return; return;
if (!loopback) if (!loopback)
@ -552,7 +561,7 @@ void main_mobile(const char *name, int *quit, int latency, int interval, void (*
/* do not process audio for an audio slave, since it is done by audio master */ /* do not process audio for an audio slave, since it is done by audio master */
if (sender->master) /* if master is set, we are an audio slave */ if (sender->master) /* if master is set, we are an audio slave */
continue; continue;
process_sender_audio(sender, quit, latspl); process_sender_audio(sender, quit, buffer_size);
} }
/* process timers */ /* process timers */
@ -646,12 +655,12 @@ next_char:
if (myhandler) if (myhandler)
myhandler(); myhandler();
display_measurements((double)interval / 1000.0); display_measurements(dsp_interval / 1000.0);
now = get_time(); now = get_time();
/* sleep interval */ /* sleep interval */
sleep = ((double)interval / 1000.0) - (now - begin_time); sleep = (dsp_interval / 1000.0) - (now - begin_time);
if (sleep > 0) if (sleep > 0)
usleep(sleep * 1000000.0); usleep(sleep * 1000000.0);

View File

@ -2,13 +2,13 @@
extern int num_kanal; extern int num_kanal;
extern const char *kanal[]; extern const char *kanal[];
extern int swap_links; extern int swap_links;
extern int num_audiodev; extern int num_device;
extern const char *audiodev[];
extern int allow_sdr; extern int allow_sdr;
extern int use_sdr; extern int use_sdr;
extern int samplerate; extern const char *dsp_device[];
extern int interval; extern int dsp_samplerate;
extern int latency; extern double dsp_interval;
extern int dsp_buffer;
extern int uses_emphasis; extern int uses_emphasis;
extern int do_pre_emphasis; extern int do_pre_emphasis;
extern int do_de_emphasis; extern int do_de_emphasis;
@ -42,7 +42,7 @@ int main_mobile_handle_options(int short_option, int argi, char **argv);
extern int quit; extern int quit;
void sighandler(int sigset); void sighandler(int sigset);
void main_mobile(const char *name, int *quit, int latency, int interval, void (*myhandler)(void), const char *station_id, int station_id_digits); void main_mobile(const char *name, int *quit, void (*myhandler)(void), const char *station_id, int station_id_digits);
void dump_info(void); void dump_info(void);

View File

@ -38,7 +38,7 @@ int cant_recover = 0;
int check_channel = 1; int check_channel = 1;
/* Init transceiver instance and link to list of transceivers. */ /* Init transceiver instance and link to list of transceivers. */
int sender_create(sender_t *sender, const char *kanal, double sendefrequenz, double empfangsfrequenz, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, enum paging_signal paging_signal) int sender_create(sender_t *sender, const char *kanal, double sendefrequenz, double empfangsfrequenz, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, enum paging_signal paging_signal)
{ {
sender_t *master, *slave; sender_t *master, *slave;
int rc = 0; int rc = 0;
@ -46,7 +46,7 @@ int sender_create(sender_t *sender, const char *kanal, double sendefrequenz, dou
sender->kanal = kanal; sender->kanal = kanal;
sender->sendefrequenz = sendefrequenz; sender->sendefrequenz = sendefrequenz;
sender->empfangsfrequenz = (loopback) ? sendefrequenz : empfangsfrequenz; sender->empfangsfrequenz = (loopback) ? sendefrequenz : empfangsfrequenz;
strncpy(sender->audiodev, audiodev, sizeof(sender->audiodev) - 1); strncpy(sender->device, device, sizeof(sender->device) - 1);
sender->samplerate = samplerate; sender->samplerate = samplerate;
sender->rx_gain = rx_gain; sender->rx_gain = rx_gain;
sender->tx_gain = tx_gain; sender->tx_gain = tx_gain;
@ -90,7 +90,7 @@ int sender_create(sender_t *sender, const char *kanal, double sendefrequenz, dou
PDEBUG(DSENDER, DEBUG_NOTICE, "Please use at least one channel distance to avoid that.\n"); PDEBUG(DSENDER, DEBUG_NOTICE, "Please use at least one channel distance to avoid that.\n");
PDEBUG(DSENDER, DEBUG_NOTICE, "------------------------------------------------------------------------\n"); PDEBUG(DSENDER, DEBUG_NOTICE, "------------------------------------------------------------------------\n");
} }
if (!strcmp(master->audiodev, audiodev)) if (!strcmp(master->device, device))
break; break;
} }
if (master) { if (master) {
@ -169,7 +169,7 @@ error:
return rc; return rc;
} }
int sender_open_audio(int latspl) int sender_open_audio(int buffer_size, double interval)
{ {
sender_t *master, *inst; sender_t *master, *inst;
int channels; int channels;
@ -226,7 +226,7 @@ int sender_open_audio(int latspl)
} }
/* open device */ /* open device */
master->audio = master->audio_open(master->audiodev, tx_f, rx_f, am, channels, paging_frequency, master->samplerate, latspl, (master->max_deviation) ?: 1.0, master->max_modulation, master->modulation_index); master->audio = master->audio_open(master->device, tx_f, rx_f, am, channels, paging_frequency, master->samplerate, buffer_size, interval, (master->max_deviation) ?: 1.0, master->max_modulation, master->modulation_index);
if (!master->audio) { if (!master->audio) {
PDEBUG(DSENDER, DEBUG_ERROR, "No device for transceiver!\n"); PDEBUG(DSENDER, DEBUG_ERROR, "No device for transceiver!\n");
return -EIO; return -EIO;
@ -321,7 +321,7 @@ static void gain_samples(sample_t *samples, int length, double gain)
} }
/* Handle audio streaming of one transceiver. */ /* Handle audio streaming of one transceiver. */
void process_sender_audio(sender_t *sender, int *quit, int latspl) void process_sender_audio(sender_t *sender, int *quit, int buffer_size)
{ {
sender_t *inst; sender_t *inst;
int rc, count; int rc, count;
@ -332,8 +332,8 @@ void process_sender_audio(sender_t *sender, int *quit, int latspl)
/* count instances for audio channel */ /* count instances for audio channel */
for (num_chan = 0, inst = sender; inst; num_chan++, inst = inst->slave); for (num_chan = 0, inst = sender; inst; num_chan++, inst = inst->slave);
sample_t buff[num_chan][latspl], *samples[num_chan]; sample_t buff[num_chan][buffer_size], *samples[num_chan];
uint8_t pbuff[num_chan][latspl], *power[num_chan]; uint8_t pbuff[num_chan][buffer_size], *power[num_chan];
enum paging_signal paging_signal[num_chan]; enum paging_signal paging_signal[num_chan];
int on[num_chan]; int on[num_chan];
double rf_level_db[num_chan]; double rf_level_db[num_chan];
@ -345,7 +345,7 @@ void process_sender_audio(sender_t *sender, int *quit, int latspl)
#ifdef DEBUG_TIME_CONSUMPTION #ifdef DEBUG_TIME_CONSUMPTION
t1 = get_time(); t1 = get_time();
#endif #endif
count = sender->audio_get_tosend(sender->audio, latspl); count = sender->audio_get_tosend(sender->audio, buffer_size);
if (count < 0) { if (count < 0) {
PDEBUG_CHAN(DSENDER, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count); PDEBUG_CHAN(DSENDER, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
if (count == -EPIPE) { if (count == -EPIPE) {
@ -364,8 +364,8 @@ cant_recover:
#endif #endif
if (count > 0) { if (count > 0) {
/* limit to our buffer */ /* limit to our buffer */
if (count > latspl) if (count > buffer_size)
count = latspl; count = buffer_size;
/* loop through all channels */ /* loop through all channels */
for (i = 0, inst = sender; inst; i++, inst = inst->slave) { for (i = 0, inst = sender; inst; i++, inst = inst->slave) {
/* load TX data from audio loop or from sender instance */ /* load TX data from audio loop or from sender instance */
@ -414,7 +414,7 @@ cant_recover:
t3 = get_time(); t3 = get_time();
#endif #endif
count = sender->audio_read(sender->audio, samples, latspl, num_chan, rf_level_db); count = sender->audio_read(sender->audio, samples, buffer_size, num_chan, rf_level_db);
if (count < 0) { if (count < 0) {
/* special case when audio_read wants us to quit */ /* special case when audio_read wants us to quit */
if (count == -EPERM) { if (count == -EPERM) {

View File

@ -43,8 +43,8 @@ typedef struct sender {
/* audio */ /* audio */
void *audio; void *audio;
char audiodev[64]; /* audio device name (alsa or sdr) */ char device[64]; /* audio device name (alsa or sdr) */
void *(*audio_open)(const char *, double *, double *, int *, int, double, int, int, double, double, double); void *(*audio_open)(const char *, double *, double *, int *, int, double, int, int, double, double, double, double);
int (*audio_start)(void *); int (*audio_start)(void *);
void (*audio_close)(void *); void (*audio_close)(void *);
int (*audio_write)(void *, sample_t **, uint8_t **, int, enum paging_signal *, int *, int); int (*audio_write)(void *, sample_t **, uint8_t **, int, enum paging_signal *, int *, int);
@ -93,13 +93,13 @@ extern sender_t *sender_head;
extern int cant_recover; extern int cant_recover;
extern int check_channel; extern int check_channel;
int sender_create(sender_t *sender, const char *kanal, double sendefrequenz, double empfangsfrequenz, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, enum paging_signal paging_signal); int sender_create(sender_t *sender, const char *kanal, double sendefrequenz, double empfangsfrequenz, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, enum paging_signal paging_signal);
void sender_destroy(sender_t *sender); void sender_destroy(sender_t *sender);
void sender_set_fm(sender_t *sender, double max_deviation, double max_modulation, double speech_deviation, double max_display); void sender_set_fm(sender_t *sender, double max_deviation, double max_modulation, double speech_deviation, double max_display);
void sender_set_am(sender_t *sender, double max_modulation, double speech_deviation, double max_display, double modulation_index); void sender_set_am(sender_t *sender, double max_modulation, double speech_deviation, double max_display, double modulation_index);
int sender_open_audio(int latspl); int sender_open_audio(int buffer_size, double interval);
int sender_start_audio(void); int sender_start_audio(void);
void process_sender_audio(sender_t *sender, int *quit, int latspl); void process_sender_audio(sender_t *sender, int *quit, int buffer_size);
void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int count); void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int count);
void sender_receive(sender_t *sender, sample_t *samples, int count, double rf_level_db); void sender_receive(sender_t *sender, sample_t *samples, int count, double rf_level_db);
void sender_paging(sender_t *sender, int on); void sender_paging(sender_t *sender, int on);

View File

@ -93,7 +93,8 @@ typedef struct sdr {
int channels; /* number of frequencies */ int channels; /* number of frequencies */
double amplitude; /* amplitude of each carrier */ double amplitude; /* amplitude of each carrier */
int samplerate; /* sample rate of audio data */ int samplerate; /* sample rate of audio data */
int latspl; /* latency in audio samples */ int buffer_size; /* buffer in audio samples */
double interval; /* how often to process the loop */
wave_rec_t wave_rx_rec; wave_rec_t wave_rx_rec;
wave_rec_t wave_tx_rec; wave_rec_t wave_tx_rec;
wave_play_t wave_rx_play; wave_play_t wave_rx_play;
@ -136,7 +137,7 @@ static void show_spectrum(const char *direction, double halfbandwidth, double ce
PDEBUG(DSDR, DEBUG_INFO, "Frequency P = %.4f MHz (Paging Frequency)\n", paging_frequency / 1e6); PDEBUG(DSDR, DEBUG_INFO, "Frequency P = %.4f MHz (Paging Frequency)\n", paging_frequency / 1e6);
} }
void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int latspl, double max_deviation, double max_modulation, double modulation_index) void *sdr_open(const char __attribute__((__unused__)) *device, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index)
{ {
sdr_t *sdr; sdr_t *sdr;
int threads = 1, oversample = 1; /* always use threads */ int threads = 1, oversample = 1; /* always use threads */
@ -179,13 +180,14 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
sdr->channels = channels; sdr->channels = channels;
sdr->amplitude = 1.0 / (double)channels; sdr->amplitude = 1.0 / (double)channels;
sdr->samplerate = samplerate; sdr->samplerate = samplerate;
sdr->latspl = latspl; sdr->buffer_size = buffer_size;
sdr->interval = interval;
sdr->threads = threads; /* always required, because write may block */ sdr->threads = threads; /* always required, because write may block */
sdr->oversample = oversample; sdr->oversample = oversample;
if (threads) { if (threads) {
memset(&sdr->thread_read, 0, sizeof(sdr->thread_read)); memset(&sdr->thread_read, 0, sizeof(sdr->thread_read));
sdr->thread_read.buffer_size = sdr->latspl * 2 * sdr->oversample + 2; sdr->thread_read.buffer_size = sdr->buffer_size * 2 * sdr->oversample + 2;
sdr->thread_read.buffer = calloc(sdr->thread_read.buffer_size, sizeof(*sdr->thread_read.buffer)); sdr->thread_read.buffer = calloc(sdr->thread_read.buffer_size, sizeof(*sdr->thread_read.buffer));
if (!sdr->thread_read.buffer) { if (!sdr->thread_read.buffer) {
PDEBUG(DSDR, DEBUG_ERROR, "No mem!\n"); PDEBUG(DSDR, DEBUG_ERROR, "No mem!\n");
@ -202,7 +204,7 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
iir_lowpass_init(&sdr->thread_read.lp[1], samplerate / 2.0, sdr_config->samplerate, 2); iir_lowpass_init(&sdr->thread_read.lp[1], samplerate / 2.0, sdr_config->samplerate, 2);
} }
memset(&sdr->thread_write, 0, sizeof(sdr->thread_write)); memset(&sdr->thread_write, 0, sizeof(sdr->thread_write));
sdr->thread_write.buffer_size = sdr->latspl * 2 + 2; sdr->thread_write.buffer_size = sdr->buffer_size * 2 + 2;
sdr->thread_write.buffer = calloc(sdr->thread_write.buffer_size, sizeof(*sdr->thread_write.buffer)); sdr->thread_write.buffer = calloc(sdr->thread_write.buffer_size, sizeof(*sdr->thread_write.buffer));
if (!sdr->thread_write.buffer) { if (!sdr->thread_write.buffer) {
PDEBUG(DSDR, DEBUG_ERROR, "No mem!\n"); PDEBUG(DSDR, DEBUG_ERROR, "No mem!\n");
@ -221,32 +223,32 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
} }
/* alloc fm modulation buffers */ /* alloc fm modulation buffers */
sdr->modbuff = calloc(sdr->latspl * 2, sizeof(*sdr->modbuff)); sdr->modbuff = calloc(sdr->buffer_size * 2, sizeof(*sdr->modbuff));
if (!sdr->modbuff) { if (!sdr->modbuff) {
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n"); PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
goto error; goto error;
} }
sdr->modbuff_I = calloc(sdr->latspl, sizeof(*sdr->modbuff_I)); sdr->modbuff_I = calloc(sdr->buffer_size, sizeof(*sdr->modbuff_I));
if (!sdr->modbuff_I) { if (!sdr->modbuff_I) {
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n"); PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
goto error; goto error;
} }
sdr->modbuff_Q = calloc(sdr->latspl, sizeof(*sdr->modbuff_Q)); sdr->modbuff_Q = calloc(sdr->buffer_size, sizeof(*sdr->modbuff_Q));
if (!sdr->modbuff_Q) { if (!sdr->modbuff_Q) {
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n"); PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
goto error; goto error;
} }
sdr->modbuff_carrier = calloc(sdr->latspl, sizeof(*sdr->modbuff_carrier)); sdr->modbuff_carrier = calloc(sdr->buffer_size, sizeof(*sdr->modbuff_carrier));
if (!sdr->modbuff_carrier) { if (!sdr->modbuff_carrier) {
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n"); PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
goto error; goto error;
} }
sdr->wavespl0 = calloc(sdr->latspl, sizeof(*sdr->wavespl0)); sdr->wavespl0 = calloc(sdr->buffer_size, sizeof(*sdr->wavespl0));
if (!sdr->wavespl0) { if (!sdr->wavespl0) {
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n"); PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
goto error; goto error;
} }
sdr->wavespl1 = calloc(sdr->latspl, sizeof(*sdr->wavespl1)); sdr->wavespl1 = calloc(sdr->buffer_size, sizeof(*sdr->wavespl1));
if (!sdr->wavespl1) { if (!sdr->wavespl1) {
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n"); PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
goto error; goto error;
@ -567,7 +569,7 @@ static void *sdr_write_child(void *arg)
} }
/* delay some time */ /* delay some time */
usleep(1000); usleep(sdr->interval * 1000.0);
} }
PDEBUG(DSDR, DEBUG_DEBUG, "Thread received exit!\n"); PDEBUG(DSDR, DEBUG_DEBUG, "Thread received exit!\n");
@ -619,7 +621,7 @@ static void *sdr_read_child(void *arg)
} }
/* delay some time */ /* delay some time */
usleep(1000); usleep(sdr->interval * 1000.0);
} }
PDEBUG(DSDR, DEBUG_DEBUG, "Thread received exit!\n"); PDEBUG(DSDR, DEBUG_DEBUG, "Thread received exit!\n");
@ -757,8 +759,8 @@ int sdr_write(void *inst, sample_t **samples, uint8_t **power, int num, enum pag
int c, s, ss; int c, s, ss;
int sent = 0; int sent = 0;
if (num > sdr->latspl) { if (num > sdr->buffer_size) {
fprintf(stderr, "exceeding maximum size given by sdr_latspl, please fix!\n"); fprintf(stderr, "exceeding maximum size given by sdr->buffer_size, please fix!\n");
abort(); abort();
} }
if (channels != sdr->channels && channels != 0) { if (channels != sdr->channels && channels != 0) {
@ -858,8 +860,8 @@ int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_l
int count = 0; int count = 0;
int c, s, ss; int c, s, ss;
if (num > sdr->latspl) { if (num > sdr->buffer_size) {
fprintf(stderr, "exceeding maximum size given by sdr_latspl, please fix!\n"); fprintf(stderr, "exceeding maximum size given by sdr->buffer_size, please fix!\n");
abort(); abort();
} }
@ -981,19 +983,19 @@ int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_l
return count; return count;
} }
/* how much do we need to send (in audio sample duration) to get the target delay (latspl) */ /* how much do we need to send (in audio sample duration) to get the target delay (buffer size) */
int sdr_get_tosend(void *inst, int latspl) int sdr_get_tosend(void *inst, int buffer_size)
{ {
sdr_t *sdr = (sdr_t *)inst; sdr_t *sdr = (sdr_t *)inst;
int count = 0; int count = 0;
#ifdef HAVE_UHD #ifdef HAVE_UHD
if (sdr_config->uhd) if (sdr_config->uhd)
count = uhd_get_tosend(latspl * sdr->oversample); count = uhd_get_tosend(buffer_size * sdr->oversample);
#endif #endif
#ifdef HAVE_SOAPY #ifdef HAVE_SOAPY
if (sdr_config->soapy) if (sdr_config->soapy)
count = soapy_get_tosend(latspl * sdr->oversample); count = soapy_get_tosend(buffer_size * sdr->oversample);
#endif #endif
if (count < 0) if (count < 0)
return count; return count;

View File

@ -2,10 +2,10 @@
enum paging_signal; enum paging_signal;
int sdr_start(void *inst); int sdr_start(void *inst);
void *sdr_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int latspl, double max_deviation, double max_modulation, double modulation_index); void *sdr_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index);
void sdr_close(void *inst); void sdr_close(void *inst);
int sdr_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels); int sdr_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels);
int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_level_db); int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_level_db);
int sdr_get_tosend(void *inst, int latspl); int sdr_get_tosend(void *inst, int buffer_size);
void calibrate_bias(void); void calibrate_bias(void);

View File

@ -27,9 +27,9 @@
* *
* If a RX time stamp is valid and first chunk is to be transmitted (tosend() * If a RX time stamp is valid and first chunk is to be transmitted (tosend()
* is called), TX time stamp becomes valid and is set to RX time stamp, but * is called), TX time stamp becomes valid and is set to RX time stamp, but
* advanced by the duration of the latency (latspl). tosend() always returns * advanced by the duration of the buffer size. tosend() always returns
* the number of samples that are needed, to make TX time stamp advance RX time * the number of samples that are needed, to make TX time stamp advance RX time
* stamp by given latency. * stamp by given buffer size.
* *
* If chunk is transmitted to SDR, the TX time stamp is advanced by the * If chunk is transmitted to SDR, the TX time stamp is advanced by the
* duration of the transmitted chunk. * duration of the transmitted chunk.
@ -557,7 +557,7 @@ int soapy_receive(float *buff, int max)
} }
/* estimate number of samples that can be sent */ /* estimate number of samples that can be sent */
int soapy_get_tosend(int latspl) int soapy_get_tosend(int buffer_size)
{ {
int tosend; int tosend;
@ -567,23 +567,23 @@ int soapy_get_tosend(int latspl)
/* RX time stamp is valid the first time, set the TX time stamp in advance */ /* RX time stamp is valid the first time, set the TX time stamp in advance */
if (!tx_valid) { if (!tx_valid) {
tx_timeNs = rx_timeNs + latspl * Ns_per_sample; tx_timeNs = rx_timeNs + buffer_size * Ns_per_sample;
tx_valid = 1; tx_valid = 1;
return 0; return 0;
} }
/* we check how advance our transmitted time stamp is */ /* we check how advance our transmitted time stamp is */
pthread_mutex_lock(&timestamp_mutex); pthread_mutex_lock(&timestamp_mutex);
tosend = latspl - (tx_timeNs - rx_timeNs) / Ns_per_sample; tosend = buffer_size - (tx_timeNs - rx_timeNs) / Ns_per_sample;
pthread_mutex_unlock(&timestamp_mutex); pthread_mutex_unlock(&timestamp_mutex);
/* in case of underrun */ /* in case of underrun */
if (tosend > latspl) { if (tosend > buffer_size) {
PDEBUG(DSOAPY, DEBUG_ERROR, "SDR TX underrun, seems we are too slow. Use lower SDR sample rate.\n"); PDEBUG(DSOAPY, DEBUG_ERROR, "SDR TX underrun, seems we are too slow. Use lower SDR sample rate.\n");
tosend = latspl; tosend = buffer_size;
} }
/* race condition and routing errors may cause TX time stamps to be in advance of slightly more than latspl */ /* race condition and routing errors may cause TX time stamps to be in advance of slightly more than buffer_size */
if (tosend < 0) if (tosend < 0)
tosend = 0; tosend = 0;

View File

@ -4,5 +4,5 @@ int soapy_start(void);
void soapy_close(void); void soapy_close(void);
int soapy_send(float *buff, int num); int soapy_send(float *buff, int num);
int soapy_receive(float *buff, int max); int soapy_receive(float *buff, int max);
int soapy_get_tosend(int latspl); int soapy_get_tosend(int buffer_size);

View File

@ -631,7 +631,7 @@ int uhd_receive(float *buff, int max)
} }
/* estimate number of samples that can be sent */ /* estimate number of samples that can be sent */
int uhd_get_tosend(int latspl) int uhd_get_tosend(int buffer_size)
{ {
double advance; double advance;
int tosend; int tosend;
@ -645,7 +645,7 @@ int uhd_get_tosend(int latspl)
tx_time_secs = rx_time_secs; tx_time_secs = rx_time_secs;
tx_time_fract_sec = rx_time_fract_sec; tx_time_fract_sec = rx_time_fract_sec;
if (tx_timestamps) { if (tx_timestamps) {
tx_time_fract_sec += (double)latspl / samplerate; tx_time_fract_sec += (double)buffer_size / samplerate;
if (tx_time_fract_sec >= 1.0) { if (tx_time_fract_sec >= 1.0) {
tx_time_fract_sec -= 1.0; tx_time_fract_sec -= 1.0;
tx_time_secs++; tx_time_secs++;
@ -660,7 +660,7 @@ int uhd_get_tosend(int latspl)
PDEBUG(DSOAPY, DEBUG_ERROR, "SDR TX underrun, seems we are too slow. Use lower SDR sample rate.\n"); PDEBUG(DSOAPY, DEBUG_ERROR, "SDR TX underrun, seems we are too slow. Use lower SDR sample rate.\n");
advance = 0; advance = 0;
} }
tosend = latspl - (int)(advance * samplerate); tosend = buffer_size - (int)(advance * samplerate);
if (tosend < 0) if (tosend < 0)
tosend = 0; tosend = 0;

View File

@ -4,5 +4,5 @@ int uhd_start(void);
void uhd_close(void); void uhd_close(void);
int uhd_send(float *buff, int num); int uhd_send(float *buff, int num);
int uhd_receive(float *buff, int max); int uhd_receive(float *buff, int max);
int uhd_get_tosend(int latspl); int uhd_get_tosend(int buffer_size);

View File

@ -1,10 +1,10 @@
enum paging_signal; enum paging_signal;
void *sound_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int latspl, double max_deviation, double max_modulation, double modulation_index); void *sound_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int *am, int channels, double paging_frequency, int samplerate, int buffer_size, double interval, double max_deviation, double max_modulation, double modulation_index);
int sound_start(void *inst); int sound_start(void *inst);
void sound_close(void *inst); void sound_close(void *inst);
int sound_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels); int sound_write(void *inst, sample_t **samples, uint8_t **power, int num, enum paging_signal *paging_signal, int *on, int channels);
int sound_read(void *inst, sample_t **samples, int num, int channels, double *rf_level_db); int sound_read(void *inst, sample_t **samples, int num, int channels, double *rf_level_db);
int sound_get_tosend(void *inst, int latspl); int sound_get_tosend(void *inst, int buffer_size);

View File

@ -187,7 +187,7 @@ static void dev_close(sound_t *sound)
snd_pcm_close(sound->chandle); snd_pcm_close(sound->chandle);
} }
void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int __attribute__((unused)) *am, int channels, double __attribute__((unused)) paging_frequency, int samplerate, int __attribute((unused)) latspl, double max_deviation, double __attribute__((unused)) max_modulation, double __attribute__((unused)) modulation_index) void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int __attribute__((unused)) *am, int channels, double __attribute__((unused)) paging_frequency, int samplerate, int __attribute((unused)) buffer_size, double __attribute__((unused)) interval, double max_deviation, double __attribute__((unused)) max_modulation, double __attribute__((unused)) modulation_index)
{ {
sound_t *sound; sound_t *sound;
int rc; int rc;
@ -487,7 +487,7 @@ int sound_read(void *inst, sample_t **samples, int num, int channels, double __a
* get playback buffer space * get playback buffer space
* *
* return number of samples to be sent */ * return number of samples to be sent */
int sound_get_tosend(void *inst, int latspl) int sound_get_tosend(void *inst, int buffer_size)
{ {
sound_t *sound = (sound_t *)inst; sound_t *sound = (sound_t *)inst;
int rc; int rc;
@ -497,7 +497,7 @@ int sound_get_tosend(void *inst, int latspl)
rc = snd_pcm_delay(sound->phandle, &delay); rc = snd_pcm_delay(sound->phandle, &delay);
if (rc < 0) { if (rc < 0) {
if (rc == -32) if (rc == -32)
PDEBUG(DSOUND, DEBUG_ERROR, "Buffer underrun: Please use higher latency and enable real time scheduling\n"); PDEBUG(DSOUND, DEBUG_ERROR, "Buffer underrun: Please use higher buffer and enable real time scheduling\n");
else else
PDEBUG(DSOUND, DEBUG_ERROR, "failed to get delay from interface (%s)\n", snd_strerror(rc)); PDEBUG(DSOUND, DEBUG_ERROR, "failed to get delay from interface (%s)\n", snd_strerror(rc));
if (rc == -EPIPE) { if (rc == -EPIPE) {
@ -511,7 +511,7 @@ int sound_get_tosend(void *inst, int latspl)
return rc; return rc;
} }
tosend = latspl - delay; tosend = buffer_size - delay;
return tosend; return tosend;
} }

View File

@ -289,10 +289,10 @@ int main(int argc, char *argv[])
mandatory = 1; mandatory = 1;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
/* set channel types for more than 1 channel */ /* set channel types for more than 1 channel */
if (num_kanal > 1 && num_chan_type == 0) { if (num_kanal > 1 && num_chan_type == 0) {
chan_type[0] = CHAN_TYPE_CC; chan_type[0] = CHAN_TYPE_CC;
@ -302,9 +302,9 @@ int main(int argc, char *argv[])
} }
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -370,7 +370,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = mpt1327_create(band, kanal[i], chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db); rc = mpt1327_create(band, kanal[i], chan_type[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, squelch_db);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create transceiver instance. Quitting!\n"); fprintf(stderr, "Failed to create transceiver instance. Quitting!\n");
goto fail; goto fail;
@ -380,7 +380,7 @@ int main(int argc, char *argv[])
mpt1327_check_channels(); mpt1327_check_channels();
main_mobile("mpt1327", &quit, latency, interval, NULL, station_id, 7); main_mobile("mpt1327", &quit, NULL, station_id, 7);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -580,7 +580,7 @@ static void mpt1327_new_state(mpt1327_t *mpt1327, enum mpt1327_state new_state,
static void mpt1327_timeout(struct timer *timer); static void mpt1327_timeout(struct timer *timer);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int mpt1327_create(enum mpt1327_band band, const char *kanal, enum mpt1327_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db) int mpt1327_create(enum mpt1327_band band, const char *kanal, enum mpt1327_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db)
{ {
sender_t *sender; sender_t *sender;
mpt1327_t *mpt1327; mpt1327_t *mpt1327;
@ -607,7 +607,7 @@ int mpt1327_create(enum mpt1327_band band, const char *kanal, enum mpt1327_chan_
PDEBUG(DMPT1327, DEBUG_DEBUG, "Creating 'MPT1327' instance for Channel %s on Band %s (sample rate %d).\n", kanal, mpt1327_band_def[band].name, samplerate); PDEBUG(DMPT1327, DEBUG_DEBUG, "Creating 'MPT1327' instance for Channel %s on Band %s (sample rate %d).\n", kanal, mpt1327_band_def[band].name, samplerate);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&mpt1327->sender, kanal, mpt1327_channel2freq(band, atoi(kanal), 0), mpt1327_channel2freq(band, atoi(kanal), 1), audiodev, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&mpt1327->sender, kanal, mpt1327_channel2freq(band, atoi(kanal), 0), mpt1327_channel2freq(band, atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DMPT1327, DEBUG_ERROR, "Failed to init 'Sender' processing!\n"); PDEBUG(DMPT1327, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
goto error; goto error;

View File

@ -146,7 +146,7 @@ void mpt1327_channel_list(void);
int mpt1327_channel_by_short_name(const char *short_name); int mpt1327_channel_by_short_name(const char *short_name);
const char *chan_type_short_name(enum mpt1327_chan_type chan_type); const char *chan_type_short_name(enum mpt1327_chan_type chan_type);
const char *chan_type_long_name(enum mpt1327_chan_type chan_type); const char *chan_type_long_name(enum mpt1327_chan_type chan_type);
int mpt1327_create(enum mpt1327_band band, const char *kanal, enum mpt1327_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db); int mpt1327_create(enum mpt1327_band band, const char *kanal, enum mpt1327_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db);
void mpt1327_check_channels(void); void mpt1327_check_channels(void);
void mpt1327_destroy(sender_t *sender); void mpt1327_destroy(sender_t *sender);
void mpt1327_receive_codeword(mpt1327_t *mpt1327, uint64_t bits, double quality, double level); void mpt1327_receive_codeword(mpt1327_t *mpt1327, uint64_t bits, double quality, double level);

View File

@ -293,10 +293,10 @@ int main(int argc, char *argv[])
mandatory = 1; mandatory = 1;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
/* set channel types for more than 1 channel */ /* set channel types for more than 1 channel */
if (num_kanal > 1 && num_chan_type == 0) { if (num_kanal > 1 && num_chan_type == 0) {
if (loopback) if (loopback)
@ -318,9 +318,9 @@ int main(int argc, char *argv[])
num_supervisory = num_kanal; num_supervisory = num_kanal;
} }
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
return -EINVAL; return -EINVAL;
} }
@ -397,7 +397,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = nmt_create(nmt_system, country, kanal[i], chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, ms_power, traffic_area, area_no, compandor, supervisory[i], smsc_number, send_callerid, loopback); rc = nmt_create(nmt_system, country, kanal[i], chan_type[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, ms_power, traffic_area, area_no, compandor, supervisory[i], smsc_number, send_callerid, loopback);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create transceiver instance. Quitting!\n"); fprintf(stderr, "Failed to create transceiver instance. Quitting!\n");
goto fail; goto fail;
@ -407,7 +407,7 @@ int main(int argc, char *argv[])
nmt_check_channels(nmt_system); nmt_check_channels(nmt_system);
main_mobile("nmt", &quit, latency, interval, myhandler, station_id, 7); main_mobile("nmt", &quit, myhandler, station_id, 7);
fail: fail:
/* fifo */ /* fifo */

View File

@ -261,7 +261,7 @@ static inline int is_chan_class_tc(enum nmt_chan_type chan_type)
static void nmt_timeout(struct timer *timer); static void nmt_timeout(struct timer *timer);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int nmt_create(int nmt_system, const char *country, const char *kanal, enum nmt_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback) int nmt_create(int nmt_system, const char *country, const char *kanal, enum nmt_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback)
{ {
nmt_t *nmt; nmt_t *nmt;
int rc; int rc;
@ -300,7 +300,7 @@ int nmt_create(int nmt_system, const char *country, const char *kanal, enum nmt_
PDEBUG(DNMT, DEBUG_DEBUG, "Creating 'NMT' instance for channel = %s (sample rate %d).\n", kanal, samplerate); PDEBUG(DNMT, DEBUG_DEBUG, "Creating 'NMT' instance for channel = %s (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&nmt->sender, kanal, nmt_channel2freq(nmt_system, country, atoi(kanal), 0, NULL, NULL, NULL), nmt_channel2freq(nmt_system, country, atoi(kanal), 1, NULL, NULL, NULL), audiodev, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&nmt->sender, kanal, nmt_channel2freq(nmt_system, country, atoi(kanal), 0, NULL, NULL, NULL), nmt_channel2freq(nmt_system, country, atoi(kanal), 1, NULL, NULL, NULL), device, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DNMT, DEBUG_ERROR, "Failed to init transceiver process!\n"); PDEBUG(DNMT, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error; goto error;

View File

@ -143,7 +143,7 @@ void nmt_channel_list(int nmt_system);
int nmt_channel_by_short_name(int nmt_system, const char *short_name); int nmt_channel_by_short_name(int nmt_system, const char *short_name);
const char *chan_type_short_name(int nmt_system, enum nmt_chan_type chan_type); const char *chan_type_short_name(int nmt_system, enum nmt_chan_type chan_type);
const char *chan_type_long_name(int nmt_system, enum nmt_chan_type chan_type); const char *chan_type_long_name(int nmt_system, enum nmt_chan_type chan_type);
int nmt_create(int nmt_system, const char *country, const char *kanal, enum nmt_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback); int nmt_create(int nmt_system, const char *country, const char *kanal, enum nmt_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback);
void nmt_check_channels(int nmt_system); void nmt_check_channels(int nmt_system);
void nmt_destroy(sender_t *sender); void nmt_destroy(sender_t *sender);
void nmt_go_idle(nmt_t *nmt); void nmt_go_idle(nmt_t *nmt);

View File

@ -281,10 +281,10 @@ int main(int argc, char *argv[])
mandatory = 1; mandatory = 1;
} }
if (use_sdr) { if (use_sdr) {
/* set audiodev */ /* set device */
for (i = 0; i < num_kanal; i++) for (i = 0; i < num_kanal; i++)
audiodev[i] = "sdr"; dsp_device[i] = "sdr";
num_audiodev = num_kanal; num_device = num_kanal;
/* set channel types for more than 1 channel */ /* set channel types for more than 1 channel */
if (num_kanal > 1 && num_chan_type == 0) { if (num_kanal > 1 && num_chan_type == 0) {
chan_type[0] = CHAN_TYPE_CC; chan_type[0] = CHAN_TYPE_CC;
@ -294,9 +294,9 @@ int main(int argc, char *argv[])
} }
} }
if (num_kanal == 1 && num_audiodev == 0) if (num_kanal == 1 && num_device == 0)
num_audiodev = 1; /* use default */ num_device = 1; /* use default */
if (num_kanal != num_audiodev) { if (num_kanal != num_device) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0); exit(0);
} }
@ -352,7 +352,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */ /* create transceiver instance */
for (i = 0; i < num_kanal; i++) { for (i = 0; i < num_kanal; i++) {
rc = r2000_create(band, kanal[i], chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, relais, deport, agi, sm_power, taxe, crins, destruction, nconv, recall, loopback); rc = r2000_create(band, kanal[i], chan_type[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, relais, deport, agi, sm_power, taxe, crins, destruction, nconv, recall, loopback);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to create transceiver instance. Quitting!\n"); fprintf(stderr, "Failed to create transceiver instance. Quitting!\n");
goto fail; goto fail;
@ -363,7 +363,7 @@ int main(int argc, char *argv[])
r2000_check_channels(); r2000_check_channels();
main_mobile("radiocom2000", &quit, latency, interval, NULL, station_id, 9); main_mobile("radiocom2000", &quit, NULL, station_id, 9);
fail: fail:
/* destroy transceiver instance */ /* destroy transceiver instance */

View File

@ -409,7 +409,7 @@ uint8_t r2000_encode_super(r2000_t *r2000)
static void r2000_timeout(struct timer *timer); static void r2000_timeout(struct timer *timer);
/* Create transceiver instance and link to a list. */ /* Create transceiver instance and link to a list. */
int r2000_create(int band, const char *kanal, enum r2000_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint16_t relais, uint8_t deport, uint8_t agi, uint8_t sm_power, uint8_t taxe, uint8_t crins, int destruction, uint8_t nconv, int recall, int loopback) int r2000_create(int band, const char *kanal, enum r2000_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint16_t relais, uint8_t deport, uint8_t agi, uint8_t sm_power, uint8_t taxe, uint8_t crins, int destruction, uint8_t nconv, int recall, int loopback)
{ {
sender_t *sender; sender_t *sender;
r2000_t *r2000 = NULL; r2000_t *r2000 = NULL;
@ -437,7 +437,7 @@ int r2000_create(int band, const char *kanal, enum r2000_chan_type chan_type, co
PDEBUG(DR2000, DEBUG_DEBUG, "Creating 'Radiocom 2000' instance for channel = %s (sample rate %d).\n", kanal, samplerate); PDEBUG(DR2000, DEBUG_DEBUG, "Creating 'Radiocom 2000' instance for channel = %s (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */ /* init general part of transceiver */
rc = sender_create(&r2000->sender, kanal, r2000_channel2freq(band, atoi(kanal), 0), r2000_channel2freq(band, atoi(kanal), 1), audiodev, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); rc = sender_create(&r2000->sender, kanal, r2000_channel2freq(band, atoi(kanal), 0), r2000_channel2freq(band, atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) { if (rc < 0) {
PDEBUG(DR2000, DEBUG_ERROR, "Failed to init transceiver process!\n"); PDEBUG(DR2000, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error; goto error;

View File

@ -123,7 +123,7 @@ void r2000_channel_list(void);
int r2000_channel_by_short_name(const char *short_name); int r2000_channel_by_short_name(const char *short_name);
const char *chan_type_short_name(enum r2000_chan_type chan_type); const char *chan_type_short_name(enum r2000_chan_type chan_type);
const char *chan_type_long_name(enum r2000_chan_type chan_type); const char *chan_type_long_name(enum r2000_chan_type chan_type);
int r2000_create(int band, const char *kanal, enum r2000_chan_type chan_type, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint16_t relais, uint8_t deport, uint8_t agi, uint8_t sm_power, uint8_t taxe, uint8_t crins, int destruction, uint8_t nconv, int recall, int loopback); int r2000_create(int band, const char *kanal, enum r2000_chan_type chan_type, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, uint16_t relais, uint8_t deport, uint8_t agi, uint8_t sm_power, uint8_t taxe, uint8_t crins, int destruction, uint8_t nconv, int recall, int loopback);
void r2000_check_channels(void); void r2000_check_channels(void);
void r2000_destroy(sender_t *sender); void r2000_destroy(sender_t *sender);
void r2000_go_idle(r2000_t *r2000); void r2000_go_idle(r2000_t *r2000);

View File

@ -48,8 +48,8 @@ int fast_math = 0;
void *get_sender_by_empfangsfrequenz() { return NULL; } void *get_sender_by_empfangsfrequenz() { return NULL; }
static double frequency = 0.0; static double frequency = 0.0;
static int samplerate = 100000; static int dsp_samplerate = 100000;
static int latency = 30; static int dsp_buffer = 30;
static const char *tx_wave_file = NULL; static const char *tx_wave_file = NULL;
static const char *rx_wave_file = NULL; static const char *rx_wave_file = NULL;
static const char *tx_audiodev = NULL; static const char *tx_audiodev = NULL;
@ -114,7 +114,7 @@ void print_help(const char *arg0)
printf(" -f --frequency <frequency>\n"); printf(" -f --frequency <frequency>\n");
printf(" Give frequency in Hertz.\n"); printf(" Give frequency in Hertz.\n");
printf(" -s --samplerate <sample rate>\n"); printf(" -s --samplerate <sample rate>\n");
printf(" Give signal processing sample rate in Hz. (default = %d)\n", samplerate); printf(" Give signal processing sample rate in Hz. (default = %d)\n", dsp_samplerate);
printf(" This sample rate must be high enough for the signal's spectrum to fit.\n"); printf(" This sample rate must be high enough for the signal's spectrum to fit.\n");
printf(" I will inform you, if this bandwidth is too low.\n"); printf(" I will inform you, if this bandwidth is too low.\n");
printf(" -r --tx-wave-file <filename>\n"); printf(" -r --tx-wave-file <filename>\n");
@ -194,7 +194,7 @@ static int handle_options(int short_option, int argi, char **argv)
frequency = atof(argv[argi]); frequency = atof(argv[argi]);
break; break;
case 's': case 's':
samplerate = atof(argv[argi]); dsp_samplerate = atof(argv[argi]);
break; break;
case 'r': case 'r':
tx_wave_file = options_strdup(argv[argi]); tx_wave_file = options_strdup(argv[argi]);
@ -297,7 +297,7 @@ int main(int argc, char *argv[])
radio_t radio; radio_t radio;
struct termios term, term_orig; struct termios term, term_orig;
int c; int c;
int latspl; int buffer_size;
debuglevel = 0; debuglevel = 0;
@ -322,7 +322,7 @@ int main(int argc, char *argv[])
fm_init(fast_math); fm_init(fast_math);
am_init(fast_math); am_init(fast_math);
rc = sdr_configure(samplerate); rc = sdr_configure(dsp_samplerate);
if (rc < 0) if (rc < 0)
return rc; return rc;
if (rc == 0) { if (rc == 0) {
@ -358,10 +358,10 @@ int main(int argc, char *argv[])
exit(0); exit(0);
} }
/* now we have latency and sample rate */ /* now we have buffer size and sample rate */
latspl = samplerate * latency / 1000; buffer_size = dsp_samplerate * dsp_buffer / 1000;
rc = radio_init(&radio, latspl, samplerate, frequency, tx_wave_file, rx_wave_file, (tx) ? tx_audiodev : NULL, (rx) ? rx_audiodev : NULL, modulation, bandwidth, deviation, modulation_index, time_constant_us, volume, stereo, rds, rds2); rc = radio_init(&radio, buffer_size, dsp_samplerate, frequency, tx_wave_file, rx_wave_file, (tx) ? tx_audiodev : NULL, (rx) ? rx_audiodev : NULL, modulation, bandwidth, deviation, modulation_index, time_constant_us, volume, stereo, rds, rds2);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to initialize radio with given options, exitting!\n"); fprintf(stderr, "Failed to initialize radio with given options, exitting!\n");
exit(0); exit(0);
@ -370,7 +370,7 @@ int main(int argc, char *argv[])
void *sdr = NULL; void *sdr = NULL;
float *sendbuff = NULL; float *sendbuff = NULL;
sendbuff = calloc(latspl * 2, sizeof(*sendbuff)); sendbuff = calloc(buffer_size * 2, sizeof(*sendbuff));
if (!sendbuff) { if (!sendbuff) {
fprintf(stderr, "No mem!\n"); fprintf(stderr, "No mem!\n");
goto error; goto error;
@ -393,7 +393,7 @@ int main(int argc, char *argv[])
tx_frequencies[0] = frequency; tx_frequencies[0] = frequency;
rx_frequencies[0] = frequency; rx_frequencies[0] = frequency;
am[0] = 0; am[0] = 0;
sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, am, 1, 0.0, samplerate, latspl, 0.0, 0.0, 0.0); sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, am, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 0.0, 0.0, 0.0);
if (!sdr) if (!sdr)
goto error; goto error;
sdr_start(sdr); sdr_start(sdr);
@ -422,15 +422,15 @@ int main(int argc, char *argv[])
int tosend, got; int tosend, got;
while (!quit) { while (!quit) {
usleep(1000); usleep(1000);
got = sdr_read(sdr, (void *)sendbuff, latspl, 0, NULL); got = sdr_read(sdr, (void *)sendbuff, buffer_size, 0, NULL);
if (rx) { if (rx) {
got = radio_rx(&radio, sendbuff, got); got = radio_rx(&radio, sendbuff, got);
if (got < 0) if (got < 0)
break; break;
} }
tosend = sdr_get_tosend(sdr, latspl); tosend = sdr_get_tosend(sdr, buffer_size);
if (tosend > latspl / 10) if (tosend > buffer_size / 10)
tosend = latspl / 10; tosend = buffer_size / 10;
if (tosend == 0) { if (tosend == 0) {
continue; continue;
} }

View File

@ -38,14 +38,14 @@
static char freq_name[2][64]; static char freq_name[2][64];
int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant_us, double volume, int stereo, int rds, int rds2) int radio_init(radio_t *radio, int buffer_size, int samplerate, double frequency, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant_us, double volume, int stereo, int rds, int rds2)
{ {
int rc = -EINVAL; int rc = -EINVAL;
clipper_init(CLIP_POINT); clipper_init(CLIP_POINT);
memset(radio, 0, sizeof(*radio)); memset(radio, 0, sizeof(*radio));
radio->latspl = latspl; radio->buffer_size = buffer_size;
radio->volume = volume; radio->volume = volume;
radio->stereo = stereo; radio->stereo = stereo;
radio->rds = rds; radio->rds = rds;
@ -100,7 +100,7 @@ int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, con
/* open audio device */ /* open audio device */
radio->tx_audio_samplerate = 48000; radio->tx_audio_samplerate = 48000;
radio->tx_audio_channels = (stereo) ? 2 : 1; radio->tx_audio_channels = (stereo) ? 2 : 1;
radio->tx_sound = sound_open(tx_audiodev, NULL, NULL, NULL, radio->tx_audio_channels, 0.0, radio->tx_audio_samplerate, radio->latspl, 1.0, 0.0, 2.0); radio->tx_sound = sound_open(tx_audiodev, NULL, NULL, NULL, radio->tx_audio_channels, 0.0, radio->tx_audio_samplerate, radio->buffer_size, 1.0, 1.0, 0.0, 2.0);
if (!radio->tx_sound) { if (!radio->tx_sound) {
rc = -EIO; rc = -EIO;
PDEBUG(DRADIO, DEBUG_ERROR, "Failed to open sound device!\n"); PDEBUG(DRADIO, DEBUG_ERROR, "Failed to open sound device!\n");
@ -167,7 +167,7 @@ int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, con
if (radio->tx_sound && !strcmp(tx_audiodev, rx_audiodev)) if (radio->tx_sound && !strcmp(tx_audiodev, rx_audiodev))
radio->rx_sound = radio->tx_sound; radio->rx_sound = radio->tx_sound;
else else
radio->rx_sound = sound_open(rx_audiodev, NULL, NULL, NULL, radio->rx_audio_channels, 0.0, radio->rx_audio_samplerate, radio->latspl, 1.0, 0.0, 2.0); radio->rx_sound = sound_open(rx_audiodev, NULL, NULL, NULL, radio->rx_audio_channels, 0.0, radio->rx_audio_samplerate, radio->buffer_size, 1.0, 1.0, 0.0, 2.0);
if (!radio->rx_sound) { if (!radio->rx_sound) {
rc = -EIO; rc = -EIO;
PDEBUG(DRADIO, DEBUG_ERROR, "Failed to open sound device!\n"); PDEBUG(DRADIO, DEBUG_ERROR, "Failed to open sound device!\n");
@ -310,8 +310,8 @@ int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, con
} }
/* audio buffers: how many sample for audio (rounded down) */ /* audio buffers: how many sample for audio (rounded down) */
int tx_size = (int)((double)latspl / radio->tx_resampler[0].factor); int tx_size = (int)((double)buffer_size / radio->tx_resampler[0].factor);
int rx_size = (int)((double)latspl / radio->rx_resampler[0].factor); int rx_size = (int)((double)buffer_size / radio->rx_resampler[0].factor);
if (tx_size > rx_size) if (tx_size > rx_size)
radio->audio_buffer_size = tx_size; radio->audio_buffer_size = tx_size;
else else
@ -324,7 +324,7 @@ int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, con
} }
/* signal buffers */ /* signal buffers */
radio->signal_buffer_size = latspl; radio->signal_buffer_size = buffer_size;
radio->signal_buffer = calloc(radio->signal_buffer_size * 3, sizeof(*radio->signal_buffer)); radio->signal_buffer = calloc(radio->signal_buffer_size * 3, sizeof(*radio->signal_buffer));
radio->signal_power_buffer = calloc(radio->signal_buffer_size, sizeof(*radio->signal_power_buffer)); radio->signal_power_buffer = calloc(radio->signal_buffer_size, sizeof(*radio->signal_power_buffer));
if (!radio->signal_buffer || !radio->signal_power_buffer) { if (!radio->signal_buffer || !radio->signal_power_buffer) {
@ -334,9 +334,9 @@ int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, con
} }
/* temporary I/Q/carrier buffers, used while demodulating */ /* temporary I/Q/carrier buffers, used while demodulating */
radio->I_buffer = calloc(latspl, sizeof(*radio->I_buffer)); radio->I_buffer = calloc(buffer_size, sizeof(*radio->I_buffer));
radio->Q_buffer = calloc(latspl, sizeof(*radio->Q_buffer)); radio->Q_buffer = calloc(buffer_size, sizeof(*radio->Q_buffer));
radio->carrier_buffer = calloc(latspl, sizeof(*radio->carrier_buffer)); radio->carrier_buffer = calloc(buffer_size, sizeof(*radio->carrier_buffer));
if (!radio->I_buffer || !radio->Q_buffer || !radio->carrier_buffer) { if (!radio->I_buffer || !radio->Q_buffer || !radio->carrier_buffer) {
PDEBUG(DRADIO, DEBUG_ERROR, "No memory!!\n"); PDEBUG(DRADIO, DEBUG_ERROR, "No memory!!\n");
rc = -ENOMEM; rc = -ENOMEM;
@ -438,8 +438,8 @@ int radio_tx(radio_t *radio, float *baseband, int signal_num)
sample_t *signal_samples[3]; sample_t *signal_samples[3];
uint8_t *signal_power; uint8_t *signal_power;
if (signal_num > radio->latspl) { if (signal_num > radio->buffer_size) {
PDEBUG(DRADIO, DEBUG_ERROR, "signal_num > latspl, please fix!.\n"); PDEBUG(DRADIO, DEBUG_ERROR, "signal_num > buffer_size, please fix!.\n");
abort(); abort();
} }
@ -611,8 +611,8 @@ int radio_rx(radio_t *radio, float *baseband, int signal_num)
sample_t *samples[3]; sample_t *samples[3];
double p; double p;
if (signal_num > radio->latspl) { if (signal_num > radio->buffer_size) {
PDEBUG(DRADIO, DEBUG_ERROR, "signal_num > latspl, please fix!.\n"); PDEBUG(DRADIO, DEBUG_ERROR, "signal_num > buffer_size, please fix!.\n");
abort(); abort();
} }

View File

@ -24,7 +24,7 @@ enum audio_mode {
typedef struct radio { typedef struct radio {
/* modes */ /* modes */
int latspl; /* maximum number of samples */ int buffer_size; /* maximum number of samples */
enum modulation modulation; /* modulation type */ enum modulation modulation; /* modulation type */
enum audio_mode tx_audio_mode; /* mode for audio source */ enum audio_mode tx_audio_mode; /* mode for audio source */
enum audio_mode rx_audio_mode; /* mode for audio sink */ enum audio_mode rx_audio_mode; /* mode for audio sink */
@ -81,7 +81,7 @@ typedef struct radio {
sample_t *carrier_buffer; sample_t *carrier_buffer;
} radio_t; } radio_t;
int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant, double volume, int stereo, int rds, int rds2); int radio_init(radio_t *radio, int buffer_size, int samplerate, double frequency, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant, double volume, int stereo, int rds, int rds2);
void radio_exit(radio_t *radio); void radio_exit(radio_t *radio);
int radio_start(radio_t *radio); int radio_start(radio_t *radio);
int radio_tx(radio_t *radio, float *baseband, int num); int radio_tx(radio_t *radio, float *baseband, int num);

View File

@ -61,8 +61,8 @@ static int color_bar = 0;
static int grid_only = 0; static int grid_only = 0;
static const char *station_id = "Jolly Roger"; static const char *station_id = "Jolly Roger";
static int grid_width = 0; static int grid_width = 0;
static int __attribute__((__unused__)) latency = 200; static int __attribute__((__unused__)) dsp_buffer = 200;
static double samplerate = 10e6; static double dsp_samplerate = 10e6;
static const char *wave_file = NULL; static const char *wave_file = NULL;
/* global variable to quit main loop */ /* global variable to quit main loop */
@ -186,7 +186,7 @@ static int handle_options(int short_option, int argi, char **argv)
printf("Given channel is '%s' (video = %.2f MHz, audio = %.2f MHz)\n", argv[argi], frequency / 1e6, (frequency + audio_offset) / 1e6); printf("Given channel is '%s' (video = %.2f MHz, audio = %.2f MHz)\n", argv[argi], frequency / 1e6, (frequency + audio_offset) / 1e6);
break; break;
case 's': case 's':
samplerate = atof(argv[argi]); dsp_samplerate = atof(argv[argi]);
break; break;
case 'w': case 'w':
wave_file = options_strdup(argv[argi]); wave_file = options_strdup(argv[argi]);
@ -272,7 +272,7 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
int rc; int rc;
sample_t *buffers[1]; sample_t *buffers[1];
rc = wave_create_record(&rec, wave_file, samplerate, 1, 1.0); rc = wave_create_record(&rec, wave_file, dsp_samplerate, 1, 1.0);
if (rc < 0) { if (rc < 0) {
// FIXME cleanup // FIXME cleanup
exit(0); exit(0);
@ -286,7 +286,7 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
#ifdef HAVE_SDR #ifdef HAVE_SDR
float *buff = NULL; float *buff = NULL;
void *sdr = NULL; void *sdr = NULL;
int latspl = samplerate * latency / 1000; int buffer_size = dsp_samplerate * dsp_buffer / 1000;
float *sendbuff = NULL; float *sendbuff = NULL;
if ((sdr_config->uhd == 0 && sdr_config->soapy == 0)) { if ((sdr_config->uhd == 0 && sdr_config->soapy == 0)) {
@ -294,7 +294,7 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
goto error; goto error;
} }
sendbuff = calloc(latspl * 2, sizeof(*sendbuff)); sendbuff = calloc(buffer_size * 2, sizeof(*sendbuff));
if (!sendbuff) { if (!sendbuff) {
fprintf(stderr, "No mem!\n"); fprintf(stderr, "No mem!\n");
goto error; goto error;
@ -311,7 +311,7 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
if (sample_tone) { if (sample_tone) {
/* bandwidth is 2*(deviation + 2*f(sig)) = 2 * (50 + 2*15) = 160khz */ /* bandwidth is 2*(deviation + 2*f(sig)) = 2 * (50 + 2*15) = 160khz */
fm_mod_t mod; fm_mod_t mod;
fm_mod_init(&mod, samplerate, audio_offset, modulation * 0.1); fm_mod_init(&mod, dsp_samplerate, audio_offset, modulation * 0.1);
mod.state = MOD_STATE_ON; /* do not ramp up */ mod.state = MOD_STATE_ON; /* do not ramp up */
fm_modulate_complex(&mod, sample_tone, power_tone, samples, buff); fm_modulate_complex(&mod, sample_tone, power_tone, samples, buff);
} }
@ -333,7 +333,7 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
tx_frequencies[0] = frequency; tx_frequencies[0] = frequency;
rx_frequencies[0] = frequency; rx_frequencies[0] = frequency;
am[0] = 0; am[0] = 0;
sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, am, 1, 0.0, samplerate, latspl, 0.0, 0.0, 0.0); sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, am, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 0.0, 0.0, 0.0);
if (!sdr) if (!sdr)
goto error; goto error;
sdr_start(sdr); sdr_start(sdr);
@ -342,10 +342,10 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
int s, ss, tosend; int s, ss, tosend;
while (!quit) { while (!quit) {
usleep(1000); usleep(1000);
sdr_read(sdr, (void *)sendbuff, latspl, 0, NULL); sdr_read(sdr, (void *)sendbuff, buffer_size, 0, NULL);
tosend = sdr_get_tosend(sdr, latspl); tosend = sdr_get_tosend(sdr, buffer_size);
if (tosend > latspl / 10) if (tosend > buffer_size / 10)
tosend = latspl / 10; tosend = buffer_size / 10;
if (tosend == 0) { if (tosend == 0) {
continue; continue;
} }
@ -395,12 +395,12 @@ static int tx_test_picture(enum bas_type type)
int count; int count;
/* test image, add some samples in case of overflow due to rounding errors */ /* test image, add some samples in case of overflow due to rounding errors */
test_bas = calloc(samplerate / 25.0 * 4.0 + 10.0, sizeof(sample_t)); test_bas = calloc(dsp_samplerate / 25.0 * 4.0 + 10.0, sizeof(sample_t));
if (!test_bas) { if (!test_bas) {
fprintf(stderr, "No mem!\n"); fprintf(stderr, "No mem!\n");
goto error; goto error;
} }
bas_init(&bas, samplerate, type, fbas, circle_radius, color_bar, grid_only, station_id, grid_width, NULL, 0, 0); bas_init(&bas, dsp_samplerate, type, fbas, circle_radius, color_bar, grid_only, station_id, grid_width, NULL, 0, 0);
count = bas_generate(&bas, test_bas); count = bas_generate(&bas, test_bas);
count += bas_generate(&bas, test_bas + count); count += bas_generate(&bas, test_bas + count);
count += bas_generate(&bas, test_bas + count); count += bas_generate(&bas, test_bas + count);
@ -420,7 +420,7 @@ static int tx_test_picture(enum bas_type type)
} }
/* emphasis 50us, but 1000Hz does not change level */ /* emphasis 50us, but 1000Hz does not change level */
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
test_tone[i] = sin((double)i * 2.0 * M_PI * 1000.0 / samplerate) * 50000; test_tone[i] = sin((double)i * 2.0 * M_PI * 1000.0 / dsp_samplerate) * 50000;
memset(test_power, 1, count); memset(test_power, 1, count);
} }
@ -463,12 +463,12 @@ static int tx_img(const char *filename)
} }
/* test image, add some samples in case of overflow due to rounding errors */ /* test image, add some samples in case of overflow due to rounding errors */
img_bas = calloc(samplerate / 25.0 * 4.0 + 10.0, sizeof(sample_t)); img_bas = calloc(dsp_samplerate / 25.0 * 4.0 + 10.0, sizeof(sample_t));
if (!img_bas) { if (!img_bas) {
fprintf(stderr, "No mem!\n"); fprintf(stderr, "No mem!\n");
goto error; goto error;
} }
bas_init(&bas, samplerate, BAS_IMAGE, fbas, circle_radius, color_bar, grid_only, NULL, grid_width, img, width, height); bas_init(&bas, dsp_samplerate, BAS_IMAGE, fbas, circle_radius, color_bar, grid_only, NULL, grid_width, img, width, height);
count = bas_generate(&bas, img_bas); count = bas_generate(&bas, img_bas);
count += bas_generate(&bas, img_bas + count); count += bas_generate(&bas, img_bas + count);
count += bas_generate(&bas, img_bas + count); count += bas_generate(&bas, img_bas + count);
@ -513,7 +513,7 @@ int main(int argc, char *argv[])
if (!wave_file) { if (!wave_file) {
#ifdef HAVE_SDR #ifdef HAVE_SDR
rc = sdr_configure(samplerate); rc = sdr_configure(dsp_samplerate);
if (rc < 0) if (rc < 0)
return rc; return rc;
#endif #endif

View File

@ -93,7 +93,7 @@ int main(int argc, char *argv[])
fm_init(fast_math); fm_init(fast_math);
zeit_init(audio_level_dBm, alerting); zeit_init(audio_level_dBm, alerting);
main_mobile("zeitansage", &quit, latency, interval, NULL, "1191", 4); main_mobile("zeitansage", &quit, NULL, "1191", 4);
//fail: //fail:
/* exits */ /* exits */