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:
@@ -624,7 +624,7 @@ again:
|
||||
switch (nmt->dsp_mode) {
|
||||
case DSP_MODE_AUDIO:
|
||||
case DSP_MODE_DTMF:
|
||||
jitter_load(&nmt->sender.audio, samples, length);
|
||||
jitter_load(&nmt->sender.dejitter, samples, length);
|
||||
/* send after dejitter, so audio is flushed */
|
||||
if (nmt->dms.frame_valid) {
|
||||
fsk_dms_frame(nmt, samples, length);
|
||||
|
||||
@@ -281,9 +281,9 @@ int main(int argc, char *argv[])
|
||||
printf("No channel (\"Kanal\") is specified, I suggest channel 1 (-k 1).\n\n");
|
||||
mandatory = 1;
|
||||
}
|
||||
if (num_kanal == 1 && num_sounddev == 0)
|
||||
num_sounddev = 1; /* use defualt */
|
||||
if (num_kanal != num_sounddev) {
|
||||
if (num_kanal == 1 && num_audiodev == 0)
|
||||
num_audiodev = 1; /* use defualt */
|
||||
if (num_kanal != num_audiodev) {
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
@@ -335,7 +335,7 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
dsp_init();
|
||||
rc = call_init(station_id, call_sounddev, samplerate, latency, 7, loopback);
|
||||
rc = call_init(station_id, call_audiodev, samplerate, latency, 7, loopback);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to create call control instance. Quitting!\n");
|
||||
goto fail;
|
||||
@@ -343,21 +343,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* create transceiver instance */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
rc = nmt_create(kanal[i], (loopback) ? CHAN_TYPE_TEST : chan_type[i], sounddev[i], samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, ms_power, nmt_digits2value(traffic_area, 2), area_no, compandor, supervisory, smsc_number, send_callerid, loopback);
|
||||
rc = nmt_create(kanal[i], (loopback) ? CHAN_TYPE_TEST : chan_type[i], audiodev[i], samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, ms_power, nmt_digits2value(traffic_area, 2), area_no, compandor, supervisory, smsc_number, send_callerid, loopback);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to create transceiver instance. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
if (kanal[i] > 200) {
|
||||
printf("Base station on channel %d ready, please tune transmitter to %.4f MHz and receiver to %.4f MHz.\n", kanal[i], nmt_channel2freq(kanal[i], 0), nmt_channel2freq(kanal[i], 1));
|
||||
printf("Base station on channel %d ready, please tune transmitter to %.4f MHz and receiver to %.4f MHz.\n", kanal[i], nmt_channel2freq(kanal[i], 0) / 1e6, nmt_channel2freq(kanal[i], 1) / 1e6);
|
||||
} else {
|
||||
printf("Base station on channel %d ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], nmt_channel2freq(kanal[i], 0), nmt_channel2freq(kanal[i], 1));
|
||||
printf("Base station on channel %d ready, please tune transmitter to %.3f MHz and receiver to %.3f MHz.\n", kanal[i], nmt_channel2freq(kanal[i], 0) / 1e6, nmt_channel2freq(kanal[i], 1) / 1e6);
|
||||
}
|
||||
}
|
||||
|
||||
nmt_check_channels();
|
||||
|
||||
main_loop(&quit, latency, interval, myhandler);
|
||||
main_common(&quit, latency, interval, myhandler);
|
||||
|
||||
fail:
|
||||
/* fifo */
|
||||
|
||||
@@ -218,7 +218,7 @@ double nmt_channel2freq(int channel, int uplink)
|
||||
if (uplink)
|
||||
freq -= 10.000;
|
||||
|
||||
return freq;
|
||||
return freq * 1e6;
|
||||
}
|
||||
|
||||
/* convert 7-digits dial string to NMT number */
|
||||
@@ -303,7 +303,7 @@ uint8_t nmt_country_by_short_name(const char *short_name)
|
||||
static void nmt_timeout(struct timer *timer);
|
||||
|
||||
/* Create transceiver instance and link to a list. */
|
||||
int nmt_create(int channel, enum nmt_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, 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 channel, enum nmt_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, 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;
|
||||
int rc;
|
||||
@@ -334,7 +334,7 @@ int nmt_create(int channel, enum nmt_chan_type chan_type, const char *sounddev,
|
||||
PDEBUG(DNMT, DEBUG_DEBUG, "Creating 'NMT' instance for channel = %d (sample rate %d).\n", channel, samplerate);
|
||||
|
||||
/* init general part of transceiver */
|
||||
rc = sender_create(&nmt->sender, channel, sounddev, samplerate, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
|
||||
rc = sender_create(&nmt->sender, channel, nmt_channel2freq(channel, 0), nmt_channel2freq(channel, 1), audiodev, samplerate, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
|
||||
if (rc < 0) {
|
||||
PDEBUG(DNMT, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||
goto error;
|
||||
@@ -1816,7 +1816,7 @@ void call_rx_audio(int callref, int16_t *samples, int count)
|
||||
if (nmt->compandor)
|
||||
compress_audio(&nmt->cstate, samples, count);
|
||||
count = samplerate_upsample(&nmt->sender.srstate, samples, count, up);
|
||||
jitter_save(&nmt->sender.audio, up, count);
|
||||
jitter_save(&nmt->sender.dejitter, up, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ const char *chan_type_long_name(enum nmt_chan_type chan_type);
|
||||
double nmt_channel2freq(int channel, int uplink);
|
||||
void nmt_country_list(void);
|
||||
uint8_t nmt_country_by_short_name(const char *short_name);
|
||||
int nmt_create(int channel, enum nmt_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, 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 channel, enum nmt_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, 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(void);
|
||||
void nmt_destroy(sender_t *sender);
|
||||
void nmt_go_idle(nmt_t *nmt);
|
||||
|
||||
Reference in New Issue
Block a user