Prepare for SDR: Add bandwidth and deviation info to sender instance

This commit is contained in:
Andreas Eversberg 2017-01-06 12:22:51 +01:00
parent 9ff8c3bb25
commit c5cf88ce57
10 changed files with 35 additions and 9 deletions

View File

@ -99,6 +99,7 @@
#define PI M_PI
#define BANDWIDTH 20000.0 /* maximum bandwidth */
#define FSK_DEVIATION 32767.0 /* +-8 KHz */
#define SAT_DEVIATION 8192.0 /* +-2 KHz */
#define COMPANDOR_0DB 45000 /* works quite well */
@ -191,6 +192,10 @@ int dsp_init_sender(amps_t *amps, int high_pass, int tolerant)
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for transceiver.\n");
/* set deviation and modulation parameters */
amps->sender.bandwidth = BANDWIDTH;
amps->sender.sample_deviation = 8000.0 / (double)FSK_DEVIATION;
if (amps->sender.samplerate < 96000) {
PDEBUG(DDSP, DEBUG_ERROR, "Sample rate must be at least 96000 Hz to process FSK and SAT signals.\n");
return -EINVAL;

View File

@ -35,12 +35,10 @@
#define PI 3.1415927
/* signaling */
/* NOTE: The peak deviation is similar for paging tone and signaling tone,
* so both tones should be equal after pre-emphasis. This is why the paging
* tones is so much louder.*/
#define BANDWIDTH 15000.0 /* maximum bandwidth */
#define TX_PEAK_TONE 8192.0 /* peak amplitude for all tones */
#warning FIXME: only with emphasis, use seperate option for volume, override by sdr
#define TX_PEAK_PAGE 32766.0 /* peak amplitude paging tone */
// FIXME: what is the allowed deviation of tone?
#define CHUNK_DURATION 0.010 /* 10 ms */
// FIXME: how long until we detect a tone?
@ -94,6 +92,10 @@ int dsp_init_sender(anetz_t *anetz, int page_sequence)
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
/* set deviation and modulation parameters */
anetz->sender.bandwidth = BANDWIDTH;
anetz->sender.sample_deviation = 11000.0 / (double)TX_PEAK_TONE;
anetz->page_sequence = page_sequence;
audio_init_loss(&anetz->sender.loss, LOSS_INTERVAL, anetz->sender.loss_volume, LOSS_TIME);

View File

@ -35,6 +35,7 @@
#define PI 3.1415927
/* signaling */
#define BANDWIDTH 5000.0 /* maximum bandwidth */
#define TX_PEAK_TONE 5000.0 /* peak amplitude for all tones */
#define BIT_DURATION 0.010 /* bit length: 10 ms */
#define FILTER_STEP 0.001 /* step every 1 ms */
@ -85,6 +86,10 @@ int dsp_init_sender(bnetz_t *bnetz)
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
/* set deviation and modulation parameters */
bnetz->sender.bandwidth = BANDWIDTH;
bnetz->sender.sample_deviation = 1250.0 / (double)TX_PEAK_TONE; // FIXME: calc real value
audio_init_loss(&bnetz->sender.loss, LOSS_INTERVAL, bnetz->sender.loss_volume, LOSS_TIME);
bnetz->samples_per_bit = bnetz->sender.samplerate * BIT_DURATION;

View File

@ -42,6 +42,7 @@ extern int voice_deviation;
#define PI M_PI
#define BANDWIDTH 5500.0 /* maximum bandwidth */
#define FSK_DEVIATION 10000
#define COMPANDOR_0DB 30000
#define BITRATE 5280.0 /* bits per second */
@ -88,6 +89,10 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], do
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init FSK for 'Sender'.\n");
/* set deviation and modulation parameters */
cnetz->sender.bandwidth = BANDWIDTH;
cnetz->sender.sample_deviation = 2500.0 / (double)FSK_DEVIATION;
if (measure_speed) {
cnetz->measure_speed = measure_speed;
cant_recover = 1;

View File

@ -473,7 +473,7 @@ int call_init(const char *station_id, const char *audiodev, int samplerate, int
return 0;
/* open sound device for call control */
call.sound = sound_open(audiodev, NULL, NULL, 1, samplerate);
call.sound = sound_open(audiodev, NULL, NULL, 1, samplerate, 3700.0, 0.0);
if (!call.sound) {
PDEBUG(DSENDER, DEBUG_ERROR, "No sound device!\n");

View File

@ -40,6 +40,8 @@ int sender_create(sender_t *sender, int kanal, double sendefrequenz, double empf
sender->kanal = kanal;
sender->sendefrequenz = sendefrequenz;
sender->empfangsfrequenz = empfangsfrequenz;
sender->bandwidth = 4000; /* default is overwritten by dsp.c */
sender->sample_deviation = 0.2; /* default is overwritten by dsp.c */
strncpy(sender->audiodev, audiodev, sizeof(sender->audiodev) - 1);
sender->samplerate = samplerate;
sender->rx_gain = rx_gain;
@ -172,7 +174,7 @@ int sender_open_audio(void)
}
/* open device */
master->audio = master->audio_open(master->audiodev, tx_f, rx_f, channels, master->samplerate);
master->audio = master->audio_open(master->audiodev, tx_f, rx_f, channels, master->samplerate, master->bandwidth, master->sample_deviation);
if (!master->audio) {
PDEBUG(DSENDER, DEBUG_ERROR, "No audio device!\n");
return -EIO;

View File

@ -27,11 +27,13 @@ typedef struct sender {
int kanal; /* channel number */
double sendefrequenz; /* transmitter frequency */
double empfangsfrequenz; /* receiver frequency */
double bandwidth; /* max NF frequency to be transmitted unaffected by filtering */
double sample_deviation; /* frequency deviation of one sample step (after pre-emphasis) */
/* audio */
void *audio;
char audiodev[64]; /* audio device name (alsa or sdr) */
void *(*audio_open)(const char *, double *, double *, int, int);
void *(*audio_open)(const char *, double *, double *, int, int, double, double);
void (*audio_close)(void *);
int (*audio_write)(void *, int16_t **, int, int);
int (*audio_read)(void *, int16_t **, int, int);

View File

@ -1,5 +1,5 @@
void *sound_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int channels, int samplerate);
void *sound_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int channels, int samplerate, double bandwidth, double sample_deviation);
void sound_close(void *inst);
int sound_write(void *inst, int16_t **samples, int num, int channels);
int sound_read(void *inst, int16_t **samples, int num, int channels);

View File

@ -128,7 +128,7 @@ static int sound_prepare(sound_t *sound)
return 0;
}
void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int channels, int samplerate)
void *sound_open(const char *audiodev, double __attribute__((unused)) *tx_frequency, double __attribute__((unused)) *rx_frequency, int channels, int samplerate, double __attribute__((unused)) bandwidth, double __attribute__((unused)) sample_deviation)
{
sound_t *sound;
int rc;

View File

@ -43,6 +43,7 @@
*/
/* signaling */
#define BANDWIDTH 6000.0 /* maximum bandwidth FIXME */
#define COMPANDOR_0DB 32767 /* works quite well */
#define TX_PEAK_FSK 10000.0 /* peak amplitude of signaling FSK +-3.5 KHz @ 1500 Hz */
#define TX_PEAK_SUPER (TX_PEAK_FSK / 3.5 * 0.3 / 2.68) /* peak amplitude of supervisory signal +-0.3 KHz @ 4015 Hz */
@ -115,6 +116,10 @@ int dsp_init_sender(nmt_t *nmt)
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for Transceiver.\n");
/* set deviation and modulation parameters */
nmt->sender.bandwidth = BANDWIDTH;
nmt->sender.sample_deviation = 2500.0 / (double)TX_PEAK_FSK; // FIXME: calc real value
PDEBUG(DDSP, DEBUG_DEBUG, "Using FSK level of %.0f (3.5 KHz deviation @ 1500 Hz)\n", TX_PEAK_FSK);
PDEBUG(DDSP, DEBUG_DEBUG, "Using Supervisory level of %.0f (0.3 KHz deviation @ 4015 Hz)\n", TX_PEAK_SUPER);