Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rx decoders #1153

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
346 changes: 333 additions & 13 deletions src/applications/gqrx/mainwindow.cpp

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions src/applications/gqrx/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "qtgui/dockfft.h"
#include "qtgui/dockbookmarks.h"
#include "qtgui/dockrds.h"
#include "qtgui/dockfax.h"
#include "qtgui/dockrtty.h"
#include "qtgui/afsk1200win.h"
#include "qtgui/iq_tool.h"
#include "qtgui/dxc_options.h"
Expand Down Expand Up @@ -97,13 +99,21 @@ public slots:
std::vector<float> d_audioFftData;
bool d_have_audio; /*!< Whether we have audio (i.e. not with demod_off. */

QImage fax_image;
bool fax_running;
QString fax_name;
bool rtty_running;
QString rtty_name;

/* dock widgets */
DockRxOpt *uiDockRxOpt;
DockAudio *uiDockAudio;
DockInputCtl *uiDockInputCtl;
DockFft *uiDockFft;
DockBookmarks *uiDockBookmarks;
DockRDS *uiDockRDS;
DockFAX *uiDockFAX;
DockRTTY *uiDockRTTY;

CIqTool *iq_tool;
DXCOptions *dxc_options;
Expand All @@ -118,6 +128,9 @@ public slots:
QTimer *iq_fft_timer;
QTimer *audio_fft_timer;
QTimer *rds_timer;
QTimer *fax_timer;
QTimer *rtty_timer;

quint64 d_last_fft_ms;
float d_avg_fft_rate;
bool d_frame_drop;
Expand Down Expand Up @@ -220,6 +233,34 @@ private slots:
/* RDS */
void setRdsDecoder(bool checked);

/* FAX */
void start_fax_decoder();
void stop_fax_decoder();
void reset_fax_decoder();
void set_fax_lpm(float);
void set_fax_black_freq(float);
void set_fax_white_freq(float);
void set_fax_ioc(float);
void force_fax_reset();
void force_fax_sync();
void force_fax_start();
int save_fax();

/* RTTY */
void start_rtty_decoder();
void stop_rtty_decoder();
void reset_rtty_decoder();
void set_rtty_baud_rate(float);
void set_rtty_mark_freq(float);
void set_rtty_space_freq(float);
void set_rtty_threshold(float);
void set_rtty_bandwidth(float);
void set_rtty_transwidth(float);
void set_rtty_filterlen(float);
void set_rtty_mode(int);
void set_rtty_parity(int);
int save_rtty();

/* Bookmarks */
void onBookmarkActivated(qint64 freq, const QString& demod, int bandwidth);

Expand Down Expand Up @@ -261,6 +302,8 @@ private slots:
void iqFftTimeout();
void audioFftTimeout();
void rdsTimeout();
void faxTimeout();
void rttyTimeout();
};

#endif // MAINWINDOW_H
60 changes: 27 additions & 33 deletions src/applications/gqrx/receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* https://gqrx.dk/
*
* Copyright 2011-2014 Alexandru Csete OZ9AEC.
* Generic rx decoder interface Copyright 2022 Marc CAPDEVILLE F4JMZ
*
* Gqrx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -72,6 +73,7 @@ receiver::receiver(const std::string input_device,
d_iq_rev(false),
d_dc_cancel(false),
d_iq_balance(false),
d_rx_chain(RX_CHAIN_NONE),
d_demod(RX_DEMOD_OFF)
{

Expand Down Expand Up @@ -1388,6 +1390,8 @@ void receiver::connect_all(rx_chain type)
break;
}

d_rx_chain = type;

// Audio path (if there is a receiver)
if (type != RX_CHAIN_NONE)
{
Expand Down Expand Up @@ -1418,47 +1422,37 @@ void receiver::connect_all(rx_chain type)
}
}

