Beispiel #1
0
/*! \brief Public contructor.
 *  \param input_device Input device specifier.
 *  \param audio_device Audio output device specifier,
 *                      e.g. hw:0 when using ALSA or Portaudio.
 *
 * \todo Option to use UHD device instead of FCD.
 */
receiver::receiver(const std::string input_device, const std::string audio_device)
    : d_running(false),
      d_input_rate(96000.0),
      d_audio_rate(48000),
      d_rf_freq(144800000.0),
      d_filter_offset(0.0),
      d_recording_wav(false),
      d_sniffer_active(false),
      d_iq_rev(false),
      d_dc_cancel(false),
      d_iq_balance(false),
      d_demod(RX_DEMOD_OFF)
{
    tb = gr_make_top_block("gqrx");

    if (input_device.empty())
    {
        // FIXME: other OS
        src = osmosdr_make_source_c("file=/dev/random,freq=428e6,rate=96000,repeat=true,throttle=true");
    }
    else
    {
        input_devstr = input_device;
        src = osmosdr_make_source_c(input_device);
    }

    rx = make_nbrx(d_input_rate, d_audio_rate);
    lo = gr_make_sig_source_c(d_input_rate, GR_SIN_WAVE, 0.0, 1.0);
    mixer = gr_make_multiply_cc();

    iq_swap = make_iq_swap_cc(false);
    dc_corr = make_dc_corr_cc(d_input_rate, 1.0);
    iq_fft = make_rx_fft_c(4096u, 0);

    audio_fft = make_rx_fft_f(3072u);
    audio_gain0 = gr_make_multiply_const_ff(0.1);
    audio_gain1 = gr_make_multiply_const_ff(0.1);

#ifdef WITH_PULSEAUDIO //pafix
    audio_snk = make_pa_sink(audio_device, d_audio_rate, "GQRX", "Audio output");
#else
    audio_snk = audio_make_sink(d_audio_rate, audio_device, true);
#endif

    output_devstr = audio_device;

    /* wav sink and source is created when rec/play is started */
    audio_null_sink = gr_make_null_sink(sizeof(float));
    sniffer = make_sniffer_f();
    /* sniffer_rr is created at each activation. */

    set_demod(RX_DEMOD_NFM);
}
Beispiel #2
0
		TopBlock(double centre_freq_1, double centre_freq_2, double sample_rate, double fft_width, double bandwidth1, double bandwidth2,
				double step, unsigned int avg_size, double spread, double threshold, double ptime, float gain, float ppm) : gr_top_block("Top Block"),
			vector_length(sample_rate/fft_width),
			window(GetWindow(vector_length)),

			source(osmosdr_make_source_c()), /* OsmoSDR Source */
			stv(gr_make_stream_to_vector(sizeof(float)*2, vector_length)), /* Stream to vector */
			/* Based on the logpwrfft (a block implemented in python) */
			fft(gr_make_fft_vcc_fftw(vector_length, true, window, false, 1)),
			ctf(gr_make_complex_to_mag_squared(vector_length)),
			iir(gr_make_single_pole_iir_filter_ff(1.0, vector_length)),
			lg(gr_make_nlog10_ff(10, vector_length, -20 * log10(vector_length) -10 * log10(GetWindowPower()/vector_length))),
			/* Sink - this does most of the interesting work */
			sink(make_scanner_sink(source, vector_length, centre_freq_1, centre_freq_2, sample_rate, bandwidth1, bandwidth2, step, avg_size, spread, threshold, ptime, gain, ppm))
		{
			/* Set up the OsmoSDR Source */
			source->set_sample_rate(sample_rate);
			source->set_center_freq(centre_freq_1);
			source->set_freq_corr(ppm);
			source->set_gain_mode(false);
			source->set_gain(gain);
			source->set_if_gain(20.0);

			/* Set up the connections */
			connect(source, 0, stv, 0);
			connect(stv, 0, fft, 0);
			connect(fft, 0, ctf, 0);
			connect(ctf, 0, iir, 0);
			connect(iir, 0, lg, 0);
			connect(lg, 0, sink, 0);
		}
Beispiel #3
0
    TopBlock(double centerFreq, double sampleRate, double freqRes, double cycFreqRes, std::string fileName) :
        gr_top_block("Top Block"),
        Np(pow2roundup((int)sampleRate/freqRes)),
        L(Np/4),
        P(pow2roundup(sampleRate/cycFreqRes/L)),
        N(P*L),
        vector_length(N),
        source(osmosdr_make_source_c()), /* OsmoSDR Source */
        fileSource(gr_make_file_source(sizeof(float)*2, "/home/ylb/QAM16_44_1k.dat", false)),
        stv(gr_make_stream_to_vector(sizeof(float)*2, vector_length)), /* Stream to vector */
        /* autoFam - this does most of the interesting work */
        sink(make_autofam_sink(source, vector_length, centerFreq, sampleRate, freqRes, cycFreqRes, fileName))
    {

        /* Set up the OsmoSDR Source */
        source->set_sample_rate(sampleRate);
        source->set_center_freq(centerFreq);
        source->set_freq_corr(0.0);
        source->set_gain_mode(false);
        source->set_gain(30);
        source->set_if_gain(25.0);

        /* Set up the connections */
        connect(fileSource, 0, stv, 0);
        connect(stv, 0, sink, 0);
    }
Beispiel #4
0
/*! \brief Select new input device.
 *
 * \bug When using ALSA, program will crash if the new device
 *      is the same as the previously used device:
 *      audio_alsa_source[hw:1]: Device or resource busy
 */
void receiver::set_input_device(const std::string device)
{
    if (device.empty())
        return;

    if (input_devstr.compare(device) == 0)
    {
#ifndef QT_NO_DEBUG_OUTPUT
        std::cout << "No change in input device:" << std::endl
                  << "  old: " << input_devstr << std::endl
                  << "  new: " << device << std::endl;
#endif
        return;
    }

    input_devstr = device;

    tb->lock();

    tb->disconnect(src, 0, iq_swap, 0);
    src.reset();
    src = osmosdr_make_source_c(device);
    tb->connect(src, 0, iq_swap, 0);

    tb->unlock();
}