osmoradio: Fix disabling of emphasis

pull/1/head
Andreas Eversberg 3 years ago
parent 90c47658c1
commit 99a4bfc7f0
  1. 2
      src/radio/main.c
  2. 37
      src/radio/radio.c
  3. 1
      src/radio/radio.h

@ -136,7 +136,7 @@ void print_help(const char *arg0)
printf(" Give modulation index of amplitude modulated signal. (default %.0f)\n", modulation_index);
printf(" -E --emphasis <uS> | 0\n");
printf(" Use given time constant of pre- and de-emphasis for frequency\n");
printf(" modulation. Give 0 to disbale. (default = %.0f uS)\n", time_constant_us);
printf(" modulation. Give 0 to disbale emphasis. (default = %.0f uS)\n", time_constant_us);
printf(" VHF broadcast 50 uS in Europe and 75 uS in the United States.\n");
printf(" Other radio FM should use 530 uS, to cover complete speech spectrum.\n");
printf(" -V --volume %.3f\n", volume);

@ -235,14 +235,17 @@ int radio_init(radio_t *radio, int latspl, int samplerate, const char *tx_wave_f
/* init filters (using signal sample rate) */
switch (radio->modulation) {
case MODULATION_FM:
/* time constant */
PDEBUG(DRADIO, DEBUG_INFO, "Using emphasis cut-off at %.0f Hz.\n", timeconstant2cutoff(time_constant_us));
rc = init_emphasis(&radio->fm_emphasis[0], radio->signal_samplerate, timeconstant2cutoff(time_constant_us), DC_CUTOFF, radio->audio_bandwidth);
if (rc < 0)
goto error;
rc = init_emphasis(&radio->fm_emphasis[1], radio->signal_samplerate, timeconstant2cutoff(time_constant_us), DC_CUTOFF, radio->audio_bandwidth);
if (rc < 0)
goto error;
if (time_constant_us > 0.0) {
radio->emphasis = 1;
/* time constant */
PDEBUG(DRADIO, DEBUG_INFO, "Using emphasis cut-off at %.0f Hz.\n", timeconstant2cutoff(time_constant_us));
rc = init_emphasis(&radio->fm_emphasis[0], radio->signal_samplerate, timeconstant2cutoff(time_constant_us), DC_CUTOFF, radio->audio_bandwidth);
if (rc < 0)
goto error;
rc = init_emphasis(&radio->fm_emphasis[1], radio->signal_samplerate, timeconstant2cutoff(time_constant_us), DC_CUTOFF, radio->audio_bandwidth);
if (rc < 0)
goto error;
}
rc = fm_mod_init(&radio->fm_mod, radio->signal_samplerate, 0.0, 1.0);
if (rc < 0)
goto error;
@ -552,10 +555,12 @@ int radio_tx(radio_t *radio, float *baseband, int signal_num)
* and modulate */
switch (radio->modulation) {
case MODULATION_FM:
pre_emphasis(&radio->fm_emphasis[0], signal_samples[0], signal_num);
if (radio->emphasis)
pre_emphasis(&radio->fm_emphasis[0], signal_samples[0], signal_num);
clipper_process(signal_samples[0], signal_num);
if (radio->stereo) {
pre_emphasis(&radio->fm_emphasis[1], signal_samples[1], signal_num);
if (radio->emphasis)
pre_emphasis(&radio->fm_emphasis[1], signal_samples[1], signal_num);
clipper_process(signal_samples[1], signal_num);
/* add pilot tone */
double phasestep = radio->pilot_phasestep;
@ -643,11 +648,13 @@ int radio_rx(radio_t *radio, float *baseband, int signal_num)
iir_process(&radio->rx_lp_sum, samples[0], signal_num);
iir_process(&radio->rx_lp_diff, samples[1], signal_num);
}
dc_filter(&radio->fm_emphasis[0], samples[0], signal_num);
de_emphasis(&radio->fm_emphasis[0], samples[0], signal_num);
if (radio->stereo) {
dc_filter(&radio->fm_emphasis[1], samples[1], signal_num);
de_emphasis(&radio->fm_emphasis[1], samples[1], signal_num);
if (radio->emphasis) {
dc_filter(&radio->fm_emphasis[0], samples[0], signal_num);
de_emphasis(&radio->fm_emphasis[0], samples[0], signal_num);
if (radio->stereo) {
dc_filter(&radio->fm_emphasis[1], samples[1], signal_num);
de_emphasis(&radio->fm_emphasis[1], samples[1], signal_num);
}
}
break;
case MODULATION_AM_DSB:

@ -30,6 +30,7 @@ typedef struct radio {
double volume; /* volume change (gain/dampen) */
int stereo; /* use stere FM */
int rds, rds2; /* use RDS */
int emphasis; /* use pre-/de-emphasis with FM */
/* audio stage */
double tx_audio_samplerate; /* sample rate of audio source */
double rx_audio_samplerate; /* sample rate of audio sink */

Loading…
Cancel
Save