>From 2d5e63a579991830732fda10ad35fd2170252d69 Mon Sep 17 00:00:00 2001 From: "A. Maitland Bottoms" Date: Tue, 22 Jan 2019 22:54:21 -0500 Subject: [PATCH] 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. --- gr-vocoder/examples/CMakeLists.txt | 7 +- gr-vocoder/examples/grfreedv.grc | 809 +++------ gr-vocoder/examples/loopback-codec2.grc | 1773 +++++++------------- gr-vocoder/grc/vocoder_codec2_decode_ps.block.yml | 12 +- gr-vocoder/grc/vocoder_codec2_encode_sp.block.yml | 12 +- gr-vocoder/grc/vocoder_freedv_rx_ss.block.yml | 22 +- gr-vocoder/grc/vocoder_freedv_tx_ss.block.yml | 25 +- gr-vocoder/include/gnuradio/vocoder/codec2.h | 8 +- gr-vocoder/include/gnuradio/vocoder/freedv_api.h | 11 +- gr-vocoder/include/gnuradio/vocoder/freedv_rx_ss.h | 6 +- gr-vocoder/include/gnuradio/vocoder/freedv_tx_ss.h | 5 +- gr-vocoder/lib/freedv_rx_ss_impl.cc | 31 +- gr-vocoder/lib/freedv_rx_ss_impl.h | 10 +- gr-vocoder/lib/freedv_tx_ss_impl.cc | 53 +- gr-vocoder/lib/freedv_tx_ss_impl.h | 17 +- gr-vocoder/swig/vocoder_swig.i | 6 +- 16 files changed, 970 insertions(+), 1837 deletions(-) diff --git a/gr-vocoder/examples/CMakeLists.txt b/gr-vocoder/examples/CMakeLists.txt index 20e250fe29..9bfe72c782 100644 --- a/gr-vocoder/examples/CMakeLists.txt +++ b/gr-vocoder/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011,2016 Free Software Foundation, Inc. +# Copyright 2011,2016,2019 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -36,7 +36,12 @@ if(LIBCODEC2_FOUND) GR_PYTHON_INSTALL( PROGRAMS codec2_audio_loopback.py + DESTINATION ${GR_PKG_VOCODER_EXAMPLES_DIR} + ) + install( + PROGRAMS grfreedv.grc + loopback-codec2.grc DESTINATION ${GR_PKG_VOCODER_EXAMPLES_DIR} ) endif(LIBCODEC2_FOUND) diff --git a/gr-vocoder/examples/grfreedv.grc b/gr-vocoder/examples/grfreedv.grc index 9f6b95d5bd..dc8594eee9 100644 --- a/gr-vocoder/examples/grfreedv.grc +++ b/gr-vocoder/examples/grfreedv.grc @@ -1,616 +1,193 @@ - - - - Wed Jun 29 19:22:27 2016 - - options - - author - A. MAitland Bottoms - - - window_size - - - - category - Custom - - - comment - - - - description - A FreeDV Modulator - - - _enabled - True - - - _coordinate - (8, 8) - - - _rotation - 0 - - - generate_options - qt_gui - - - hier_block_src_path - .: - - - id - grfreedv - - - max_nouts - 0 - - - qt_qss_theme - - - - realtime_scheduling - - - - run_command - {python} -u {filename} - - - run_options - prompt - - - run - True - - - thread_safe_setters - - - - title - GNU Radio FreeDV - - - - variable - - comment - - - - _enabled - True - - - _coordinate - (8, 160) - - - _rotation - 0 - - - id - samp_rate - - - value - 8000 - - - - variable_qtgui_range - - comment - - - - value - -120 - - - _enabled - True - - - _coordinate - (232, 16) - - - gui_hint - - - - _rotation - 0 - - - id - squelch - - - label - squelch slider - - - min_len - 256 - - - orient - Qt.Horizontal - - - start - -127 - - - step - 1 - - - stop - 128 - - - rangeType - float - - - widget - counter_slider - - - - audio_sink - - alias - - - - comment - - - - affinity - - - - device_name - - - - _enabled - True - - - _coordinate - (920, 228) - - - _rotation - 0 - - - id - audio_sink_0 - - - num_inputs - 1 - - - ok_to_block - True - - - samp_rate - samp_rate - - - - audio_source - - alias - - - - comment - - - - affinity - - - - device_name - hw:2,0 - - - _enabled - 0 - - - _coordinate - (16, 325) - - - _rotation - 0 - - - id - audio_source_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - num_outputs - 1 - - - ok_to_block - True - - - samp_rate - 48000 - - - - blocks_float_to_short - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - _coordinate - (256, 228) - - - _rotation - 0 - - - id - blocks_float_to_short_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - scale - 32768 - - - vlen - 1 - - - - blocks_short_to_float - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - _coordinate - (736, 228) - - - _rotation - 0 - - - id - blocks_short_to_float_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - scale - 32768 - - - vlen - 1 - - - - blocks_wavfile_source - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - file - /usr/share/codec2/wav/all.wav - - - _coordinate - (24, 221) - - - _rotation - 0 - - - id - blocks_wavfile_source_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - nchan - 1 - - - repeat - True - - - - rational_resampler_xxx - - alias - - - - comment - - - - affinity - - - - decim - 6 - - - _enabled - 0 - - - fbw - 0 - - - _coordinate - (216, 303) - - - _rotation - 0 - - - id - rational_resampler_xxx_0 - - - interp - 1 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - taps - - - - type - fff - - - - vocoder_freedv_rx_ss - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - _coordinate - (576, 325) - - - _rotation - 0 - - - id - vocoder_freedv_rx_ss_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - mode - freedv_api.MODE_1600 - - - squelch_thresh - squelch - - - - vocoder_freedv_tx_ss - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - _coordinate - (424, 221) - - - _rotation - 0 - - - id - vocoder_freedv_tx_ss_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - mode - freedv_api.MODE_1600 - - - txt_msg - 'GNU Radio' - - - - audio_source_0 - rational_resampler_xxx_0 - 0 - 0 - - - blocks_float_to_short_0 - vocoder_freedv_tx_ss_0 - 0 - 0 - - - blocks_short_to_float_0 - audio_sink_0 - 0 - 0 - - - blocks_wavfile_source_0 - blocks_float_to_short_0 - 0 - 0 - - - rational_resampler_xxx_0 - blocks_float_to_short_0 - 0 - 0 - - - vocoder_freedv_rx_ss_0 - blocks_short_to_float_0 - 0 - 0 - - - vocoder_freedv_tx_ss_0 - vocoder_freedv_rx_ss_0 - 0 - 0 - - +options: + parameters: + author: A. Maitland Bottoms + category: Custom + cmake_opt: '' + comment: '' + copyright: '2016,2019 Free Software Foundation, Inc.' + description: A FreeDV Modulator + gen_cmake: 'On' + gen_linking: dynamic + generate_options: qt_gui + hier_block_src_path: '.:' + id: grfreedv + max_nouts: '0' + output_language: python + placement: (0,0) + qt_qss_theme: '' + realtime_scheduling: '' + run: 'True' + run_command: '{python} -u {filename}' + run_options: prompt + sizing_mode: fixed + thread_safe_setters: '' + title: GNU Radio FreeDV + window_size: '' + states: + coordinate: [8, 8] + rotation: 0 + state: enabled + +blocks: +- name: samp_rate + id: variable + parameters: + comment: '' + value: '8000' + states: + coordinate: [8, 160] + rotation: 0 + state: enabled +- name: squelch + id: variable_qtgui_range + parameters: + comment: '' + gui_hint: '' + label: squelch slider + min_len: '256' + orient: Qt.Horizontal + rangeType: float + start: '-127' + step: '1' + stop: '128' + value: '-120' + widget: counter_slider + states: + coordinate: [232, 16] + rotation: 0 + state: enabled +- name: audio_sink_0 + id: audio_sink + parameters: + affinity: '' + alias: '' + comment: '' + device_name: '' + num_inputs: '1' + ok_to_block: 'True' + samp_rate: samp_rate + states: + coordinate: [792, 316.0] + rotation: 0 + state: enabled +- name: audio_source_0 + id: audio_source + parameters: + affinity: '' + alias: '' + comment: '' + device_name: hw:2,0 + maxoutbuf: '0' + minoutbuf: '0' + num_outputs: '1' + ok_to_block: 'True' + samp_rate: '48000' + states: + coordinate: [16, 325] + rotation: 0 + state: disabled +- name: blocks_float_to_short_0 + id: blocks_float_to_short + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + scale: '32768' + vlen: '1' + states: + coordinate: [256, 228] + rotation: 0 + state: enabled +- name: blocks_short_to_float_0 + id: blocks_short_to_float + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + scale: '32768' + vlen: '1' + states: + coordinate: [736, 228] + rotation: 0 + state: enabled +- name: blocks_wavfile_source_0 + id: blocks_wavfile_source + parameters: + affinity: '' + alias: '' + comment: '' + file: /usr/share/codec2/wav/all.wav + maxoutbuf: '0' + minoutbuf: '0' + nchan: '1' + repeat: 'True' + states: + coordinate: [24, 221] + rotation: 0 + state: enabled +- name: rational_resampler_xxx_0 + id: rational_resampler_xxx + parameters: + affinity: '' + alias: '' + comment: '' + decim: '6' + fbw: '0' + interp: '1' + maxoutbuf: '0' + minoutbuf: '0' + taps: '' + type: fff + states: + coordinate: [216, 303] + rotation: 0 + state: disabled +- name: vocoder_freedv_rx_ss_0 + id: vocoder_freedv_rx_ss + parameters: + affinity: '' + alias: '' + comment: '' + interleave_frames: '1' + maxoutbuf: '0' + minoutbuf: '0' + mode: freedv_api.MODE_1600 + squelch_enable: 'True' + squelch_thresh: squelch + states: + coordinate: [568, 92.0] + rotation: 0 + state: enabled +- name: vocoder_freedv_tx_ss_0 + id: vocoder_freedv_tx_ss + parameters: + affinity: '' + alias: '' + clip_val: 'False' + comment: '' + interleave_frames: '1' + maxoutbuf: '0' + minoutbuf: '0' + mode: freedv_api.MODE_1600 + tx_bpf_val: 'True' + txt_msg: '''GNU Radio''' + states: + coordinate: [360, 84.0] + rotation: 0 + state: enabled + +connections: +- [audio_source_0, '0', rational_resampler_xxx_0, '0'] +- [blocks_float_to_short_0, '0', vocoder_freedv_tx_ss_0, '0'] +- [blocks_short_to_float_0, '0', audio_sink_0, '0'] +- [blocks_wavfile_source_0, '0', blocks_float_to_short_0, '0'] +- [rational_resampler_xxx_0, '0', blocks_float_to_short_0, '0'] +- [vocoder_freedv_rx_ss_0, '0', blocks_short_to_float_0, '0'] +- [vocoder_freedv_tx_ss_0, '0', vocoder_freedv_rx_ss_0, '0'] + +metadata: + file_format: 1 diff --git a/gr-vocoder/examples/loopback-codec2.grc b/gr-vocoder/examples/loopback-codec2.grc index 4d22c8fc74..742fb4cefe 100644 --- a/gr-vocoder/examples/loopback-codec2.grc +++ b/gr-vocoder/examples/loopback-codec2.grc @@ -1,1184 +1,589 @@ - - - Fri Mar 7 18:08:43 2014 - - options - - id - loopback_codec2 - - - _enabled - True - - - title - Codec2 Looback Test - - - author - Martin Braun - - - description - An example how to use the Codec2 Vocoder - - - window_size - 1280, 1024 - - - generate_options - qt_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - max_nouts - 0 - - - realtime_scheduling - - - - _coordinate - (0, -1) - - - _rotation - 0 - - - - variable - - id - scale - - - _enabled - True - - - value - 2**13 - - - _coordinate - (301, -1) - - - _rotation - 0 - - - - variable - - id - samp_rate - - - _enabled - True - - - value - 48000 - - - _coordinate - (186, 0) - - - _rotation - 0 - - - - blocks_float_to_short - - id - blocks_float_to_short_0 - - - _enabled - True - - - vlen - 1 - - - scale - scale - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (417, 119) - - - _rotation - 0 - - - - qtgui_time_sink_x - - id - qtgui_time_sink_x_0_0 - - - _enabled - True - - - type - float - - - name - Audio Pre-Encoding - - - size - 1024 - - - srate - 8000 - - - ymin - -1 - - - ymax - 1 - - - nconnections - 1 - - - update_time - 0.10 - - - tr_mode - qtgui.TRIG_MODE_FREE - - - tr_slope - qtgui.TRIG_SLOPE_POS - - - tr_level - 0.0 - - - tr_delay - 0 - - - tr_chan - 0 - - - tr_tag - "" - - - entags - True - - - gui_hint - - - - affinity - - - - _coordinate - (434, 202) - - - _rotation - 0 - - - - rational_resampler_xxx - - id - rational_resampler_xxx_0 - - - _enabled - True - - - type - fff - - - interp - 1 - - - decim - 6 - - - taps - - - - fbw - 0 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (204, 94) - - - _rotation - 0 - - - - virtual_source - - id - virtual_source_1_0 - - - _enabled - True - - - stream_id - Decoded Speech - - - _coordinate - (3, 449) - - - _rotation - 0 - - - - variable_qtgui_check_box - - id - play_encoded - - - _enabled - True - - - label - Encode Audio - - - type - int - - - value - True - - - true - 1 - - - false - 0 - - - gui_hint - - - - _coordinate - (834, 0) - - - _rotation - 0 - - - - blks2_selector - - id - blks2_selector_0 - - - _enabled - True - - - type - float - - - num_inputs - 2 - - - num_outputs - 1 - - - input_index - play_encoded - - - output_index - 0 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (280, 411) - - - _rotation - 0 - - - - rational_resampler_xxx - - id - rational_resampler_xxx_1 - - - _enabled - True - - - type - fff - - - interp - 6 - - - decim - 1 - - - taps - - - - fbw - 0 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (478, 400) - - - _rotation - 0 - - - - audio_sink - - id - audio_sink_0 - - - _enabled - True - - - samp_rate - 48000 - - - device_name - - - - ok_to_block - True - - - num_inputs - 1 - - - affinity - - - - _coordinate - (706, 424) - - - _rotation - 0 - - - - vocoder_codec2_encode_sp - - id - vocoder_codec2_encode_sp_0 - - - _enabled - True - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (590, 123) - - - _rotation - 0 - - - - blocks_vector_to_stream - - id - blocks_vector_to_stream_0 - - - _enabled - True - - - type - byte - - - num_items - 50 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (822, 119) - - - _rotation - 0 - - - - virtual_source - - id - virtual_source_0 - - - _enabled - True - - - stream_id - Encoded Speech - - - _coordinate - (0, 298) - - - _rotation - 0 - - - - blocks_stream_to_vector - - id - blocks_stream_to_vector_0 - - - _enabled - True - - - type - byte - - - num_items - 50 - - - vlen - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (444, 298) - - - _rotation - 0 - - - - vocoder_codec2_decode_ps - - id - vocoder_codec2_decode_ps_0 - - - _enabled - True - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (641, 302) - - - _rotation - 0 - - - - blocks_short_to_float - - id - blocks_short_to_float_0 - - - _enabled - True - - - vlen - 1 - - - scale - scale - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (735, 361) - - - _rotation - 0 - - - - virtual_sink - - id - virtual_sink_2 - - - _enabled - True - - - stream_id - Decoded Speech - - - _coordinate - (960, 393) - - - _rotation - 0 - - - - qtgui_time_sink_x - - id - qtgui_time_sink_x_0 - - - _enabled - True - - - type - float - - - name - Audio Post-Encoding - - - size - 1024 - - - srate - 8000 - - - ymin - -1 - - - ymax - 1 - - - nconnections - 1 - - - update_time - 0.10 - - - tr_mode - qtgui.TRIG_MODE_FREE - - - tr_slope - qtgui.TRIG_SLOPE_POS - - - tr_level - 0.0 - - - tr_delay - 0 - - - tr_chan - 0 - - - tr_tag - "" - - - entags - True - - - gui_hint - - - - affinity - - - - _coordinate - (960, 283) - - - _rotation - 0 - - - - audio_source - - id - audio_source_0 - - - _enabled - False - - - samp_rate - 48000 - - - device_name - - - - ok_to_block - True - - - num_outputs - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (0, 117) - - - _rotation - 0 - - - - blocks_wavfile_source - - id - blocks_wavfile_source_0 - - - _enabled - True - - - file - /home/mbr0wn/12345.wav - - - repeat - True - - - nchan - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (-1, 225) - - - _rotation - 0 - - - - blocks_packed_to_unpacked_xx - - id - blocks_packed_to_unpacked_xx_0 - - - _enabled - True - - - type - byte - - - bits_per_chunk - 1 - - - endianness - gr.GR_LSB_FIRST - - - num_ports - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (229, 290) - - - _rotation - 0 - - - - virtual_sink - - id - virtual_sink_0 - - - _enabled - True - - - stream_id - Encoded Speech - - - _coordinate - (908, 207) - - - _rotation - 0 - - - - blocks_unpacked_to_packed_xx - - id - blocks_unpacked_to_packed_xx_0 - - - _enabled - True - - - type - byte - - - bits_per_chunk - 1 - - - endianness - gr.GR_LSB_FIRST - - - num_ports - 1 - - - affinity - - - - minoutbuf - 0 - - - maxoutbuf - 0 - - - _coordinate - (694, 199) - - - _rotation - 0 - - - - virtual_sink - - id - virtual_sink_1 - - - _enabled - True - - - stream_id - Raw Audio - - - _coordinate - (508, 25) - - - _rotation - 0 - - - - virtual_source - - id - virtual_source_1 - - - _enabled - True - - - stream_id - Raw Audio - - - _coordinate - (-1, 389) - - - _rotation - 0 - - - - audio_source_0 - rational_resampler_xxx_0 - 0 - 0 - - - rational_resampler_xxx_0 - blocks_float_to_short_0 - 0 - 0 - - - blocks_float_to_short_0 - vocoder_codec2_encode_sp_0 - 0 - 0 - - - blocks_wavfile_source_0 - rational_resampler_xxx_0 - 0 - 0 - - - rational_resampler_xxx_0 - qtgui_time_sink_x_0_0 - 0 - 0 - - - rational_resampler_xxx_0 - virtual_sink_1 - 0 - 0 - - - virtual_source_1 - blks2_selector_0 - 0 - 0 - - - virtual_source_1_0 - blks2_selector_0 - 0 - 1 - - - rational_resampler_xxx_1 - audio_sink_0 - 0 - 0 - - - blks2_selector_0 - rational_resampler_xxx_1 - 0 - 0 - - - vocoder_codec2_encode_sp_0 - blocks_vector_to_stream_0 - 0 - 0 - - - blocks_vector_to_stream_0 - blocks_unpacked_to_packed_xx_0 - 0 - 0 - - - blocks_unpacked_to_packed_xx_0 - virtual_sink_0 - 0 - 0 - - - blocks_short_to_float_0 - virtual_sink_2 - 0 - 0 - - - blocks_short_to_float_0 - qtgui_time_sink_x_0 - 0 - 0 - - - vocoder_codec2_decode_ps_0 - blocks_short_to_float_0 - 0 - 0 - - - blocks_stream_to_vector_0 - vocoder_codec2_decode_ps_0 - 0 - 0 - - - virtual_source_0 - blocks_packed_to_unpacked_xx_0 - 0 - 0 - - - blocks_packed_to_unpacked_xx_0 - blocks_stream_to_vector_0 - 0 - 0 - - +options: + parameters: + author: Martin Braun + category: Custom + cmake_opt: '' + comment: '' + copyright: '2014,2019 Free Software Foundation, Inc.' + description: An example how to use the Codec2 Vocoder + gen_cmake: 'On' + gen_linking: dynamic + generate_options: qt_gui + hier_block_src_path: '.:' + id: loopback_codec2 + max_nouts: '0' + output_language: python + placement: (0,0) + qt_qss_theme: '' + realtime_scheduling: '' + run: 'True' + run_command: '{python} -u {filename}' + run_options: prompt + sizing_mode: fixed + thread_safe_setters: '' + title: Codec2 Looback Test + window_size: 1280, 1024 + states: + coordinate: [0, -1] + rotation: 0 + state: enabled + +blocks: +- name: play_encoded + id: variable_qtgui_check_box + parameters: + comment: '' + 'false': '0' + gui_hint: '' + label: Encode Audio + 'true': '1' + type: int + value: 'True' + states: + coordinate: [688, 12.0] + rotation: 0 + state: enabled +- name: samp_rate + id: variable + parameters: + comment: '' + value: '48000' + states: + coordinate: [186, 0] + rotation: 0 + state: enabled +- name: scale + id: variable + parameters: + comment: '' + value: 2**13 + states: + coordinate: [301, -1] + rotation: 0 + state: enabled +- name: audio_sink_0 + id: audio_sink + parameters: + affinity: '' + alias: '' + comment: '' + device_name: '' + num_inputs: '1' + ok_to_block: 'True' + samp_rate: '48000' + states: + coordinate: [784, 420.0] + rotation: 0 + state: enabled +- name: audio_source_0 + id: audio_source + parameters: + affinity: '' + alias: '' + comment: '' + device_name: '' + maxoutbuf: '0' + minoutbuf: '0' + num_outputs: '1' + ok_to_block: 'True' + samp_rate: '48000' + states: + coordinate: [0, 116.0] + rotation: 0 + state: enabled +- name: blocks_add_xx_0 + id: blocks_add_xx + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '' + minoutbuf: '' + num_inputs: '2' + type: float + vlen: '1' + states: + coordinate: [480, 408.0] + rotation: 0 + state: true +- name: blocks_float_to_short_0 + id: blocks_float_to_short + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + scale: scale + vlen: '1' + states: + coordinate: [416, 116.0] + rotation: 0 + state: enabled +- name: blocks_multiply_const_vxx_0 + id: blocks_multiply_const_vxx + parameters: + affinity: '' + alias: '' + comment: '' + const: 0.0 if play_encoded else 1.0 + maxoutbuf: '' + minoutbuf: '' + type: float + vlen: '1' + states: + coordinate: [224, 388.0] + rotation: 0 + state: true +- name: blocks_multiply_const_vxx_1 + id: blocks_multiply_const_vxx + parameters: + affinity: '' + alias: '' + comment: '' + const: 1.0 if play_encoded else 0.0 + maxoutbuf: '' + minoutbuf: '' + type: float + vlen: '1' + states: + coordinate: [224, 452.0] + rotation: 0 + state: true +- name: blocks_packed_to_unpacked_xx_0 + id: blocks_packed_to_unpacked_xx + parameters: + affinity: '' + alias: '' + bits_per_chunk: '1' + comment: '' + endianness: gr.GR_LSB_FIRST + maxoutbuf: '0' + minoutbuf: '0' + num_ports: '1' + type: byte + states: + coordinate: [224, 284.0] + rotation: 0 + state: enabled +- name: blocks_short_to_float_0 + id: blocks_short_to_float + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + scale: scale + vlen: '1' + states: + coordinate: [735, 361] + rotation: 0 + state: enabled +- name: blocks_stream_to_vector_0 + id: blocks_stream_to_vector + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + num_items: '48' + type: byte + vlen: '1' + states: + coordinate: [432, 296.0] + rotation: 0 + state: enabled +- name: blocks_unpacked_to_packed_xx_0 + id: blocks_unpacked_to_packed_xx + parameters: + affinity: '' + alias: '' + bits_per_chunk: '1' + comment: '' + endianness: gr.GR_LSB_FIRST + maxoutbuf: '0' + minoutbuf: '0' + num_ports: '1' + type: byte + states: + coordinate: [694, 199] + rotation: 0 + state: enabled +- name: blocks_vector_to_stream_0 + id: blocks_vector_to_stream + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + num_items: '48' + type: byte + vlen: '1' + states: + coordinate: [824, 120.0] + rotation: 0 + state: enabled +- name: blocks_wavfile_source_0 + id: blocks_wavfile_source + parameters: + affinity: '' + alias: '' + comment: '' + file: /home/mbr0wn/12345.wav + maxoutbuf: '0' + minoutbuf: '0' + nchan: '1' + repeat: 'True' + states: + coordinate: [-1, 225] + rotation: 0 + state: disabled +- name: qtgui_time_sink_x_0 + id: qtgui_time_sink_x + parameters: + affinity: '' + alias: '' + alpha1: '1.0' + alpha10: '1.0' + alpha2: '1.0' + alpha3: '1.0' + alpha4: '1.0' + alpha5: '1.0' + alpha6: '1.0' + alpha7: '1.0' + alpha8: '1.0' + alpha9: '1.0' + autoscale: 'False' + axislabels: 'True' + color1: '"blue"' + color10: '"blue"' + color2: '"red"' + color3: '"green"' + color4: '"black"' + color5: '"cyan"' + color6: '"magenta"' + color7: '"yellow"' + color8: '"dark red"' + color9: '"dark green"' + comment: '' + ctrlpanel: 'False' + entags: 'True' + grid: 'False' + gui_hint: '' + label1: '' + label10: '' + label2: '' + label3: '' + label4: '' + label5: '' + label6: '' + label7: '' + label8: '' + label9: '' + legend: 'True' + marker1: '-1' + marker10: '-1' + marker2: '-1' + marker3: '-1' + marker4: '-1' + marker5: '-1' + marker6: '-1' + marker7: '-1' + marker8: '-1' + marker9: '-1' + name: Audio Post-Encoding + nconnections: '1' + size: '1024' + srate: '8000' + stemplot: 'False' + style1: '1' + style10: '1' + style2: '1' + style3: '1' + style4: '1' + style5: '1' + style6: '1' + style7: '1' + style8: '1' + style9: '1' + tr_chan: '0' + tr_delay: '0' + tr_level: '0.0' + tr_mode: qtgui.TRIG_MODE_FREE + tr_slope: qtgui.TRIG_SLOPE_POS + tr_tag: '""' + type: float + update_time: '0.10' + width1: '1' + width10: '1' + width2: '1' + width3: '1' + width4: '1' + width5: '1' + width6: '1' + width7: '1' + width8: '1' + width9: '1' + ylabel: Amplitude + ymax: '1' + ymin: '-1' + yunit: '""' + states: + coordinate: [960, 283] + rotation: 0 + state: enabled +- name: qtgui_time_sink_x_0_0 + id: qtgui_time_sink_x + parameters: + affinity: '' + alias: '' + alpha1: '1.0' + alpha10: '1.0' + alpha2: '1.0' + alpha3: '1.0' + alpha4: '1.0' + alpha5: '1.0' + alpha6: '1.0' + alpha7: '1.0' + alpha8: '1.0' + alpha9: '1.0' + autoscale: 'False' + axislabels: 'True' + color1: '"blue"' + color10: '"blue"' + color2: '"red"' + color3: '"green"' + color4: '"black"' + color5: '"cyan"' + color6: '"magenta"' + color7: '"yellow"' + color8: '"dark red"' + color9: '"dark green"' + comment: '' + ctrlpanel: 'False' + entags: 'True' + grid: 'False' + gui_hint: '' + label1: '' + label10: '' + label2: '' + label3: '' + label4: '' + label5: '' + label6: '' + label7: '' + label8: '' + label9: '' + legend: 'True' + marker1: '-1' + marker10: '-1' + marker2: '-1' + marker3: '-1' + marker4: '-1' + marker5: '-1' + marker6: '-1' + marker7: '-1' + marker8: '-1' + marker9: '-1' + name: Audio Pre-Encoding + nconnections: '1' + size: '1024' + srate: '8000' + stemplot: 'False' + style1: '1' + style10: '1' + style2: '1' + style3: '1' + style4: '1' + style5: '1' + style6: '1' + style7: '1' + style8: '1' + style9: '1' + tr_chan: '0' + tr_delay: '0' + tr_level: '0.0' + tr_mode: qtgui.TRIG_MODE_FREE + tr_slope: qtgui.TRIG_SLOPE_POS + tr_tag: '""' + type: float + update_time: '0.10' + width1: '1' + width10: '1' + width2: '1' + width3: '1' + width4: '1' + width5: '1' + width6: '1' + width7: '1' + width8: '1' + width9: '1' + ylabel: Amplitude + ymax: '1' + ymin: '-1' + yunit: '""' + states: + coordinate: [434, 202] + rotation: 0 + state: enabled +- name: rational_resampler_xxx_0 + id: rational_resampler_xxx + parameters: + affinity: '' + alias: '' + comment: '' + decim: '6' + fbw: '0.4' + interp: '1' + maxoutbuf: '0' + minoutbuf: '0' + taps: '' + type: fff + states: + coordinate: [208, 92.0] + rotation: 0 + state: enabled +- name: rational_resampler_xxx_1 + id: rational_resampler_xxx + parameters: + affinity: '' + alias: '' + comment: '' + decim: '1' + fbw: '0.4' + interp: '6' + maxoutbuf: '0' + minoutbuf: '0' + taps: '' + type: fff + states: + coordinate: [568, 396.0] + rotation: 0 + state: enabled +- name: virtual_sink_0 + id: virtual_sink + parameters: + affinity: '' + alias: '' + comment: '' + stream_id: Encoded Speech + states: + coordinate: [908, 207] + rotation: 0 + state: enabled +- name: virtual_sink_1 + id: virtual_sink + parameters: + affinity: '' + alias: '' + comment: '' + stream_id: Raw Audio + states: + coordinate: [508, 25] + rotation: 0 + state: enabled +- name: virtual_sink_2 + id: virtual_sink + parameters: + affinity: '' + alias: '' + comment: '' + stream_id: Decoded Speech + states: + coordinate: [960, 393] + rotation: 0 + state: enabled +- name: virtual_source_0 + id: virtual_source + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '' + minoutbuf: '' + stream_id: Encoded Speech + states: + coordinate: [0, 292.0] + rotation: 0 + state: enabled +- name: virtual_source_1 + id: virtual_source + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '' + minoutbuf: '' + stream_id: Raw Audio + states: + coordinate: [-1, 389] + rotation: 0 + state: enabled +- name: virtual_source_1_0 + id: virtual_source + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '' + minoutbuf: '' + stream_id: Decoded Speech + states: + coordinate: [3, 449] + rotation: 0 + state: enabled +- name: vocoder_codec2_decode_ps_0 + id: vocoder_codec2_decode_ps + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + mode: codec2.MODE_2400 + states: + coordinate: [608, 296.0] + rotation: 0 + state: enabled +- name: vocoder_codec2_encode_sp_0 + id: vocoder_codec2_encode_sp + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + mode: codec2.MODE_2400 + states: + coordinate: [592, 116.0] + rotation: 0 + state: enabled + +connections: +- [audio_source_0, '0', rational_resampler_xxx_0, '0'] +- [blocks_add_xx_0, '0', rational_resampler_xxx_1, '0'] +- [blocks_float_to_short_0, '0', vocoder_codec2_encode_sp_0, '0'] +- [blocks_multiply_const_vxx_0, '0', blocks_add_xx_0, '0'] +- [blocks_multiply_const_vxx_1, '0', blocks_add_xx_0, '1'] +- [blocks_packed_to_unpacked_xx_0, '0', blocks_stream_to_vector_0, '0'] +- [blocks_short_to_float_0, '0', qtgui_time_sink_x_0, '0'] +- [blocks_short_to_float_0, '0', virtual_sink_2, '0'] +- [blocks_stream_to_vector_0, '0', vocoder_codec2_decode_ps_0, '0'] +- [blocks_unpacked_to_packed_xx_0, '0', virtual_sink_0, '0'] +- [blocks_vector_to_stream_0, '0', blocks_unpacked_to_packed_xx_0, '0'] +- [blocks_wavfile_source_0, '0', rational_resampler_xxx_0, '0'] +- [rational_resampler_xxx_0, '0', blocks_float_to_short_0, '0'] +- [rational_resampler_xxx_0, '0', qtgui_time_sink_x_0_0, '0'] +- [rational_resampler_xxx_0, '0', virtual_sink_1, '0'] +- [rational_resampler_xxx_1, '0', audio_sink_0, '0'] +- [virtual_source_0, '0', blocks_packed_to_unpacked_xx_0, '0'] +- [virtual_source_1, '0', blocks_multiply_const_vxx_0, '0'] +- [virtual_source_1_0, '0', blocks_multiply_const_vxx_1, '0'] +- [vocoder_codec2_decode_ps_0, '0', blocks_short_to_float_0, '0'] +- [vocoder_codec2_encode_sp_0, '0', blocks_vector_to_stream_0, '0'] + +metadata: + file_format: 1 diff --git a/gr-vocoder/grc/vocoder_codec2_decode_ps.block.yml b/gr-vocoder/grc/vocoder_codec2_decode_ps.block.yml index 0aec7ec4c1..1fc0e7dbad 100644 --- a/gr-vocoder/grc/vocoder_codec2_decode_ps.block.yml +++ b/gr-vocoder/grc/vocoder_codec2_decode_ps.block.yml @@ -7,15 +7,16 @@ parameters: dtype: int default: codec2.MODE_2400 options: [codec2.MODE_3200, codec2.MODE_2400, codec2.MODE_1600, codec2.MODE_1400, - codec2.MODE_1300, codec2.MODE_1200, codec2.MODE_700, codec2.MODE_700B] + codec2.MODE_1300, codec2.MODE_1200, codec2.MODE_700, codec2.MODE_700B, + codec2.MODE_700C, codec2.MODE_WB, codec2.MODE_450, codec2.MODE_450PWB] option_labels: [3200 bps, 2400 bps, 1600 bps, 1400 bps, 1300 bps, 1200 bps, 700 - bps, 700B bps] - hide: ${ 'part' if vlen == 1 else 'none' } + bps, 700B bps, 700C bps, Wideband, 450 bps, 450PWB bps] + hide: none inputs: - domain: stream dtype: byte - vlen: '${ { 0: 64, 1: 48, 2: 64, 3: 56, 4: 52, 5: 48, 6: 28, 7: 28 }[mode] }' + vlen: '${ { 0: 64, 1: 48, 2: 64, 3: 56, 4: 52, 5: 48, 6: 28, 7: 28, 8: 28, 9: 64, 10: 18, 11: 18 }[mode] }' outputs: - domain: stream @@ -27,4 +28,7 @@ templates: from gnuradio.vocoder import codec2 make: vocoder.codec2_decode_ps(${mode}) +documentation: |- + Not all modes may be supported by the underlying codec2 library. + file_format: 1 diff --git a/gr-vocoder/grc/vocoder_codec2_encode_sp.block.yml b/gr-vocoder/grc/vocoder_codec2_encode_sp.block.yml index f03787341c..0357fa2ac7 100644 --- a/gr-vocoder/grc/vocoder_codec2_encode_sp.block.yml +++ b/gr-vocoder/grc/vocoder_codec2_encode_sp.block.yml @@ -7,10 +7,11 @@ parameters: dtype: int default: codec2.MODE_2400 options: [codec2.MODE_3200, codec2.MODE_2400, codec2.MODE_1600, codec2.MODE_1400, - codec2.MODE_1300, codec2.MODE_1200, codec2.MODE_700, codec2.MODE_700B] + codec2.MODE_1300, codec2.MODE_1200, codec2.MODE_700, codec2.MODE_700B, + codec2.MODE_700C, codec2.MODE_WB, codec2.MODE_450, codec2.MODE_450PWB] option_labels: [3200 bps, 2400 bps, 1600 bps, 1400 bps, 1300 bps, 1200 bps, 700 - bps, 700B bps] - hide: ${ 'part' if vlen == 1 else 'none' } + bps, 700B bps, 700C bps, Wideband, 450 bps, 450PWB bps] + hide: none inputs: - domain: stream @@ -19,7 +20,7 @@ inputs: outputs: - domain: stream dtype: byte - vlen: '${ { 0: 64, 1: 48, 2: 64, 3: 56, 4: 52, 5: 48, 6: 28, 7: 28 }[mode] }' + vlen: '${ { 0: 64, 1: 48, 2: 64, 3: 56, 4: 52, 5: 48, 6: 28, 7: 28, 8: 28, 9: 64, 10: 18, 11: 18 }[mode] }' templates: imports: |- @@ -27,4 +28,7 @@ templates: from gnuradio.vocoder import codec2 make: vocoder.codec2_encode_sp(${mode}) +documentation: |- + Not all modes may be supported by the underlying codec2 library. + file_format: 1 diff --git a/gr-vocoder/grc/vocoder_freedv_rx_ss.block.yml b/gr-vocoder/grc/vocoder_freedv_rx_ss.block.yml index 4b486d41cb..fd3392e13f 100644 --- a/gr-vocoder/grc/vocoder_freedv_rx_ss.block.yml +++ b/gr-vocoder/grc/vocoder_freedv_rx_ss.block.yml @@ -7,12 +7,20 @@ parameters: dtype: int default: freedv_api.MODE_1600 options: [freedv_api.MODE_1600, freedv_api.MODE_700, freedv_api.MODE_700B, freedv_api.MODE_2400A, - freedv_api.MODE_2400B, freedv_api.MODE_800XA] - option_labels: ['1600', '700', 700B, 2400A, 2400B, 800XA] + freedv_api.MODE_2400B, freedv_api.MODE_800XA, freedv_api.MODE_700C, freedv_api.MODE_700D] + option_labels: ['1600', '700', 700B, 2400A, 2400B, 800XA, 700C, 700D] - id: squelch_thresh label: Squelch Threshold dtype: float default: '-100.0' +- id: interleave_frames + label: Interleave Frames + dtype: int + default: '1' +- id: squelch_enable + label: Squelch Enable + dtype: bool + default: True inputs: - domain: stream @@ -26,8 +34,16 @@ templates: imports: |- from gnuradio import vocoder from gnuradio.vocoder import freedv_api - make: vocoder.freedv_rx_ss(${mode},${squelch_thresh}) + make: vocoder.freedv_rx_ss(${mode},${squelch_thresh},${interleave_frames}) callbacks: + - set_squelch_en(${squelch_enable}) - set_squelch_thresh(${squelch_thresh}) +documentation: |- + Not all modes may be supported by the underlying codec2 library. + interleave_frames is an integer between 1 and 32, and is only used in the 700D mode. + (must be set the same on both transmitter and receiver) + Squelch Enable defaults to On + Squelch Threshold - cutoff level for receiver + file_format: 1 diff --git a/gr-vocoder/grc/vocoder_freedv_tx_ss.block.yml b/gr-vocoder/grc/vocoder_freedv_tx_ss.block.yml index 6ae73dfbbb..1fb13ec106 100644 --- a/gr-vocoder/grc/vocoder_freedv_tx_ss.block.yml +++ b/gr-vocoder/grc/vocoder_freedv_tx_ss.block.yml @@ -7,12 +7,24 @@ parameters: dtype: int default: freedv_api.MODE_1600 options: [freedv_api.MODE_1600, freedv_api.MODE_700, freedv_api.MODE_700B, freedv_api.MODE_2400A, - freedv_api.MODE_2400B, freedv_api.MODE_800XA] - option_labels: ['1600', '700', 700B, 2400A, 2400B, 800XA] + freedv_api.MODE_2400B, freedv_api.MODE_800XA, freedv_api.MODE_700C, freedv_api.MODE_700D] + option_labels: ['1600', '700', 700B, 2400A, 2400B, 800XA, 700C, 700D] - id: txt_msg label: Text Message dtype: string default: '''GNU Radio''' +- id: interleave_frames + label: Interleave Frames + dtype: int + default: 1 +- id: clip_val + label: Clip + dtype: bool + default: False +- id: tx_bpf_val + label: Tx BPF + dtype: bool + default: True inputs: - domain: stream @@ -26,6 +38,13 @@ templates: imports: |- from gnuradio import vocoder from gnuradio.vocoder import freedv_api - make: vocoder.freedv_tx_ss(${mode},${txt_msg}) + make: vocoder.freedv_tx_ss(${mode},${txt_msg},${interleave_frames}) + +documentation: |- + Not all modes may be supported by the underlying codec2 library. + interleave_frames is an integer between 1 and 32, and is only used in the 700D mode. + (must be set the same on both transmitter and receiver) + Clip reduces the Peak/Average Power Ratio from 12dB to 8dB by clipping. + Tx BPF: enable a bandpass filter file_format: 1 diff --git a/gr-vocoder/include/gnuradio/vocoder/codec2.h b/gr-vocoder/include/gnuradio/vocoder/codec2.h index afa53d5ac0..cca0fc46be 100644 --- a/gr-vocoder/include/gnuradio/vocoder/codec2.h +++ b/gr-vocoder/include/gnuradio/vocoder/codec2.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2014,2016 Free Software Foundation, Inc. + * Copyright 2014,2016,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -48,6 +48,12 @@ namespace gr { #ifdef CODEC2_MODE_700B MODE_700B = CODEC2_MODE_700B, #endif +#ifdef CODEC2_MODE_700C + MODE_700C = CODEC2_MODE_700C, +#endif +#ifdef CODEC2_MODE_WB + MODE_WB = CODEC2_MODE_WB, +#endif }; private: diff --git a/gr-vocoder/include/gnuradio/vocoder/freedv_api.h b/gr-vocoder/include/gnuradio/vocoder/freedv_api.h index 230da4e108..7838fb4a08 100644 --- a/gr-vocoder/include/gnuradio/vocoder/freedv_api.h +++ b/gr-vocoder/include/gnuradio/vocoder/freedv_api.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 * @@ -56,6 +56,15 @@ namespace gr { #ifdef FREEDV_MODE_800XA MODE_800XA = FREEDV_MODE_800XA, #endif +#ifdef FREEDV_MODE_700C + MODE_700C = FREEDV_MODE_700C, +#endif +#ifdef FREEDV_MODE_700D + MODE_700D = FREEDV_MODE_700D, + SYNC_UNSYNC = FREEDV_SYNC_UNSYNC, + SYNC_AUTO = FREEDV_SYNC_AUTO, + SYNC_MANUAL = FREEDV_SYNC_MANUAL, +#endif }; private: diff --git a/gr-vocoder/include/gnuradio/vocoder/freedv_rx_ss.h b/gr-vocoder/include/gnuradio/vocoder/freedv_rx_ss.h index a6568dee7d..d1d1a55989 100644 --- a/gr-vocoder/include/gnuradio/vocoder/freedv_rx_ss.h +++ b/gr-vocoder/include/gnuradio/vocoder/freedv_rx_ss.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 * @@ -50,11 +50,13 @@ namespace gr { * * \param mode Operating Mode designation * \param squelch_thresh FreeDV modem squelch threshold value + * \param interleave_frames FreeDV 700D mode number of frames to average error */ - static sptr make(int mode=freedv_api::MODE_1600, float squelch_thresh=-100.0); + static sptr make(int mode=freedv_api::MODE_1600, float squelch_thresh=-100.0, int interleave_frames=1); virtual void set_squelch_thresh(float squelch_thresh) = 0; virtual float squelch_thresh() = 0; + virtual void set_squelch_en(bool squelch_enable) = 0; }; } /* namespace vocoder */ diff --git a/gr-vocoder/include/gnuradio/vocoder/freedv_tx_ss.h b/gr-vocoder/include/gnuradio/vocoder/freedv_tx_ss.h index 0e80d78bfb..21754c604a 100644 --- a/gr-vocoder/include/gnuradio/vocoder/freedv_tx_ss.h +++ b/gr-vocoder/include/gnuradio/vocoder/freedv_tx_ss.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 * @@ -49,8 +49,9 @@ namespace gr { * * \param mode Operating Mode designation * \param msg_txt Low Rate message text (callsign, location) + * \param interleave_frames FreeDV 700D mode number of frames to average error */ - static sptr make(int mode=freedv_api::MODE_1600,const std::string msg_txt="GNU Radio"); + static sptr make(int mode=freedv_api::MODE_1600,const std::string msg_txt="GNU Radio",int interleave_frames=1); }; } /* namespace vocoder */ 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, diff --git a/gr-vocoder/swig/vocoder_swig.i b/gr-vocoder/swig/vocoder_swig.i index 1bf451539d..7af9c0002a 100644 --- a/gr-vocoder/swig/vocoder_swig.i +++ b/gr-vocoder/swig/vocoder_swig.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011,2013,2016 Free Software Foundation, Inc. + * Copyright 2011,2013,2016,2019 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -93,8 +93,12 @@ GR_SWIG_BLOCK_MAGIC2(vocoder, codec2_encode_sp); #include "gnuradio/vocoder/freedv_tx_ss.h" %} +#ifdef FREEDV_MODE_700D +#else %ignore freedv_set_smooth_symbols; %ignore freedv_set_clip; +#endif + %include %include "gnuradio/vocoder/freedv_api.h" %include "gnuradio/vocoder/freedv_rx_ss.h" -- 2.11.0