diff --git a/src/amps/dsp.c b/src/amps/dsp.c index 776ec3b..4b7e08b 100644 --- a/src/amps/dsp.c +++ b/src/amps/dsp.c @@ -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; diff --git a/src/anetz/dsp.c b/src/anetz/dsp.c index 41888cd..e47f7f2 100644 --- a/src/anetz/dsp.c +++ b/src/anetz/dsp.c @@ -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); diff --git a/src/bnetz/dsp.c b/src/bnetz/dsp.c index 2e2a7f1..90a1821 100644 --- a/src/bnetz/dsp.c +++ b/src/bnetz/dsp.c @@ -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; diff --git a/src/cnetz/dsp.c b/src/cnetz/dsp.c index a35e8c8..ae453c6 100644 --- a/src/cnetz/dsp.c +++ b/src/cnetz/dsp.c @@ -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; diff --git a/src/common/call.c b/src/common/call.c index 7f8fae6..ab57390 100644 --- a/src/common/call.c +++ b/src/common/call.c @@ -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"); diff --git a/src/common/sender.c b/src/common/sender.c index 45760e1..3438554 100644 --- a/src/common/sender.c +++ b/src/common/sender.c @@ -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; diff --git a/src/common/sender.h b/src/common/sender.h index c89b405..94bdee8 100644 --- a/src/common/sender.h +++ b/src/common/sender.h @@ -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); diff --git a/src/common/sound.h b/src/common/sound.h index 45eb2c0..313a559 100644 --- a/src/common/sound.h +++ b/src/common/sound.h @@ -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); diff --git a/src/common/sound_alsa.c b/src/common/sound_alsa.c index 15fe1a9..c8d0668 100644 --- a/src/common/sound_alsa.c +++ b/src/common/sound_alsa.c @@ -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; diff --git a/src/nmt/dsp.c b/src/nmt/dsp.c index 49f7fb4..e3ff165 100644 --- a/src/nmt/dsp.c +++ b/src/nmt/dsp.c @@ -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);