void receiver::get_rds_data(std::string &outbuff, int &num)
{
rx->get_rds_data(outbuff, num);
enum receiver::rx_chain receiver::get_rx_chain() {
return d_rx_chain;
}

void receiver::start_rds_decoder(void)
{
if (d_running)
{
stop();
rx->start_rds_decoder();
start();
}
else
{
rx->start_rds_decoder();
}
/* generic rx decoder functions */
int receiver::start_decoder(enum receiver_base_cf::rx_decoder decoder_type) {
return rx->start_decoder(decoder_type);
}

void receiver::stop_rds_decoder(void)
{
if (d_running)
{
stop();
rx->stop_rds_decoder();
start();
}
else
{
rx->stop_rds_decoder();
}
int receiver::stop_decoder(enum receiver_base_cf::rx_decoder decoder_type) {
return rx->stop_decoder(decoder_type);
}

bool receiver::is_rds_decoder_active(void) const
{
return rx->is_rds_decoder_active();
bool receiver::is_decoder_active(enum receiver_base_cf::rx_decoder decoder_type) const {
return rx->is_decoder_active(decoder_type);
}

void receiver::reset_rds_parser(void)
{
rx->reset_rds_parser();
int receiver::reset_decoder(enum receiver_base_cf::rx_decoder decoder_type) {
return rx->reset_decoder(decoder_type);
}

int receiver::set_decoder_param(enum receiver_base_cf::rx_decoder decoder_type, std::string param, std::string val) {
return rx->set_decoder_param(decoder_type,param,val);
}

int receiver::get_decoder_param(enum receiver_base_cf::rx_decoder decoder_type, std::string param, std::string &val) {
return rx->get_decoder_param(decoder_type,param,val);
}

int receiver::get_decoder_data(enum receiver_base_cf::rx_decoder decoder_type,void* data, int &num) {
return rx->get_decoder_data(decoder_type,data,num);
}

std::string receiver::escape_filename(std::string filename)
Expand Down
17 changes: 11 additions & 6 deletions src/applications/gqrx/receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* https://gqrx.dk/
*
* Copyright 2011-2014 Alexandru Csete OZ9AEC.
* Generic rx decoder interface Copyright 2022 Marc CAPDEVILLE F4JMZ
*
* Gqrx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -219,15 +220,18 @@ class receiver
bool is_recording_audio(void) const { return d_recording_wav; }
bool is_snifffer_active(void) const { return d_sniffer_active; }

/* rds functions */
void get_rds_data(std::string &outbuff, int &num);
void start_rds_decoder(void);
void stop_rds_decoder();
bool is_rds_decoder_active(void) const;
void reset_rds_parser(void);
/* generic rx decoder functions */
int start_decoder(enum receiver_base_cf::rx_decoder decoder_type);
int stop_decoder(enum receiver_base_cf::rx_decoder decoder_type);
bool is_decoder_active(enum receiver_base_cf::rx_decoder decoder_type) const;
int reset_decoder(enum receiver_base_cf::rx_decoder decoder_type);
int set_decoder_param(enum receiver_base_cf::rx_decoder decoder_type, std::string param, std::string val);
int get_decoder_param(enum receiver_base_cf::rx_decoder decoder_type, std::string param, std::string &val);
int get_decoder_data(enum receiver_base_cf::rx_decoder decoder_type, void* data, int& num);

/* utility functions */
static std::string escape_filename(std::string filename);
enum rx_chain get_rx_chain();

private:
void connect_all(rx_chain type);
Expand All @@ -253,6 +257,7 @@ class receiver
std::string input_devstr; /*!< Current input device string. */
std::string output_devstr; /*!< Current output device string. */

rx_chain d_rx_chain; /*! Current Rx chain */
rx_demod d_demod; /*!< Current demodulator. */

gr::top_block_sptr tb; /*!< The GNU Radio top block. */
Expand Down
17 changes: 17 additions & 0 deletions src/dsp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ add_source_files(SRCS_LIST
lpf.h
resampler_xx.cpp
resampler_xx.h
rtty/rtty_demod.cpp
rtty/rtty_demod.h
rtty/fsk_demod.h
rtty/fsk_demod_impl.h
rtty/fsk_demod_impl.cpp
rtty/async_rx.h
rtty/async_rx_impl.h
rtty/async_rx_impl.cpp
rtty/char_store.h
rtty/char_store.cpp
rx_agc_xx.cpp
rx_agc_xx.h
rx_demod_am.cpp
Expand All @@ -49,4 +59,11 @@ add_source_files(SRCS_LIST
sniffer_f.h
stereo_demod.cpp
stereo_demod.h
fax/fax_decoder.h
fax/fax_decoder_impl.cpp
fax/fax_decoder_impl.h
fax/fax_demod.cpp
fax/fax_demod.h
fax/fax_store.cpp
fax/fax_store.h
)
59 changes: 59 additions & 0 deletions src/dsp/fax/fax_decoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* fax decoder block header
*
* Copyright 2022 Marc CAPDEVILLE F4JMZ
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

#ifndef FAX_DECODER_H
#define FAX_DECODER_H

#include <gnuradio/block.h>

namespace gr {
namespace fax {
class fax_decoder : virtual public gr::block
{
public:

#if GNURADIO_VERSION < 0x030900
typedef boost::shared_ptr<fax_decoder> sptr;
#else
typedef std::shared_ptr<fax_decoder> sptr;
#endif

static sptr make(float sample_rate, float lpm, float ioc);

virtual void set_sample_rate(float sample_rate) = 0;
virtual float sample_rate() const = 0;

virtual void set_lpm(float lpm) = 0;
virtual float lpm() const = 0;

virtual void set_ioc(float ioc) = 0;
virtual float ioc() const = 0;

virtual void set_state(int state) = 0;
virtual int state() const = 0;

virtual void reset() = 0;
};

} // namespace fax
} // namespace gr

#endif // FAX_DECODER_H
Loading
Loading