Created
February 1, 2024 00:51
-
-
Save marcusmueller/6baaf9667168bdd065c74b553595bd8f to your computer and use it in GitHub Desktop.
reproduction Flowgraph for https://github.com/gnuradio/gnuradio/issues/6103
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GNU Radio C++ Flow Graph CMakeLists.txt | |
# | |
# Title: Fm Tx | |
# GNU Radio version: v3.11.0.0git-649-gd7cdf222 | |
cmake_minimum_required(VERSION 3.8) | |
set(CMAKE_CXX_STANDARD 14) | |
project(fm_tx) | |
find_package(Gnuradio "3.11" COMPONENTS | |
blocks | |
fec | |
fft | |
filter | |
analog | |
digital | |
dtv | |
audio | |
channels | |
pdu | |
iio | |
qtgui | |
trellis | |
uhd | |
uhd UHD 4.0 RFNoC | |
video-sdl | |
vocoder | |
wavelet | |
zeromq | |
network | |
soapy | |
) | |
find_package(Qt5Widgets REQUIRED) | |
set(CMAKE_AUTOMOC TRUE) | |
add_executable(fm_tx fm_tx.cpp) | |
target_link_libraries(fm_tx | |
gnuradio::gnuradio-blocks | |
gnuradio::gnuradio-qtgui | |
Boost::program_options | |
gnuradio::gnuradio-audio | |
gnuradio::gnuradio-qtgui | |
gnuradio::gnuradio-analog | |
gnuradio::gnuradio-filter | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************** | |
GNU Radio C++ Flow Graph Source File | |
Title: Fm Tx | |
GNU Radio version: v3.11.0.0git-649-gd7cdf222 | |
********************/ | |
#include "fm_tx.hpp" | |
namespace po = boost::program_options; | |
using namespace gr; | |
fm_tx::fm_tx (long nitems) | |
: QWidget(), | |
nitems(nitems) { | |
this->setWindowTitle("Fm Tx"); | |
// check_set_qss | |
// set icon | |
this->top_scroll_layout = new QVBoxLayout(); | |
this->setLayout(this->top_scroll_layout); | |
this->top_scroll = new QScrollArea(); | |
this->top_scroll->setFrameStyle(QFrame::NoFrame); | |
this->top_scroll_layout->addWidget(this->top_scroll); | |
this->top_scroll->setWidgetResizable(true); | |
this->top_widget = new QWidget(); | |
this->top_scroll->setWidget(this->top_widget); | |
this->top_layout = new QVBoxLayout(this->top_widget); | |
this->top_grid_layout = new QGridLayout(); | |
this->top_layout->addLayout(this->top_grid_layout); | |
this->settings = new QSettings("GNU Radio", "fm_tx"); | |
this->tb = gr::make_top_block("Fm Tx"); | |
// Blocks: | |
qtgui_time_sink_x_0_0_0 = qtgui::time_sink_f::make( | |
1024, // size | |
audio_rate, // samp_rate | |
"", // name | |
1 // number of inputs | |
); | |
QWidget* _qtgui_time_sink_x_0_0_0_win; | |
qtgui_time_sink_x_0_0_0->set_update_time(0.10); | |
qtgui_time_sink_x_0_0_0->set_y_axis(-1, 1); | |
qtgui_time_sink_x_0_0_0->set_y_label("Amplitude", ""); | |
qtgui_time_sink_x_0_0_0->enable_tags(true); | |
qtgui_time_sink_x_0_0_0->set_trigger_mode(gr::qtgui::TRIG_MODE_FREE, gr::qtgui::TRIG_SLOPE_POS, 0.0, 0,0, ""); | |
qtgui_time_sink_x_0_0_0->enable_autoscale(false); | |
qtgui_time_sink_x_0_0_0->enable_grid(false); | |
qtgui_time_sink_x_0_0_0->enable_axis_labels(true); | |
qtgui_time_sink_x_0_0_0->enable_control_panel(false); | |
qtgui_time_sink_x_0_0_0->enable_stem_plot(false); | |
{ | |
std::string labels[10] = {"Signal 1", "Signal 2", "Signal 3", "Signal 4", "Signal 5", | |
"Signal 6", "Signal 7", "Signal 8", "Signal 9", "Signal 10"}; | |
int widths[10] = {1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1}; | |
std::string colors[10] = {"blue", "red", "green", "black", "cyan", | |
"magenta", "yellow", "dark red", "dark green", "dark blue"}; | |
double alphas[10] = {1.0, 1.0, 1.0, 1.0, 1.0, | |
1.0, 1.0, 1.0, 1.0, 1.0}; | |
int markers[10] = {-1, -1, -1, -1, -1, | |
-1, -1, -1, -1, -1}; | |
int styles[10] = {1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1}; | |
for (int i = 0; i < 1; i++) { | |
if (sizeof(labels[i]) == 0) { | |
qtgui_time_sink_x_0_0_0->set_line_label(i, "Data " + std::to_string(i)); | |
} else { | |
qtgui_time_sink_x_0_0_0->set_line_label(i, labels[i]); | |
} | |
qtgui_time_sink_x_0_0_0->set_line_width(i, widths[i]); | |
qtgui_time_sink_x_0_0_0->set_line_color(i, colors[i]); | |
qtgui_time_sink_x_0_0_0->set_line_style(i, styles[i]); | |
qtgui_time_sink_x_0_0_0->set_line_marker(i, markers[i]); | |
qtgui_time_sink_x_0_0_0->set_line_alpha(i, alphas[i]); | |
} | |
} | |
_qtgui_time_sink_x_0_0_0_win = this->qtgui_time_sink_x_0_0_0->qwidget(); | |
top_grid_layout->addWidget(_qtgui_time_sink_x_0_0_0_win, 0, 0, 1, 1); | |
for(int r = 0;r < 1; r++) | |
top_grid_layout->setRowStretch(r, 1); | |
for(int c = 0; c <1; c++) | |
top_grid_layout->setColumnStretch(c, 1); | |
qtgui_time_sink_x_0_0 = qtgui::time_sink_c::make( | |
1024, // size | |
tx_rate, // samp_rate | |
"", // name | |
1 // number of inputs | |
); | |
QWidget* _qtgui_time_sink_x_0_0_win; | |
qtgui_time_sink_x_0_0->set_update_time(0.10); | |
qtgui_time_sink_x_0_0->set_y_axis(-1, 1); | |
qtgui_time_sink_x_0_0->set_y_label("Amplitude", ""); | |
qtgui_time_sink_x_0_0->enable_tags(true); | |
qtgui_time_sink_x_0_0->set_trigger_mode(gr::qtgui::TRIG_MODE_FREE, gr::qtgui::TRIG_SLOPE_POS, 0.0, 0,0, ""); | |
qtgui_time_sink_x_0_0->enable_autoscale(false); | |
qtgui_time_sink_x_0_0->enable_grid(false); | |
qtgui_time_sink_x_0_0->enable_axis_labels(true); | |
qtgui_time_sink_x_0_0->enable_control_panel(false); | |
qtgui_time_sink_x_0_0->enable_stem_plot(false); | |
{ | |
std::string labels[10] = {"Signal 1", "Signal 2", "Signal 3", "Signal 4", "Signal 5", | |
"Signal 6", "Signal 7", "Signal 8", "Signal 9", "Signal 10"}; | |
int widths[10] = {1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1}; | |
std::string colors[10] = {"blue", "red", "green", "black", "cyan", | |
"magenta", "yellow", "dark red", "dark green", "dark blue"}; | |
double alphas[10] = {1.0, 1.0, 1.0, 1.0, 1.0, | |
1.0, 1.0, 1.0, 1.0, 1.0}; | |
int markers[10] = {-1, -1, -1, -1, -1, | |
-1, -1, -1, -1, -1}; | |
int styles[10] = {1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1}; | |
for(int i=0; i <2; i++) { | |
if (sizeof(labels[i]) == 0) { | |
if (i % 2 == 0) | |
qtgui_time_sink_x_0_0->set_line_label(i, "Re Data " + std::to_string(i)); | |
else | |
qtgui_time_sink_x_0_0->set_line_label(i, "Im Data " + std::to_string(i)); | |
} | |
else | |
qtgui_time_sink_x_0_0->set_line_label(i, labels[i]); | |
qtgui_time_sink_x_0_0->set_line_width(i, widths[i]); | |
qtgui_time_sink_x_0_0->set_line_color(i, colors[i]); | |
qtgui_time_sink_x_0_0->set_line_style(i, styles[i]); | |
qtgui_time_sink_x_0_0->set_line_marker(i, markers[i]); | |
qtgui_time_sink_x_0_0->set_line_alpha(i, alphas[i]); | |
} | |
} | |
_qtgui_time_sink_x_0_0_win = this->qtgui_time_sink_x_0_0->qwidget(); | |
top_grid_layout->addWidget(_qtgui_time_sink_x_0_0_win, 0, 1, 1, 1); | |
for(int r = 0;r < 1; r++) | |
top_grid_layout->setRowStretch(r, 1); | |
for(int c = 1; c <2; c++) | |
top_grid_layout->setColumnStretch(c, 1); | |
qtgui_freq_sink_x_0_0 = qtgui::freq_sink_c::make( | |
1024, // size | |
fft::window::WIN_BLACKMAN_hARRIS, // wintype | |
0, // fc | |
tx_rate, // bw | |
"", // name | |
1 // nconnections | |
); | |
QWidget* _qtgui_freq_sink_x_0_0_win; | |
qtgui_freq_sink_x_0_0->set_update_time(0.10); | |
qtgui_freq_sink_x_0_0->set_y_axis((-140), 10); | |
qtgui_freq_sink_x_0_0->set_y_label("Relative Gain", "dB"); | |
qtgui_freq_sink_x_0_0->set_trigger_mode(gr::qtgui::TRIG_MODE_FREE, 0.0, 0, ""); | |
qtgui_freq_sink_x_0_0->enable_autoscale(false); | |
qtgui_freq_sink_x_0_0->enable_grid(false); | |
qtgui_freq_sink_x_0_0->set_fft_average(1.0); | |
qtgui_freq_sink_x_0_0->enable_axis_labels(true); | |
qtgui_freq_sink_x_0_0->enable_control_panel(false); | |
{ | |
std::string labels[10] = {"", "", "", "", "", | |
"", "", "", "", ""}; | |
int widths[10] = {1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1}; | |
std::string colors[10] = {"blue", "red", "green", "black", "cyan", | |
"magenta", "yellow", "dark red", "dark green", "dark blue"}; | |
double alphas[10] = {1.0, 1.0, 1.0, 1.0, 1.0, | |
1.0, 1.0, 1.0, 1.0, 1.0}; | |
for (int i = 0; i < 1; i++) { | |
if (sizeof(labels[i]) == 0) { | |
qtgui_freq_sink_x_0_0->set_line_label(i, "Data " + std::to_string(i)); | |
} else { | |
qtgui_freq_sink_x_0_0->set_line_label(i, labels[i]); | |
} | |
qtgui_freq_sink_x_0_0->set_line_width(i, widths[i]); | |
qtgui_freq_sink_x_0_0->set_line_color(i, colors[i]); | |
qtgui_freq_sink_x_0_0->set_line_alpha(i, alphas[i]); | |
} | |
} | |
_qtgui_freq_sink_x_0_0_win = this->qtgui_freq_sink_x_0_0->qwidget(); | |
top_grid_layout->addWidget(_qtgui_freq_sink_x_0_0_win, 1, 1, 1, 1); | |
for(int r = 1;r < 2; r++) | |
top_grid_layout->setRowStretch(r, 1); | |
for(int c = 1; c <2; c++) | |
top_grid_layout->setColumnStretch(c, 1); | |
qtgui_freq_sink_x_0 = qtgui::freq_sink_f::make( | |
1024, // size | |
fft::window::WIN_BLACKMAN_hARRIS, // wintype | |
0, // fc | |
audio_rate, // bw | |
"", // name | |
1 // nconnections | |
); | |
QWidget* _qtgui_freq_sink_x_0_win; | |
qtgui_freq_sink_x_0->set_update_time(0.10); | |
qtgui_freq_sink_x_0->set_y_axis((-140), 10); | |
qtgui_freq_sink_x_0->set_y_label("Relative Gain", "dB"); | |
qtgui_freq_sink_x_0->set_trigger_mode(gr::qtgui::TRIG_MODE_FREE, 0.0, 0, ""); | |
qtgui_freq_sink_x_0->enable_autoscale(false); | |
qtgui_freq_sink_x_0->enable_grid(false); | |
qtgui_freq_sink_x_0->set_fft_average(1.0); | |
qtgui_freq_sink_x_0->enable_axis_labels(true); | |
qtgui_freq_sink_x_0->enable_control_panel(false); | |
qtgui_freq_sink_x_0->set_plot_pos_half(not true); | |
{ | |
std::string labels[10] = {"", "", "", "", "", | |
"", "", "", "", ""}; | |
int widths[10] = {1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1}; | |
std::string colors[10] = {"blue", "red", "green", "black", "cyan", | |
"magenta", "yellow", "dark red", "dark green", "dark blue"}; | |
double alphas[10] = {1.0, 1.0, 1.0, 1.0, 1.0, | |
1.0, 1.0, 1.0, 1.0, 1.0}; | |
for (int i = 0; i < 1; i++) { | |
if (sizeof(labels[i]) == 0) { | |
qtgui_freq_sink_x_0->set_line_label(i, "Data " + std::to_string(i)); | |
} else { | |
qtgui_freq_sink_x_0->set_line_label(i, labels[i]); | |
} | |
qtgui_freq_sink_x_0->set_line_width(i, widths[i]); | |
qtgui_freq_sink_x_0->set_line_color(i, colors[i]); | |
qtgui_freq_sink_x_0->set_line_alpha(i, alphas[i]); | |
} | |
} | |
_qtgui_freq_sink_x_0_win = this->qtgui_freq_sink_x_0->qwidget(); | |
top_grid_layout->addWidget(_qtgui_freq_sink_x_0_win, 1, 0, 1, 1); | |
for(int r = 1;r < 2; r++) | |
top_grid_layout->setRowStretch(r, 1); | |
for(int c = 0; c <1; c++) | |
top_grid_layout->setColumnStretch(c, 1); | |
std::vector<float> taps = {irdes.low_pass_2(nfilts, nfilts*in_rate, 20e3, 2e3, 60, window.WIN_KAISER}; | |
this->pfb_arb_resampler_xxx_0 = gr::filter::pfb_arb_resampler_fff::make( | |
resamp_rate, | |
taps, | |
nfilts); | |
this->pfb_arb_resampler_xxx_0->declare_sample_delay(0); | |
this->blocks_skiphead_0 = blocks::skiphead::make(sizeof(gr_complex)*1, 5000); | |
this->blocks_head_0 = blocks::head::make(sizeof(gr_complex)*1, nitems); | |
this->blocks_file_sink_0 = blocks::file_sink::make(sizeof(gr_complex)*1, "dummy.dat", false); | |
this->blocks_add_xx_0 = blocks::add_ff::make(1); | |
this->audio_sink_0 = audio::sink::make(int(audio_rate), "", true); | |
this->analog_wfm_tx_0 = gr::analog::frequency_modulator_fc::make(2 * (GR_M_PI) * 75e3 / int(tx_rate)); | |
this->analog_sig_source_x_1 = analog::sig_source_f::make(audio_rate, analog::GR_COS_WAVE, 440, 0.25, 0,0); | |
this->analog_sig_source_x_0 = analog::sig_source_f::make(audio_rate, analog::GR_COS_WAVE, 350, 0.25, 0,0); | |
// Connections: | |
this->tb->hier_block2::connect(this->analog_sig_source_x_0, 0, this->blocks_add_xx_0, 0); | |
this->tb->hier_block2::connect(this->analog_sig_source_x_1, 0, this->blocks_add_xx_0, 1); | |
this->tb->hier_block2::connect(this->analog_wfm_tx_0, 0, this->blocks_skiphead_0, 0); | |
this->tb->hier_block2::connect(this->analog_wfm_tx_0, 0, this->qtgui_freq_sink_x_0_0, 0); | |
this->tb->hier_block2::connect(this->analog_wfm_tx_0, 0, this->qtgui_time_sink_x_0_0, 0); | |
this->tb->hier_block2::connect(this->blocks_add_xx_0, 0, this->audio_sink_0, 0); | |
this->tb->hier_block2::connect(this->blocks_add_xx_0, 0, this->pfb_arb_resampler_xxx_0, 0); | |
this->tb->hier_block2::connect(this->blocks_add_xx_0, 0, this->qtgui_freq_sink_x_0, 0); | |
this->tb->hier_block2::connect(this->blocks_add_xx_0, 0, this->qtgui_time_sink_x_0_0_0, 0); | |
this->tb->hier_block2::connect(this->blocks_head_0, 0, this->blocks_file_sink_0, 0); | |
this->tb->hier_block2::connect(this->blocks_skiphead_0, 0, this->blocks_head_0, 0); | |
this->tb->hier_block2::connect(this->pfb_arb_resampler_xxx_0, 0, this->analog_wfm_tx_0, 0); | |
} | |
fm_tx::~fm_tx () { | |
} | |
// Callbacks: | |
long fm_tx::get_nitems () const { | |
return this->nitems; | |
} | |
void fm_tx::set_nitems (long nitems) { | |
this->nitems = nitems; | |
this->blocks_head_0->set_length(this->nitems); | |
} | |
double fm_tx::get_in_rate () const { | |
return this->in_rate; | |
} | |
void fm_tx::set_in_rate (double in_rate) { | |
this->in_rate = in_rate; | |
this->set_resamp_rate(this->in_rate/this->audio_rate); | |
} | |
double fm_tx::get_audio_rate () const { | |
return this->audio_rate; | |
} | |
void fm_tx::set_audio_rate (double audio_rate) { | |
this->audio_rate = audio_rate; | |
this->set_resamp_rate(this->in_rate/this->audio_rate); | |
this->analog_sig_source_x_0->set_sampling_freq(this->audio_rate); | |
this->analog_sig_source_x_1->set_sampling_freq(this->audio_rate); | |
this->qtgui_freq_sink_x_0->set_frequency_range(0, this->audio_rate); | |
this->qtgui_time_sink_x_0_0_0->set_samp_rate(this->audio_rate); | |
} | |
double fm_tx::get_tx_rate () const { | |
return this->tx_rate; | |
} | |
void fm_tx::set_tx_rate (double tx_rate) { | |
this->tx_rate = tx_rate; | |
this->qtgui_freq_sink_x_0_0->set_frequency_range(0, this->tx_rate); | |
this->qtgui_time_sink_x_0_0->set_samp_rate(this->tx_rate); | |
} | |
double fm_tx::get_resamp_rate () const { | |
return this->resamp_rate; | |
} | |
void fm_tx::set_resamp_rate (double resamp_rate) { | |
this->resamp_rate = resamp_rate; | |
this->pfb_arb_resampler_xxx_0->set_rate(this->resamp_rate); | |
} | |
long fm_tx::get_nfilts () const { | |
return this->nfilts; | |
} | |
void fm_tx::set_nfilts (long nfilts) { | |
this->nfilts = nfilts; | |
} | |
int main (int argc, char **argv) { | |
long nitems = "1000000"; | |
po::options_description desc("Options"); | |
desc.add_options() | |
("help", "display help") | |
("nitems", po::value<long>(&nitems), "Parameter") | |
; | |
po::variables_map vm; | |
po::store(po::parse_command_line(argc, argv, desc), vm); | |
po::notify(vm); | |
if (vm.count("help")) { | |
std::cout << desc << std::endl; | |
return 0; | |
} | |
QApplication app(argc, argv); | |
fm_tx* top_block = new fm_tx(nitems); | |
top_block->tb->start(); | |
top_block->show(); | |
app.exec(); | |
return 0; | |
} | |
#include "moc_fm_tx.cpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef FM_TX_HPP | |
#define FM_TX_HPP | |
/******************** | |
GNU Radio C++ Flow Graph Header File | |
Title: Fm Tx | |
GNU Radio version: v3.11.0.0git-649-gd7cdf222 | |
********************/ | |
/******************** | |
** Create includes | |
********************/ | |
#include <gnuradio/top_block.h> | |
#include <gnuradio/analog/sig_source.h> | |
#include <gnuradio/analog/frequency_modulator_fc.h> | |
#include <gnuradio/math.h> | |
#include <gnuradio/audio/sink.h> | |
#include <gnuradio/blocks/add_blk.h> | |
#include <gnuradio/blocks/file_sink.h> | |
#include <gnuradio/blocks/head.h> | |
#include <gnuradio/blocks/skiphead.h> | |
#include <string> | |
#include <gnuradio/filter/pfb_arb_resampler_fff.h> | |
#include <gnuradio/qtgui/freq_sink_f.h> | |
#include <gnuradio/qtgui/freq_sink_c.h> | |
#include <gnuradio/qtgui/time_sink_c.h> | |
#include <gnuradio/qtgui/time_sink_f.h> | |
#include <QVBoxLayout> | |
#include <QScrollArea> | |
#include <QWidget> | |
#include <QGridLayout> | |
#include <QSettings> | |
#include <QApplication> | |
#include <boost/program_options.hpp> | |
using namespace gr; | |
class fm_tx : public QWidget { | |
Q_OBJECT | |
private: | |
QVBoxLayout *top_scroll_layout; | |
QScrollArea *top_scroll; | |
QWidget *top_widget; | |
QVBoxLayout *top_layout; | |
QGridLayout *top_grid_layout; | |
QSettings *settings; | |
qtgui::time_sink_f::sptr qtgui_time_sink_x_0_0_0; | |
qtgui::time_sink_c::sptr qtgui_time_sink_x_0_0; | |
qtgui::freq_sink_c::sptr qtgui_freq_sink_x_0_0; | |
qtgui::freq_sink_f::sptr qtgui_freq_sink_x_0; | |
gr::filter::pfb_arb_resampler_fff::sptr pfb_arb_resampler_xxx_0; | |
blocks::skiphead::sptr blocks_skiphead_0; | |
blocks::head::sptr blocks_head_0; | |
blocks::file_sink::sptr blocks_file_sink_0; | |
blocks::add_ff::sptr blocks_add_xx_0; | |
audio::sink::sptr audio_sink_0; | |
gr::analog::frequency_modulator_fc::sptr analog_wfm_tx_0; | |
analog::sig_source_f::sptr analog_sig_source_x_1; | |
analog::sig_source_f::sptr analog_sig_source_x_0; | |
// Parameters: | |
long nitems = "1000000"; | |
// Variables: | |
double in_rate = 50e3; | |
double audio_rate = 44.1e3; | |
double tx_rate = 400e3; | |
double resamp_rate = in_rate/audio_rate; | |
long nfilts = 32; | |
public: | |
top_block_sptr tb; | |
fm_tx(long nitems); | |
~fm_tx(); | |
long get_nitems () const; | |
void set_nitems(long nitems); | |
double get_in_rate () const; | |
void set_in_rate(double in_rate); | |
double get_audio_rate () const; | |
void set_audio_rate(double audio_rate); | |
double get_tx_rate () const; | |
void set_tx_rate(double tx_rate); | |
double get_resamp_rate () const; | |
void set_resamp_rate(double resamp_rate); | |
long get_nfilts () const; | |
void set_nfilts(long nfilts); | |
}; | |
#endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment