diff options
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r-- | gnuradio-core/src/lib/CMakeLists.txt | 7 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/CMakeLists.txt | 31 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/Makefile.am | 9 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/general.i | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.cc | 129 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h | 87 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.i | 60 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_keep_one_in_n.cc | 24 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_keep_one_in_n.h | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/CMakeLists.txt | 233 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_tagged_file_sink.cc | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/CMakeLists.txt | 26 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py | 8 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/vocoder/.gitignore | 2 |
16 files changed, 474 insertions, 153 deletions
diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 10752ecd8..c3ce5a145 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -46,7 +46,7 @@ INCLUDE_DIRECTORIES(${GNURADIO_CORE_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) -ADD_DEFINITIONS(-DGSL_DLL) #needed for gsl windows port but safe to always define +ADD_DEFINITIONS(${GSL_DEFINITIONS}) INCLUDE_DIRECTORIES(${GSL_INCLUDE_DIRS}) LINK_DIRECTORIES(${GSL_LIBRARY_DIRS}) @@ -63,6 +63,11 @@ LIST(APPEND gnuradio_core_libs ${FFTW3F_LIBRARIES} ) +#need to link with librt on ubuntu 11.10 for shm_* +IF(LINUX) + LIST(APPEND gnuradio_core_libs rt) +ENDIF() + ADD_LIBRARY(gnuradio-core SHARED ${gnuradio_core_sources}) TARGET_LINK_LIBRARIES(gnuradio-core ${gnuradio_core_libs}) SET_TARGET_PROPERTIES(gnuradio-core PROPERTIES DEFINE_SYMBOL "gnuradio_core_EXPORTS") diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt index 2c060de80..551715467 100644 --- a/gnuradio-core/src/lib/filter/CMakeLists.txt +++ b/gnuradio-core/src/lib/filter/CMakeLists.txt @@ -27,9 +27,15 @@ FOREACH(gr_core_filter_asm ${gr_core_filter_asms}) SET_PROPERTY(SOURCE ${gr_core_filter_asm} PROPERTY LANGUAGE C) ENDFOREACH(gr_core_filter_asm) -#uname -p says i386, but we know better when its x86 apple -IF(APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386") - SET(CMAKE_SYSTEM_PROCESSOR "x86_64") +#detect 32 or 64 bit compiler +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x86_64)$") + include(CheckTypeSize) + check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY) + if (${SIZEOF_VOID_P} EQUAL 8) + set(CMAKE_SYSTEM_PROCESSOR_x86 64) + else() + set(CMAKE_SYSTEM_PROCESSOR_x86 32) + endif() ENDIF() ######################################################################## @@ -44,7 +50,7 @@ ENDIF() # - This way the targets would depend only on their sources. ######################################################################## EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c " + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c " import os, sys sys.path.append('${GR_CORE_PYTHONPATH}') sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}') @@ -108,10 +114,11 @@ ADD_CUSTOM_COMMAND( ${generated_filter_includes} ${generated_filter_swigs} DEPENDS ${generated_filter_deps} - COMMAND ${PYTHON_EXECUTABLE} -B -c - \"import os, sys\;sys.path.append('${GR_CORE_PYTHONPATH}')\;sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}')\;os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'\;from generate_all import generate_all\;generate_all()\" + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c + "import os, sys;sys.path.append('${GR_CORE_PYTHONPATH}');sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}');os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}';from generate_all import generate_all;generate_all()" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "generating filter files" + VERBATIM ) ADD_CUSTOM_TARGET(filter_generated DEPENDS @@ -132,7 +139,7 @@ IF(MSVC) ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_generic.cc ) ELSE(MSVC) -IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x86_64)$") +IF(CMAKE_SYSTEM_PROCESSOR_x86) LIST(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_x86.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_x86.cc @@ -157,9 +164,9 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x86_64)$") ${CMAKE_CURRENT_SOURCE_DIR}/qa_complex_dotprod_x86.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_ccomplex_dotprod_x86.cc ) -ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x86_64)$") +ENDIF() -IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +IF(CMAKE_SYSTEM_PROCESSOR_x86 AND ${CMAKE_SYSTEM_PROCESSOR_x86} EQUAL 64) LIST(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse64.S ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow64.S @@ -173,7 +180,7 @@ IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_sse64.S ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_mmx64.S ) -ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86)$") +ELSEIF(CMAKE_SYSTEM_PROCESSOR_x86 AND ${CMAKE_SYSTEM_PROCESSOR_x86} EQUAL 32) LIST(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse.S ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow.S @@ -212,14 +219,14 @@ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") LIST(APPEND test_gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_armv7_a.cc ) -ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +ELSE() LIST(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_generic.cc ) LIST(APPEND test_gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_generic.cc ) -ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +ENDIF() ENDIF(MSVC) ######################################################################## diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h index 2eae11807..0fd8ba35b 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h @@ -124,6 +124,7 @@ class GR_CORE_API gr_pfb_clock_sync_ccf : public gr_block * \param init_phase (float) The initial phase to look at, or which filter to start * with (default = 0). * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). + * \param osps (int) The number of output samples per symbol (default=1). * */ friend GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index cb3f0da4b..ab6201de1 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -289,6 +289,7 @@ SET(gr_core_general_triple_threats gr_annotator_alltoall gr_annotator_1to1 gr_burst_tagger + gr_correlate_access_code_tag_bb ) FOREACH(file_tt ${gr_core_general_triple_threats}) diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index fe545f98c..e389e05e1 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -172,7 +172,8 @@ libgeneral_la_SOURCES = \ gr_probe_density_b.cc \ gr_annotator_alltoall.cc \ gr_annotator_1to1.cc \ - gr_burst_tagger.cc + gr_burst_tagger.cc \ + gr_correlate_access_code_tag_bb.cc libgeneral_qa_la_SOURCES = \ qa_general.cc \ @@ -338,7 +339,8 @@ grinclude_HEADERS = \ gr_probe_density_b.h \ gr_annotator_alltoall.h \ gr_annotator_1to1.h \ - gr_burst_tagger.h + gr_burst_tagger.h \ + gr_correlate_access_code_tag_bb.h noinst_HEADERS = \ qa_general.h \ @@ -474,4 +476,5 @@ swiginclude_HEADERS = \ gr_probe_density_b.i \ gr_annotator_alltoall.i \ gr_annotator_1to1.i \ - gr_burst_tagger.i + gr_burst_tagger.i \ + gr_correlate_access_code_tag_bb.i diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index e965eea64..107f5c9ea 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -138,6 +138,7 @@ #include <gr_annotator_1to1.h> #include <gr_burst_tagger.h> #include <gr_cpm.h> +#include <gr_correlate_access_code_tag_bb.h> %} %include "gri_control_loop.i" @@ -256,3 +257,4 @@ %include "gr_annotator_1to1.i" %include "gr_burst_tagger.i" %include "gr_cpm.i" +%include "gr_correlate_access_code_tag_bb.i" diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.cc b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.cc new file mode 100644 index 000000000..23311f7a4 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.cc @@ -0,0 +1,129 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2010,2011 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_correlate_access_code_tag_bb.h> +#include <gr_io_signature.h> +#include <stdexcept> +#include <gr_count_bits.h> +#include <cstdio> +#include <iostream> + +#define VERBOSE 0 + + +gr_correlate_access_code_tag_bb_sptr +gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, const std::string &tag_name) +{ + return gnuradio::get_initial_sptr(new gr_correlate_access_code_tag_bb (access_code, threshold, tag_name)); +} + + +gr_correlate_access_code_tag_bb::gr_correlate_access_code_tag_bb ( + const std::string &access_code, int threshold, const std::string &tag_name) + : gr_sync_block ("correlate_access_code_tag_bb", + gr_make_io_signature (1, 1, sizeof(char)), + gr_make_io_signature (1, 1, sizeof(char))), + d_data_reg(0), d_mask(0), d_len(0), + d_threshold(threshold) + +{ + if (!set_access_code(access_code)){ + fprintf(stderr, "gr_correlate_access_code_tag_bb: access_code is > 64 bits\n"); + throw std::out_of_range ("access_code is > 64 bits"); + } + + std::stringstream str; + str << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(str.str()); + d_key = pmt::pmt_string_to_symbol(tag_name); +} + +gr_correlate_access_code_tag_bb::~gr_correlate_access_code_tag_bb () +{ +} + +bool +gr_correlate_access_code_tag_bb::set_access_code( + const std::string &access_code) +{ + d_len = access_code.length(); // # of bytes in string + if (d_len > 64) + return false; + + // set len top bits to 1. + d_mask = ((~0ULL) >> (64 - d_len)) << (64 - d_len); + + d_access_code = 0; + for (unsigned i=0; i < 64; i++){ + d_access_code <<= 1; + if (i < d_len) + d_access_code |= access_code[i] & 1; // look at LSB only + } + + return true; +} + +int +gr_correlate_access_code_tag_bb::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + + uint64_t abs_out_sample_cnt = nitems_written(0); + + for (int i = 0; i < noutput_items; i++){ + + out[i] = in[i]; + + // compute hamming distance between desired access code and current data + unsigned long long wrong_bits = 0; + unsigned int nwrong = d_threshold+1; + int new_flag = 0; + + wrong_bits = (d_data_reg ^ d_access_code) & d_mask; + nwrong = gr_count_bits64(wrong_bits); + + // test for access code with up to threshold errors + new_flag = (nwrong <= d_threshold); + + // shift in new data and new flag + d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); + if (new_flag) { + if(VERBOSE) std::cout << "writing tag at sample " << abs_out_sample_cnt + i << std::endl; + add_item_tag(0, //stream ID + abs_out_sample_cnt + i - 64 + d_len, //sample + d_key, //frame info + pmt::pmt_t(), //data (unused) + d_me //block src id + ); + } + } + + return noutput_items; +} + diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h new file mode 100644 index 000000000..e543f5cfb --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2011 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. + */ + +#ifndef INCLUDED_gr_correlate_access_code_tag_bb_H +#define INCLUDED_gr_correlate_access_code_tag_bb_H + +#include <gr_core_api.h> +#include <gr_sync_block.h> +#include <string> + +class gr_correlate_access_code_tag_bb; +typedef boost::shared_ptr<gr_correlate_access_code_tag_bb> gr_correlate_access_code_tag_bb_sptr; + +/*! + * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" + * \param threshold maximum number of bits that may be wrong + * \param tag_name key of the tag inserted into the tag stream + */ +GR_CORE_API gr_correlate_access_code_tag_bb_sptr +gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, + const std::string &tag_name); + +/*! + * \brief Examine input for specified access code, one bit at a time. + * \ingroup sync_blk + * + * input: stream of bits, 1 bit per input byte (data in LSB) + * output: unaltered stream of bits (plus tags) + * + * This block annotates the input stream with tags. The tags have key + * name [tag_name], specified in the constructor. Used for searching + * an input data stream for preambles, etc. + */ +class GR_CORE_API gr_correlate_access_code_tag_bb : public gr_sync_block +{ + friend GR_CORE_API gr_correlate_access_code_tag_bb_sptr + gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, + const std::string &tag_name); + private: + unsigned long long d_access_code; // access code to locate start of packet + // access code is left justified in the word + unsigned long long d_data_reg; // used to look for access_code + unsigned long long d_mask; // masks access_code bits (top N bits are set where + // N is the number of bits in the access code) + unsigned int d_threshold; // how many bits may be wrong in sync vector + unsigned int d_len; //the length of the access code + + pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID + + protected: + gr_correlate_access_code_tag_bb(const std::string &access_code, int threshold, + const std::string &tag_name); + + public: + ~gr_correlate_access_code_tag_bb(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + + /*! + * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" + */ + bool set_access_code (const std::string &access_code); +}; + +#endif /* INCLUDED_gr_correlate_access_code_tag_bb_H */ diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.i b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.i new file mode 100644 index 000000000..fb832194d --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.i @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006 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. + */ + +GR_SWIG_BLOCK_MAGIC(gr,correlate_access_code_tag_bb); + +/*! + * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" + * \param threshold maximum number of bits that may be wrong + */ +gr_correlate_access_code_tag_bb_sptr +gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, const std::string &tag_name) + throw(std::out_of_range); + +/*! + * \brief Examine input for specified access code, one bit at a time. + * \ingroup block + * + * input: stream of bits, 1 bit per input byte (data in LSB) + * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit) + * + * Each output byte contains two valid bits, the data bit, and the + * flag bit. The LSB (bit 0) is the data bit, and is the original + * input data, delayed 64 bits. Bit 1 is the + * flag bit and is 1 if the corresponding data bit is the first data + * bit following the access code. Otherwise the flag bit is 0. + */ +class gr_correlate_access_code_tag_bb : public gr_sync_block +{ + friend gr_correlate_access_code_tag_bb_sptr + gr_make_correlate_access_code_tag_bb (const std::string &access_code, int threshold, const std::string &tag_name); + protected: + gr_correlate_access_code_tag_bb(const std::string &access_code, int threshold, const std::string &tag_name); + + public: + ~gr_correlate_access_code_tag_bb(); + + /*! + * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" + */ + bool set_access_code (const std::string &access_code); +}; diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc index 85495e277..8bccefa95 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc @@ -40,6 +40,12 @@ gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n) gr_make_io_signature (1, 1, item_size)), d_count(n) { + // To avoid bad behavior with using set_relative_rate in this block with + // VERY large values of n, we will keep track of things ourselves. Using + // this to turn off automatic tag propagation, which will be handled + // locally in general_work(). + set_tag_propagation_policy(TPP_DONT); + set_n(n); } @@ -52,7 +58,10 @@ gr_keep_one_in_n::set_n(int n) d_n = n; d_count = n; - set_relative_rate(1.0 / (float)n); + // keep our internal understanding of the relative rate of this block + // don't set the relative rate, though, and we will handle our own + // tag propagation. + d_decim_rate = 1.0/(float)d_n; } int @@ -80,6 +89,19 @@ gr_keep_one_in_n::general_work (int noutput_items, ni++; } + // Because we have set TPP_DONT, we have to propagate the tags here manually. + // Adjustment of the tag sample value is done using the float d_decim_rate. + std::vector<pmt::pmt_t> tags; + std::vector<pmt::pmt_t>::iterator t; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni); + for(t = tags.begin(); t != tags.end(); t++) { + uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0)); + add_item_tag(0, newcount * d_decim_rate, + pmt::pmt_tuple_ref(*t, 1), + pmt::pmt_tuple_ref(*t, 2), + pmt::pmt_tuple_ref(*t, 3)); + } + consume_each (ni); return no; } diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h index f12a7a0f1..c32ed2a26 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h @@ -44,6 +44,7 @@ class GR_CORE_API gr_keep_one_in_n : public gr_block int d_n; int d_count; + float d_decim_rate; protected: gr_keep_one_in_n (size_t item_size, int n); diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt index a06a61e6d..a223d291f 100644 --- a/gnuradio-core/src/lib/gengen/CMakeLists.txt +++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt @@ -22,148 +22,121 @@ ######################################################################## ######################################################################## -# Generate the makefile.gen, then extract its sources: -# This is a round-about way to extract the sources, -# but it requires minimum changed to the python utils. -# -# The recommended way to do this: -# - Make a generation macro that registers the sources command. -# - List the generation macro with each templated source file. -# - Create a python script (very generic) to perform generation. -# - This way the targets would depend only on their sources. +# generate the python helper script which calls into the build utils ######################################################################## -EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c " -import os, sys +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re sys.path.append('${GR_CORE_PYTHONPATH}') -sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}') os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' -os.environ['gendir'] = '${CMAKE_CURRENT_BINARY_DIR}' -os.environ['do_makefile'] = '1' -os.environ['do_sources'] = '0' -from generate_all import generate_all -generate_all() - " WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') -MACRO(GEGEN_GEN_EXTRACT outvar ext) - EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import os; print ';'.join( - map(lambda x: os.path.join('${CMAKE_CURRENT_BINARY_DIR}', x.replace('\\\\', '').strip()), - filter(lambda f: '${ext}' in f, open('${CMAKE_CURRENT_BINARY_DIR}/Makefile.gen').readlines() - )))" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ${outvar}) - FILE(TO_CMAKE_PATH "${${outvar}}" ${outvar}) -ENDMACRO(GEGEN_GEN_EXTRACT) - -GEGEN_GEN_EXTRACT(generated_gengen_sources ".cc") -GEGEN_GEN_EXTRACT(generated_gengen_includes ".h") -GEGEN_GEN_EXTRACT(generated_gengen_swigs ".i") - -#TODO simplify this list with a triple-threat for loop -SET(generated_gengen_deps - ${CMAKE_CURRENT_SOURCE_DIR}/generate_all.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_common.py - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_const_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_const_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_const_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_const_vXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_const_vXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_add_const_vXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_argmax_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_argmax_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_argmax_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_chunks_to_symbols_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_chunks_to_symbols_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_chunks_to_symbols_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_divide_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_divide_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_divide_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_integrate_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_integrate_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_integrate_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_max_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_max_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_max_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_const_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_const_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_const_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_const_vXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_const_vXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_multiply_const_vXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_mute_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_mute_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_mute_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_noise_source_X.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_noise_source_X.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_noise_source_X.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_packed_to_unpacked_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_packed_to_unpacked_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_packed_to_unpacked_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_peak_detector_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_peak_detector_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_peak_detector_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sample_and_hold_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sample_and_hold_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sample_and_hold_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sig_source_X.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sig_source_X.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sig_source_X.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sub_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sub_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sub_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_unpacked_to_packed_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_unpacked_to_packed_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_unpacked_to_packed_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vector_source_X.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vector_source_X.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vector_source_X.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vector_sink_X.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vector_sink_X.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vector_sink_X.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_xor_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_xor_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_xor_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_and_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_and_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_and_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_and_const_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_and_const_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_and_const_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_or_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_or_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_or_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_not_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_not_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_not_XX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_moving_average_XX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_moving_average_XX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_moving_average_XX.i.t -) +if __name__ == '__main__': + import build_utils + root, inp = sys.argv[1:3] + for sig in sys.argv[3:]: + name = re.sub ('X+', sig, root) + d = build_utils.standard_dict(name, sig) + build_utils.expand_template(d, inp) -ADD_CUSTOM_COMMAND( - OUTPUT - ${generated_gengen_sources} - ${generated_gengen_includes} - ${generated_gengen_swigs} - DEPENDS ${generated_gengen_deps} - COMMAND ${PYTHON_EXECUTABLE} -B -c - \"import os, sys\;sys.path.append('${GR_CORE_PYTHONPATH}')\;sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}')\;os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'\;from generate_all import generate_all\;generate_all()\" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "generating gengen files" -) +") + +######################################################################## +# generation helper macro to generate various files from template +######################################################################## +MACRO(expand_h_cc_i root) + + FOREACH(ext h cc i) + #make a list of all the generated files + UNSET(expanded_files_${ext}) + FOREACH(sig ${ARGN}) + STRING(REGEX REPLACE "X+" ${sig} name ${root}) + LIST(APPEND expanded_files_${ext} ${CMAKE_CURRENT_BINARY_DIR}/${name}.${ext}) + ENDFOREACH(sig) + + #create a command to generate the files + ADD_CUSTOM_COMMAND( + OUTPUT ${expanded_files_${ext}} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.${ext}.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.${ext}.t ${ARGN} + ) + ENDFOREACH(ext) + + #make source files depends on headers to force generation + SET_SOURCE_FILES_PROPERTIES(${expanded_files_cc} + PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" + ) + + #install rules for the generated cc, h, and i files + LIST(APPEND generated_gengen_sources ${expanded_files_cc}) + LIST(APPEND generated_gengen_includes ${expanded_files_h}) + LIST(APPEND generated_gengen_swigs ${expanded_files_i}) + +ENDMACRO(expand_h_cc_i) + +######################################################################## +# Invoke macro to generate various sources +######################################################################## +expand_h_cc_i(gr_vector_source_X b s i f c) +expand_h_cc_i(gr_vector_sink_X b s i f c) +expand_h_cc_i(gr_noise_source_X s i f c) +expand_h_cc_i(gr_sig_source_X s i f c) + +expand_h_cc_i(gr_add_const_XX ss ii ff cc sf) +expand_h_cc_i(gr_multiply_const_XX ss ii ff cc) +expand_h_cc_i(gr_add_XX ss ii ff cc) +expand_h_cc_i(gr_sub_XX ss ii ff cc) +expand_h_cc_i(gr_multiply_XX ss ii ff cc) +expand_h_cc_i(gr_divide_XX ss ii ff cc) +expand_h_cc_i(gr_mute_XX ss ii ff cc) +expand_h_cc_i(gr_add_const_vXX ss ii ff cc) +expand_h_cc_i(gr_multiply_const_vXX ss ii ff cc) +expand_h_cc_i(gr_integrate_XX ss ii ff cc) +expand_h_cc_i(gr_moving_average_XX ss ii ff cc) + +expand_h_cc_i(gr_chunks_to_symbols_XX bf bc sf sc if ic) +expand_h_cc_i(gr_unpacked_to_packed_XX bb ss ii) +expand_h_cc_i(gr_packed_to_unpacked_XX bb ss ii) +expand_h_cc_i(gr_xor_XX bb ss ii) +expand_h_cc_i(gr_and_XX bb ss ii) +expand_h_cc_i(gr_and_const_XX bb ss ii) +expand_h_cc_i(gr_or_XX bb ss ii) +expand_h_cc_i(gr_not_XX bb ss ii) +expand_h_cc_i(gr_sample_and_hold_XX bb ss ii ff) +expand_h_cc_i(gr_argmax_XX fs is ss) +expand_h_cc_i(gr_max_XX ff ii ss) +expand_h_cc_i(gr_peak_detector_XX fb ib sb) ADD_CUSTOM_TARGET(gengen_generated DEPENDS - ${generated_gengen_sources} ${generated_gengen_includes} ${generated_gengen_swigs} ) ######################################################################## +# Create the master gengen swig include files +######################################################################## +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i " +// +// This file is machine generated. All edits will be overwritten +// +") + +FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i "%{\n") +FOREACH(swig_file ${generated_gengen_swigs}) + GET_FILENAME_COMPONENT(name ${swig_file} NAME_WE) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i "#include<${name}.h>\n") +ENDFOREACH(swig_file) +FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i "%}\n") + +FOREACH(swig_file ${generated_gengen_swigs}) + GET_FILENAME_COMPONENT(name ${swig_file} NAME) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i "%include<${name}>\n") +ENDFOREACH(swig_file) + +######################################################################## # Handle the generated sources + a few non-generated ones ######################################################################## LIST(APPEND gnuradio_core_sources diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc index 91618bad6..67184b9c5 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc +++ b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc @@ -183,7 +183,8 @@ gr_tagged_file_sink::work (int noutput_items, //std::cout << "Found end of burst: " // << idx_stop << ", " << N << std::endl; - int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize, idx_stop-idx, d_handle); + int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize, + idx_stop-idx, d_handle); if (count == 0) { if(ferror(d_handle)) { perror("gr_tagged_file_sink: error writing file"); @@ -200,7 +201,8 @@ gr_tagged_file_sink::work (int noutput_items, } } if(d_state == IN_BURST) { - int count = fwrite (&inbuf[idx], d_itemsize, noutput_items-idx, d_handle); + int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize, + noutput_items-idx, d_handle); if (count == 0) { if(ferror(d_handle)) { perror("gr_tagged_file_sink: error writing file"); diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index c46b720c5..0d10245bf 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -42,15 +42,41 @@ SET(GR_SWIG_LIBRARIES gnuradio-core) # smaller pieces for the compiler to digest. prior to this change, on # X86_64, g++'s resident set size was 650MB! # ---------------------------------------------------------------- +FILE(GLOB GR_SWIG_SOURCE_DEPS + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/runtime/*.i" + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/runtime/*.h" +) GR_SWIG_MAKE(gnuradio_core_runtime gnuradio_core_runtime.i) +UNSET(GR_SWIG_SOURCE_DEPS) + +FILE(GLOB GR_SWIG_SOURCE_DEPS + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/general/*.i" + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/general/*.h" +) GR_SWIG_MAKE(gnuradio_core_general gnuradio_core_general.i) +UNSET(GR_SWIG_SOURCE_DEPS) + SET(GR_SWIG_TARGET_DEPS gengen_generated) GR_SWIG_MAKE(gnuradio_core_gengen gnuradio_core_gengen.i) +UNSET(GR_SWIG_TARGET_DEPS) + SET(GR_SWIG_TARGET_DEPS filter_generated) GR_SWIG_MAKE(gnuradio_core_filter gnuradio_core_filter.i) UNSET(GR_SWIG_TARGET_DEPS) + +FILE(GLOB GR_SWIG_SOURCE_DEPS + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/io/*.i" + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/io/*.h" +) GR_SWIG_MAKE(gnuradio_core_io gnuradio_core_io.i) +UNSET(GR_SWIG_SOURCE_DEPS) + +FILE(GLOB GR_SWIG_SOURCE_DEPS + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/hier/*.i" + "${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/hier/*.h" +) GR_SWIG_MAKE(gnuradio_core_hier gnuradio_core_hier.i) +UNSET(GR_SWIG_SOURCE_DEPS) GR_SWIG_INSTALL(TARGETS gnuradio_core_runtime diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py index 200c4cfbe..6f7fc520f 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py @@ -54,13 +54,13 @@ class _logpwrfft_base(gr.hier_block2): fft = self._fft_block[0](fft_size, True, fft_window) window_power = sum(map(lambda x: x*x, fft_window)) - c2mag = gr.complex_to_mag(fft_size) + c2magsq = gr.complex_to_mag_squared(fft_size) self._avg = gr.single_pole_iir_filter_ff(1.0, fft_size) - self._log = gr.nlog10_ff(20, fft_size, + self._log = gr.nlog10_ff(10, fft_size, -20*math.log10(fft_size) # Adjust for number of bins -10*math.log10(window_power/fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)+3.0) # Adjust for reference scale - self.connect(self, self._sd, fft, c2mag, self._avg, self._log, self) + -20*math.log10(ref_scale/2)) # Adjust for reference scale + self.connect(self, self._sd, fft, c2magsq, self._avg, self._log, self) self._average = average self._avg_alpha = avg_alpha diff --git a/gnuradio-core/src/python/gnuradio/vocoder/.gitignore b/gnuradio-core/src/python/gnuradio/vocoder/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/vocoder/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in |