Rework on audio interface

Sound instance is now called audio instance and uses funcation pointers.
This gives a clean interface to be exchanged with other technologies,
linke SDR.
This commit is contained in:
Andreas Eversberg
2017-01-04 14:14:02 +01:00
parent d54d3ac265
commit 9ff8c3bb25
29 changed files with 231 additions and 162 deletions

View File

@@ -83,7 +83,7 @@ double amps_channel2freq(int channel, int uplink)
if (uplink)
freq -= 45.000;
return freq;
return freq * 1e6;
}
enum amps_chan_type amps_channel2type(int channel)
@@ -376,7 +376,7 @@ static amps_t *search_pc(void)
static void amps_go_idle(amps_t *amps);
/* Create transceiver instance and link to a list. */
int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev, int samplerate, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback)
int amps_create(int channel, enum amps_chan_type chan_type, const char *audiodev, int samplerate, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback)
{
sender_t *sender;
amps_t *amps;
@@ -442,7 +442,7 @@ int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev
PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %d (sample rate %d).\n", channel, samplerate);
/* init general part of transceiver */
rc = sender_create(&amps->sender, channel, sounddev, samplerate, rx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
rc = sender_create(&amps->sender, channel, amps_channel2freq(channel, 0), amps_channel2freq(channel, 1), audiodev, samplerate, rx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;
@@ -919,7 +919,7 @@ void call_rx_audio(int callref, int16_t *samples, int count)
int16_t up[(int)((double)count * amps->sender.srstate.factor + 0.5) + 10];
compress_audio(&amps->cstate, samples, count);
count = samplerate_upsample(&amps->sender.srstate, samples, count, up);
jitter_save(&amps->sender.audio, up, count);
jitter_save(&amps->sender.dejitter, up, count);
}
}

View File

@@ -163,7 +163,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(int channel, enum amps_chan_type chan_type, const char *sounddev, int samplerate, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback);
int amps_create(int channel, enum amps_chan_type chan_type, const char *audiodev, int samplerate, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback);
void amps_destroy(sender_t *sender);
void amps_rx_signaling_tone(amps_t *amps, int tone, double quality);
void amps_rx_sat(amps_t *amps, int tone, double quality);

View File

@@ -481,7 +481,7 @@ again:
test_tone_encode(amps, samples, length);
break;
case DSP_MODE_AUDIO_RX_AUDIO_TX:
jitter_load(&amps->sender.audio, samples, length);
jitter_load(&amps->sender.dejitter, samples, length);
/* pre-emphasis */
if (amps->pre_emphasis)
pre_emphasis(&amps->estate, samples, length);

View File

@@ -1701,7 +1701,7 @@ static const char *ie_chan(uint64_t value)
if (value == 0)
return "No channel";
sprintf(string, "%" PRIu64 " = %.3f MHz", value, amps_channel2freq(value, 0));
sprintf(string, "%" PRIu64 " = %.3f MHz", value, amps_channel2freq(value, 0) / 1e6);
return string;
}

View File

@@ -259,9 +259,9 @@ int main(int argc, char *argv[])
print_help(argv[-skip_args]);
return 0;
}
if (num_kanal == 1 && num_sounddev == 0)
num_sounddev = 1; /* use defualt */
if (num_kanal != num_sounddev) {
if (num_kanal == 1 && num_audiodev == 0)
num_audiodev = 1; /* use defualt */
if (num_kanal != num_audiodev) {
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
exit(0);
}
@@ -291,7 +291,7 @@ int main(int argc, char *argv[])
}
dsp_init();
init_frame();
rc = call_init(station_id, call_sounddev, samplerate, latency, 10, loopback);
rc = call_init(station_id, call_audiodev, samplerate, latency, 10, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create call control instance. Quitting!\n");
goto fail;
@@ -348,15 +348,15 @@ int main(int argc, char *argv[])
amps_si si;
init_sysinfo(&si, ms_power, ms_power, dcc, sid >> 1, regh, regr, pureg, pdreg, locaid, regincr, bis);
rc = amps_create(kanal[i], chan_type[i], sounddev[i], samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, &si, sid, scc, polarity, tolerant, loopback);
rc = amps_create(kanal[i], chan_type[i], audiodev[i], samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, &si, sid, scc, polarity, tolerant, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail;
}
printf("Base station on channel %d ready (%s), please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], chan_type_long_name(chan_type[i]), amps_channel2freq(kanal[i], 0), amps_channel2freq(kanal[i], 1));
printf("Base station on channel %d ready (%s), please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], chan_type_long_name(chan_type[i]), amps_channel2freq(kanal[i], 0) / 1e6, amps_channel2freq(kanal[i], 1) / 1e6);
}
main_loop(&quit, latency, interval, NULL);
main_common(&quit, latency, interval, NULL);
fail:
/* cleanup functions */