osmoradio: Display wave form

pull/1/head
Andreas Eversberg 3 years ago
parent 99a4bfc7f0
commit b38bb16adc
  1. 13
      src/radio/main.c
  2. 18
      src/radio/radio.c
  3. 4
      src/radio/radio.h

@ -34,7 +34,6 @@ enum paging_signal;
#include "../libdebug/debug.h"
#include "../libsdr/sdr_config.h"
#include "../libsdr/sdr.h"
#include "../libdisplay/display.h"
#include "../liboptions/options.h"
#include "radio.h"
@ -355,7 +354,7 @@ int main(int argc, char *argv[])
/* now we have latency and sample rate */
latspl = samplerate * latency / 1000;
rc = radio_init(&radio, latspl, samplerate, tx_wave_file, rx_wave_file, (tx) ? tx_audiodev : NULL, (rx) ? rx_audiodev : NULL, modulation, bandwidth, deviation, modulation_index, time_constant_us, volume, stereo, rds, rds2);
rc = radio_init(&radio, latspl, samplerate, frequency, tx_wave_file, rx_wave_file, (tx) ? tx_audiodev : NULL, (rx) ? rx_audiodev : NULL, modulation, bandwidth, deviation, modulation_index, time_constant_us, volume, stereo, rds, rds2);
if (rc < 0) {
fprintf(stderr, "Failed to initialize radio with given options, exitting!\n");
exit(0);
@ -458,6 +457,7 @@ next_char:
/* toggle measurements display */
display_iq_on(0);
display_spectrum_on(0);
display_wave_on(0);
display_measurements_on(-1);
goto next_char;
#endif
@ -465,14 +465,23 @@ next_char:
/* toggle IQ display */
display_measurements_on(0);
display_spectrum_on(0);
display_wave_on(0);
display_iq_on(-1);
goto next_char;
case 's':
/* toggle spectrum display */
display_measurements_on(0);
display_iq_on(0);
display_wave_on(0);
display_spectrum_on(-1);
goto next_char;
case 'w':
/* toggle wave display */
display_measurements_on(0);
display_iq_on(0);
display_spectrum_on(0);
display_wave_on(-1);
goto next_char;
case 'B':
calibrate_bias();
goto next_char;

@ -36,7 +36,9 @@
#define PILOT_FREQ 19000.0
#define PILOT_BW 5.0
int radio_init(radio_t *radio, int latspl, int samplerate, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant_us, double volume, int stereo, int rds, int rds2)
static char freq_name[2][64];
int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant_us, double volume, int stereo, int rds, int rds2)
{
int rc = -EINVAL;
@ -232,6 +234,10 @@ int radio_init(radio_t *radio, int latspl, int samplerate, const char *tx_wave_f
if (rc < 0)
goto error;
/* init display of wave form */
sprintf(freq_name[0], "%.4f MHz", frequency / 1e6);
display_wave_init(&radio->dispwav[0], radio->rx_audio_samplerate, freq_name[0]);
/* init filters (using signal sample rate) */
switch (radio->modulation) {
case MODULATION_FM:
@ -252,6 +258,11 @@ int radio_init(radio_t *radio, int latspl, int samplerate, const char *tx_wave_f
rc = fm_demod_init(&radio->fm_demod, radio->signal_samplerate, 0.0, 2 * radio->signal_bandwidth);
if (rc < 0)
goto error;
if (stereo) {
sprintf(freq_name[0], "%.4f MHz left", frequency / 1e6);
sprintf(freq_name[1], "%.4f MHz right", frequency / 1e6);
display_wave_init(&radio->dispwav[1], samplerate, freq_name[1]);
}
break;
case MODULATION_AM_DSB:
iir_lowpass_init(&radio->tx_am_bw_limit, radio->audio_bandwidth, radio->signal_samplerate, 1);
@ -706,6 +717,11 @@ int radio_rx(radio_t *radio, float *baseband, int signal_num)
samples[1][i] = samples[0][i];
}
/* display wave */
display_wave(&radio->dispwav[0], samples[0], audio_num, 1.0);
if (radio->stereo && radio->rx_audio_channels == 2)
display_wave(&radio->dispwav[1], samples[1], audio_num, 1.0);
/* store received audio */
switch (radio->rx_audio_mode) {
case AUDIO_MODE_WAVEFILE:

@ -5,6 +5,7 @@
#include "../libjitter/jitter.h"
#include "../libfm/fm.h"
#include "../libam/am.h"
#include "../libdisplay/display.h"
enum modulation {
MODULATION_NONE = 0,
@ -48,6 +49,7 @@ typedef struct radio {
sample_t *testtone[2]; /* test tone sample */
int testtone_length;
int testtone_pos;
dispwav_t dispwav[2]; /* display wave form */
/* signal stage */
double signal_samplerate;
double signal_bandwidth;
@ -79,7 +81,7 @@ typedef struct radio {
sample_t *carrier_buffer;
} radio_t;
int radio_init(radio_t *radio, int latspl, int samplerate, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant, double volume, int stereo, int rds, int rds2);
int radio_init(radio_t *radio, int latspl, int samplerate, double frequency, const char *tx_wave_file, const char *rx_wave_file, const char *tx_audiodev, const char *rx_audiodev, enum modulation modulation, double bandwidth, double deviation, double modulation_index, double time_constant, double volume, int stereo, int rds, int rds2);
void radio_exit(radio_t *radio);
int radio_start(radio_t *radio);
int radio_tx(radio_t *radio, float *baseband, int num);

Loading…
Cancel
Save