Add support for AM to libmobile and libsdr
This commit is contained in:
@@ -55,6 +55,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
amps_LDADD += \
|
amps_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -44,6 +44,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
anetz_LDADD += \
|
anetz_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -61,6 +61,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
bnetz_LDADD += \
|
bnetz_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
/* init sound */
|
/* init sound */
|
||||||
audio = sound_open(audiodev, NULL, NULL, 1, 0.0, samplerate, latspl, 1.0, 4000.0);
|
audio = sound_open(audiodev, NULL, NULL, NULL, 1, 0.0, samplerate, latspl, 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;
|
||||||
|
@@ -44,6 +44,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
cnetz_LDADD += \
|
cnetz_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -1395,7 +1395,7 @@ int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int latency,
|
|||||||
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
/* init sound */
|
/* init sound */
|
||||||
datenklo->audio = sound_open(audiodev, NULL, NULL, channels, 0.0, datenklo->samplerate, datenklo->latspl, 1.0, 4000.0);
|
datenklo->audio = sound_open(audiodev, NULL, NULL, NULL, channels, 0.0, datenklo->samplerate, datenklo->latspl, 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;
|
||||||
|
@@ -52,6 +52,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
imts_LDADD += \
|
imts_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -307,7 +307,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
/* init sound */
|
/* init sound */
|
||||||
audio = sound_open(audiodev, NULL, NULL, 1, 0.0, samplerate, latspl, 1.0, 4000.0);
|
audio = sound_open(audiodev, NULL, NULL, NULL, 1, 0.0, samplerate, latspl, 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;
|
||||||
|
@@ -38,6 +38,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
jollycom_LDADD += \
|
jollycom_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -38,6 +38,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
jtacs_LDADD += \
|
jtacs_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -111,8 +111,8 @@ void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, int num, float *bas
|
|||||||
else if (phase >= 65536.0)
|
else if (phase >= 65536.0)
|
||||||
phase -= 65536.0;
|
phase -= 65536.0;
|
||||||
} else {
|
} else {
|
||||||
*baseband++ = cos(phase) * vector;
|
*baseband++ += cos(phase) * vector;
|
||||||
*baseband++ = sin(phase) * vector;
|
*baseband++ += sin(phase) * vector;
|
||||||
phase += rot;
|
phase += rot;
|
||||||
if (phase < 0.0)
|
if (phase < 0.0)
|
||||||
phase += 2.0 * M_PI;
|
phase += 2.0 * M_PI;
|
||||||
|
@@ -299,7 +299,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, 1, 0.0, console.samplerate, latspl, 1.4, 4000.0);
|
console.sound = sound_open(console.audiodev, NULL, NULL, NULL, 1, 0.0, console.samplerate, latspl, 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;
|
||||||
|
@@ -183,36 +183,38 @@ int sender_open_audio(int latspl)
|
|||||||
channels++;
|
channels++;
|
||||||
}
|
}
|
||||||
double tx_f[channels], rx_f[channels], paging_frequency = 0.0;
|
double tx_f[channels], rx_f[channels], paging_frequency = 0.0;
|
||||||
|
int am[channels];
|
||||||
for (i = 0, inst = master; inst; i++, inst = inst->slave) {
|
for (i = 0, inst = master; inst; i++, inst = inst->slave) {
|
||||||
tx_f[i] = inst->sendefrequenz;
|
tx_f[i] = inst->sendefrequenz;
|
||||||
rx_f[i] = inst->empfangsfrequenz;
|
rx_f[i] = inst->empfangsfrequenz;
|
||||||
|
am[i] = inst->am;
|
||||||
if (inst->ruffrequenz)
|
if (inst->ruffrequenz)
|
||||||
paging_frequency = inst->ruffrequenz;
|
paging_frequency = inst->ruffrequenz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (master->write_rx_wave) {
|
if (master->write_rx_wave) {
|
||||||
rc = wave_create_record(&master->wave_rx_rec, master->write_rx_wave, master->samplerate, channels, master->max_deviation);
|
rc = wave_create_record(&master->wave_rx_rec, master->write_rx_wave, master->samplerate, channels, (master->max_deviation) ?: 1.0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (master->write_tx_wave) {
|
if (master->write_tx_wave) {
|
||||||
rc = wave_create_record(&master->wave_tx_rec, master->write_tx_wave, master->samplerate, channels, master->max_deviation);
|
rc = wave_create_record(&master->wave_tx_rec, master->write_tx_wave, master->samplerate, channels, (master->max_deviation) ?: 1.0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (master->read_rx_wave) {
|
if (master->read_rx_wave) {
|
||||||
rc = wave_create_playback(&master->wave_rx_play, master->read_rx_wave, &master->samplerate, &channels, master->max_deviation);
|
rc = wave_create_playback(&master->wave_rx_play, master->read_rx_wave, &master->samplerate, &channels, (master->max_deviation) ?: 1.0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
|
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (master->read_tx_wave) {
|
if (master->read_tx_wave) {
|
||||||
rc = wave_create_playback(&master->wave_tx_play, master->read_tx_wave, &master->samplerate, &channels, master->max_deviation);
|
rc = wave_create_playback(&master->wave_tx_play, master->read_tx_wave, &master->samplerate, &channels, (master->max_deviation) ?: 1.0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
|
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
|
||||||
return rc;
|
return rc;
|
||||||
@@ -220,7 +222,7 @@ int sender_open_audio(int latspl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* open device */
|
/* open device */
|
||||||
master->audio = master->audio_open(master->audiodev, tx_f, rx_f, channels, paging_frequency, master->samplerate, latspl, master->max_deviation, master->max_modulation);
|
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);
|
||||||
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;
|
||||||
@@ -293,6 +295,19 @@ void sender_set_fm(sender_t *sender, double max_deviation, double max_modulation
|
|||||||
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Deviation at speech level: %.1f kHz\n", speech_deviation / 1000.0);
|
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Deviation at speech level: %.1f kHz\n", speech_deviation / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set amplitude modulation and parameters */
|
||||||
|
void sender_set_am(sender_t *sender, double max_modulation, double speech_level, double max_display, double modulation_index)
|
||||||
|
{
|
||||||
|
sender->am = 1;
|
||||||
|
sender->max_deviation = 0;
|
||||||
|
sender->max_modulation = max_modulation;
|
||||||
|
sender->speech_deviation = speech_level;
|
||||||
|
sender->max_display = max_display;
|
||||||
|
sender->modulation_index = modulation_index;
|
||||||
|
|
||||||
|
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Modulation degree: %.0f %%, Maximum modulation: %.1f kHz\n", modulation_index / 100.0, max_modulation / 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
static void gain_samples(sample_t *samples, int length, double gain)
|
static void gain_samples(sample_t *samples, int length, double gain)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@@ -33,16 +33,18 @@ typedef struct sender {
|
|||||||
double empfangsfrequenz; /* receiver frequency */
|
double empfangsfrequenz; /* receiver frequency */
|
||||||
double ruffrequenz; /* special paging frequency used for B-Netz */
|
double ruffrequenz; /* special paging frequency used for B-Netz */
|
||||||
|
|
||||||
/* fm levels */
|
/* FM/AM levels */
|
||||||
double max_deviation; /* max frequency deviation */
|
int am; /* use AM instead of FM */
|
||||||
|
double max_deviation; /* max frequency deviation / level */
|
||||||
double max_modulation; /* max frequency modulated */
|
double max_modulation; /* max frequency modulated */
|
||||||
double speech_deviation; /* deviation of 1000 Hz reference tone at speech level */
|
double speech_deviation; /* deviation / level of 1000 Hz reference tone at speech level */
|
||||||
|
double modulation_index; /* AM modulation index */
|
||||||
double max_display; /* level of displaying wave form */
|
double max_display; /* level of displaying wave form */
|
||||||
|
|
||||||
/* audio */
|
/* audio */
|
||||||
void *audio;
|
void *audio;
|
||||||
char audiodev[64]; /* audio device name (alsa or sdr) */
|
char audiodev[64]; /* audio device name (alsa or sdr) */
|
||||||
void *(*audio_open)(const char *, double *, double *, int, double, int, int, double, double);
|
void *(*audio_open)(const char *, double *, double *, int *, int, double, int, int, 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,6 +95,7 @@ extern int cant_recover;
|
|||||||
int sender_create(sender_t *sender, const char *kanal, double sendefrequenz, double empfangsfrequenz, const char *audiodev, int use_sdr, 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, 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 *audiodev, int use_sdr, 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, 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);
|
||||||
int sender_open_audio(int latspl);
|
int sender_open_audio(int latspl);
|
||||||
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 latspl);
|
||||||
|
@@ -30,6 +30,7 @@ enum paging_signal;
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "../libfm/fm.h"
|
#include "../libfm/fm.h"
|
||||||
|
#include "../libam/am.h"
|
||||||
#include "../libtimer/timer.h"
|
#include "../libtimer/timer.h"
|
||||||
#include "../libmobile/sender.h"
|
#include "../libmobile/sender.h"
|
||||||
#include "sdr_config.h"
|
#include "sdr_config.h"
|
||||||
@@ -71,8 +72,11 @@ typedef struct sdr_thread {
|
|||||||
typedef struct sdr_chan {
|
typedef struct sdr_chan {
|
||||||
double tx_frequency; /* frequency used */
|
double tx_frequency; /* frequency used */
|
||||||
double rx_frequency; /* frequency used */
|
double rx_frequency; /* frequency used */
|
||||||
fm_mod_t mod; /* modulator instance */
|
int am; /* use AM instead of FM */
|
||||||
fm_demod_t demod; /* demodulator instance */
|
fm_mod_t fm_mod; /* modulator instance */
|
||||||
|
fm_demod_t fm_demod; /* demodulator instance */
|
||||||
|
am_mod_t am_mod; /* modulator instance */
|
||||||
|
am_demod_t am_demod; /* demodulator instance */
|
||||||
dispmeasparam_t *dmp_rf_level;
|
dispmeasparam_t *dmp_rf_level;
|
||||||
dispmeasparam_t *dmp_freq_offset;
|
dispmeasparam_t *dmp_freq_offset;
|
||||||
dispmeasparam_t *dmp_deviation;
|
dispmeasparam_t *dmp_deviation;
|
||||||
@@ -94,9 +98,10 @@ typedef struct sdr {
|
|||||||
wave_rec_t wave_tx_rec;
|
wave_rec_t wave_tx_rec;
|
||||||
wave_play_t wave_rx_play;
|
wave_play_t wave_rx_play;
|
||||||
wave_play_t wave_tx_play;
|
wave_play_t wave_tx_play;
|
||||||
float *modbuff; /* buffer for FM transmodulation */
|
float *modbuff; /* buffer for transmodulation */
|
||||||
sample_t *modbuff_I;
|
sample_t *modbuff_I;
|
||||||
sample_t *modbuff_Q;
|
sample_t *modbuff_Q;
|
||||||
|
sample_t *modbuff_carrier;
|
||||||
sample_t *wavespl0; /* sample buffer for wave generation */
|
sample_t *wavespl0; /* sample buffer for wave generation */
|
||||||
sample_t *wavespl1;
|
sample_t *wavespl1;
|
||||||
} sdr_t;
|
} sdr_t;
|
||||||
@@ -131,7 +136,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 channels, double paging_frequency, int samplerate, int latspl, double max_deviation, double max_modulation)
|
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)
|
||||||
{
|
{
|
||||||
sdr_t *sdr;
|
sdr_t *sdr;
|
||||||
int threads = 1, oversample = 1; /* always use threads */
|
int threads = 1, oversample = 1; /* always use threads */
|
||||||
@@ -231,6 +236,11 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
|
|||||||
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));
|
||||||
|
if (!sdr->modbuff_carrier) {
|
||||||
|
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
sdr->wavespl0 = calloc(sdr->latspl, sizeof(*sdr->wavespl0));
|
sdr->wavespl0 = calloc(sdr->latspl, sizeof(*sdr->wavespl0));
|
||||||
if (!sdr->wavespl0) {
|
if (!sdr->wavespl0) {
|
||||||
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
|
PDEBUG(DSDR, DEBUG_ERROR, "NO MEM!\n");
|
||||||
@@ -297,7 +307,14 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
|
|||||||
double tx_offset;
|
double tx_offset;
|
||||||
tx_offset = sdr->chan[c].tx_frequency - tx_center_frequency;
|
tx_offset = sdr->chan[c].tx_frequency - tx_center_frequency;
|
||||||
PDEBUG(DSDR, DEBUG_DEBUG, "Frequency #%d: TX offset: %.6f MHz\n", c, tx_offset / 1e6);
|
PDEBUG(DSDR, DEBUG_DEBUG, "Frequency #%d: TX offset: %.6f MHz\n", c, tx_offset / 1e6);
|
||||||
rc = fm_mod_init(&sdr->chan[c].mod, samplerate, tx_offset, sdr->amplitude);
|
sdr->chan[c].am = am[c];
|
||||||
|
if (am[c]) {
|
||||||
|
double gain, bias;
|
||||||
|
gain = modulation_index / 2.0;
|
||||||
|
bias = 1.0 - gain;
|
||||||
|
rc = am_mod_init(&sdr->chan[c].am_mod, samplerate, tx_offset, sdr->amplitude * gain, sdr->amplitude * bias);
|
||||||
|
} else
|
||||||
|
rc = fm_mod_init(&sdr->chan[c].fm_mod, samplerate, tx_offset, sdr->amplitude);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -305,7 +322,7 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
|
|||||||
double tx_offset;
|
double tx_offset;
|
||||||
tx_offset = sdr->chan[sdr->paging_channel].tx_frequency - tx_center_frequency;
|
tx_offset = sdr->chan[sdr->paging_channel].tx_frequency - tx_center_frequency;
|
||||||
PDEBUG(DSDR, DEBUG_DEBUG, "Paging Frequency: TX offset: %.6f MHz\n", tx_offset / 1e6);
|
PDEBUG(DSDR, DEBUG_DEBUG, "Paging Frequency: TX offset: %.6f MHz\n", tx_offset / 1e6);
|
||||||
rc = fm_mod_init(&sdr->chan[sdr->paging_channel].mod, samplerate, tx_offset, sdr->amplitude);
|
rc = fm_mod_init(&sdr->chan[sdr->paging_channel].fm_mod, samplerate, tx_offset, sdr->amplitude);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -400,7 +417,11 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
|
|||||||
double rx_offset;
|
double rx_offset;
|
||||||
rx_offset = sdr->chan[c].rx_frequency - rx_center_frequency;
|
rx_offset = sdr->chan[c].rx_frequency - rx_center_frequency;
|
||||||
PDEBUG(DSDR, DEBUG_DEBUG, "Frequency #%d: RX offset: %.6f MHz\n", c, rx_offset / 1e6);
|
PDEBUG(DSDR, DEBUG_DEBUG, "Frequency #%d: RX offset: %.6f MHz\n", c, rx_offset / 1e6);
|
||||||
rc = fm_demod_init(&sdr->chan[c].demod, samplerate, rx_offset, bandwidth);
|
sdr->chan[c].am = am[c];
|
||||||
|
if (am[c])
|
||||||
|
rc = am_demod_init(&sdr->chan[c].am_demod, samplerate, rx_offset, bandwidth, 1.0 / modulation_index);
|
||||||
|
else
|
||||||
|
rc = fm_demod_init(&sdr->chan[c].fm_demod, samplerate, rx_offset, bandwidth / 2.0);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -428,10 +449,12 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
|
|||||||
if (!sender)
|
if (!sender)
|
||||||
continue;
|
continue;
|
||||||
sdr->chan[c].dmp_rf_level = display_measurements_add(&sender->dispmeas, "RF Level", "%.1f dB", DISPLAY_MEAS_AVG, DISPLAY_MEAS_LEFT, -96.0, 0.0, -INFINITY);
|
sdr->chan[c].dmp_rf_level = display_measurements_add(&sender->dispmeas, "RF Level", "%.1f dB", DISPLAY_MEAS_AVG, DISPLAY_MEAS_LEFT, -96.0, 0.0, -INFINITY);
|
||||||
sdr->chan[c].dmp_freq_offset = display_measurements_add(&sender->dispmeas, "Freq. Offset", "%+.2f KHz", DISPLAY_MEAS_AVG, DISPLAY_MEAS_CENTER, -max_deviation / 1000.0 * 2.0, max_deviation / 1000.0 * 2.0, 0.0);
|
if (!am[c]) {
|
||||||
|
sdr->chan[c].dmp_freq_offset = display_measurements_add(&sender->dispmeas, "Freq. Offset", "%+.2f KHz", DISPLAY_MEAS_AVG, DISPLAY_MEAS_CENTER, -max_modulation / 1000.0 * 2.0, max_modulation / 1000.0 * 2.0, 0.0);
|
||||||
sdr->chan[c].dmp_deviation = display_measurements_add(&sender->dispmeas, "Deviation", "%.2f KHz", DISPLAY_MEAS_PEAK2PEAK, DISPLAY_MEAS_LEFT, 0.0, max_deviation / 1000.0 * 1.5, max_deviation / 1000.0);
|
sdr->chan[c].dmp_deviation = display_measurements_add(&sender->dispmeas, "Deviation", "%.2f KHz", DISPLAY_MEAS_PEAK2PEAK, DISPLAY_MEAS_LEFT, 0.0, max_deviation / 1000.0 * 1.5, max_deviation / 1000.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sdr_config->swap_links) {
|
if (sdr_config->swap_links) {
|
||||||
double temp;
|
double temp;
|
||||||
@@ -700,6 +723,7 @@ void sdr_close(void *inst)
|
|||||||
free(sdr->modbuff);
|
free(sdr->modbuff);
|
||||||
free(sdr->modbuff_I);
|
free(sdr->modbuff_I);
|
||||||
free(sdr->modbuff_Q);
|
free(sdr->modbuff_Q);
|
||||||
|
free(sdr->modbuff_carrier);
|
||||||
free(sdr->wavespl0);
|
free(sdr->wavespl0);
|
||||||
free(sdr->wavespl1);
|
free(sdr->wavespl1);
|
||||||
wave_destroy_record(&sdr->wave_rx_rec);
|
wave_destroy_record(&sdr->wave_rx_rec);
|
||||||
@@ -710,11 +734,13 @@ void sdr_close(void *inst)
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
for (c = 0; c < sdr->channels; c++) {
|
for (c = 0; c < sdr->channels; c++) {
|
||||||
fm_mod_exit(&sdr->chan[c].mod);
|
fm_mod_exit(&sdr->chan[c].fm_mod);
|
||||||
fm_demod_exit(&sdr->chan[c].demod);
|
fm_demod_exit(&sdr->chan[c].fm_demod);
|
||||||
|
am_mod_exit(&sdr->chan[c].am_mod);
|
||||||
|
am_demod_exit(&sdr->chan[c].am_demod);
|
||||||
}
|
}
|
||||||
if (sdr->paging_channel)
|
if (sdr->paging_channel)
|
||||||
fm_mod_exit(&sdr->chan[sdr->paging_channel].mod);
|
fm_mod_exit(&sdr->chan[sdr->paging_channel].fm_mod);
|
||||||
free(sdr->chan);
|
free(sdr->chan);
|
||||||
}
|
}
|
||||||
free(sdr);
|
free(sdr);
|
||||||
@@ -747,9 +773,12 @@ int sdr_write(void *inst, sample_t **samples, uint8_t **power, int num, enum pag
|
|||||||
for (c = 0; c < channels; c++) {
|
for (c = 0; c < channels; c++) {
|
||||||
/* switch to paging channel, if requested */
|
/* switch to paging channel, if requested */
|
||||||
if (on[c] && sdr->paging_channel)
|
if (on[c] && sdr->paging_channel)
|
||||||
fm_modulate_complex(&sdr->chan[sdr->paging_channel].mod, samples[c], power[c], num, buff);
|
fm_modulate_complex(&sdr->chan[sdr->paging_channel].fm_mod, samples[c], power[c], num, buff);
|
||||||
else
|
else if (sdr->chan[c].am) {
|
||||||
fm_modulate_complex(&sdr->chan[c].mod, samples[c], power[c], num, buff);
|
if (power[c][0])
|
||||||
|
am_modulate_complex(&sdr->chan[c].am_mod, samples[c], num, buff);
|
||||||
|
} else
|
||||||
|
fm_modulate_complex(&sdr->chan[c].fm_mod, samples[c], power[c], num, buff);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buff = (float *)samples;
|
buff = (float *)samples;
|
||||||
@@ -914,7 +943,10 @@ int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_l
|
|||||||
|
|
||||||
if (channels) {
|
if (channels) {
|
||||||
for (c = 0; c < channels; c++) {
|
for (c = 0; c < channels; c++) {
|
||||||
fm_demodulate_complex(&sdr->chan[c].demod, samples[c], count, buff, sdr->modbuff_I, sdr->modbuff_Q);
|
if (sdr->chan[c].am)
|
||||||
|
am_demodulate_complex(&sdr->chan[c].am_demod, samples[c], count, buff, sdr->modbuff_I, sdr->modbuff_Q, sdr->modbuff_carrier);
|
||||||
|
else
|
||||||
|
fm_demodulate_complex(&sdr->chan[c].fm_demod, samples[c], count, buff, sdr->modbuff_I, sdr->modbuff_Q);
|
||||||
sender_t *sender = get_sender_by_empfangsfrequenz(sdr->chan[c].rx_frequency);
|
sender_t *sender = get_sender_by_empfangsfrequenz(sdr->chan[c].rx_frequency);
|
||||||
if (!sender || !count)
|
if (!sender || !count)
|
||||||
continue;
|
continue;
|
||||||
@@ -928,6 +960,7 @@ int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_l
|
|||||||
avg = log10(avg) * 20;
|
avg = log10(avg) * 20;
|
||||||
display_measurements_update(sdr->chan[c].dmp_rf_level, avg, 0.0);
|
display_measurements_update(sdr->chan[c].dmp_rf_level, avg, 0.0);
|
||||||
rf_level_db[c] = avg;
|
rf_level_db[c] = avg;
|
||||||
|
if (!sdr->chan[c].am) {
|
||||||
min = 0.0;
|
min = 0.0;
|
||||||
max = 0.0;
|
max = 0.0;
|
||||||
avg = 0.0;
|
avg = 0.0;
|
||||||
@@ -944,6 +977,7 @@ int sdr_read(void *inst, sample_t **samples, int num, int channels, double *rf_l
|
|||||||
display_measurements_update(sdr->chan[c].dmp_deviation, min / 2.0 / 1000.0, max / 2.0 / 1000.0);
|
display_measurements_update(sdr->chan[c].dmp_deviation, min / 2.0 / 1000.0, max / 2.0 / 1000.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
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 channels, double paging_frequency, int samplerate, int latspl, double max_deviation, double max_modulation);
|
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_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);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
enum paging_signal;
|
enum paging_signal;
|
||||||
|
|
||||||
void *sound_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int channels, double paging_frequency, int samplerate, int latspl, double max_deviation, double max_modulation);
|
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);
|
||||||
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);
|
||||||
|
@@ -131,7 +131,7 @@ static int sound_prepare(sound_t *sound)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int channels, double __attribute__((unused)) paging_frequency, int samplerate, int __attribute((unused)) latspl, double max_deviation, double __attribute__((unused)) max_modulation)
|
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)
|
||||||
{
|
{
|
||||||
sound_t *sound;
|
sound_t *sound;
|
||||||
int rc, rc_rec, rc_play;
|
int rc, rc_rec, rc_play;
|
||||||
|
@@ -51,6 +51,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
nmt_LDADD += \
|
nmt_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -39,6 +39,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
radiocom2000_LDADD += \
|
radiocom2000_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -383,9 +383,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
double tx_frequencies[1], rx_frequencies[1];
|
double tx_frequencies[1], rx_frequencies[1];
|
||||||
|
int am[1];
|
||||||
tx_frequencies[0] = frequency;
|
tx_frequencies[0] = frequency;
|
||||||
rx_frequencies[0] = frequency;
|
rx_frequencies[0] = frequency;
|
||||||
sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, 1, 0.0, samplerate, latspl, 0.0, 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);
|
||||||
if (!sdr)
|
if (!sdr)
|
||||||
goto error;
|
goto error;
|
||||||
sdr_start(sdr);
|
sdr_start(sdr);
|
||||||
|
@@ -98,7 +98,7 @@ int radio_init(radio_t *radio, int latspl, int samplerate, const char *tx_wave_f
|
|||||||
/* 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, radio->tx_audio_channels, 0.0, radio->tx_audio_samplerate, radio->latspl, 1.0, 0.0);
|
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);
|
||||||
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");
|
||||||
@@ -164,7 +164,7 @@ int radio_init(radio_t *radio, int latspl, int samplerate, const char *tx_wave_f
|
|||||||
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, radio->rx_audio_channels, 0.0, radio->rx_audio_samplerate, radio->latspl, 1.0, 0.0);
|
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);
|
||||||
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");
|
||||||
|
@@ -39,6 +39,7 @@ endif
|
|||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
tacs_LDADD += \
|
tacs_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
|
@@ -81,6 +81,7 @@ test_dms_LDADD += \
|
|||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(top_builddir)/src/libfm/libfm.a \
|
$(top_builddir)/src/libfm/libfm.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
endif
|
endif
|
||||||
@@ -115,6 +116,7 @@ test_sms_LDADD += \
|
|||||||
$(top_builddir)/src/libsdr/libsdr.a \
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
$(top_builddir)/src/libfft/libfft.a \
|
$(top_builddir)/src/libfft/libfft.a \
|
||||||
$(top_builddir)/src/libfm/libfm.a \
|
$(top_builddir)/src/libfm/libfm.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a \
|
||||||
$(UHD_LIBS) \
|
$(UHD_LIBS) \
|
||||||
$(SOAPY_LIBS)
|
$(SOAPY_LIBS)
|
||||||
endif
|
endif
|
||||||
|
@@ -31,7 +31,8 @@ osmotv_LDADD = \
|
|||||||
|
|
||||||
if HAVE_SDR
|
if HAVE_SDR
|
||||||
osmotv_LDADD += \
|
osmotv_LDADD += \
|
||||||
$(top_builddir)/src/libsdr/libsdr.a
|
$(top_builddir)/src/libsdr/libsdr.a \
|
||||||
|
$(top_builddir)/src/libam/libam.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
osmotv_LDADD += \
|
osmotv_LDADD += \
|
||||||
|
@@ -321,9 +321,11 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
|
|||||||
}
|
}
|
||||||
|
|
||||||
double tx_frequencies[1], rx_frequencies[1];
|
double tx_frequencies[1], rx_frequencies[1];
|
||||||
|
int am[1];
|
||||||
tx_frequencies[0] = frequency;
|
tx_frequencies[0] = frequency;
|
||||||
rx_frequencies[0] = frequency;
|
rx_frequencies[0] = frequency;
|
||||||
sdr = sdr_open(NULL, tx_frequencies, rx_frequencies, 1, 0.0, samplerate, latspl, 0.0, 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);
|
||||||
if (!sdr)
|
if (!sdr)
|
||||||
goto error;
|
goto error;
|
||||||
sdr_start(sdr);
|
sdr_start(sdr);
|
||||||
|
Reference in New Issue
Block a user