summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/io/gr_wavfile_sink.h6
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.h3
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc23
-rwxr-xr-xgnuradio-examples/python/volk_benchmark/volk_math.py17
-rw-r--r--gr-digital/examples/narrowband/receive_path.py12
5 files changed, 48 insertions, 13 deletions
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h b/gnuradio-core/src/lib/io/gr_wavfile_sink.h
index 6a6b7ebf0..6d06d74e9 100644
--- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h
+++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.h
@@ -44,10 +44,10 @@ gr_make_wavfile_sink (const char *filename,
int bits_per_sample = 16);
/*!
- * \brief Read stream from a Microsoft PCM (.wav) file, output floats
+ * \brief Write stream to a Microsoft PCM (.wav) file.
*
- * Values are within [-1;1].
- * Check gr_make_wavfile_source() for extra info.
+ * Values must be floats within [-1;1].
+ * Check gr_make_wavfile_sink() for extra info.
*
* \ingroup sink_blk
*/
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h
index e8e393756..9478e1ce0 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.h
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.h
@@ -93,6 +93,7 @@ class GR_CORE_API gr_buffer {
uint64_t nitems_written() { return d_abs_write_offset; }
+ size_t get_sizeof_item() { return d_sizeof_item; }
/*!
* \brief Adds a new tag to the buffer.
@@ -249,6 +250,8 @@ class GR_CORE_API gr_buffer_reader {
uint64_t nitems_read() { return d_abs_read_offset; }
+ size_t get_sizeof_item() { return d_buffer->get_sizeof_item(); }
+
/*!
* \brief Return the block that reads via this reader.
*
diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
index 5d1057e0f..e97fa13a4 100644
--- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
+++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
@@ -28,6 +28,7 @@
#include <gr_block_detail.h>
#include <gr_io_signature.h>
#include <gr_buffer.h>
+#include <volk/volk.h>
#include <iostream>
#include <map>
@@ -243,6 +244,28 @@ gr_flat_flowgraph::merge_connections(gr_flat_flowgraph_sptr old_ffg)
if (GR_FLAT_FLOWGRAPH_DEBUG)
std::cout << "new block" << std::endl;
connect_block_inputs(block);
+
+ const int alignment = volk_get_alignment();
+ for(int i = 0; i < block->detail()->ninputs(); i++) {
+ void *r = (void*)block->detail()->input(i)->read_pointer();
+ unsigned long int ri = (unsigned long int)r % alignment;
+ if(ri != 0) {
+ size_t itemsize = block->detail()->input(i)->get_sizeof_item();
+ block->detail()->input(i)->update_read_pointer(ri/itemsize);
+ block->set_unaligned(0);
+ block->set_is_unaligned(false);
+ }
+ }
+ for(int i = 0; i < block->detail()->noutputs(); i++) {
+ void *w = (void*)block->detail()->output(i)->write_pointer();
+ unsigned long int wi = (unsigned long int)w % alignment;
+ if(wi != 0) {
+ size_t itemsize = block->detail()->output(i)->get_sizeof_item();
+ block->detail()->output(i)->update_write_pointer(wi/itemsize);
+ block->set_unaligned(0);
+ block->set_is_unaligned(false);
+ }
+ }
}
// Now deal with the fact that the block details might have changed numbers of
diff --git a/gnuradio-examples/python/volk_benchmark/volk_math.py b/gnuradio-examples/python/volk_benchmark/volk_math.py
index 8b0081387..8bf9ed6f3 100755
--- a/gnuradio-examples/python/volk_benchmark/volk_math.py
+++ b/gnuradio-examples/python/volk_benchmark/volk_math.py
@@ -21,7 +21,7 @@ def multiply_const_ff(N):
######################################################################
def multiply_cc(N):
- op = gr.multiply_cc()
+ op = gr.multiply_cc(1)
tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_gr_complex, 2, 1)
return tb
@@ -134,16 +134,15 @@ def main():
conn = create_connection(args.database)
new_table(conn, label)
- if not args.all:
- func = avail_tests[args.test]
- res = run_tests(func, N, iters)
+ if args.all:
+ tests = xrange(len(avail_tests))
+ else:
+ tests = args.tests
+
+ for test in tests:
+ res = run_tests(avail_tests[test], N, iters)
if res is not None:
replace_results(conn, label, N, iters, res)
- else:
- for f in avail_tests:
- res = run_tests(f, N, iters)
- if res is not None:
- replace_results(conn, label, N, iters, res)
if __name__ == "__main__":
try:
diff --git a/gr-digital/examples/narrowband/receive_path.py b/gr-digital/examples/narrowband/receive_path.py
index 1c5e58963..1f9310506 100644
--- a/gr-digital/examples/narrowband/receive_path.py
+++ b/gr-digital/examples/narrowband/receive_path.py
@@ -45,17 +45,25 @@ class receive_path(gr.hier_block2):
self._rx_callback = rx_callback # this callback is fired when a packet arrives
self._demod_class = demod_class # the demodulator_class we're using
+ self._chbw_factor = options.chbw_factor # channel filter bandwidth factor
+
# Get demod_kwargs
demod_kwargs = self._demod_class.extract_kwargs_from_options(options)
# Build the demodulator
self.demodulator = self._demod_class(**demod_kwargs)
+
+ # Make sure the channel BW factor is between 1 and sps/2
+ # or the filter won't work.
+ if(self._chbw_factor < 1.0 or self._chbw_factor > self.samples_per_symbol()/2):
+ sys.stderr.write("Channel bandwidth factor ({0}) must be within the range [1.0, {1}].\n".format(self._chbw_factor, self.samples_per_symbol()/2))
+ sys.exit(1)
# Design filter to get actual channel we want
sw_decim = 1
chan_coeffs = gr.firdes.low_pass (1.0, # gain
sw_decim * self.samples_per_symbol(), # sampling rate
- 1.0, # midpoint of trans. band
+ self._chbw_factor, # midpoint of trans. band
0.5, # width of trans. band
gr.firdes.WIN_HANN) # filter type
self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)
@@ -129,6 +137,8 @@ class receive_path(gr.hier_block2):
help="set samples/symbol [default=%default]")
expert.add_option("", "--log", action="store_true", default=False,
help="Log all parts of flow graph to files (CAUTION: lots of data)")
+ expert.add_option("", "--chbw-factor", type="float", default=1.0,
+ help="Channel bandwidth = chbw_factor x signal bandwidth [defaut=%default]")
# Make a static method to call before instantiation
add_options = staticmethod(add_options)