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_bufferpull/1/head
parent
de685b3cb6
commit
6fa74a1296
|
@ -348,7 +348,7 @@ Find out what band and channels your phone supports. Then get a list of all avai
|
|||
|
||||
<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.
|
||||
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.
|
||||
Transmit with a normal loud speech volume, but not too loud.
|
||||
The actual level is not yet relevant.
|
||||
|
@ -356,7 +356,7 @@ The actual level is not yet relevant.
|
|||
|
||||
<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:336 notice : Created channel #YK
|
||||
|
@ -382,7 +382,7 @@ If the phone transmits, your base station should respond to the seize sequence b
|
|||
|
||||
<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:336 notice : Created channel #YK
|
||||
|
|
|
@ -491,7 +491,7 @@ static amps_t *search_pc(void)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
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);
|
||||
|
||||
/* init general part of transceiver */
|
||||
rc = sender_create(&s->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(&s->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) {
|
||||
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||
goto error;
|
||||
|
|
|
@ -174,7 +174,7 @@ const char *amps_min12number(uint32_t min1);
|
|||
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_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_go_idle(amps_t *amps);
|
||||
void amps_rx_signaling_tone(amps_t *amps, int tone, double quality);
|
||||
|
|
|
@ -235,7 +235,7 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
|
|||
int i;
|
||||
|
||||
/* override default */
|
||||
samplerate = 96000;
|
||||
dsp_samplerate = 96000;
|
||||
|
||||
main_mobile_init();
|
||||
|
||||
|
@ -269,10 +269,10 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
if (use_sdr) {
|
||||
/* set audiodev */
|
||||
/* set device */
|
||||
for (i = 0; i < num_kanal; i++)
|
||||
audiodev[i] = "sdr";
|
||||
num_audiodev = num_kanal;
|
||||
dsp_device[i] = "sdr";
|
||||
num_device = num_kanal;
|
||||
/* set channel types for more than 1 channel */
|
||||
if (num_kanal > 1 && num_chan_type == 0) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
if (num_kanal == 1 && num_device == 0)
|
||||
num_device = 1; /* use default */
|
||||
if (num_kanal != num_device) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
@ -320,8 +320,8 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
|
|||
|
||||
}
|
||||
|
||||
if (bis && latency > 5) {
|
||||
fprintf(stderr, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--latency 5).\n");
|
||||
if (bis && dsp_buffer > 5) {
|
||||
fprintf(stderr, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--buffer 5).\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ int main_amps_tacs(const char *name, int argc, char *argv[])
|
|||
amps_si si;
|
||||
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
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);
|
||||
}
|
||||
|
||||
main_mobile(name, &quit, latency, interval, NULL, station_id, 10);
|
||||
main_mobile(name, &quit, NULL, station_id, 10);
|
||||
|
||||
fail:
|
||||
/* destroy transceiver instance */
|
||||
|
|
|
@ -183,7 +183,7 @@ static void anetz_timeout(struct timer *timer);
|
|||
static void anetz_go_idle(anetz_t *anetz);
|
||||
|
||||
/* 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;
|
||||
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);
|
||||
|
||||
/* 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) {
|
||||
PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
|
||||
goto error;
|
||||
|
|
|
@ -54,7 +54,7 @@ typedef struct anetz {
|
|||
|
||||
double anetz_kanal2freq(int kanal, int unterband);
|
||||
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_loss_indication(anetz_t *anetz, double loss_time);
|
||||
void anetz_receive_tone(anetz_t *anetz, int bit);
|
||||
|
|
|
@ -161,14 +161,14 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
if (use_sdr) {
|
||||
/* set audiodev */
|
||||
/* set device */
|
||||
for (i = 0; i < num_kanal; i++)
|
||||
audiodev[i] = "sdr";
|
||||
num_audiodev = num_kanal;
|
||||
dsp_device[i] = "sdr";
|
||||
num_device = num_kanal;
|
||||
}
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
if (num_kanal == 1 && num_device == 0)
|
||||
num_device = 1; /* use default */
|
||||
if (num_kanal != num_device) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* create transceiver instance */
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
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);
|
||||
}
|
||||
|
||||
main_mobile("anetz", &quit, latency, interval, NULL, station_id, 5);
|
||||
main_mobile("anetz", &quit, NULL, station_id, 5);
|
||||
|
||||
fail:
|
||||
/* destroy transceiver instance */
|
||||
|
|
|
@ -154,7 +154,7 @@ static void bnetz_timeout(struct timer *timer);
|
|||
static void bnetz_go_idle(bnetz_t *bnetz);
|
||||
|
||||
/* Create transceiver instance and link to a list. */
|
||||
int bnetz_create(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;
|
||||
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);
|
||||
|
||||
/* 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) {
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||
goto error;
|
||||
|
|
|
@ -113,7 +113,7 @@ typedef struct bnetz {
|
|||
|
||||
double bnetz_kanal2freq(int kanal, int unterband);
|
||||
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_loss_indication(bnetz_t *bnetz, double loss_time);
|
||||
void bnetz_receive_tone(bnetz_t *bnetz, int bit);
|
||||
|
|
|
@ -42,10 +42,10 @@
|
|||
char start_digit = 's';
|
||||
const char *station_id = "50993";
|
||||
const char *dialing;
|
||||
const char *audiodev = "hw:0,0";
|
||||
int samplerate = 48000;
|
||||
const char *dsp_audiodev = "hw:0,0";
|
||||
int dsp_samplerate = 48000;
|
||||
const char *write_tx_wave = NULL;
|
||||
int latency = 50;
|
||||
int dsp_buffer = 50;
|
||||
|
||||
/* states */
|
||||
enum tx_mode {
|
||||
|
@ -58,7 +58,6 @@ char funkwahl[128];
|
|||
int digit_pos = 0;
|
||||
const char *tx_telegramm = NULL;
|
||||
int tx_telegramm_pos = 0;
|
||||
int latspl;
|
||||
|
||||
/* instances */
|
||||
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);
|
||||
#ifdef HAVE_ALSA
|
||||
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
|
||||
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(" Write audio to given wave file also.\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]);
|
||||
break;
|
||||
case 'a':
|
||||
audiodev = options_strdup(argv[argi]);
|
||||
dsp_audiodev = options_strdup(argv[argi]);
|
||||
break;
|
||||
case 's':
|
||||
samplerate = atoi(argv[argi]);
|
||||
dsp_samplerate = atoi(argv[argi]);
|
||||
break;
|
||||
case 'w':
|
||||
write_tx_wave = options_strdup(argv[argi]);
|
||||
|
@ -216,7 +215,7 @@ again:
|
|||
case TX_MODE_SILENCE:
|
||||
memset(samples, 0, length * sizeof(*samples));
|
||||
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])
|
||||
tx_mode = TX_MODE_FSK;
|
||||
else
|
||||
|
@ -239,18 +238,18 @@ again:
|
|||
/* loop that gets audio from encoder and forwards it to sound card.
|
||||
* 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 };
|
||||
uint8_t pbuff[latspl], *power[1] = { pbuff };
|
||||
sample_t buff[buffer_size], *samples[1] = { buff };
|
||||
uint8_t pbuff[buffer_size], *power[1] = { pbuff };
|
||||
int count;
|
||||
int __attribute__((unused)) rc;
|
||||
|
||||
while (tx_mode != TX_MODE_DONE) {
|
||||
#ifdef HAVE_ALSA
|
||||
count = sound_get_tosend(audio, latspl);
|
||||
count = sound_get_tosend(audio, buffer_size);
|
||||
#else
|
||||
count = samplerate / 1000;
|
||||
count = dsp_samplerate / 1000;
|
||||
#endif
|
||||
if (count < 0) {
|
||||
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 rc, argi;
|
||||
int buffer_size;
|
||||
|
||||
/* init */
|
||||
bnetz_init_telegramm();
|
||||
memset(&fsk_mod, 0, sizeof(fsk_mod));
|
||||
|
||||
/* latency of send buffer in samples */
|
||||
latspl = samplerate * latency / 1000;
|
||||
/* size of send buffer in samples */
|
||||
buffer_size = dsp_samplerate * dsp_buffer / 1000;
|
||||
|
||||
/* handle options / config file */
|
||||
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);
|
||||
|
||||
/* 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");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
/* 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) {
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n");
|
||||
goto exit;
|
||||
|
@ -355,7 +355,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* open 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) {
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
||||
goto exit;
|
||||
|
@ -375,7 +375,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n");
|
||||
|
||||
process_signal();
|
||||
process_signal(buffer_size);
|
||||
|
||||
exit:
|
||||
/* close wave */
|
||||
|
|
|
@ -160,14 +160,14 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
if (use_sdr) {
|
||||
/* set audiodev */
|
||||
/* set device */
|
||||
for (i = 0; i < num_kanal; i++)
|
||||
audiodev[i] = "sdr";
|
||||
num_audiodev = num_kanal;
|
||||
dsp_device[i] = "sdr";
|
||||
num_device = num_kanal;
|
||||
}
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
if (num_kanal == 1 && num_device == 0)
|
||||
num_device = 1; /*deviceuse default */
|
||||
if (num_kanal != num_device) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* create transceiver instance */
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
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);
|
||||
}
|
||||
|
||||
main_mobile("bnetz", &quit, latency, interval, NULL, station_id, 5);
|
||||
main_mobile("bnetz", &quit, NULL, station_id, 5);
|
||||
|
||||
fail:
|
||||
/* destroy transceiver instance */
|
||||
|
|
|
@ -264,7 +264,7 @@ int cnetz_init(void)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
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) {
|
||||
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");
|
||||
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 */
|
||||
/* 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) {
|
||||
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||
goto error;
|
||||
|
|
|
@ -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_long_name(enum cnetz_chan_type chan_type);
|
||||
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_go_idle(cnetz_t *cnetz);
|
||||
void cnetz_sync_frame(cnetz_t *cnetz, double sync, int ts);
|
||||
|
|
|
@ -516,10 +516,10 @@ int main(int argc, char *argv[])
|
|||
mandatory = 1;
|
||||
}
|
||||
if (use_sdr) {
|
||||
/* set audiodev */
|
||||
/* set device */
|
||||
for (i = 0; i < num_kanal; i++)
|
||||
audiodev[i] = "sdr";
|
||||
num_audiodev = num_kanal;
|
||||
dsp_device[i] = "sdr";
|
||||
num_device = num_kanal;
|
||||
/* set channel types for more than 1 channel */
|
||||
if (num_kanal > 1 && num_chan_type == 0) {
|
||||
chan_type[0] = CHAN_TYPE_OGK;
|
||||
|
@ -528,9 +528,9 @@ int main(int argc, char *argv[])
|
|||
num_chan_type = num_kanal;
|
||||
}
|
||||
}
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
if (num_kanal == 1 && num_device == 0)
|
||||
num_device = 1; /* use default */
|
||||
if (num_kanal != num_device) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* create transceiver instance */
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
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:
|
||||
flush_db();
|
||||
|
|
|
@ -1381,7 +1381,7 @@ error:
|
|||
}
|
||||
|
||||
/* 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 rc;
|
||||
|
@ -1390,12 +1390,12 @@ int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int latency,
|
|||
if (datenklo->slave)
|
||||
channels = 2;
|
||||
|
||||
/* latency of send buffer in samples */
|
||||
datenklo->latspl = datenklo->samplerate * latency / 1000;
|
||||
/* size of send buffer in samples */
|
||||
datenklo->buffer_size = datenklo->samplerate * buffer / 1000;
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
/* 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) {
|
||||
PDEBUG(DDATENKLO, DEBUG_ERROR, "No sound device!\n");
|
||||
return -EIO;
|
||||
|
@ -1484,8 +1484,8 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
|
|||
if (datenklo->slave)
|
||||
num_chan = 2;
|
||||
|
||||
sample_t buff[num_chan][datenklo->latspl], *samples[num_chan];
|
||||
uint8_t pbuff[num_chan][datenklo->latspl], *power[num_chan];
|
||||
sample_t buff[num_chan][datenklo->buffer_size], *samples[num_chan];
|
||||
uint8_t pbuff[num_chan][datenklo->buffer_size], *power[num_chan];
|
||||
for (i = 0; i < num_chan; i++) {
|
||||
samples[i] = buff[i];
|
||||
power[i] = pbuff[i];
|
||||
|
@ -1524,7 +1524,7 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
|
|||
process_timer();
|
||||
|
||||
#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) {
|
||||
PDEBUG(DDSP, DEBUG_ERROR, "Failed to read RX data from audio device (rc = %d)\n", count);
|
||||
if (count == -EPIPE) {
|
||||
|
@ -1556,7 +1556,7 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
|
|||
}
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
count = sound_get_tosend(datenklo->audio, datenklo->latspl);
|
||||
count = sound_get_tosend(datenklo->audio, datenklo->buffer_size);
|
||||
#else
|
||||
count = samplerate / 1000;
|
||||
#endif
|
||||
|
@ -1576,7 +1576,7 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
|
|||
}
|
||||
if (loopback) {
|
||||
/* 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));
|
||||
if (loopback == 2 && num_chan == 2) {
|
||||
/* swap */
|
||||
|
|
|
@ -19,7 +19,7 @@ typedef struct datenklo {
|
|||
double force_tx_baud, force_rx_baud; /* override IOCTL */
|
||||
int tx_back, rx_back; /* set if back channel is used for path */
|
||||
int samplerate; /* audio sample rate */
|
||||
int latspl; /* latenc */
|
||||
int buffer_size; /* audio buffer size */
|
||||
int loopback; /* loopback mode */
|
||||
|
||||
/* states */
|
||||
|
@ -86,7 +86,7 @@ typedef struct datenklo {
|
|||
|
||||
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_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_init_global(void);
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ static int tx_baudrate[MAX_DEVICES] = { 0 }, rx_baudrate[MAX_DEVICES] = { 0 };
|
|||
static int num_ttydev = 0;
|
||||
static const char *ttydev[MAX_DEVICES] = { "/dev/ttyDATENKLO0" };
|
||||
static const char *audiodev = "hw:0,0";
|
||||
static int samplerate = 48000;
|
||||
static int latency = 50;
|
||||
static int dsp_samplerate = 48000;
|
||||
static int dsp_buffer = 50;
|
||||
static int stereo = 0;
|
||||
static int loopback = 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(" Sound card and device number (default = '%s')\n", audiodev);
|
||||
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(" 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(" Perform audio loopback to test modem.\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]);
|
||||
break;
|
||||
case 's':
|
||||
samplerate = atoi(argv[argi]);
|
||||
dsp_samplerate = atoi(argv[argi]);
|
||||
break;
|
||||
case 'b':
|
||||
latency = atoi(argv[argi]);
|
||||
dsp_buffer = atoi(argv[argi]);
|
||||
break;
|
||||
case 'l':
|
||||
loopback = atoi(argv[argi]);
|
||||
|
@ -298,7 +298,7 @@ int main(int argc, char *argv[])
|
|||
/* increment last name */
|
||||
if (i && ttydev[i] == NULL)
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Datenklo\" instance. Quitting!\n");
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
fprintf(stderr, "Failed to initialize audio. Quitting!\n");
|
||||
goto fail;
|
||||
|
|
|
@ -237,7 +237,7 @@ void euro_exit(void)
|
|||
static void call_timeout(struct timer *timer);
|
||||
|
||||
/* 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;
|
||||
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);
|
||||
|
||||
/* 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) {
|
||||
PDEBUG(DEURO, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||
goto error;
|
||||
|
|
|
@ -82,7 +82,7 @@ double euro_kanal2freq(const char *kanal, int fm);
|
|||
void euro_list_channels(void);
|
||||
int euro_init(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_get_id(euro_t *euro, char *id);
|
||||
void euro_receive_id(euro_t *euro, char *id);
|
||||
|
|
|
@ -208,21 +208,21 @@ int main(int argc, char *argv[])
|
|||
goto fail;
|
||||
}
|
||||
if (use_sdr) {
|
||||
/* set audiodev */
|
||||
/* set device */
|
||||
for (i = 0; i < num_kanal; i++)
|
||||
audiodev[i] = "sdr";
|
||||
num_audiodev = num_kanal;
|
||||
dsp_device[i] = "sdr";
|
||||
num_device = num_kanal;
|
||||
}
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
if (num_kanal == 1 && num_device == 0)
|
||||
num_device = 1; /* use default */
|
||||
if (num_kanal != num_device) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* inits */
|
||||
fm_init(fast_math);
|
||||
dsp_init(samplerate);
|
||||
dsp_init(dsp_samplerate);
|
||||
euro_init();
|
||||
|
||||
/* TX is default */
|
||||
|
@ -231,7 +231,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* create transceiver instance */
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
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);
|
||||
}
|
||||
|
||||
main_mobile("eurosignal", &quit, latency, interval, NULL, station_id, 6);
|
||||
main_mobile("eurosignal", &quit, NULL, station_id, 6);
|
||||
|
||||
fail:
|
||||
/* destroy transceiver instance */
|
||||
|
|
|
@ -195,9 +195,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use default */
|
||||
if (num_kanal != num_audiodev) {
|
||||
if (num_kanal == 1 && num_device == 0)
|
||||
num_device = 1; /* use default */
|
||||
if (num_kanal != num_device) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ int main(int argc, char *argv[])
|
|||
fm_init(fast_math);
|
||||
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Kanal\" instance. Quitting!\n");
|
||||
goto fail;
|
||||
|
@ -270,7 +270,7 @@ int main(int argc, char *argv[])
|
|||
if (config_loaded)
|
||||
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:
|
||||
|
||||
/* destroy transceiver instance */
|
||||
|
|
|
@ -198,17 +198,17 @@ int main(int argc, char *argv[])
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (num_audiodev <= 1)
|
||||
audiodev[1] = audiodev[0];
|
||||
if (num_device <= 1)
|
||||
dsp_device[1] = dsp_device[0];
|
||||
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));
|
||||
if (!sniffer) {
|
||||
PDEBUG(DCNETZ, DEBUG_ERROR, "No memory!\n");
|
||||
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) {
|
||||
fprintf(stderr, "Failed to create \"Sniffer\" instance. Quitting!\n");
|
||||
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);
|
||||
|
||||
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)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
main_mobile(NULL, &quit, latency, interval, NULL, NULL, 0);
|
||||
main_mobile(NULL, &quit, NULL, NULL, 0);
|
||||
|
||||
fail:
|
||||
/* destroy transceiver instance */
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
/* presets */
|
||||
const char *station_id = "6681739";
|
||||
const char *dialing;
|
||||
const char *audiodev = "hw:0,0";
|
||||
int samplerate = 48000;
|
||||
const char *dsp_audiodev = "hw:0,0";
|
||||
int dsp_samplerate = 48000;
|
||||
const char *write_tx_wave = NULL;
|
||||
int latency = 50;
|
||||
int dsp_buffer = 50;
|
||||
|
||||
#define TONE_DONE -1
|
||||
#define TONE_SILENCE 0
|
||||
|
@ -53,7 +53,6 @@ static struct dial_string {
|
|||
int length;
|
||||
} dial_string[2048];
|
||||
static int dial_pos = 0;
|
||||
static int latspl;
|
||||
|
||||
/* instances */
|
||||
#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);
|
||||
#ifdef HAVE_ALSA
|
||||
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
|
||||
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(" 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]);
|
||||
break;
|
||||
case 'a':
|
||||
audiodev = options_strdup(argv[argi]);
|
||||
dsp_audiodev = options_strdup(argv[argi]);
|
||||
break;
|
||||
case 's':
|
||||
samplerate = atoi(argv[argi]);
|
||||
dsp_samplerate = atoi(argv[argi]);
|
||||
break;
|
||||
case 'w':
|
||||
write_tx_wave = options_strdup(argv[argi]);
|
||||
|
@ -148,7 +147,7 @@ again:
|
|||
default:
|
||||
for (i = 0; i < count; i++) {
|
||||
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.
|
||||
* 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 };
|
||||
uint8_t pbuff[latspl], *power[1] = { pbuff };
|
||||
sample_t buff[buffer_size], *samples[1] = { buff };
|
||||
uint8_t pbuff[buffer_size], *power[1] = { pbuff };
|
||||
int count;
|
||||
int __attribute__((unused)) rc;
|
||||
|
||||
while (dial_string[dial_pos].tone != TONE_DONE) {
|
||||
#ifdef HAVE_ALSA
|
||||
count = sound_get_tosend(audio, latspl);
|
||||
count = sound_get_tosend(audio, buffer_size);
|
||||
#else
|
||||
count = samplerate / 1000;
|
||||
count = dsp_samplerate / 1000;
|
||||
#endif
|
||||
if (count < 0) {
|
||||
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 i, d, p, pulses, tone = 0;
|
||||
int buffer_size;
|
||||
int rc, argi;
|
||||
|
||||
memset(dial_string, 0, sizeof(dial_string));
|
||||
|
||||
/* latency of send buffer in samples */
|
||||
latspl = samplerate * latency / 1000;
|
||||
/* size of send buffer in samples */
|
||||
buffer_size = dsp_samplerate * dsp_buffer / 1000;
|
||||
|
||||
/* handle options / config file */
|
||||
add_options();
|
||||
|
@ -248,7 +248,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
dialing = argv[argi];
|
||||
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")) {
|
||||
/* check for valid phone number */
|
||||
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].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].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++) {
|
||||
pulses = station_id[i] - '0';
|
||||
if (pulses == 0)
|
||||
|
@ -277,37 +277,37 @@ int main(int argc, char *argv[])
|
|||
tone = TONE_SILENCE;
|
||||
else
|
||||
tone = TONE_GUARD;
|
||||
dial_string[d].tone = TONE_CONNECT; dial_string[d++].length = 0.025 * (double)samplerate; /* mark */
|
||||
dial_string[d].tone = tone; dial_string[d++].length = 0.025 * (double)samplerate; /* space */
|
||||
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)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].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++) {
|
||||
pulses = dialing[i] - '0';
|
||||
if (pulses == 0)
|
||||
pulses = 10;
|
||||
dial_string[d].console = dialing[i];
|
||||
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_GUARD; dial_string[d++].length = 0.040 * (double)samplerate; /* space */
|
||||
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)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';
|
||||
} else {
|
||||
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_GUARD; dial_string[d++].length = 0.025 * (double)samplerate; /* space */
|
||||
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)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 */
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
/* 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) {
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n");
|
||||
goto exit;
|
||||
|
@ -316,7 +316,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* open 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) {
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
||||
goto exit;
|
||||
|
@ -336,7 +336,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n");
|
||||
|
||||
process_signal();
|
||||
process_signal(buffer_size);
|
||||
|
||||
exit:
|
||||
/* close wave */
|
||||
|
|
|
@ -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);
|
||||
|
||||
/* 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;
|
||||
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 */
|
||||
/* 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) {
|
||||
PDEBUG(DIMTS, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
|
||||
goto error;
|
||||
|
|
|
@ -129,7 +129,7 @@ typedef struct imts {
|
|||
void imts_list_channels(void);
|
||||
double imts_channel2freq(const char *kanal, int uplink);
|
||||
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_loss_indication(imts_t *imts, double loss_time);
|
||||
void imts_signal_indication(imts_t *imts);
|
||||
|
|
|
@ -50,7 +50,7 @@ static double detector_test_length_3 = 0.0;
|
|||
|
||||
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(" Use given RF level to detect loss of signal. When the signal gets lost\n");
|
||||
|