summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2015-04-21 19:53:28 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2015-04-21 19:53:28 -0700
commitd8a491fde1f29e10d77f536ea1234ee96089202a (patch)
tree924e5e2e840d2908b90622538405e988a5fdc467
parentb43c396c9cc2733041a1433f287735a2df48be82 (diff)
parentcf62a81f75bee12de344c47206d23404aeb2f0f2 (diff)
Merge remote-tracking branch 'nowls/burst_shaping'
-rw-r--r--gr-digital/examples/CMakeLists.txt7
-rw-r--r--gr-digital/examples/burst_shaper.grc880
-rw-r--r--gr-digital/grc/digital_burst_shaper.xml71
-rw-r--r--gr-digital/include/gnuradio/digital/CMakeLists.txt1
-rw-r--r--gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t115
-rw-r--r--gr-digital/lib/CMakeLists.txt1
-rw-r--r--gr-digital/lib/burst_shaper_XX_impl.cc.t329
-rw-r--r--gr-digital/lib/burst_shaper_XX_impl.h.t90
-rwxr-xr-xgr-digital/python/digital/qa_burst_shaper.py274
-rw-r--r--gr-digital/swig/digital_swig.i6
10 files changed, 1774 insertions, 0 deletions
diff --git a/gr-digital/examples/CMakeLists.txt b/gr-digital/examples/CMakeLists.txt
index fa15501936..38ee443ab7 100644
--- a/gr-digital/examples/CMakeLists.txt
+++ b/gr-digital/examples/CMakeLists.txt
@@ -31,6 +31,13 @@ GR_PYTHON_INSTALL(PROGRAMS
COMPONENT "digital_python"
)
+install(
+ FILES
+ burst_shaper.grc
+ DESTINATION ${GR_PKG_DIGITAL_EXAMPLES_DIR}
+ COMPONENT "digital_python"
+)
+
# Narrowband
GR_PYTHON_INSTALL(PROGRAMS
narrowband/transmit_path.py
diff --git a/gr-digital/examples/burst_shaper.grc b/gr-digital/examples/burst_shaper.grc
new file mode 100644
index 0000000000..35a98a3267
--- /dev/null
+++ b/gr-digital/examples/burst_shaper.grc
@@ -0,0 +1,880 @@
+<?xml version='1.0' encoding='ASCII'?>
+<?grc format='1' created='3.7.8'?>
+<flow_graph>
+ <timestamp>Fri Apr 17 12:31:57 2015</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>burst_shaper</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value></value>
+ </param>
+ <param>
+ <key>author</key>
+ <value></value>
+ </param>
+ <param>
+ <key>description</key>
+ <value></value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>no_gui</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>run</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>thread_safe_setters</key>
+ <value></value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(10, 10)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>32000</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(392, 11)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>window_taps</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>fft.window.hann(10)</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(232, 11)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>import</key>
+ <param>
+ <key>id</key>
+ <value>import_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>import</key>
+ <value>import pmt</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(8, 99)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>import</key>
+ <param>
+ <key>id</key>
+ <value>import_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>import</key>
+ <value>from gnuradio import fft</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(96, 99)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_vector_source_x</key>
+ <param>
+ <key>id</key>
+ <value>blocks_vector_source_x_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>vector</key>
+ <value>[1.0, -1.0]*15</value>
+ </param>
+ <param>
+ <key>tags</key>
+ <value>[gr.python_to_tag({'offset':0, 'key':pmt.intern('packet_len'), 'value':pmt.from_long(20), 'srcid':pmt.intern('vector_source')})]</value>
+ </param>
+ <param>
+ <key>repeat</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(8, 171)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_vector_source_x</key>
+ <param>
+ <key>id</key>
+ <value>blocks_vector_source_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>vector</key>
+ <value>[complex(1.0), complex(-1.0)]*15</value>
+ </param>
+ <param>
+ <key>tags</key>
+ <value>[gr.python_to_tag({'offset':0, 'key':pmt.intern('packet_len'), 'value':pmt.from_long(20), 'srcid':pmt.intern('vector_source')})]</value>
+ </param>
+ <param>
+ <key>repeat</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(8, 307)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_tagged_stream_to_pdu</key>
+ <param>
+ <key>id</key>
+ <value>blocks_tagged_stream_to_pdu_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>tag</key>
+ <value>packet_len</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(632, 163)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_message_debug</key>
+ <param>
+ <key>id</key>
+ <value>blocks_message_debug_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(888, 168)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_message_debug</key>
+ <param>
+ <key>id</key>
+ <value>blocks_message_debug_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(888, 304)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_tag_debug</key>
+ <param>
+ <key>id</key>
+ <value>blocks_tag_debug_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>name</key>
+ <value>Float</value>
+ </param>
+ <param>
+ <key>filter</key>
+ <value>"packet_len"</value>
+ </param>
+ <param>
+ <key>num_inputs</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>display</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(632, 211)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_tagged_stream_to_pdu</key>
+ <param>
+ <key>id</key>
+ <value>blocks_tagged_stream_to_pdu_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>tag</key>
+ <value>packet_len</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(632, 299)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_burst_shaper_xx</key>
+ <param>
+ <key>id</key>
+ <value>digital_burst_shaper_xx_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>window</key>
+ <value>window_taps</value>
+ </param>
+ <param>
+ <key>pre_padding</key>
+ <value>5</value>
+ </param>
+ <param>
+ <key>post_padding</key>
+ <value>5</value>
+ </param>
+ <param>
+ <key>insert_phasing</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>length_tag_name</key>
+ <value>"packet_len"</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(232, 155)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_throttle</key>
+ <param>
+ <key>id</key>
+ <value>blocks_throttle_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>samples_per_second</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>ignoretag</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(456, 187)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_burst_shaper_xx</key>
+ <param>
+ <key>id</key>
+ <value>digital_burst_shaper_xx_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>window</key>
+ <value>window_taps</value>
+ </param>
+ <param>
+ <key>pre_padding</key>
+ <value>5</value>
+ </param>
+ <param>
+ <key>post_padding</key>
+ <value>5</value>
+ </param>
+ <param>
+ <key>insert_phasing</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>length_tag_name</key>
+ <value>"packet_len"</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(232, 291)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_throttle</key>
+ <param>
+ <key>id</key>
+ <value>blocks_throttle_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>samples_per_second</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>ignoretag</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(456, 323)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_tag_debug</key>
+ <param>
+ <key>id</key>
+ <value>blocks_tag_debug_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>name</key>
+ <value>Complex</value>
+ </param>
+ <param>
+ <key>filter</key>
+ <value>"packet_len"</value>
+ </param>
+ <param>
+ <key>num_inputs</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>display</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(632, 347)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>blocks_throttle_0</source_block_id>
+ <sink_block_id>blocks_tagged_stream_to_pdu_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_vector_source_x_0_0</source_block_id>
+ <sink_block_id>digital_burst_shaper_xx_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_burst_shaper_xx_0</source_block_id>
+ <sink_block_id>blocks_throttle_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_burst_shaper_xx_0_0</source_block_id>
+ <sink_block_id>blocks_throttle_0_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_vector_source_x_0</source_block_id>
+ <sink_block_id>digital_burst_shaper_xx_0_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_tagged_stream_to_pdu_1</source_block_id>
+ <sink_block_id>blocks_message_debug_0_0</sink_block_id>
+ <source_key>pdus</source_key>
+ <sink_key>print</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_tagged_stream_to_pdu_0</source_block_id>
+ <sink_block_id>blocks_message_debug_0</sink_block_id>
+ <source_key>pdus</source_key>
+ <sink_key>print</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0</source_block_id>
+ <sink_block_id>blocks_tag_debug_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0_0</source_block_id>
+ <sink_block_id>blocks_tagged_stream_to_pdu_1</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0_0</source_block_id>
+ <sink_block_id>blocks_tag_debug_0_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+</flow_graph>
diff --git a/gr-digital/grc/digital_burst_shaper.xml b/gr-digital/grc/digital_burst_shaper.xml
new file mode 100644
index 0000000000..5c0bc78d0a
--- /dev/null
+++ b/gr-digital/grc/digital_burst_shaper.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<block>
+ <name>Burst Shaper</name>
+ <key>digital_burst_shaper_xx</key>
+ <category>Packet Operators</category>
+ <import>from gnuradio import digital</import>
+ <make>digital.burst_shaper_$(type.fcn)($window, $pre_padding, $post_padding, $insert_phasing, $length_tag_name)</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ <opt>taps:float_vector</opt>
+ </option>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:cc</opt>
+ <opt>taps:complex_vector</opt>
+ </option>
+ </param>
+ <param>
+ <name>Window Taps</name>
+ <key>window</key>
+ <value>([])</value>
+ <type>$(type.taps)</type>
+ </param>
+ <param>
+ <name>Pre-padding Length</name>
+ <key>pre_padding</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Post-padding Length</name>
+ <key>post_padding</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Insert phasing symbols</name>
+ <key>insert_phasing</key>
+ <value>False</value>
+ <type>enum</type>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ </param>
+ <param>
+ <name>Length Tag Name</name>
+ <key>length_tag_name</key>
+ <value>"packet_len"</value>
+ <type>string</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-digital/include/gnuradio/digital/CMakeLists.txt b/gr-digital/include/gnuradio/digital/CMakeLists.txt
index e85e5bcc33..d8fe2b6c4d 100644
--- a/gr-digital/include/gnuradio/digital/CMakeLists.txt
+++ b/gr-digital/include/gnuradio/digital/CMakeLists.txt
@@ -22,6 +22,7 @@
#######################################################################
include(GrMiscUtils)
GR_EXPAND_X_H(digital chunks_to_symbols_XX bf bc sf sc if ic)
+GR_EXPAND_X_H(digital burst_shaper_XX cc ff)
add_custom_target(digital_generated_includes DEPENDS
${generated_includes}
diff --git a/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t b/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
new file mode 100644
index 0000000000..43d422ba80
--- /dev/null
+++ b/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
@@ -0,0 +1,115 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2015 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* @WARNING@ */
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gnuradio/digital/api.h>
+#include <gnuradio/block.h>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief Burst shaper block for applying burst padding and ramping.
+ * \ingroup packet_operators_blk
+ *
+ * \details
+ *
+ * This block applies a configurable amount of zero padding before
+ * and/or after a burst indicated by tagged stream length tags.
+ *
+ * If phasing symbols are used, an alternating pattern of +1/-1
+ * symbols of length ceil(N/2) will be inserted before and after
+ * each burst, where N is the length of the taps vector. The ramp-
+ * up/ramp-down shape will be applied to these phasing symbols.
+ *
+ * If phasing symbols are not used, the taper will be applied
+ * directly to the head and tail of each burst.
+ *
+ * Length tags will be updated to include the length of any added
+ * zero padding or phasing symbols.
+ *
+ * \li input: stream of @I_TYPE@
+ * \li output: stream of @O_TYPE@
+ */
+ class DIGITAL_API @NAME@ : virtual public block
+ {
+ public:
+ // gr::digital::@BASE_NAME@::sptr
+ typedef boost::shared_ptr<@BASE_NAME@> sptr;
+
+ /*!
+ * Make a burst shaper block.
+ *
+ * \param taps: vector of window taper taps; the first ceil(N/2)
+ * items are the up flank and the last ceil(N/2)
+ * items are the down flank. If taps.size() is odd,
+ * the middle tap will be used as the last item of
+ * the up flank and first item of the down flank.
+ * \param pre_padding: number of zero samples to insert before
+ * the burst.
+ * \param post_padding: number of zero samples to append after
+ * the burst.
+ * \param insert_phasing: if true, insert alternating +1/-1
+ * pattern of length ceil(N/2) before and
+ * after the burst and apply ramp up and
+ * ramp down taps, respectively, to the
+ * inserted patterns instead of the head
+ * and tail items of the burst.
+ * \param length_tag_name: the name of the tagged stream length
+ * tag key.
+ */
+ static sptr make(const std::vector<@O_TYPE@> &taps,
+ int pre_padding=0, int post_padding=0,
+ bool insert_phasing=false,
+ const std::string &length_tag_name="packet_len");
+
+ /*!
+ * Returns the amount of zero padding inserted before each burst.
+ */
+ virtual int pre_padding() const = 0;
+
+ /*!
+ * Returns the amount of zero padding inserted after each burst.
+ */
+ virtual int post_padding() const = 0;
+
+ /*!
+ * Returns the total amount of zero padding and phasing symbols
+ * inserted before each burst.
+ */
+ virtual int prefix_length() const = 0;
+
+ /*!
+ * Returns the total amount of zero padding and phasing symbols
+ * inserted after each burst.
+ */
+ virtual int suffix_length() const = 0;
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index c5591e8c91..daa577f56f 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -45,6 +45,7 @@ endif(ENABLE_GR_CTRLPORT)
########################################################################
include(GrMiscUtils)
GR_EXPAND_X_CC_H(digital chunks_to_symbols_XX_impl bf bc sf sc if ic)
+GR_EXPAND_X_CC_H(digital burst_shaper_XX_impl cc ff)
########################################################################
# Setup library
diff --git a/gr-digital/lib/burst_shaper_XX_impl.cc.t b/gr-digital/lib/burst_shaper_XX_impl.cc.t
new file mode 100644
index 0000000000..bd92665701
--- /dev/null
+++ b/gr-digital/lib/burst_shaper_XX_impl.cc.t
@@ -0,0 +1,329 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2015 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* @WARNING@ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <boost/format.hpp>
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+#include "@IMPL_NAME@.h"
+
+#ifndef VOLK_MULT_gr_complex
+#define VOLK_MULT_gr_complex volk_32fc_x2_multiply_32fc
+#endif
+#ifndef VOLK_MULT_float
+#define VOLK_MULT_float volk_32f_x2_multiply_32f
+#endif
+
+namespace gr {
+ namespace digital {
+
+ @BASE_NAME@::sptr
+ @BASE_NAME@::make(const std::vector<@I_TYPE@> &taps,
+ int pre_padding, int post_padding,
+ bool insert_phasing,
+ const std::string &length_tag_name)
+ {
+ return gnuradio::get_initial_sptr
+ (new @IMPL_NAME@(taps, pre_padding, post_padding,
+ insert_phasing, length_tag_name));
+ }
+
+ @IMPL_NAME@::@IMPL_NAME@(const std::vector<@I_TYPE@> &taps,
+ int pre_padding, int post_padding,
+ bool insert_phasing,
+ const std::string &length_tag_name)
+ : gr::block("@BASE_NAME@",
+ gr::io_signature::make(1, 1, sizeof(@I_TYPE@)),
+ gr::io_signature::make(1, 1, sizeof(@O_TYPE@))),
+ d_up_ramp(taps.begin(), taps.begin() + taps.size()/2 + taps.size()%2),
+ d_down_ramp(taps.begin() + taps.size()/2, taps.end()),
+ d_nprepad(pre_padding),
+ d_npostpad(post_padding),
+ d_insert_phasing(insert_phasing),
+ d_length_tag_key(pmt::string_to_symbol(length_tag_name)),
+ d_ncopy(0),
+ d_limit(0),
+ d_index(0),
+ d_nprocessed(0),
+ d_finished(false),
+ d_state(STATE_WAIT)
+ {
+ assert(d_up_ramp.size() == d_down_ramp.size());
+
+ d_up_phasing.resize(d_up_ramp.size());
+ d_down_phasing.resize(d_down_ramp.size());
+
+ @I_TYPE@ symbol;
+ for(unsigned int i = 0; i < d_up_ramp.size(); i++) {
+ symbol = (i%2 == 0) ? @I_TYPE@(1.0f) : @I_TYPE@(-1.0f);
+ d_up_phasing[i] = symbol * d_up_ramp[i];
+ d_down_phasing[i] = symbol * d_down_ramp[i];
+ }
+
+ //set_relative_rate(1.0);
+ set_tag_propagation_policy(TPP_DONT);
+ }
+
+ @IMPL_NAME@::~@IMPL_NAME@()
+ {
+ }
+
+ void
+ @IMPL_NAME@::forecast(int noutput_items,
+ gr_vector_int &ninput_items_required) {
+ //if(d_state == STATE_COPY
+ ninput_items_required[0] = noutput_items;
+ }
+
+ int
+ @IMPL_NAME@::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const @I_TYPE@ *in = reinterpret_cast<const @I_TYPE@ *>(input_items[0]);
+ @O_TYPE@ *out = reinterpret_cast<@O_TYPE@ *>(output_items[0]);
+
+ int nwritten = 0;
+ int nread = 0;
+ int nspace = 0;
+ int nskip = 0;
+ uint64_t curr_tag_index = nitems_read(0);
+
+ std::vector<tag_t> length_tags, tags;
+ get_tags_in_window(length_tags, 0, 0, ninput_items[0], d_length_tag_key);
+ get_tags_in_window(tags, 0, 0, ninput_items[0]);
+ std::sort(length_tags.rbegin(), length_tags.rend(), tag_t::offset_compare);
+ std::sort(tags.rbegin(), tags.rend(), tag_t::offset_compare);
+
+ while((nwritten < noutput_items) && (nread < ninput_items[0])) {
+ if(d_finished) {
+ d_finished = false;
+ break;
+ }
+ nspace = noutput_items - nwritten;
+ switch(d_state) {
+ case(STATE_WAIT):
+ if(!tags.empty()) {
+ curr_tag_index = tags.back().offset;
+ d_ncopy = pmt::to_long(tags.back().value);
+ tags.pop_back();
+ nskip = (int)(curr_tag_index - d_nprocessed);
+ add_length_tag(nwritten);
+ enter_prepad();
+ }
+ else {
+ nskip = ninput_items[0] - nread;
+ }
+ if(nskip > 0) {
+ GR_LOG_WARN(d_logger,
+ boost::format("Dropping %1% samples") %
+ nskip);
+ nread += nskip;
+ d_nprocessed += nskip;
+ }
+ break;
+
+ case(STATE_PREPAD):
+ write_padding(out, nwritten, nspace);
+ if(d_index == d_limit)
+ enter_rampup();
+ break;
+
+ case(STATE_RAMPUP):
+ apply_ramp(out, in, nwritten, nread, nspace);
+ if(d_index == d_limit)
+ enter_copy();
+ break;
+
+ case(STATE_COPY):
+ copy_items(out, in, nwritten, nread, nspace);
+ if(d_index == d_limit)
+ enter_rampdown();
+ break;
+
+ case(STATE_RAMPDOWN):
+ apply_ramp(out, in, nwritten, nread, nspace);
+ if(d_index == d_limit)
+ enter_postpad();
+ break;
+
+ case(STATE_POSTPAD):
+ write_padding(out, nwritten, nspace);
+ if(d_index == d_limit)
+ enter_wait();
+ break;
+
+ default:
+ throw std::runtime_error("@BASE_NAME@: invalid state");
+ }
+ }
+
+ consume_each(nread);
+
+ return nwritten;
+ }
+
+ int
+ @IMPL_NAME@::prefix_length() const {
+ return (d_insert_phasing) ?
+ d_nprepad + d_up_ramp.size() : d_nprepad;
+ }
+
+ int
+ @IMPL_NAME@::suffix_length() const {
+ return (d_insert_phasing) ?
+ d_npostpad + d_down_ramp.size() : d_npostpad;
+ }
+
+ void
+ @IMPL_NAME@::write_padding(@O_TYPE@ *&dst, int &nwritten, int nspace) {
+ int nprocess = std::min(d_limit - d_index, nspace);
+ std::memset(dst, 0x00, nprocess * sizeof(@O_TYPE@));
+ dst += nprocess;
+ nwritten += nprocess;
+ d_index += nprocess;
+ }
+
+ void
+ @IMPL_NAME@::copy_items(@O_TYPE@ *&dst, const @I_TYPE@ *&src, int &nwritten,
+ int &nread, int nspace) {
+ int nprocess = std::min(d_limit - d_index, nspace);
+ std::memcpy(dst, src, nprocess * sizeof(@O_TYPE@));
+ dst += nprocess;
+ nwritten += nprocess;
+ src += nprocess;
+ nread += nprocess;
+ d_index += nprocess;
+ }
+
+ void
+ @IMPL_NAME@::apply_ramp(@O_TYPE@ *&dst, const @I_TYPE@ *&src, int &nwritten,
+ int &nread, int nspace) {
+ int nprocess = std::min(d_limit - d_index, nspace);
+ @O_TYPE@ *phasing;
+ const @O_TYPE@ *ramp;
+
+ if(d_state == STATE_RAMPUP) {
+ phasing = &d_up_phasing[d_index];
+ ramp = &d_up_ramp[d_index];
+ }
+ else {
+ phasing = &d_down_phasing[d_index];
+ ramp = &d_down_ramp[d_index];
+ }
+
+ if(d_insert_phasing)
+ std::memcpy(dst, phasing, nprocess * sizeof(@O_TYPE@));
+ else {
+ VOLK_MULT_@O_TYPE@(dst, src, ramp, nprocess);
+ src += nprocess;
+ nread += nprocess;
+ }
+
+ dst += nprocess;
+ nwritten += nprocess;
+ d_index += nprocess;
+ }
+
+ void
+ @IMPL_NAME@::add_length_tag(int offset)
+ {
+ add_item_tag(0, nitems_written(0) + offset, d_length_tag_key,
+ pmt::from_long(d_ncopy + prefix_length() +
+ suffix_length()),
+ pmt::string_to_symbol(name()));
+ }
+
+ void
+ @IMPL_NAME@::propagate_tags(std::vector<tag_t> &tags, int offset)
+ {
+ // FIXME: need to handle offsets correctly
+ std::vector<tag_t>::iterator tag;
+ for(tag = tags.begin(); tag != tags.end(); tag++) {
+ tag_t new_tag = *tag;
+ new_tag.offset = nitems_written(0) + offset;
+ add_item_tag(0, new_tag);
+ }
+ }
+
+ void
+ @IMPL_NAME@::enter_wait() {
+ d_finished = true;
+ d_nprocessed += d_ncopy;
+ d_index = 0;
+ d_state = STATE_WAIT;
+ }
+
+ void
+ @IMPL_NAME@::enter_prepad() {
+ d_limit = d_nprepad;
+ d_index = 0;
+ d_state = STATE_PREPAD;
+ }
+
+ void
+ @IMPL_NAME@::enter_rampup() {
+ if(d_insert_phasing)
+ d_limit = d_up_ramp.size();
+ else
+ d_limit = std::min((size_t)(d_ncopy/2), d_up_ramp.size());
+ d_index = 0;
+ d_state = STATE_RAMPUP;
+ }
+
+ void
+ @IMPL_NAME@::enter_copy() {
+ if(d_insert_phasing)
+ d_limit = d_ncopy;
+ else
+ d_limit = d_ncopy - std::min((size_t)((d_ncopy/2)*2),
+ d_up_ramp.size() +
+ d_down_ramp.size());
+ d_index = 0;
+ d_state = STATE_COPY;
+ }
+
+ void
+ @IMPL_NAME@::enter_rampdown() {
+ if(d_insert_phasing)
+ d_limit = d_down_ramp.size();
+ else
+ d_limit = std::min((size_t)(d_ncopy/2), d_down_ramp.size());
+ d_index = 0;
+ d_state = STATE_RAMPDOWN;
+ }
+
+ void
+ @IMPL_NAME@::enter_postpad() {
+ d_limit = d_npostpad;
+ d_index = 0;
+ d_state = STATE_POSTPAD;
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
diff --git a/gr-digital/lib/burst_shaper_XX_impl.h.t b/gr-digital/lib/burst_shaper_XX_impl.h.t
new file mode 100644
index 0000000000..90c7df8e88
--- /dev/null
+++ b/gr-digital/lib/burst_shaper_XX_impl.h.t
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2015 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* @WARNING@ */
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gnuradio/digital/@BASE_NAME@.h>
+
+namespace gr {
+ namespace digital {
+
+ class @IMPL_NAME@ : public @BASE_NAME@
+ {
+ protected:
+ enum state_t {STATE_WAIT, STATE_PREPAD, STATE_RAMPUP,
+ STATE_COPY, STATE_RAMPDOWN, STATE_POSTPAD};
+
+ private:
+ const std::vector<@O_TYPE@> d_up_ramp;
+ const std::vector<@O_TYPE@> d_down_ramp;
+ const int d_nprepad;
+ const int d_npostpad;
+ const bool d_insert_phasing;
+ const pmt::pmt_t d_length_tag_key;
+ std::vector<@O_TYPE@> d_up_phasing;
+ std::vector<@O_TYPE@> d_down_phasing;
+ int d_ncopy;
+ int d_limit;
+ int d_index;
+ uint64_t d_nprocessed;
+ bool d_finished;
+ state_t d_state;
+
+ void write_padding(@O_TYPE@ *&dst, int &nwritten, int nspace);
+ void copy_items(@O_TYPE@ *&dst, const @I_TYPE@ *&src, int &nwritten,
+ int &nread, int nspace);
+ void apply_ramp(@O_TYPE@ *&dst, const @I_TYPE@ *&src, int &nwritten,
+ int &nread, int nspace);
+ void add_length_tag(int offset);
+ void propagate_tags(std::vector<tag_t> &tags, int offset);
+ void enter_wait();
+ void enter_prepad();
+ void enter_rampup();
+ void enter_copy();
+ void enter_rampdown();
+ void enter_postpad();
+
+ public:
+ @IMPL_NAME@(const std::vector<@O_TYPE@> &taps, int pre_padding,
+ int post_padding, bool insert_phasing,
+ const std::string &length_tag_name);
+ ~@IMPL_NAME@();
+
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ int pre_padding() const { return d_nprepad; }
+ int post_padding() const { return d_npostpad; }
+ int prefix_length() const;
+ int suffix_length() const;
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-digital/python/digital/qa_burst_shaper.py b/gr-digital/python/digital/qa_burst_shaper.py
new file mode 100755
index 0000000000..d00c23007b
--- /dev/null
+++ b/gr-digital/python/digital/qa_burst_shaper.py
@@ -0,0 +1,274 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright 2015 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from gnuradio import blocks, digital
+import pmt
+import numpy as np
+
+def make_length_tag(offset, length):
+ return gr.python_to_tag({'offset' : offset,
+ 'key' : pmt.intern('packet_len'),
+ 'value' : pmt.from_long(length),
+ 'srcid' : pmt.intern('qa_burst_shaper')})
+
+def compare_tags(a, b):
+ a = gr.tag_to_python(a)
+ b = gr.tag_to_python(b)
+ return a.key == b.key and a.offset == b.offset and \
+ a.value == b.value
+ #return a.key == b.key and a.offset == b.offset and \
+ # a.srcid == b.srcid and a.value == b.value
+
+class qa_burst_shaper (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_ff (self):
+ prepad = 10
+ postpad = 10
+ length = 20
+ data = np.ones(length + 10) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5), -4.0*np.ones(5)))
+ tags = (make_length_tag(0, length),)
+ expected = np.concatenate((np.zeros(prepad), window[0:5],
+ np.ones(length - len(window)), window[5:10],
+ np.zeros(postpad)))
+ etag = make_length_tag(0, length + prepad + postpad)
+
+ # flowgraph
+ source = blocks.vector_source_f(data, tags=tags)
+ shaper = digital.burst_shaper_ff(window, pre_padding=prepad,
+ post_padding=postpad)
+ sink = blocks.vector_sink_f()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertFloatTuplesAlmostEqual(sink.data(), expected, 6)
+ self.assertTrue(compare_tags(sink.tags()[0], etag))
+
+ def test_cc (self):
+ prepad = 10
+ postpad = 10
+ length = 20
+ data = np.ones(length + 10,
+ dtype=complex) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5, dtype=complex),
+ -4.0*np.ones(5, dtype=complex)))
+ tags = (make_length_tag(0, length),)
+ expected = np.concatenate((np.zeros(prepad, dtype=complex), window[0:5],
+ np.ones(length - len(window), dtype=complex),
+ window[5:10], np.zeros(postpad,
+ dtype=complex)))
+ etag = make_length_tag(0, length + prepad + postpad)
+
+ # flowgraph
+ source = blocks.vector_source_c(data, tags=tags)
+ shaper = digital.burst_shaper_cc(window, pre_padding=prepad,
+ post_padding=postpad)
+ sink = blocks.vector_sink_c()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertComplexTuplesAlmostEqual(sink.data(), expected, 6)
+ self.assertTrue(compare_tags(sink.tags()[0], etag))
+
+ def test_ff_with_phasing (self):
+ prepad = 10
+ postpad = 10
+ length = 20
+ data = np.ones(length + 10) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5), -4.0*np.ones(5)))
+ tags = (make_length_tag(0, length),)
+ phasing = np.zeros(5)
+ for i in xrange(5):
+ phasing[i] = ((-1.0)**i)
+ expected = np.concatenate((np.zeros(prepad), phasing*window[0:5],
+ np.ones(length), phasing*window[5:10],
+ np.zeros(postpad)))
+ etag = make_length_tag(0, length + prepad + postpad + len(window))
+
+ # flowgraph
+ source = blocks.vector_source_f(data, tags=tags)
+ shaper = digital.burst_shaper_ff(window, pre_padding=prepad,
+ post_padding=postpad,
+ insert_phasing=True)
+ sink = blocks.vector_sink_f()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertFloatTuplesAlmostEqual(sink.data(), expected, 6)
+ self.assertTrue(compare_tags(sink.tags()[0], etag))
+
+ def test_cc_with_phasing (self):
+ prepad = 10
+ postpad = 10
+ length = 20
+ data = np.ones(length + 10,
+ dtype=complex) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5, dtype=complex),
+ -4.0*np.ones(5, dtype=complex)))
+ tags = (make_length_tag(0, length),)
+ phasing = np.zeros(5, dtype=complex)
+ for i in xrange(5):
+ phasing[i] = complex((-1.0)**i)
+ expected = np.concatenate((np.zeros(prepad, dtype=complex),
+ phasing*window[0:5],
+ np.ones(length, dtype=complex),
+ phasing*window[5:10],
+ np.zeros(postpad, dtype=complex)))
+ etag = make_length_tag(0, length + prepad + postpad + len(window))
+
+ # flowgraph
+ source = blocks.vector_source_c(data, tags=tags)
+ shaper = digital.burst_shaper_cc(window, pre_padding=prepad,
+ post_padding=postpad,
+ insert_phasing=True)
+ sink = blocks.vector_sink_c()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertComplexTuplesAlmostEqual(sink.data(), expected, 6)
+ self.assertTrue(compare_tags(sink.tags()[0], etag))
+
+ def test_odd_window (self):
+ prepad = 10
+ postpad = 10
+ length = 20
+ data = np.ones(length + 10) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5), -3.0*np.ones(1),
+ -4.0*np.ones(5)))
+ tags = (make_length_tag(0, length),)
+ expected = np.concatenate((np.zeros(prepad), window[0:6],
+ np.ones(length - len(window) - 1),
+ window[5:11], np.zeros(postpad)))
+ etag = make_length_tag(0, length + prepad + postpad)
+
+ # flowgraph
+ source = blocks.vector_source_f(data, tags=tags)
+ shaper = digital.burst_shaper_ff(window, pre_padding=prepad,
+ post_padding=postpad)
+ sink = blocks.vector_sink_f()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertFloatTuplesAlmostEqual(sink.data(), expected, 6)
+ self.assertTrue(compare_tags(sink.tags()[0], etag))
+
+ def test_short_burst (self):
+ prepad = 10
+ postpad = 10
+ length = 9
+ data = np.ones(length + 10) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5), -3.0*np.ones(1),
+ -4.0*np.ones(5)))
+ tags = (make_length_tag(0, length),)
+ expected = np.concatenate((np.zeros(prepad), window[0:4],
+ np.ones(1), window[5:9],
+ np.zeros(postpad)))
+ etag = make_length_tag(0, length + prepad + postpad)
+
+ # flowgraph
+ source = blocks.vector_source_f(data, tags=tags)
+ shaper = digital.burst_shaper_ff(window, pre_padding=prepad,
+ post_padding=postpad)
+ sink = blocks.vector_sink_f()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertFloatTuplesAlmostEqual(sink.data(), expected, 6)
+ self.assertTrue(compare_tags(sink.tags()[0], etag))
+
+ def test_consecutive_bursts (self):
+ prepad = 10
+ postpad = 10
+ length1 = 15
+ length2 = 25
+ data = np.concatenate((np.ones(length1), -1.0*np.ones(length2),
+ np.zeros(10))) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5), -4.0*np.ones(5)))
+ tags = (make_length_tag(0, length1), make_length_tag(length1, length2))
+ expected = np.concatenate((np.zeros(prepad), window[0:5],
+ np.ones(length1 - len(window)), window[5:10],
+ np.zeros(postpad + prepad), -1.0*window[0:5],
+ -1.0*np.ones(length2 - len(window)),
+ -1.0*window[5:10], np.zeros(postpad)))
+ etags = (make_length_tag(0, length1 + prepad + postpad),
+ make_length_tag(length1 + prepad + postpad,
+ length2 + prepad + postpad))
+
+ # flowgraph
+ source = blocks.vector_source_f(data, tags=tags)
+ shaper = digital.burst_shaper_ff(window, pre_padding=prepad,
+ post_padding=postpad)
+ sink = blocks.vector_sink_f()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertFloatTuplesAlmostEqual(sink.data(), expected, 6)
+ for i in xrange(len(etags)):
+ self.assertTrue(compare_tags(sink.tags()[i], etags[i]))
+
+ def test_tag_gap (self):
+ prepad = 10
+ postpad = 10
+ length = 20
+ data = np.ones(2*length + 10) # need 10 more to push things through
+ window = np.concatenate((-2.0*np.ones(5), -4.0*np.ones(5)))
+ tags = (make_length_tag(0, length), make_length_tag(length + 5, length))
+ expected = np.concatenate((np.zeros(prepad), window[0:5],
+ np.ones(length - len(window)), window[5:10],
+ np.zeros(postpad)))
+ etags = (make_length_tag(0, length + prepad + postpad),
+ make_length_tag(length + prepad + postpad,
+ length + prepad + postpad))
+
+ # flowgraph
+ source = blocks.vector_source_f(data, tags=tags)
+ shaper = digital.burst_shaper_ff(window, pre_padding=prepad,
+ post_padding=postpad)
+ sink = blocks.vector_sink_f()
+ self.tb.connect(source, shaper, sink)
+ self.tb.run ()
+
+ # checks
+ self.assertFloatTuplesAlmostEqual(sink.data(),
+ np.concatenate((expected, expected),
+ 6))
+ for i in xrange(len(etags)):
+ self.assertTrue(compare_tags(sink.tags()[i], etags[i]))
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_burst_shaper, "qa_burst_shaper.xml")
diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i
index 9797e797cf..d7a3b81c15 100644
--- a/gr-digital/swig/digital_swig.i
+++ b/gr-digital/swig/digital_swig.i
@@ -39,6 +39,8 @@
%{
#include "gnuradio/digital/additive_scrambler_bb.h"
#include "gnuradio/digital/binary_slicer_fb.h"
+#include "gnuradio/digital/burst_shaper_cc.h"
+#include "gnuradio/digital/burst_shaper_ff.h"
#include "gnuradio/digital/chunks_to_symbols_bc.h"
#include "gnuradio/digital/chunks_to_symbols_bf.h"
#include "gnuradio/digital/chunks_to_symbols_ic.h"
@@ -118,6 +120,8 @@
%include "gnuradio/digital/additive_scrambler_bb.h"
%include "gnuradio/digital/binary_slicer_fb.h"
+%include "gnuradio/digital/burst_shaper_cc.h"
+%include "gnuradio/digital/burst_shaper_ff.h"
%include "gnuradio/digital/chunks_to_symbols_bc.h"
%include "gnuradio/digital/chunks_to_symbols_bf.h"
%include "gnuradio/digital/chunks_to_symbols_ic.h"
@@ -193,6 +197,8 @@
GR_SWIG_BLOCK_MAGIC2(digital, additive_scrambler_bb);
GR_SWIG_BLOCK_MAGIC2(digital, binary_slicer_fb);
+GR_SWIG_BLOCK_MAGIC2(digital, burst_shaper_cc);
+GR_SWIG_BLOCK_MAGIC2(digital, burst_shaper_ff);
GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bc);
GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bf);
GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_ic);