summaryrefslogtreecommitdiff
path: root/gr-vocoder/lib
diff options
context:
space:
mode:
authorA. Maitland Bottoms <bottoms@debian.org>2019-03-11 22:54:21 -0400
committerAndrej Rode <mail@andrejro.de>2019-03-24 20:14:42 +0100
commite02eed791069c82bd262f4b2cbe324db76326e54 (patch)
tree8d7393cb9ef7caa8a2088d66ca19f1a285307b5f /gr-vocoder/lib
parentb9e5abc5972706f078a51b6d0bb9dbb6535c5b9c (diff)
gr-vocoder: update codec2 and freedv blocks.
Update to add support for newer modes in codec2 0.8.1. Fixup grc blocks yml templates, update examples.
Diffstat (limited to 'gr-vocoder/lib')
-rw-r--r--gr-vocoder/lib/freedv_rx_ss_impl.cc31
-rw-r--r--gr-vocoder/lib/freedv_rx_ss_impl.h10
-rw-r--r--gr-vocoder/lib/freedv_tx_ss_impl.cc53
-rw-r--r--gr-vocoder/lib/freedv_tx_ss_impl.h17
4 files changed, 96 insertions, 15 deletions
diff --git a/gr-vocoder/lib/freedv_rx_ss_impl.cc b/gr-vocoder/lib/freedv_rx_ss_impl.cc
index 748a5c10aa..f1096b2391 100644
--- a/gr-vocoder/lib/freedv_rx_ss_impl.cc
+++ b/gr-vocoder/lib/freedv_rx_ss_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2016 Free Software Foundation, Inc.
+ * Copyright 2016-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -47,20 +47,31 @@ namespace gr {
namespace vocoder {
freedv_rx_ss::sptr
- freedv_rx_ss::make(int mode, float squelch_thresh)
+ freedv_rx_ss::make(int mode, float squelch_thresh, int interleave_frames)
{
return gnuradio::get_initial_sptr
- (new freedv_rx_ss_impl(mode, squelch_thresh));
+ (new freedv_rx_ss_impl(mode, squelch_thresh, interleave_frames));
}
- freedv_rx_ss_impl::freedv_rx_ss_impl (int mode, float squelch_thresh)
+ freedv_rx_ss_impl::freedv_rx_ss_impl (int mode, float squelch_thresh, int interleave_frames)
: gr::block("vocoder_freedv_rx_ss",
io_signature::make(1, 1, sizeof(short)),
io_signature::make(1, 1, sizeof(short))),
- d_mode(mode), d_squelch_thresh(squelch_thresh)
+ d_mode(mode), d_squelch_thresh(squelch_thresh), d_interleave_frames(interleave_frames)
{
+#ifdef FREEDV_MODE_700D
+ if (mode == FREEDV_MODE_700D) {
+ d_adv.interleave_frames = interleave_frames;
+ if((d_freedv = freedv_open_advanced(mode, &d_adv)) ==NULL)
+ throw std::runtime_error("freedv_tx_ss_impl: freedv_open_advanced failed");
+ } else {
+ if((d_freedv = freedv_open(mode)) == NULL)
+ throw std::runtime_error("freedv_tx_ss_impl: freedv_open failed");
+ }
+#else
if((d_freedv = freedv_open(mode)) == NULL)
throw std::runtime_error("freedv_rx_ss_impl: freedv_open failed");
+#endif
freedv_set_snr_squelch_thresh(d_freedv, d_squelch_thresh);
freedv_set_squelch_en(d_freedv, 0);
freedv_set_callback_txt(d_freedv, put_next_rx_char, NULL, (void *) &d_cb_state);
@@ -138,6 +149,16 @@ namespace gr {
freedv_set_snr_squelch_thresh(d_freedv, d_squelch_thresh);
}
+ void freedv_rx_ss_impl::set_squelch_en(bool squelch_enabled)
+ {
+ gr::thread::scoped_lock l(d_setlock);
+ d_squelch_en = squelch_enabled;
+ if (squelch_enabled)
+ freedv_set_squelch_en(d_freedv, 1);
+ else
+ freedv_set_squelch_en(d_freedv, 0);
+ }
+
float freedv_rx_ss_impl::squelch_thresh() {
return(d_squelch_thresh);
}
diff --git a/gr-vocoder/lib/freedv_rx_ss_impl.h b/gr-vocoder/lib/freedv_rx_ss_impl.h
index acc49d9d82..56a770be36 100644
--- a/gr-vocoder/lib/freedv_rx_ss_impl.h
+++ b/gr-vocoder/lib/freedv_rx_ss_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2016 Free Software Foundation, Inc.
+ * Copyright 2016-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -53,18 +53,24 @@ namespace gr {
int d_total_bit_errors;
float d_snr_est;
float d_squelch_thresh;
+ bool d_squelch_en;
int d_speech_samples;
int d_max_modem_samples;
float d_clock_offset;
int d_use_codecrx;
+ int d_interleave_frames;
+#ifdef FREEDV_MODE_700D
+ struct freedv_advanced d_adv;
+#endif
struct CODEC2 *d_c2 = NULL;
public:
- freedv_rx_ss_impl(int mode, float squelch_thresh);
+ freedv_rx_ss_impl(int mode, float squelch_thresh, int interleave_frames);
~freedv_rx_ss_impl();
void set_squelch_thresh(float squelch_thresh);
float squelch_thresh();
+ void set_squelch_en(bool squelch_enabled);
// Where all the action really happens
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
diff --git a/gr-vocoder/lib/freedv_tx_ss_impl.cc b/gr-vocoder/lib/freedv_tx_ss_impl.cc
index a375510050..e56267d5ef 100644
--- a/gr-vocoder/lib/freedv_tx_ss_impl.cc
+++ b/gr-vocoder/lib/freedv_tx_ss_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2016 Free Software Foundation, Inc.
+ * Copyright 2016-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -54,20 +54,31 @@ namespace gr {
namespace vocoder {
freedv_tx_ss::sptr
- freedv_tx_ss::make(int mode, const std::string msg_txt)
+ freedv_tx_ss::make(int mode, const std::string msg_txt, int interleave_frames)
{
return gnuradio::get_initial_sptr
- (new freedv_tx_ss_impl(mode, msg_txt));
+ (new freedv_tx_ss_impl(mode, msg_txt, interleave_frames));
}
- freedv_tx_ss_impl::freedv_tx_ss_impl(int mode, const std::string msg_txt)
+ freedv_tx_ss_impl::freedv_tx_ss_impl(int mode, const std::string msg_txt, int interleave_frames)
: sync_block("vocoder_freedv_tx_ss",
io_signature::make(1, 1, sizeof(short)),
io_signature::make(1, 1, sizeof(short))),
- d_mode(mode), d_msg_text(msg_txt)
+ d_mode(mode), d_msg_text(msg_txt), d_interleave_frames(interleave_frames)
{
+#ifdef FREEDV_MODE_700D
+ if (mode == FREEDV_MODE_700D) {
+ d_adv.interleave_frames = interleave_frames;
+ if((d_freedv = freedv_open_advanced(mode, &d_adv)) ==NULL)
+ throw std::runtime_error("freedv_tx_ss_impl: freedv_open_advanced failed");
+ } else {
+ if((d_freedv = freedv_open(mode)) == NULL)
+ throw std::runtime_error("freedv_tx_ss_impl: freedv_open failed");
+ }
+#else
if((d_freedv = freedv_open(mode)) == NULL)
throw std::runtime_error("freedv_tx_ss_impl: freedv_open failed");
+#endif
snprintf(d_cb_state.tx_str,79,"%s",d_msg_text.c_str());
d_cb_state.ptx_str = d_cb_state.tx_str;
freedv_set_callback_txt(d_freedv, NULL, get_next_tx_char, (void *) &d_cb_state);
@@ -80,6 +91,38 @@ namespace gr {
freedv_close(d_freedv);
}
+ void freedv_tx_ss_impl::set_clip(int val)
+ {
+ d_clip = val;
+#if defined(FREEDV_MODE_700C) || defined(FREEDV_MODE_700D)
+ freedv_set_clip(d_freedv, d_clip);
+#endif
+ }
+
+ void freedv_tx_ss_impl::set_clip(bool val)
+ {
+ if (val)
+ freedv_tx_ss_impl::set_clip(1);
+ else
+ freedv_tx_ss_impl::set_clip(0);
+ }
+
+ void freedv_tx_ss_impl::set_tx_bpf(int val)
+ {
+ d_tx_bpf = val;
+#ifdef FREEDV_MODE_700D
+ freedv_set_tx_bpf(d_freedv, d_tx_bpf);
+#endif
+ }
+
+ void freedv_tx_ss_impl::set_tx_bpf(bool val)
+ {
+ if (val)
+ freedv_tx_ss_impl::set_tx_bpf(1);
+ else
+ freedv_tx_ss_impl::set_tx_bpf(0);
+ }
+
int
freedv_tx_ss_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/gr-vocoder/lib/freedv_tx_ss_impl.h b/gr-vocoder/lib/freedv_tx_ss_impl.h
index a023b67f5b..167ee28ea8 100644
--- a/gr-vocoder/lib/freedv_tx_ss_impl.h
+++ b/gr-vocoder/lib/freedv_tx_ss_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2016 Free Software Foundation, Inc.
+ * Copyright 2016-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -48,18 +48,29 @@ namespace gr {
struct freedv_tx_callback_state d_cb_state;
struct freedv *d_freedv;
int d_mode;
+ std::string d_msg_text;
+ int d_interleave_frames;
float d_squelch_thresh;
int d_speech_samples;
int d_nom_modem_samples;
int d_use_codectx;
int d_use_datatx;
- std::string d_msg_text;
+ int d_clip;
+ int d_tx_bpf;
+#ifdef FREEDV_MODE_700D
+ struct freedv_advanced d_adv;
+#endif
struct CODEC2 *d_c2;
public:
- freedv_tx_ss_impl(int mode, const std::string txt_msg);
+ freedv_tx_ss_impl(int mode, const std::string txt_msg, int interleave_frames);
~freedv_tx_ss_impl();
+ void set_clip(bool val);
+ void set_clip(int val);
+ void set_tx_bpf(bool val);
+ void set_tx_bpf(int val);
+
// Where all the action really happens
int work(int noutput_items,
gr_vector_const_void_star &input_items,