diff options
Diffstat (limited to 'gnuradio-core')
500 files changed, 6142 insertions, 14948 deletions
diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt new file mode 100644 index 000000000..360a5c090 --- /dev/null +++ b/gnuradio-core/CMakeLists.txt @@ -0,0 +1,145 @@ +# Copyright 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. + +######################################################################## +# Setup dependencies +######################################################################## +include(GrBoost) + +find_package(GSL) + +find_package(FFTW3f) + +include(GrPython) #used for code generation + +get_filename_component(GR_CORE_PYTHONPATH + ${CMAKE_CURRENT_SOURCE_DIR}/src/python ABSOLUTE +) +GR_SET_GLOBAL(GR_CORE_PYTHONPATH ${GR_CORE_PYTHONPATH}) + +######################################################################## +# Register component +######################################################################## +include(GrComponent) +GR_REGISTER_COMPONENT("gnuradio-core" ENABLE_GR_CORE + ENABLE_GRUEL + Boost_FOUND + GSL_FOUND + FFTW3F_FOUND + PYTHONINTERP_FOUND +) + +include(GrMiscUtils) +GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS + ${GRUEL_INCLUDE_DIRS} #headers depend on gruel + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/runtime + ${CMAKE_CURRENT_BINARY_DIR}/src/lib/general + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/general + ${CMAKE_CURRENT_BINARY_DIR}/src/lib/gengen + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/gengen + ${CMAKE_CURRENT_BINARY_DIR}/src/lib/filter + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/filter + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/missing + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/reed-solomon + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/viterbi + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/io + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/g72x + ${CMAKE_CURRENT_BINARY_DIR}/src/lib/swig + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/hier +) + +GR_SET_GLOBAL(GNURADIO_CORE_SWIG_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/gruel/src/swig + ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig + ${GNURADIO_CORE_INCLUDE_DIRS} +) + +######################################################################## +# Begin conditional configuration +######################################################################## +if(ENABLE_GR_CORE) + +######################################################################## +# Setup CPack components +######################################################################## +include(GrPackage) +CPACK_SET(CPACK_COMPONENT_GROUP_CORE_DESCRIPTION "GNU Radio Core Library") + +CPACK_COMPONENT("core_runtime" + GROUP "Core" + DISPLAY_NAME "Runtime" + DESCRIPTION "Runtime" + DEPENDS "gruel_runtime" +) + +CPACK_COMPONENT("core_devel" + GROUP "Core" + DISPLAY_NAME "Development" + DESCRIPTION "C++ headers, package config, import libraries" + DEPENDS "gruel_devel" +) + +CPACK_COMPONENT("core_python" + GROUP "Core" + DISPLAY_NAME "Python" + DESCRIPTION "Python modules for runtime; GRC xml files" + DEPENDS "gruel_python;core_runtime" +) + +CPACK_COMPONENT("core_swig" + GROUP "Core" + DISPLAY_NAME "SWIG" + DESCRIPTION "SWIG development .i files" + DEPENDS "gruel_swig;core_python;core_devel" +) + +install( + FILES gnuradio-core.conf + DESTINATION ${GR_PKG_CONF_DIR} + COMPONENT "core_runtime" +) + +######################################################################## +# Add subdirectories +######################################################################## +add_subdirectory(src/lib) +if(ENABLE_TESTING) + add_subdirectory(src/tests) +endif(ENABLE_TESTING) +if(ENABLE_PYTHON) + add_subdirectory(src/lib/swig) + add_subdirectory(src/python/gnuradio) +endif(ENABLE_PYTHON) + +######################################################################## +# Create Pkg Config File +######################################################################## +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.pc +@ONLY) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.pc + DESTINATION ${GR_LIBRARY_DIR}/pkgconfig + COMPONENT "core_devel" +) + +endif(ENABLE_GR_CORE) diff --git a/gnuradio-core/src/guile/tests/filter_ctors.test b/gnuradio-core/src/guile/tests/filter_ctors.test index 4dd0bc187..fe1d9421d 100644 --- a/gnuradio-core/src/guile/tests/filter_ctors.test +++ b/gnuradio-core/src/guile/tests/filter_ctors.test @@ -36,9 +36,6 @@ ;; gr_adaptive_fir_ccf(char *name, int decimation, const std::vector<float> &taps); ;; (pass-if (true? (gr:adaptive-fir-ccf "foo" 0 #(1.0 2.0 3.0 4.0)))) -;;; ./filter/gr_cma_equalizer_cc.h -(pass-if (true? (gr:cma-equalizer-cc 0 0 0))) - ;;; ./filter/gr_fft_filter_ccc.h (pass-if (true? (gr:fft-filter-ccc 0 #(1+3i 23+5i)))) diff --git a/gnuradio-core/src/guile/tests/general_ctors.test b/gnuradio-core/src/guile/tests/general_ctors.test index 244249dd8..ca4d60460 100644 --- a/gnuradio-core/src/guile/tests/general_ctors.test +++ b/gnuradio-core/src/guile/tests/general_ctors.test @@ -71,9 +71,6 @@ ;;; ./general/gr_bin_statistics_f.h WONTFIX: requires gr_feval_dd & swig directors ;;;(pass-if (true? (gr:bin-statistics-f 1 (gr:msg-queue) 0 0 0))) -;;; ./general/gr_binary_slicer_fb.h -(pass-if (true? (gr:binary-slicer-fb))) - ;;; ./general/gr_bytes_to_syms.h (pass-if (true? (gr:bytes-to-syms))) @@ -86,14 +83,6 @@ ;;; ./general/gr_check_lfsr_32k_s.h (pass-if (true? (gr:check-lfsr-32k-s))) -;;; ./general/gr_clock_recovery_mm_cc.h -(pass-if (true? (gr:clock-recovery-mm-cc 1 1 1 1 1))) -(pass-if-throw "confirm throw gr:clock-recovery-mm-cc" #t (true? (gr:clock-recovery-mm-cc -1 1 1 1 1))) - -;;; ./general/gr_clock_recovery_mm_ff.h -(pass-if (true? (gr:clock-recovery-mm-ff 1 1 1 1 1))) -(pass-if-throw "confirm throw gr:clock-recovery-mm-ff" #t (true? (gr:clock-recovery-mm-ff -1 1 1 1 1))) - ;;; ./general/gr_complex_to_interleaved_short.h (pass-if (true? (gr:complex-to-interleaved-short))) @@ -108,22 +97,9 @@ ;;; ./general/gr_conjugate_cc.h (pass-if (true? (gr:conjugate-cc))) -;;; ./general/gr_constellation_decoder_cb.h -(pass-if (true? (gr:constellation-decoder-cb #(2+3i 23+5i) #(0 1)))) - ;;; ./general/gr_copy.h (pass-if (true? (gr:copy 1))) -;;; ./general/gr_correlate_access_code_bb.h -(pass-if (true? (gr:correlate-access-code-bb "foo" 0))) -(pass-if-throw "confirm throw correlate-access-code-bb" #t - (true? (gr:correlate-access-code-bb - "00000000000000000000000000000000000000000000000000000000000000000" 0))) - -;;; ./general/gr_costas_loop_cc.h -(pass-if (true? (gr:costas-loop-cc 0 0 0 0 2))) -(pass-if-throw "confirm throw gr:costas-loop-cc" #t (true? (gr:costas-loop-cc 0 0 0 0 3))) - ;;; ./general/gr_cpfsk_bc.h (pass-if (true? (gr:cpfsk-bc 1 1 1))) @@ -171,9 +147,6 @@ (pass-if (true? (gr:fft-vfc 4 #t #(1.0 2.0 3.0 4.0)))) (pass-if-throw "confirm throw gr:fft-vfc" #t (true? (gr:fft-vfc 4 #f #(1.0 2.0 3.0 4.0)))) -;;; ./general/gr_fll_band_edge_cc.h -(pass-if (true? (gr:fll-band-edge-cc 0 0 0 0 0))) - ;; ;;; ./general/gr_float_to_char.h (pass-if (true? (gr:float-to-char))) @@ -221,18 +194,9 @@ ;;; ./general/gr_lfsr_32k_source_s.h (pass-if (true? (gr:lfsr-32k-source-s))) -;;; ./general/gr_lms_dfe_cc.h -(pass-if (true? (gr:lms-dfe-ff 1 1 1 1))) - -;;; ./general/gr_lms_dfe_ff.h -(pass-if (true? (gr:lms-dfe-ff 1 1 1 1))) - ;;; ./general/gr_map_bb.h (pass-if (true? (gr:map-bb #(1 2)))) -;;; ./general/gr_mpsk_receiver_cc.h -(pass-if (true? (gr:mpsk-receiver-cc 1 1 1 1 1 1 1 1 1 1 1))) - ;;; ./general/gr_nlog10_ff.h (pass-if (true? (gr:nlog10-ff 1 1 1))) @@ -245,28 +209,6 @@ ;;; ./general/gr_null_source.h (pass-if (true? (gr:null-source 1))) -;;; ./general/gr_ofdm_cyclic_prefixer.h -(pass-if (true? (gr:ofdm-cyclic-prefixer 1 1))) - -;;; ./general/gr_ofdm_frame_acquisition.h -(pass-if (true? (gr:ofdm-frame-acquisition 1 1 1 #(1+3i 23+5i) 1))) - -;;; ./general/gr_ofdm_frame_sink.h -(pass-if (true? (gr:ofdm-frame-sink #(1+3i 23+5i) #(0 1) (gr:msg-queue) 128 0.25 0))) - -;;; ./general/gr_ofdm_insert_preamble.h FIXME: "Wrong type argument in position ~A: ~S" -;;; WONTFIX: Need vector<vector<complex<float>>> -;;(pass-if (true? (gr:ofdm-insert-preamble 2 #(#(1+3i 23+5i) #(1+3i 23+5i))))) - -;;; ./general/gr_ofdm_mapper_bcv.h -(pass-if (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 100 128))) -(pass-if-throw "confirm throw gr:ofdm-mapper-bcv" #t - (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 10 128))) - - -;;; ./general/gr_ofdm_sampler.h -(pass-if (true? (gr:ofdm-sampler 1 1 1))) - ;;; ./general/gr_pa_2x2_phase_combiner.h (pass-if (true? (gr:pa-2x2-phase-combiner))) @@ -280,13 +222,13 @@ (pass-if (true? (gr:phase-modulator-fc 0))) ;;; ./general/gr_pll_carriertracking_cc.h -(pass-if (true? (gr:pll-carriertracking-cc 0 0 0 0))) +(pass-if (true? (gr:pll-carriertracking-cc 0 0 0))) ;;; ./general/gr_pll_freqdet_cf.h -(pass-if (true? (gr:pll-freqdet-cf 0 0 0 0))) +(pass-if (true? (gr:pll-freqdet-cf 0 0 0))) ;;; ./general/gr_pll_refout_cc.h -(pass-if (true? (gr:pll-refout-cc 0 0 0 0))) +(pass-if (true? (gr:pll-refout-cc 0 0 0))) ;;; ./general/gr_pn_correlator_cc.h (pass-if (true? (gr:pn-correlator-cc 1 1 1))) diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt new file mode 100644 index 000000000..2e0d95798 --- /dev/null +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -0,0 +1,106 @@ +# Copyright 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. + +######################################################################## +# Setup compatibility checks and defines +######################################################################## +include(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake) + +######################################################################## +# Include subdirs rather to populate to the sources lists. +######################################################################## +GR_INCLUDE_SUBDIRECTORY(missing) +GR_INCLUDE_SUBDIRECTORY(runtime) +GR_INCLUDE_SUBDIRECTORY(filter) +GR_INCLUDE_SUBDIRECTORY(viterbi) +GR_INCLUDE_SUBDIRECTORY(general) +GR_INCLUDE_SUBDIRECTORY(gengen) +GR_INCLUDE_SUBDIRECTORY(reed-solomon) +GR_INCLUDE_SUBDIRECTORY(io) +GR_INCLUDE_SUBDIRECTORY(hier) + +list(APPEND gnuradio_core_sources bug_work_around_6.cc) +list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories(${GNURADIO_CORE_INCLUDE_DIRS}) + +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +add_definitions(${GSL_DEFINITIONS}) +include_directories(${GSL_INCLUDE_DIRS}) +link_directories(${GSL_LIBRARY_DIRS}) + +include_directories(${FFTW3F_INCLUDE_DIRS}) +link_directories(${FFTW3F_LIBRARY_DIRS}) + +######################################################################## +# Setup library +######################################################################## +list(APPEND gnuradio_core_libs + gruel + ${Boost_LIBRARIES} + ${GSL_LIBRARIES} + ${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") +set_target_properties(gnuradio-core PROPERTIES SOVERSION ${LIBVER}) +#avoid fftw and gsl link in dependent libraries: +set_target_properties(gnuradio-core PROPERTIES LINK_INTERFACE_LIBRARIES "gruel") + +install(TARGETS gnuradio-core + LIBRARY DESTINATION ${GR_LIBRARY_DIR} COMPONENT "core_runtime" # .so/.dylib file + ARCHIVE DESTINATION ${GR_LIBRARY_DIR} COMPONENT "core_devel" # .lib file + RUNTIME DESTINATION ${GR_RUNTIME_DIR} COMPONENT "core_runtime" # .dll file +) + +######################################################################## +# Setup executables +######################################################################## +add_executable(gnuradio-config-info gnuradio-config-info.cc) +target_link_libraries(gnuradio-config-info gnuradio-core ${Boost_LIBRARIES}) +install( + TARGETS gnuradio-config-info + DESTINATION ${GR_RUNTIME_DIR} + COMPONENT "core_runtime" +) + +######################################################################## +# Setup tests +######################################################################## +if(ENABLE_TESTING) + +include_directories(${CPPUNIT_INCLUDE_DIRS}) +link_directories(${CPPUNIT_LIBRARY_DIRS}) + +add_library(test-gnuradio-core SHARED ${test_gnuradio_core_sources}) +target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES}) + +endif(ENABLE_TESTING) diff --git a/gnuradio-core/src/lib/ConfigChecks.cmake b/gnuradio-core/src/lib/ConfigChecks.cmake new file mode 100644 index 000000000..30a1011e4 --- /dev/null +++ b/gnuradio-core/src/lib/ConfigChecks.cmake @@ -0,0 +1,212 @@ +# Copyright 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. + +######################################################################## +INCLUDE(GrMiscUtils) +INCLUDE(CheckCXXSourceCompiles) + +IF(MSVC) #add this directory for our provided headers +LIST(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}/msvc) +ENDIF(MSVC) + +GR_CHECK_HDR_N_DEF(netdb.h HAVE_NETDB_H) +GR_CHECK_HDR_N_DEF(sys/time.h HAVE_SYS_TIME_H) +GR_CHECK_HDR_N_DEF(sys/types.h HAVE_SYS_TYPES_H) +GR_CHECK_HDR_N_DEF(sys/select.h HAVE_SYS_SELECT_H) +GR_CHECK_HDR_N_DEF(sys/socket.h HAVE_SYS_SOCKET_H) +GR_CHECK_HDR_N_DEF(io.h HAVE_IO_H) +GR_CHECK_HDR_N_DEF(sys/mman.h HAVE_SYS_MMAN_H) +GR_CHECK_HDR_N_DEF(sys/ipc.h HAVE_SYS_IPC_H) +GR_CHECK_HDR_N_DEF(sys/shm.h HAVE_SYS_SHM_H) +GR_CHECK_HDR_N_DEF(signal.h HAVE_SIGNAL_H) +GR_CHECK_HDR_N_DEF(netinet/in.h HAVE_NETINET_IN_H) +GR_CHECK_HDR_N_DEF(arpa/inet.h HAVE_ARPA_INET_H) +GR_CHECK_HDR_N_DEF(byteswap.h HAVE_BYTESWAP_H) +GR_CHECK_HDR_N_DEF(linux/ppdev.h HAVE_LINUX_PPDEV_H) +GR_CHECK_HDR_N_DEF(dev/ppbus/ppi.h HAVE_DEV_PPBUS_PPI_H) +GR_CHECK_HDR_N_DEF(unistd.h HAVE_UNISTD_H) +GR_CHECK_HDR_N_DEF(malloc.h HAVE_MALLOC_H) + + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <stdio.h> + int main(){snprintf(0, 0, 0); return 0;} + " HAVE_SNPRINTF +) +GR_ADD_COND_DEF(HAVE_SNPRINTF) + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <signal.h> + int main(){sigaction(0, 0, 0); return 0;} + " HAVE_SIGACTION +) +GR_ADD_COND_DEF(HAVE_SIGACTION) + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <sys/select.h> + int main(){select(0, 0, 0, 0, 0); return 0;} + " HAVE_SELECT +) +GR_ADD_COND_DEF(HAVE_SELECT) + + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <unistd.h> + int main(){sysconf(0); return 0;} + " HAVE_SYSCONF +) +GR_ADD_COND_DEF(HAVE_SYSCONF) + +CHECK_CXX_SOURCE_COMPILES(" + #include <unistd.h> + int main(){getpagesize(); return 0;} + " HAVE_GETPAGESIZE +) +GR_ADD_COND_DEF(HAVE_GETPAGESIZE) + + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <Winbase.h> + int main(){Sleep(0); return 0;} + " HAVE_SSLEEP +) +GR_ADD_COND_DEF(HAVE_SSLEEP) + +CHECK_CXX_SOURCE_COMPILES(" + #include <time.h> + int main(){nanosleep(0, 0); return 0;} + " HAVE_NANOSLEEP +) +GR_ADD_COND_DEF(HAVE_NANOSLEEP) + +CHECK_CXX_SOURCE_COMPILES(" + #include <sys/time.h> + int main(){gettimeofday(0, 0); return 0;} + " HAVE_GETTIMEOFDAY +) +GR_ADD_COND_DEF(HAVE_GETTIMEOFDAY) + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <stdlib.h> + int main(){posix_memalign(0, 0, 0); return 0;} + " HAVE_POSIX_MEMALIGN +) +GR_ADD_COND_DEF(HAVE_POSIX_MEMALIGN) + +CHECK_CXX_SOURCE_COMPILES(" + #include <malloc.h> + int main(){valloc(0); return 0;} + " HAVE_VALLOC +) +GR_ADD_COND_DEF(HAVE_VALLOC) + +ADD_DEFINITIONS(-DALIGNED_MALLOC=0) + +######################################################################## +SET(CMAKE_REQUIRED_LIBRARIES -lpthread) +CHECK_CXX_SOURCE_COMPILES(" + #include <signal.h> + int main(){pthread_sigmask(0, 0, 0); return 0;} + " HAVE_PTHREAD_SIGMASK +) +GR_ADD_COND_DEF(HAVE_PTHREAD_SIGMASK) +SET(CMAKE_REQUIRED_LIBRARIES) + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <windows.h> + int main(){ + HANDLE handle; + int size; + LPCTSTR lpName; + handle = CreateFileMapping( + INVALID_HANDLE_VALUE, // use paging file + NULL, // default security + PAGE_READWRITE, // read/write access + 0, // max. object size + size, // buffer size + lpName); // name of mapping object + return 0; + } " HAVE_CREATEFILEMAPPING +) +GR_ADD_COND_DEF(HAVE_CREATEFILEMAPPING) + +######################################################################## +CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H) +IF(HAVE_WINDOWS_H) + ADD_DEFINITIONS(-DHAVE_WINDOWS_H -DUSING_WINSOCK) + MESSAGE(STATUS "Adding windows libs to gnuradio core libs...") + LIST(APPEND gnuradio_core_libs WS2_32.lib WSock32.lib) +ENDIF(HAVE_WINDOWS_H) + +######################################################################## +SET(CMAKE_REQUIRED_LIBRARIES -lrt) +CHECK_CXX_SOURCE_COMPILES(" + #include <sys/types.h> + #include <sys/mman.h> + int main(){shm_open(0, 0, 0); return 0;} + " HAVE_SHM_OPEN +) +GR_ADD_COND_DEF(HAVE_SHM_OPEN) +SET(CMAKE_REQUIRED_LIBRARIES) + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #define _GNU_SOURCE + #include <math.h> + int main(){double x, sin, cos; sincos(x, &sin, &cos); return 0;} + " HAVE_SINCOS +) +GR_ADD_COND_DEF(HAVE_SINCOS) + +CHECK_CXX_SOURCE_COMPILES(" + #define _GNU_SOURCE + #include <math.h> + int main(){float x, sin, cos; sincosf(x, &sin, &cos); return 0;} + " HAVE_SINCOSF +) +GR_ADD_COND_DEF(HAVE_SINCOSF) + +CHECK_CXX_SOURCE_COMPILES(" + #include <math.h> + int main(){sinf(0); return 0;} + " HAVE_SINF +) +GR_ADD_COND_DEF(HAVE_SINF) + +CHECK_CXX_SOURCE_COMPILES(" + #include <math.h> + int main(){cosf(0); return 0;} + " HAVE_COSF +) +GR_ADD_COND_DEF(HAVE_COSF) + +######################################################################## +CHECK_CXX_SOURCE_COMPILES(" + #include <sys/mman.h> + int main(){mmap(0, 0, 0, 0, 0, 0); return 0;} + " HAVE_MMAP +) +GR_ADD_COND_DEF(HAVE_MMAP) diff --git a/gnuradio-core/src/lib/Makefile.am b/gnuradio-core/src/lib/Makefile.am index db2482479..fc1b7917b 100644 --- a/gnuradio-core/src/lib/Makefile.am +++ b/gnuradio-core/src/lib/Makefile.am @@ -23,7 +23,7 @@ include $(top_srcdir)/Makefile.common ## Process this file with automake to produce Makefile.in # We've got to build . before swig -SUBDIRS = missing runtime filter viterbi general gengen g72x reed-solomon io hier . swig +SUBDIRS = missing runtime filter viterbi general gengen reed-solomon io hier . swig AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) @@ -42,7 +42,6 @@ libgnuradio_core_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 \ libgnuradio_core_la_LIBADD = \ filter/libfilter.la \ - g72x/libccitt.la \ viterbi/libviterbi.la \ general/libgeneral.la \ gengen/libgengen.la \ diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt new file mode 100644 index 000000000..ce7e387c2 --- /dev/null +++ b/gnuradio-core/src/lib/filter/CMakeLists.txt @@ -0,0 +1,351 @@ +# Copyright 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +#set the C language property on the assembly files so the compiler will pick them up +file(GLOB gr_core_filter_asms ${CMAKE_CURRENT_SOURCE_DIR}/*.S) +foreach(gr_core_filter_asm ${gr_core_filter_asms}) + set_property(SOURCE ${gr_core_filter_asm} PROPERTY LANGUAGE C) +endforeach(gr_core_filter_asm) + +#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() + +######################################################################## +# 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. +######################################################################## +execute_process( + 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}' +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} +) + +macro(FILTER_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(FILTER_GEN_EXTRACT) + +FILTER_GEN_EXTRACT(generated_filter_sources ".cc") +FILTER_GEN_EXTRACT(generated_filter_includes ".h") +FILTER_GEN_EXTRACT(generated_filter_swigs ".i") + +#TODO simplify this list with a triple-threat for loop +set(generated_filter_deps + ${CMAKE_CURRENT_SOURCE_DIR}/generate_all.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_XXX.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_filter_XXX.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_interp_fir_filter_XXX.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_rational_resampler_base_XXX.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_sysconfig.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_sysconfig_generic.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_util.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_freq_xlating_fir_filter_XXX.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_gri_fir_filter_with_buffer_XXX.py + ${CMAKE_CURRENT_SOURCE_DIR}/generate_utils.py + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX.h.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX_generic.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX_generic.h.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.h.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.i.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.h.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.i.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.h.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.i.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.h.t + ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.i.t + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fir_filter_with_buffer_XXX.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fir_filter_with_buffer_XXX.h.t +) + +add_custom_command( + OUTPUT + ${generated_filter_sources} + ${generated_filter_includes} + ${generated_filter_swigs} + DEPENDS ${generated_filter_deps} + 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 + ${generated_filter_sources} + ${generated_filter_includes} + ${generated_filter_swigs} +) + +######################################################################## +# Add target specific files +# May VOLK put a rest to all the insanity below. +######################################################################## +if(MSVC) + 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 + ) +else(MSVC) +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 + ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccc_simd.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccc_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_simd.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fsf_simd.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fsf_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_scc_simd.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_scc_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fcc_simd.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fcc_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_simd.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/sse_debug.c + ) + list(APPEND test_gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_float_dotprod_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_complex_dotprod_x86.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_ccomplex_dotprod_x86.cc + ) +endif() + +if(CMAKE_SYSTEM_PROCESSOR_x86 AND "${CMAKE_SYSTEM_PROCESSOR_x86}" STREQUAL "64") + list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse64.S + ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow64.S + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnowext64.S + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnow64.S + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_sse64.S + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnowext64.S + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnow64.S + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_sse64.S + ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_3dnow64.S + ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_sse64.S + ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_mmx64.S + ) +elseif(CMAKE_SYSTEM_PROCESSOR_x86 AND "${CMAKE_SYSTEM_PROCESSOR_x86}" STREQUAL "32") + list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse.S + ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow.S + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnowext.S + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnow.S + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_sse.S + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnowext.S + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnow.S + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_sse.S + ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_3dnow.S + ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_sse.S + ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_mmx.S + ) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") + list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_powerpc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_powerpc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_powerpc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_altivec.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_altivec.c + ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_fff_altivec.c + ) + list(APPEND test_gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_powerpc.cc + ) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_armv7_a.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_armv7_a.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_armv7_a.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_armv7_a.cc + ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_fff_armv7_a.c + ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_ccf_armv7_a.c + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_armv7_a.cc + ) + list(APPEND test_gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_armv7_a.cc + ) +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() +endif(MSVC) + +######################################################################## +# Append gnuradio-core library sources +######################################################################## +list(APPEND gnuradio_core_sources + ${generated_filter_sources} + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_fff_generic.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_ccc_generic.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c + ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator_cc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_generic.cc + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_generic.cc + ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_generic.c + ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_generic.c +) + +######################################################################## +# Append gnuradio-core test sources +######################################################################## +list(APPEND test_gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/qa_filter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_ccf.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_fcc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_fff.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_ccc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_scc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_rotator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_mmse_fir_interpolator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_mmse_fir_interpolator_cc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_ccf.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_ccc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fcc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fff.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fsf.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_scc.cc +) + +######################################################################## +# Install runtime headers +######################################################################## +install(FILES + ${generated_filter_includes} + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_generic.h + ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_x86.h + ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_x86.h + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_generic.h + ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_x86.h + ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_generic.h + ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_x86.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_altivec.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_fff_generic.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_ccc_generic.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_x86.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_powerpc.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_rotator.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_single_pole_iir.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vec_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_iir.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator_cc.h + ${CMAKE_CURRENT_SOURCE_DIR}/qa_filter.h + ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_generic.h + ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_x86.h + ${CMAKE_CURRENT_SOURCE_DIR}/sse_debug.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +######################################################################## +# Install swig headers +######################################################################## +if(ENABLE_PYTHON) +install(FILES + ${generated_filter_swigs} + ${CMAKE_CURRENT_SOURCE_DIR}/filter.i + ${CMAKE_CURRENT_BINARY_DIR}/filter_generated.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" +) +endif(ENABLE_PYTHON) + +######################################################################## +# Handle triple-threat files that have cc, h, and i +######################################################################## +set(gr_core_filter_triple_threats + gr_adaptive_fir_ccc + gr_adaptive_fir_ccf + gr_dc_blocker_cc + gr_dc_blocker_ff + gr_fft_filter_ccc + gr_fft_filter_fff + gr_filter_delay_fc + gr_fractional_interpolator_ff + gr_fractional_interpolator_cc + gr_goertzel_fc + gr_hilbert_fc + gr_iir_filter_ffd + gr_single_pole_iir_filter_ff + gr_single_pole_iir_filter_cc + gr_pfb_channelizer_ccf + gr_pfb_synthesis_filterbank_ccf + gr_pfb_decimator_ccf + gr_pfb_interpolator_ccf + gr_pfb_arb_resampler_ccf + gr_pfb_arb_resampler_fff + gr_pfb_clock_sync_ccf + gr_pfb_clock_sync_fff +) + +foreach(file_tt ${gr_core_filter_triple_threats}) + list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") + if(ENABLE_PYTHON) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") + endif(ENABLE_PYTHON) +endforeach(file_tt ${gr_core_filter_triple_threats}) diff --git a/gnuradio-core/src/lib/filter/Makefile.am b/gnuradio-core/src/lib/filter/Makefile.am index 0314079a2..c314431bf 100644 --- a/gnuradio-core/src/lib/filter/Makefile.am +++ b/gnuradio-core/src/lib/filter/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2002,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc. +# Copyright 2001,2002,2004-2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -188,8 +188,8 @@ EXTRA_DIST += \ # work around automake deficiency libfilter_la_common_SOURCES = \ $(GENERATED_CC) \ + gr_adaptive_fir_ccc.cc \ gr_adaptive_fir_ccf.cc \ - gr_cma_equalizer_cc.cc \ gri_fft_filter_fff_generic.cc \ gri_fft_filter_ccc_generic.cc \ gr_fft_filter_ccc.cc \ @@ -215,6 +215,7 @@ libfilter_la_common_SOURCES = \ gr_pfb_decimator_ccf.cc \ gr_pfb_interpolator_ccf.cc \ gr_pfb_arb_resampler_ccf.cc \ + gr_pfb_arb_resampler_fff.cc \ gr_pfb_clock_sync_ccf.cc \ gr_pfb_clock_sync_fff.cc \ gr_dc_blocker_cc.cc \ @@ -272,9 +273,9 @@ grinclude_HEADERS = \ ccomplex_dotprod_x86.h \ float_dotprod_generic.h \ float_dotprod_x86.h \ + gr_adaptive_fir_ccc.h \ gr_adaptive_fir_ccf.h \ gr_altivec.h \ - gr_cma_equalizer_cc.h \ gr_cpu.h \ gri_fft_filter_fff_generic.h \ gri_fft_filter_ccc_generic.h \ @@ -307,6 +308,7 @@ grinclude_HEADERS = \ gr_pfb_decimator_ccf.h \ gr_pfb_interpolator_ccf.h \ gr_pfb_arb_resampler_ccf.h \ + gr_pfb_arb_resampler_fff.h \ gr_pfb_clock_sync_ccf.h \ gr_pfb_clock_sync_fff.h \ gr_dc_blocker_cc.h \ @@ -357,8 +359,8 @@ noinst_HEADERS = \ swiginclude_HEADERS = \ filter.i \ filter_generated.i \ + gr_adaptive_fir_ccc.i \ gr_adaptive_fir_ccf.i \ - gr_cma_equalizer_cc.i \ gr_fft_filter_ccc.i \ gr_fft_filter_fff.i \ gr_filter_delay_fc.i \ @@ -374,6 +376,7 @@ swiginclude_HEADERS = \ gr_pfb_decimator_ccf.i \ gr_pfb_interpolator_ccf.i \ gr_pfb_arb_resampler_ccf.i \ + gr_pfb_arb_resampler_fff.i \ gr_pfb_clock_sync_ccf.i \ gr_pfb_clock_sync_fff.i \ gr_dc_blocker_cc.i \ diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h b/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h index 4637dc706..c03743776 100644 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h +++ b/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h @@ -23,7 +23,9 @@ #ifndef _CCOMPLEX_DOTPROD_GENERIC_H_ #define _CCOMPLEX_DOTPROD_GENERIC_H_ -void +#include <gr_core_api.h> + +GR_CORE_API void ccomplex_dotprod_generic (const float *input, const float *taps, unsigned n_2_ccomplex_blocks, float *result); diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_generic.h b/gnuradio-core/src/lib/filter/complex_dotprod_generic.h index 75d18e7f1..aed82179e 100644 --- a/gnuradio-core/src/lib/filter/complex_dotprod_generic.h +++ b/gnuradio-core/src/lib/filter/complex_dotprod_generic.h @@ -23,7 +23,9 @@ #ifndef _COMPLEX_DOTPROD_GENERIC_H_ #define _COMPLEX_DOTPROD_GENERIC_H_ -void +#include <gr_core_api.h> + +GR_CORE_API void complex_dotprod_generic (const short *input, const float *taps, unsigned n_2_complex_blocks, float *result); diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h index d9ee52cf0..af9210382 100644 --- a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h +++ b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h @@ -21,6 +21,7 @@ #ifndef INCLUDED_DOTPROD_FFF_ALTIVEC_H #define INCLUDED_DOTPROD_FFF_ALTIVEC_H +#include <gr_core_api.h> #include <stddef.h> #ifdef __cplusplus diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h index e72621a0d..667ee5fb6 100644 --- a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h +++ b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h @@ -21,6 +21,7 @@ #ifndef INCLUDED_DOTPROD_FFF_ARMV7_A_H #define INCLUDED_DOTPROD_FFF_ARMV7_A_H +#include <gr_core_api.h> #include <stddef.h> #ifdef __cplusplus diff --git a/gnuradio-core/src/lib/filter/filter.i b/gnuradio-core/src/lib/filter/filter.i index 58bb4f0d5..8c3bb9eb6 100644 --- a/gnuradio-core/src/lib/filter/filter.i +++ b/gnuradio-core/src/lib/filter/filter.i @@ -31,12 +31,12 @@ #include <gr_fractional_interpolator_ff.h> #include <gr_fractional_interpolator_cc.h> #include <gr_goertzel_fc.h> -#include <gr_cma_equalizer_cc.h> #include <gr_pfb_channelizer_ccf.h> #include <gr_pfb_synthesis_filterbank_ccf.h> #include <gr_pfb_decimator_ccf.h> #include <gr_pfb_interpolator_ccf.h> #include <gr_pfb_arb_resampler_ccf.h> +#include <gr_pfb_arb_resampler_fff.h> #include <gr_pfb_clock_sync_ccf.h> #include <gr_pfb_clock_sync_fff.h> #include <gr_dc_blocker_cc.h> @@ -53,12 +53,12 @@ %include "gr_fractional_interpolator_ff.i" %include "gr_fractional_interpolator_cc.i" %include "gr_goertzel_fc.i" -%include "gr_cma_equalizer_cc.i" %include "gr_pfb_channelizer_ccf.i" %include "gr_pfb_synthesis_filterbank_ccf.i" %include "gr_pfb_decimator_ccf.i" %include "gr_pfb_interpolator_ccf.i" %include "gr_pfb_arb_resampler_ccf.i" +%include "gr_pfb_arb_resampler_fff.i" %include "gr_pfb_decimator_ccf.i" %include "gr_pfb_interpolator_ccf.i" %include "gr_pfb_arb_resampler_ccf.i" diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_util.py b/gnuradio-core/src/lib/filter/generate_gr_fir_util.py index 4f5f5ce06..06001695e 100755 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_util.py +++ b/gnuradio-core/src/lib/filter/generate_gr_fir_util.py @@ -25,7 +25,7 @@ from generate_utils import * def make_info_struct (out, sig): out.write ( ''' -struct gr_fir_%s_info { +struct GR_CORE_API gr_fir_%s_info { const char *name; // implementation name, e.g., "generic", "SSE", "3DNow!" gr_fir_%s *(*create)(const std::vector<%s> &taps); }; @@ -74,6 +74,7 @@ def make_gr_fir_util_h (): * 'i' (short) */ +#include <gr_core_api.h> #include <gr_types.h> ''') @@ -87,7 +88,7 @@ def make_gr_fir_util_h (): make_info_struct (out, sig) out.write (''' -struct gr_fir_util { +struct GR_CORE_API gr_fir_util { // create a fast version of gr_fir_XXX. diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc new file mode 100644 index 000000000..3fed74641 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc @@ -0,0 +1,88 @@ +/* -*- c++ -*- */ +/* + * Copyright 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_adaptive_fir_ccc.h> +#include <gr_io_signature.h> + +gr_adaptive_fir_ccc::gr_adaptive_fir_ccc(const char *name, int decimation, + const std::vector<gr_complex> &taps) + : gr_sync_decimator (name, + gr_make_io_signature (1, 1, sizeof(gr_complex)), + gr_make_io_signature (1, 1, sizeof(gr_complex)), + decimation), + d_updated(false), d_taps(taps) +{ + set_history(d_taps.size()); +} + +void +gr_adaptive_fir_ccc::set_taps(const std::vector<gr_complex> &taps) +{ + d_new_taps = taps; + d_updated = true; +} + +gr_complex +gr_adaptive_fir_ccc::filter(gr_complex *x) +{ + // Generic dot product of d_taps[] and in[] + gr_complex acc(0.0, 0.0); + int l = d_taps.size(); + for (int k = 0; k < l; k++) + acc += d_taps[l-k-1] * x[k]; + return acc; +} + +int +gr_adaptive_fir_ccc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + gr_complex *in = (gr_complex *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + + if (d_updated) { + d_taps = d_new_taps; + set_history(d_taps.size()); + d_updated = false; + return 0; // history requirements may have changed. + } + + int j = 0, k, l = d_taps.size(); + for (int i = 0; i < noutput_items; i++) { + out[i] = filter(&in[j]); + + // Adjust taps + d_error = error(out[i]); + for (k = 0; k < l; k++) { + update_tap(d_taps[l-k-1], in[j+k]); + } + + j += decimation(); + } + + return noutput_items; +} diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h new file mode 100644 index 000000000..aa5422a07 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 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_ADAPTIVE_FIR_CCC_H +#define INCLUDED_GR_ADAPTIVE_FIR_CCC_H + +#include <gr_core_api.h> +#include <gr_sync_decimator.h> + +/*! + * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps + * \ingroup filter_blk + */ +class GR_CORE_API gr_adaptive_fir_ccc : public gr_sync_decimator +{ +private: + std::vector<gr_complex> d_new_taps; + bool d_updated; + +protected: + gr_complex d_error; + std::vector<gr_complex> d_taps; + + // Override to calculate error signal per output + virtual gr_complex error(const gr_complex &out) = 0; + + // Override to calculate new weight from old, corresponding input + virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; + + gr_complex filter(gr_complex *x); + + gr_adaptive_fir_ccc(const char *name, int decimation, + const std::vector<gr_complex> &taps); + +public: + void set_taps(const std::vector<gr_complex> &taps); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.i b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i index b6f4e9312..7e9a3fac3 100644 --- a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.i +++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,14 +20,12 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,binary_slicer_fb); - -gr_binary_slicer_fb_sptr gr_make_binary_slicer_fb (); - -class gr_binary_slicer_fb : public gr_sync_block +class gr_adaptive_fir_ccc : public gr_sync_decimator { - private: - gr_binary_slicer_fb (); +protected: + gr_adaptive_fir_ccc(char *name, int decimation, + const std::vector<gr_complex> &taps); - public: +public: + void set_taps(const std::vector<gr_complex> &taps); }; diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h index f860f4faa..87854201c 100644 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_ADAPTIVE_FIR_CCF_H #define INCLUDED_GR_ADAPTIVE_FIR_CCF_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> /*! * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps * \ingroup filter_blk */ -class gr_adaptive_fir_ccf : public gr_sync_decimator +class GR_CORE_API gr_adaptive_fir_ccf : public gr_sync_decimator { private: std::vector<float> d_new_taps; diff --git a/gnuradio-core/src/lib/filter/gr_altivec.h b/gnuradio-core/src/lib/filter/gr_altivec.h index c0d7cfb34..eb941ce42 100644 --- a/gnuradio-core/src/lib/filter/gr_altivec.h +++ b/gnuradio-core/src/lib/filter/gr_altivec.h @@ -29,6 +29,7 @@ * (included below) */ +#include <gr_core_api.h> #include <altivec.h> #undef bool // repair namespace pollution #undef vector // repair namespace pollution @@ -55,8 +56,8 @@ union v_float_u { float f[FLOATS_PER_VEC]; }; -void gr_print_vector_float(FILE *fp, vec_float4 v); -void gr_pvf(FILE *fp, const char *label, vec_float4 v); +GR_CORE_API void gr_print_vector_float(FILE *fp, vec_float4 v); +GR_CORE_API void gr_pvf(FILE *fp, const char *label, vec_float4 v); static inline float horizontal_add_f(vec_float4 v) diff --git a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc b/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc deleted file mode 100644 index f80bfd518..000000000 --- a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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_cma_equalizer_cc.h> - -gr_cma_equalizer_cc_sptr -gr_make_cma_equalizer_cc(int num_taps, float modulus, float mu) -{ - return gnuradio::get_initial_sptr(new gr_cma_equalizer_cc(num_taps, modulus, mu)); -} - -gr_cma_equalizer_cc::gr_cma_equalizer_cc(int num_taps, float modulus, float mu) - : gr_adaptive_fir_ccf("cma_equalizer_cc", 1, std::vector<float>(num_taps)), - d_modulus(modulus), d_mu(mu) -{ - if (num_taps > 0) - d_taps[0] = 1.0; -} - diff --git a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.h b/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.h deleted file mode 100644 index c78047c16..000000000 --- a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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. - */ - -#ifndef INCLUDED_GR_CMA_EQUALIZER_CC_H -#define INCLUDED_GR_CMA_EQUALIZER_CC_H - -#include <gr_adaptive_fir_ccf.h> - -class gr_cma_equalizer_cc; -typedef boost::shared_ptr<gr_cma_equalizer_cc> gr_cma_equalizer_cc_sptr; - -gr_cma_equalizer_cc_sptr -gr_make_cma_equalizer_cc(int num_taps, float modulus, float mu); - -/*! - * \brief Implements constant modulus adaptive filter on complex stream - * \ingroup eq_blk - */ -class gr_cma_equalizer_cc : public gr_adaptive_fir_ccf -{ -private: - float d_modulus; - float d_mu; - - friend gr_cma_equalizer_cc_sptr gr_make_cma_equalizer_cc(int num_taps, float modulus, float mu); - gr_cma_equalizer_cc(int num_taps, float modulus, float mu); - -protected: - - virtual float error(const gr_complex &out) - { - return (d_modulus - norm(out)); - } - - virtual void update_tap(float &tap, const gr_complex &in) - { - tap += d_mu*d_error*abs(in); - } - -public: -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.i b/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.i deleted file mode 100644 index 30e2fb8bd..000000000 --- a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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,cma_equalizer_cc) - -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_adaptive_fir_ccf.i" - -gr_cma_equalizer_cc_sptr gr_make_cma_equalizer_cc(int num_taps, float modulus, float mu); - -class gr_cma_equalizer_cc : public gr_adaptive_fir_ccf -{ -private: - gr_cma_equalizer_cc(int num_taps, float modulus, float mu); - -public: -}; diff --git a/gnuradio-core/src/lib/filter/gr_cpu.h b/gnuradio-core/src/lib/filter/gr_cpu.h index 01d719020..149404082 100644 --- a/gnuradio-core/src/lib/filter/gr_cpu.h +++ b/gnuradio-core/src/lib/filter/gr_cpu.h @@ -23,7 +23,9 @@ #ifndef _GR_CPU_H_ #define _GR_CPU_H_ -struct gr_cpu { +#include <gr_core_api.h> + +struct GR_CORE_API gr_cpu { static bool has_mmx (); static bool has_sse (); static bool has_sse2 (); @@ -37,4 +39,4 @@ struct gr_cpu { static bool has_armv7_a (); }; -#endif /* _GR_CPU_H_ */ +#endif /* _GR_CPU_H_ */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h index d299cc7ef..cb449f3ec 100644 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h +++ b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h @@ -24,21 +24,37 @@ #ifndef INCLUDED_GR_DC_BLOCKER_CC_H #define INCLUDED_GR_DC_BLOCKER_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <deque> +class GR_CORE_API moving_averager_c +{ +public: + moving_averager_c(int D); + ~moving_averager_c(); + + gr_complex filter(gr_complex x); + gr_complex delayed_sig() { return d_out; } + +private: + int d_length; + gr_complex d_out, d_out_d1, d_out_d2; + std::deque<gr_complex> d_delay_line; +}; + class gr_dc_blocker_cc; typedef boost::shared_ptr<gr_dc_blocker_cc> gr_dc_blocker_cc_sptr; -gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); +GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); /*! * \class gr_dc_blocker_cc - * \brief a computationally efficient controllabel DC blocker + * \brief a computationally efficient controllable DC blocker * * \ingroup filter_blk * * This block implements a computationally efficient DC blocker that produces - * a tigher notch filter around DC for a smaller group delay than an + * a tighter notch filter around DC for a smaller group delay than an * equivalent FIR filter or using a single pole IIR filter (though the IIR * filter is computationally cheaper). * @@ -57,22 +73,7 @@ gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, * Mar. 2008, pp 132-134.</EM></B> */ -class moving_averager_c -{ -public: - moving_averager_c(int D); - ~moving_averager_c(); - - gr_complex filter(gr_complex x); - gr_complex delayed_sig() { return d_out; } - -private: - int d_length; - gr_complex d_out, d_out_d1, d_out_d2; - std::deque<gr_complex> d_delay_line; -}; - -class gr_dc_blocker_cc : public gr_sync_block +class GR_CORE_API gr_dc_blocker_cc : public gr_sync_block { private: /*! @@ -80,7 +81,7 @@ class gr_dc_blocker_cc : public gr_sync_block * \param D (int) the length of the delay line * \param long_form (bool) whether to use long (true, default) or short form */ - friend gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form); + friend GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form); int d_length; bool d_long_form; diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h index 8ffb6cf6f..a7e8f1c27 100644 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h +++ b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h @@ -24,21 +24,38 @@ #ifndef INCLUDED_GR_DC_BLOCKER_FF_H #define INCLUDED_GR_DC_BLOCKER_FF_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <deque> +class GR_CORE_API moving_averager_f +{ +public: + moving_averager_f(int D); + ~moving_averager_f(); + + float filter(float x); + float delayed_sig() { return d_out; } + +private: + int d_length; + float d_out, d_out_d1, d_out_d2; + std::deque<float> d_delay_line; +}; + + class gr_dc_blocker_ff; typedef boost::shared_ptr<gr_dc_blocker_ff> gr_dc_blocker_ff_sptr; -gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); +GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); /*! * \class gr_dc_blocker_ff - * \brief a computationally efficient controllabel DC blocker + * \brief a computationally efficient controllable DC blocker * * \ingroup filter_blk * * This block implements a computationally efficient DC blocker that produces - * a tigher notch filter around DC for a smaller group delay than an + * a tighter notch filter around DC for a smaller group delay than an * equivalent FIR filter or using a single pole IIR filter (though the IIR * filter is computationally cheaper). * @@ -57,22 +74,7 @@ gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, * Mar. 2008, pp 132-134.</EM></B> */ -class moving_averager_f -{ -public: - moving_averager_f(int D); - ~moving_averager_f(); - - float filter(float x); - float delayed_sig() { return d_out; } - -private: - int d_length; - float d_out, d_out_d1, d_out_d2; - std::deque<float> d_delay_line; -}; - -class gr_dc_blocker_ff : public gr_sync_block +class GR_CORE_API gr_dc_blocker_ff : public gr_sync_block { private: /*! @@ -80,7 +82,7 @@ class gr_dc_blocker_ff : public gr_sync_block * \param D (int) the length of the delay line * \param long_form (bool) whether to use long (true, default) or short form */ - friend gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form); + friend GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form); int d_length; bool d_long_form; diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h index 68b19e775..721a44a83 100644 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h +++ b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h @@ -22,11 +22,12 @@ #ifndef INCLUDED_GR_FFT_FILTER_CCC_H #define INCLUDED_GR_FFT_FILTER_CCC_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_fft_filter_ccc; typedef boost::shared_ptr<gr_fft_filter_ccc> gr_fft_filter_ccc_sptr; -gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps); +GR_CORE_API gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps); //class gri_fft_filter_ccc_sse; class gri_fft_filter_ccc_generic; @@ -35,10 +36,10 @@ class gri_fft_filter_ccc_generic; * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps * \ingroup filter_blk */ -class gr_fft_filter_ccc : public gr_sync_decimator +class GR_CORE_API gr_fft_filter_ccc : public gr_sync_decimator { private: - friend gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps); + friend GR_CORE_API gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps); int d_nsamples; bool d_updated; diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h index 6eaa21500..b0dc74883 100644 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h +++ b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h @@ -22,11 +22,12 @@ #ifndef INCLUDED_GR_FFT_FILTER_FFF_H #define INCLUDED_GR_FFT_FILTER_FFF_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_fft_filter_fff; typedef boost::shared_ptr<gr_fft_filter_fff> gr_fft_filter_fff_sptr; -gr_fft_filter_fff_sptr gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps); +GR_CORE_API gr_fft_filter_fff_sptr gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps); class gri_fft_filter_fff_generic; //class gri_fft_filter_fff_sse; @@ -35,10 +36,10 @@ class gri_fft_filter_fff_generic; * \brief Fast FFT filter with float input, float output and float taps * \ingroup filter_blk */ -class gr_fft_filter_fff : public gr_sync_decimator +class GR_CORE_API gr_fft_filter_fff : public gr_sync_decimator { private: - friend gr_fft_filter_fff_sptr gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps); + friend GR_CORE_API gr_fft_filter_fff_sptr gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps); int d_nsamples; bool d_updated; diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h index 946edf2c7..e09e4f0df 100644 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h +++ b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_FILTER_DELAY_FC_H #define INCLUDED_GR_FILTER_DELAY_FC_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_io_signature.h> #include <gr_types.h> @@ -31,7 +32,7 @@ class gr_filter_delay_fc; typedef boost::shared_ptr<gr_filter_delay_fc> gr_filter_delay_fc_sptr; // public constructor -gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); +GR_CORE_API gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); class gr_fir_fff; @@ -50,7 +51,7 @@ class gr_fir_fff; * before initializing this block. * */ -class gr_filter_delay_fc : public gr_sync_block +class GR_CORE_API gr_filter_delay_fc : public gr_sync_block { public: ~gr_filter_delay_fc (); @@ -66,7 +67,7 @@ class gr_filter_delay_fc : public gr_sync_block unsigned int d_delay; gr_fir_fff *d_fir; - friend gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); + friend GR_CORE_API gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); }; #endif /* INCLUDED_GR_FILTER_DELAY_FC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t b/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t index eeee716ec..f6019ea40 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t @@ -29,6 +29,7 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <vector> @VRCOMPLEX_INCLUDE@ #include <gr_reverse.h> @@ -44,7 +45,7 @@ * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), 'i' (int) */ -class @FIR_TYPE@ { +class GR_CORE_API @FIR_TYPE@ { protected: std::vector<@TAP_TYPE@> d_taps; // reversed taps diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t b/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t index fc0f4f8b2..b3594b7ad 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t +++ b/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t @@ -22,6 +22,7 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <@FIR_TYPE@.h> /*! @@ -32,7 +33,7 @@ * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), 'i' (int) */ -class @FIR_TYPE@_generic : public @FIR_TYPE@ { +class GR_CORE_API @FIR_TYPE@_generic : public @FIR_TYPE@ { public: diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h index 14ff1e6b1..af61ce274 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h +++ b/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FIR_CCC_SIMD_H #define INCLUDED_GR_FIR_CCC_SIMD_H +#include <gr_core_api.h> #include <gr_fir_ccc_generic.h> /*! @@ -32,7 +33,7 @@ * subclasses. */ -class gr_fir_ccc_simd : public gr_fir_ccc_generic +class GR_CORE_API gr_fir_ccc_simd : public gr_fir_ccc_generic { protected: typedef void (*ccomplex_dotprod_t)(const float *input, diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h index 06d6b616c..262cc80e3 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h @@ -23,19 +23,20 @@ #ifndef INCLUDED_GR_FIR_CCC_X86_H #define INCLUDED_GR_FIR_CCC_X86_H +#include <gr_core_api.h> #include <gr_fir_ccc_simd.h> /*! * \brief 3DNow! version of gr_fir_ccc */ -class gr_fir_ccc_3dnow : public gr_fir_ccc_simd +class GR_CORE_API gr_fir_ccc_3dnow : public gr_fir_ccc_simd { public: gr_fir_ccc_3dnow (); gr_fir_ccc_3dnow (const std::vector<gr_complex> &taps); }; -class gr_fir_ccc_3dnowext : public gr_fir_ccc_simd +class GR_CORE_API gr_fir_ccc_3dnowext : public gr_fir_ccc_simd { public: gr_fir_ccc_3dnowext (); @@ -45,7 +46,7 @@ public: /*! * \brief SSE version of gr_fir_ccc */ -class gr_fir_ccc_sse : public gr_fir_ccc_simd +class GR_CORE_API gr_fir_ccc_sse : public gr_fir_ccc_simd { public: gr_fir_ccc_sse (); diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h index ebc6a1bc0..31d70288e 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h +++ b/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FIR_CCF_SIMD_H #define INCLUDED_GR_FIR_CCF_SIMD_H +#include <gr_core_api.h> #include <gr_fir_ccf_generic.h> @@ -33,7 +34,7 @@ * subclasses. */ -class gr_fir_ccf_simd : public gr_fir_ccf_generic +class GR_CORE_API gr_fir_ccf_simd : public gr_fir_ccf_generic { protected: typedef void (*fcomplex_dotprod_t)(const float *taps, diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h index 7f936546f..38d82060c 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_FIR_CCF_X86_H #define INCLUDED_GR_FIR_CCF_X86_H +#include <gr_core_api.h> #include <gr_fir_ccf_simd.h> /*! * \brief 3DNow! version of gr_fir_ccf * \ingroup filter_primitive */ -class gr_fir_ccf_3dnow : public gr_fir_ccf_simd +class GR_CORE_API gr_fir_ccf_3dnow : public gr_fir_ccf_simd { public: gr_fir_ccf_3dnow (); @@ -40,7 +41,7 @@ public: * \brief SSE version of gr_fir_ccf * \ingroup filter_primitive */ -class gr_fir_ccf_sse : public gr_fir_ccf_simd +class GR_CORE_API gr_fir_ccf_sse : public gr_fir_ccf_simd { public: gr_fir_ccf_sse (); diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h index e2ed8bcae..7be3776e3 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FIR_FCC_SIMD_H #define INCLUDED_GR_FIR_FCC_SIMD_H +#include <gr_core_api.h> #include <gr_fir_fcc_generic.h> @@ -33,7 +34,7 @@ * subclasses. */ -class gr_fir_fcc_simd : public gr_fir_fcc_generic +class GR_CORE_API gr_fir_fcc_simd : public gr_fir_fcc_generic { protected: typedef void (*fcomplex_dotprod_t)(const float *input, diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h index 49386c35d..98ace66de 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_FIR_FCC_X86_H #define INCLUDED_GR_FIR_FCC_X86_H +#include <gr_core_api.h> #include <gr_fir_fcc_simd.h> /*! * \brief 3DNow! version of gr_fir_fcc * \ingroup filter_primitive */ -class gr_fir_fcc_3dnow : public gr_fir_fcc_simd +class GR_CORE_API gr_fir_fcc_3dnow : public gr_fir_fcc_simd { public: gr_fir_fcc_3dnow (); @@ -40,7 +41,7 @@ public: * \brief SSE version of gr_fir_fcc * \ingroup filter_blk */ -class gr_fir_fcc_sse : public gr_fir_fcc_simd +class GR_CORE_API gr_fir_fcc_sse : public gr_fir_fcc_simd { public: gr_fir_fcc_sse (); diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h index 1694f5524..29bb3a899 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h @@ -21,12 +21,13 @@ #ifndef INCLUDED_GR_FIR_FFF_ALTIVEC_H #define INCLUDED_GR_FIR_FFF_ALTIVEC_H +#include <gr_core_api.h> #include <gr_fir_fff_generic.h> /*! * \brief altivec version of gr_fir_fff */ -class gr_fir_fff_altivec : public gr_fir_fff_generic +class GR_CORE_API gr_fir_fff_altivec : public gr_fir_fff_generic { protected: diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h index d6097cf50..5c80c930f 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h @@ -21,12 +21,13 @@ #ifndef INCLUDED_GR_FIR_FFF_ARMV7_A_H #define INCLUDED_GR_FIR_FFF_ARMV7_A_H +#include <gr_core_api.h> #include <gr_fir_fff_generic.h> /*! * \brief armv7_a using NEON coprocessor version of gr_fir_fff */ -class gr_fir_fff_armv7_a : public gr_fir_fff_generic +class GR_CORE_API gr_fir_fff_armv7_a : public gr_fir_fff_generic { protected: diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h index 82d3e3b99..781e4e7b9 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FIR_FFF_SIMD_H #define INCLUDED_GR_FIR_FFF_SIMD_H +#include <gr_core_api.h> #include <gr_fir_fff_generic.h> /*! @@ -32,7 +33,7 @@ * subclasses. */ -class gr_fir_fff_simd : public gr_fir_fff_generic +class GR_CORE_API gr_fir_fff_simd : public gr_fir_fff_generic { protected: typedef float (*float_dotprod_t)(const float *input, diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h index c288035ba..4e2f33181 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FIR_FFF_X86_H #define INCLUDED_GR_FIR_FFF_X86_H +#include <gr_core_api.h> #include <gr_fir_fff_simd.h> /*! * \brief 3DNow! version of gr_fir_fff */ -class gr_fir_fff_3dnow : public gr_fir_fff_simd +class GR_CORE_API gr_fir_fff_3dnow : public gr_fir_fff_simd { public: gr_fir_fff_3dnow (); @@ -38,7 +39,7 @@ public: /*! * \brief SSE version of gr_fir_fff */ -class gr_fir_fff_sse : public gr_fir_fff_simd +class GR_CORE_API gr_fir_fff_sse : public gr_fir_fff_simd { public: gr_fir_fff_sse (); diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t index f2e56c901..db0625504 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t @@ -28,11 +28,12 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_decimator.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); class @FIR_TYPE@; @@ -40,10 +41,10 @@ class @FIR_TYPE@; * \brief FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps * \ingroup filter_blk */ -class @NAME@ : public gr_sync_decimator +class GR_CORE_API @NAME@ : public gr_sync_decimator { private: - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); @FIR_TYPE@ *d_fir; std::vector<@TAP_TYPE@> d_new_taps; diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h index ad689407d..6fcb6bd35 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h @@ -22,6 +22,7 @@ #ifndef _GR_FIR_FSF_SIMD_H_ #define _GR_FIR_FSF_SIMD_H_ +#include <gr_core_api.h> #include <gr_fir_fsf_generic.h> /*! @@ -32,7 +33,7 @@ * subclasses. */ -class gr_fir_fsf_simd : public gr_fir_fsf_generic +class GR_CORE_API gr_fir_fsf_simd : public gr_fir_fsf_generic { protected: typedef float (*float_dotprod_t)(const float *input, diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h index 78fdf73c0..0e11059b3 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_FIR_FSF_X86_H #define INCLUDED_GR_FIR_FSF_X86_H +#include <gr_core_api.h> #include <gr_fir_fsf_simd.h> /*! * \brief 3DNow! version of gr_fir_fsf * \ingroup filter_primitive */ -class gr_fir_fsf_3dnow : public gr_fir_fsf_simd +class GR_CORE_API gr_fir_fsf_3dnow : public gr_fir_fsf_simd { public: gr_fir_fsf_3dnow (); @@ -40,7 +41,7 @@ public: * \brief SSE version of gr_fir_fsf * \ingroup filter_primitive */ -class gr_fir_fsf_sse : public gr_fir_fsf_simd +class GR_CORE_API gr_fir_fsf_sse : public gr_fir_fsf_simd { public: gr_fir_fsf_sse (); diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h index 2af45c8f4..9dced1578 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h +++ b/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FIR_SCC_SIMD_H #define INCLUDED_GR_FIR_SCC_SIMD_H +#include <gr_core_api.h> #include <gr_fir_scc_generic.h> @@ -32,7 +33,7 @@ * This base class handles alignment issues common to SSE and 3DNOW * subclasses. */ -class gr_fir_scc_simd : public gr_fir_scc_generic +class GR_CORE_API gr_fir_scc_simd : public gr_fir_scc_generic { protected: typedef void (*complex_dotprod_t)(const short *input, diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h index 0cb5e3f7c..484bdc5a0 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FIR_SCC_X86_H #define INCLUDED_GR_FIR_SCC_X86_H +#include <gr_core_api.h> #include <gr_fir_scc_simd.h> /*! * \brief 3DNow! version of gr_fir_scc */ -class gr_fir_scc_3dnow : public gr_fir_scc_simd +class GR_CORE_API gr_fir_scc_3dnow : public gr_fir_scc_simd { public: gr_fir_scc_3dnow (); @@ -38,7 +39,7 @@ public: /*! * \brief 3DNow! Ext version of gr_fir_scc */ -class gr_fir_scc_3dnowext : public gr_fir_scc_simd +class GR_CORE_API gr_fir_scc_3dnowext : public gr_fir_scc_simd { public: gr_fir_scc_3dnowext (); @@ -48,7 +49,7 @@ public: /*! * \brief SSE version of gr_fir_scc */ -class gr_fir_scc_sse : public gr_fir_scc_simd +class GR_CORE_API gr_fir_scc_sse : public gr_fir_scc_simd { public: gr_fir_scc_sse (); diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h index c77b81026..69ee46019 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h +++ b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h @@ -22,9 +22,10 @@ #ifndef INCLUDED_GR_FIR_SYSCONFIG_ARMV7_A_H #define INCLUDED_GR_FIR_SYSCONFIG_ARMV7_A_H +#include <gr_core_api.h> #include <gr_fir_sysconfig_generic.h> -class gr_fir_sysconfig_armv7_a : public gr_fir_sysconfig_generic { +class GR_CORE_API gr_fir_sysconfig_armv7_a : public gr_fir_sysconfig_generic { public: virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h index 9c31cdf1b..d6be7653f 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h +++ b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h @@ -22,9 +22,10 @@ #ifndef INCLUDED_GR_FIR_SYSCONFIG_POWERPC_H #define INCLUDED_GR_FIR_SYSCONFIG_POWERPC_H +#include <gr_core_api.h> #include <gr_fir_sysconfig_generic.h> -class gr_fir_sysconfig_powerpc : public gr_fir_sysconfig_generic { +class GR_CORE_API gr_fir_sysconfig_powerpc : public gr_fir_sysconfig_generic { public: virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h index a4d0f92b0..49899d895 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h @@ -22,9 +22,10 @@ #ifndef INCLUDED_GR_FIR_SYSCONFIG_X86_H #define INCLUDED_GR_FIR_SYSCONFIG_X86_H +#include <gr_core_api.h> #include <gr_fir_sysconfig_generic.h> -class gr_fir_sysconfig_x86 : public gr_fir_sysconfig_generic { +class GR_CORE_API gr_fir_sysconfig_x86 : public gr_fir_sysconfig_generic { public: virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h index c8378c43e..29c67895a 100644 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h +++ b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_FRACTIONAL_INTERPOLATOR_CC_H #define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_CC_H +#include <gr_core_api.h> #include <gr_block.h> class gri_mmse_fir_interpolator_cc; @@ -31,13 +32,13 @@ class gr_fractional_interpolator_cc; typedef boost::shared_ptr<gr_fractional_interpolator_cc> gr_fractional_interpolator_cc_sptr; // public constructor -gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); +GR_CORE_API gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); /*! * \brief Interpolating mmse filter with gr_complex input, gr_complex output * \ingroup filter_blk */ -class gr_fractional_interpolator_cc : public gr_block +class GR_CORE_API gr_fractional_interpolator_cc : public gr_block { public: ~gr_fractional_interpolator_cc (); @@ -60,7 +61,7 @@ private: float d_mu_inc; gri_mmse_fir_interpolator_cc *d_interp; - friend gr_fractional_interpolator_cc_sptr + friend GR_CORE_API gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); }; diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h index f50129289..7e000a6d1 100644 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h +++ b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_FRACTIONAL_INTERPOLATOR_FF_H #define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_FF_H +#include <gr_core_api.h> #include <gr_block.h> class gri_mmse_fir_interpolator; @@ -31,13 +32,13 @@ class gr_fractional_interpolator_ff; typedef boost::shared_ptr<gr_fractional_interpolator_ff> gr_fractional_interpolator_ff_sptr; // public constructor -gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); +GR_CORE_API gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); /*! * \brief Interpolating mmse filter with float input, float output * \ingroup filter_blk */ -class gr_fractional_interpolator_ff : public gr_block +class GR_CORE_API gr_fractional_interpolator_ff : public gr_block { public: ~gr_fractional_interpolator_ff (); @@ -60,7 +61,7 @@ private: float d_mu_inc; gri_mmse_fir_interpolator *d_interp; - friend gr_fractional_interpolator_ff_sptr + friend GR_CORE_API gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); }; diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t index 1205e8a08..bb05c138b 100644 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t @@ -29,6 +29,7 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_decimator.h> #include <gr_rotator.h> @@ -40,7 +41,7 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * translation that shifts center_freq down to zero Hz. The frequency * translation logically comes before the filtering operation. */ -@SPTR_NAME@ +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, double center_freq, double sampling_freq); @@ -60,7 +61,7 @@ class @FIR_TYPE@; * Uses a single input array to produce a single output array. * Additional inputs and/or outputs are ignored. */ -class @NAME@ : public gr_sync_decimator +class GR_CORE_API @NAME@ : public gr_sync_decimator { public: virtual ~@NAME@ (); @@ -73,7 +74,7 @@ class @NAME@ : public gr_sync_decimator gr_vector_void_star &output_items); private: - friend @SPTR_NAME@ + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, double center_freq, double sampling_freq); diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h b/gnuradio-core/src/lib/filter/gr_goertzel_fc.h index c60b63d88..6b5d8527c 100644 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h +++ b/gnuradio-core/src/lib/filter/gr_goertzel_fc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_GOERTZEL_FC_H #define INCLUDED_GR_GOERTZEL_FC_H +#include <gr_core_api.h> #include <gri_goertzel.h> #include <gr_sync_decimator.h> @@ -30,16 +31,16 @@ class gr_goertzel_fc; typedef boost::shared_ptr<gr_goertzel_fc> gr_goertzel_fc_sptr; // public constructor -gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq); +GR_CORE_API gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq); /*! * \brief Goertzel single-bin DFT calculation. * \ingroup dft_blk */ -class gr_goertzel_fc : public gr_sync_decimator +class GR_CORE_API gr_goertzel_fc : public gr_sync_decimator { private: - friend gr_goertzel_fc_sptr gr_make_goertzel_fc (int rate, int len, float freq); + friend GR_CORE_API gr_goertzel_fc_sptr gr_make_goertzel_fc (int rate, int len, float freq); gr_goertzel_fc(int rate, int len, float freq); gri_goertzel d_goertzel; diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h b/gnuradio-core/src/lib/filter/gr_hilbert_fc.h index adcac7793..ba73324ee 100644 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h +++ b/gnuradio-core/src/lib/filter/gr_hilbert_fc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_HILBERT_FC_H #define INCLUDED_GR_HILBERT_FC_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_io_signature.h> #include <gr_types.h> @@ -31,7 +32,7 @@ class gr_hilbert_fc; typedef boost::shared_ptr<gr_hilbert_fc> gr_hilbert_fc_sptr; // public constructor -gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); +GR_CORE_API gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); class gr_fir_fff; @@ -44,7 +45,7 @@ class gr_fir_fff; * imaginary output is hilbert filtered (90 degree phase shift) * version of input. */ -class gr_hilbert_fc : public gr_sync_block +class GR_CORE_API gr_hilbert_fc : public gr_sync_block { public: ~gr_hilbert_fc (); @@ -60,7 +61,7 @@ class gr_hilbert_fc : public gr_sync_block unsigned int d_ntaps; gr_fir_fff *d_hilb; - friend gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); + friend GR_CORE_API gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); }; diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h index 0382646f1..386d056e5 100644 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h +++ b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_IIR_FILTER_FFD_H #define INCLUDED_GR_IIR_FILTER_FFD_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gri_iir.h> #include <stdexcept> class gr_iir_filter_ffd; typedef boost::shared_ptr<gr_iir_filter_ffd> gr_iir_filter_ffd_sptr; -gr_iir_filter_ffd_sptr +GR_CORE_API gr_iir_filter_ffd_sptr gr_make_iir_filter_ffd (const std::vector<double> &fftaps, const std::vector<double> &fbtaps) throw (std::invalid_argument); @@ -56,10 +57,10 @@ gr_make_iir_filter_ffd (const std::vector<double> &fftaps, * Note that some texts define the system function with a + in the denominator. * If you're using that convention, you'll need to negate the feedback taps. */ -class gr_iir_filter_ffd : public gr_sync_block +class GR_CORE_API gr_iir_filter_ffd : public gr_sync_block { private: - friend gr_iir_filter_ffd_sptr + friend GR_CORE_API gr_iir_filter_ffd_sptr gr_make_iir_filter_ffd (const std::vector<double> &fftaps, const std::vector<double> &fbtaps) throw (std::invalid_argument); diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t index 790e0b908..4a3590fc7 100644 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t @@ -28,11 +28,12 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); class @FIR_TYPE@; @@ -40,10 +41,10 @@ class @FIR_TYPE@; * \brief Interpolating FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps * \ingroup filter_blk */ -class @NAME@ : public gr_sync_interpolator +class GR_CORE_API @NAME@ : public gr_sync_interpolator { private: - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); std::vector<@TAP_TYPE@> d_new_taps; bool d_updated; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h index 2c36c95f9..749db937e 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h @@ -24,11 +24,12 @@ #ifndef INCLUDED_GR_PFB_ARB_RESAMPLER_CCF_H #define INCLUDED_GR_PFB_ARB_RESAMPLER_CCF_H +#include <gr_core_api.h> #include <gr_block.h> class gr_pfb_arb_resampler_ccf; typedef boost::shared_ptr<gr_pfb_arb_resampler_ccf> gr_pfb_arb_resampler_ccf_sptr; -gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, +GR_CORE_API gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, const std::vector<float> &taps, unsigned int filter_size=32); @@ -41,6 +42,7 @@ class gr_fir_ccf; * gr_complex input, gr_complex output and float taps * * \ingroup filter_blk + * \ingroup pfb_blk * * This block takes in a signal stream and performs arbitrary * resampling. The resampling rate can be any real @@ -95,7 +97,7 @@ class gr_fir_ccf; * Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> */ -class gr_pfb_arb_resampler_ccf : public gr_block +class GR_CORE_API gr_pfb_arb_resampler_ccf : public gr_block { private: /*! @@ -107,7 +109,7 @@ class gr_pfb_arb_resampler_ccf : public gr_block related to quantization noise introduced during the resampling. Defaults to 32 filters. */ - friend gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, + friend GR_CORE_API gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, const std::vector<float> &taps, unsigned int filter_size); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc new file mode 100644 index 000000000..9035e67f4 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc @@ -0,0 +1,209 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009-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_pfb_arb_resampler_fff.h> +#include <gr_fir_fff.h> +#include <gr_fir_util.h> +#include <gr_io_signature.h> +#include <cstdio> + +gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, + const std::vector<float> &taps, + unsigned int filter_size) +{ + return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_fff (rate, taps, + filter_size)); +} + + +gr_pfb_arb_resampler_fff::gr_pfb_arb_resampler_fff (float rate, + const std::vector<float> &taps, + unsigned int filter_size) + : gr_block ("pfb_arb_resampler_fff", + gr_make_io_signature (1, 1, sizeof(float)), + gr_make_io_signature (1, 1, sizeof(float))), + d_updated (false) +{ + d_acc = 0; // start accumulator at 0 + + /* The number of filters is specified by the user as the filter size; + this is also the interpolation rate of the filter. We use it and the + rate provided to determine the decimation rate. This acts as a + rational resampler. The flt_rate is calculated as the residual + between the integer decimation rate and the real decimation rate and + will be used to determine to interpolation point of the resampling + process. + */ + d_int_rate = filter_size; + set_rate(rate); + + // Store the last filter between calls to work + d_last_filter = 0; + + d_start_index = 0; + + d_filters = std::vector<gr_fir_fff*>(d_int_rate); + d_diff_filters = std::vector<gr_fir_fff*>(d_int_rate); + + // Create an FIR filter for each channel and zero out the taps + std::vector<float> vtaps(0, d_int_rate); + for(unsigned int i = 0; i < d_int_rate; i++) { + d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); + d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); + } + + // Now, actually set the filters' taps + std::vector<float> dtaps; + create_diff_taps(taps, dtaps); + create_taps(taps, d_taps, d_filters); + create_taps(dtaps, d_dtaps, d_diff_filters); +} + +gr_pfb_arb_resampler_fff::~gr_pfb_arb_resampler_fff () +{ + for(unsigned int i = 0; i < d_int_rate; i++) { + delete d_filters[i]; + } +} + +void +gr_pfb_arb_resampler_fff::create_taps (const std::vector<float> &newtaps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_fff*> &ourfilter) +{ + unsigned int ntaps = newtaps.size(); + d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_int_rate); + + // Create d_numchan vectors to store each channel's taps + ourtaps.resize(d_int_rate); + + // Make a vector of the taps plus fill it out with 0's to fill + // each polyphase filter with exactly d_taps_per_filter + std::vector<float> tmp_taps; + tmp_taps = newtaps; + while((float)(tmp_taps.size()) < d_int_rate*d_taps_per_filter) { + tmp_taps.push_back(0.0); + } + + // Partition the filter + for(unsigned int i = 0; i < d_int_rate; i++) { + // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out + ourtaps[d_int_rate-1-i] = std::vector<float>(d_taps_per_filter, 0); + for(unsigned int j = 0; j < d_taps_per_filter; j++) { + ourtaps[d_int_rate - 1 - i][j] = tmp_taps[i + j*d_int_rate]; + } + + // Build a filter for each channel and add it's taps to it + ourfilter[i]->set_taps(ourtaps[d_int_rate-1-i]); + } + + // Set the history to ensure enough input items for each filter + set_history (d_taps_per_filter + 1); + + d_updated = true; +} + +void +gr_pfb_arb_resampler_fff::create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps) +{ + // Calculate the differential taps (derivative filter) by taking the difference + // between two taps. Duplicate the last one to make both filters the same length. + float tap; + difftaps.clear(); + for(unsigned int i = 0; i < newtaps.size()-1; i++) { + tap = newtaps[i+1] - newtaps[i]; + difftaps.push_back(tap); + } + difftaps.push_back(tap); +} + +void +gr_pfb_arb_resampler_fff::print_taps() +{ + unsigned int i, j; + for(i = 0; i < d_int_rate; i++) { + printf("filter[%d]: [", i); + for(j = 0; j < d_taps_per_filter; j++) { + printf(" %.4e", d_taps[i][j]); + } + printf("]\n"); + } +} + +int +gr_pfb_arb_resampler_fff::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + float *in = (float *) input_items[0]; + float *out = (float *) output_items[0]; + + if (d_updated) { + d_updated = false; + return 0; // history requirements may have changed. + } + + int i = 0, count = d_start_index; + unsigned int j; + float o0, o1; + + // Restore the last filter position + j = d_last_filter; + + // produce output as long as we can and there are enough input samples + int max_input = ninput_items[0]-(int)d_taps_per_filter; + while((i < noutput_items) && (count < max_input)) { + // start j by wrapping around mod the number of channels + while((j < d_int_rate) && (i < noutput_items)) { + // Take the current filter and derivative filter output + o0 = d_filters[j]->filter(&in[count]); + o1 = d_diff_filters[j]->filter(&in[count]); + + out[i] = o0 + o1*d_acc; // linearly interpolate between samples + i++; + + // Adjust accumulator and index into filterbank + d_acc += d_flt_rate; + j += d_dec_rate + (int)floor(d_acc); + d_acc = fmodf(d_acc, 1.0); + } + if(i < noutput_items) { // keep state for next entry + float ss = (int)(j / d_int_rate); // number of items to skip ahead by + count += ss; // we have fully consumed another input + j = j % d_int_rate; // roll filter around + } + } + + // Store the current filter position and start of next sample + d_last_filter = j; + d_start_index = std::max(0, count - ninput_items[0]); + + // consume all we've processed but no more than we can + consume_each(std::min(count, ninput_items[0])); + return i; +} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h new file mode 100644 index 000000000..7fef06143 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h @@ -0,0 +1,178 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009-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_PFB_ARB_RESAMPLER_FFF_H +#define INCLUDED_GR_PFB_ARB_RESAMPLER_FFF_H + +#include <gr_core_api.h> +#include <gr_block.h> + +class gr_pfb_arb_resampler_fff; +typedef boost::shared_ptr<gr_pfb_arb_resampler_fff> gr_pfb_arb_resampler_fff_sptr; +GR_CORE_API gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, + const std::vector<float> &taps, + unsigned int filter_size=32); + +class gr_fir_fff; + +/*! + * \class gr_pfb_arb_resampler_fff + * + * \brief Polyphase filterbank arbitrary resampler with + * float input, float output and float taps + * + * \ingroup filter_blk + * \ingroup pfb_blk + * + * This block takes in a signal stream and performs arbitrary + * resampling. The resampling rate can be any real + * number <EM>r</EM>. The resampling is done by constructing + * <EM>N</EM> filters where <EM>N</EM> is the interpolation rate. We + * then calculate <EM>D</EM> where <EM>D = floor(N/r)</EM>. + * + * Using <EM>N</EM> and <EM>D</EM>, we can perform rational resampling + * where <EM>N/D</EM> is a rational number close to the input rate + * <EM>r</EM> where we have <EM>N</EM> filters and we cycle through + * them as a polyphase filterbank with a stride of <EM>D</EM> so that + * <EM>i+1 = (i + D) % N</EM>. + * + * To get the arbitrary rate, we want to interpolate between two + * points. For each value out, we take an output from the current + * filter, <EM>i</EM>, and the next filter <EM>i+1</EM> and then + * linearly interpolate between the two based on the real resampling + * rate we want. + * + * The linear interpolation only provides us with an approximation to + * the real sampling rate specified. The error is a quantization error + * between the two filters we used as our interpolation points. To + * this end, the number of filters, <EM>N</EM>, used determines the + * quantization error; the larger <EM>N</EM>, the smaller the + * noise. You can design for a specified noise floor by setting the + * filter size (parameters <EM>filter_size</EM>). The size defaults to + * 32 filters, which is about as good as most implementations need. + * + * The trick with designing this filter is in how to specify the taps + * of the prototype filter. Like the PFB interpolator, the taps are + * specified using the interpolated filter rate. In this case, that + * rate is the input sample rate multiplied by the number of filters + * in the filterbank, which is also the interpolation rate. All other + * values should be relative to this rate. + * + * For example, for a 32-filter arbitrary resampler and using the + * GNU Radio's firdes utility to build the filter, we build a low-pass + * filter with a sampling rate of <EM>fs</EM>, a 3-dB bandwidth of + * <EM>BW</EM> and a transition bandwidth of <EM>TB</EM>. We can also + * specify the out-of-band attenuation to use, <EM>ATT</EM>, and the + * filter window function (a Blackman-harris window in this case). The + * first input is the gain of the filter, which we specify here as the + * interpolation rate (<EM>32</EM>). + * + * <B><EM>self._taps = gr.firdes.low_pass_2(32, 32*fs, BW, TB, + * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> + * + * The theory behind this block can be found in Chapter 7.5 of + * the following book. + * + * <B><EM>f. harris, "Multirate Signal Processing for Communication + * Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> + */ + +class GR_CORE_API gr_pfb_arb_resampler_fff : public gr_block +{ + private: + /*! + * Build the polyphase filterbank arbitray resampler. + * \param rate (float) Specifies the resampling rate to use + * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps + * should be generated at the filter_size sampling rate. + * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly + related to quantization noise introduced during the resampling. + Defaults to 32 filters. + */ + friend GR_CORE_API gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, + const std::vector<float> &taps, + unsigned int filter_size); + + std::vector<gr_fir_fff*> d_filters; + std::vector<gr_fir_fff*> d_diff_filters; + std::vector< std::vector<float> > d_taps; + std::vector< std::vector<float> > d_dtaps; + unsigned int d_int_rate; // the number of filters (interpolation rate) + unsigned int d_dec_rate; // the stride through the filters (decimation rate) + float d_flt_rate; // residual rate for the linear interpolation + float d_acc; + unsigned int d_last_filter; + int d_start_index; + unsigned int d_taps_per_filter; + bool d_updated; + + /*! + * Build the polyphase filterbank arbitray resampler. + * \param rate (float) Specifies the resampling rate to use + * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps + * should be generated at the filter_size sampling rate. + * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly + related to quantization noise introduced during the resampling. + Defaults to 32 filters. + */ + gr_pfb_arb_resampler_fff (float rate, + const std::vector<float> &taps, + unsigned int filter_size); + + void create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps); + + /*! + * Resets the filterbank's filter taps with the new prototype filter + * \param newtaps (vector of floats) The prototype filter to populate the filterbank. + * The taps should be generated at the interpolated sampling rate. + * \param ourtaps (vector of floats) Reference to our internal member of holding the taps. + * \param ourfilter (vector of filters) Reference to our internal filter to set the taps for. + */ + void create_taps (const std::vector<float> &newtaps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr_fir_fff*> &ourfilter); + + +public: + ~gr_pfb_arb_resampler_fff (); + + // FIXME: See about a set_taps function during runtime. + + /*! + * Print all of the filterbank taps to screen. + */ + void print_taps(); + void set_rate (float rate) { + d_dec_rate = (unsigned int)floor(d_int_rate/rate); + d_flt_rate = (d_int_rate/rate) - d_dec_rate; + set_relative_rate(rate); + } + + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.i b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i index c9c792c8a..8c1db22c3 100644 --- a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.i +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2009,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,22 +20,23 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,fll_band_edge_cc); +GR_SWIG_BLOCK_MAGIC(gr,pfb_arb_resampler_fff); -gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float alpha, float beta); +gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, + const std::vector<float> &taps, + unsigned int filter_size=32); -class gr_fll_band_edge_cc : public gr_sync_block +class gr_pfb_arb_resampler_fff : public gr_block { private: - gr_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float alpha, float beta); + gr_pfb_arb_resampler_fff (float rate, + const std::vector<float> &taps, + unsigned int filter_size); public: - ~gr_fll_band_edge_cc (); + ~gr_pfb_arb_resampler_fff (); - void set_alpha (float alpha); - void set_beta (float beta); - void design_filter(float samps_per_sym, float rolloff, int filter_size); + //void set_taps (const std::vector<float> &taps); void print_taps(); + void set_rate (float rate); }; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index 751673bc7..8fd5c4f78 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -24,11 +24,12 @@ #ifndef INCLUDED_GR_PFB_CHANNELIZER_CCF_H #define INCLUDED_GR_PFB_CHANNELIZER_CCF_H +#include <gr_core_api.h> #include <gr_block.h> class gr_pfb_channelizer_ccf; typedef boost::shared_ptr<gr_pfb_channelizer_ccf> gr_pfb_channelizer_ccf_sptr; -gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, +GR_CORE_API gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, const std::vector<float> &taps, float oversample_rate=1); @@ -43,6 +44,7 @@ class gri_fft_complex; * gr_complex input, gr_complex output and float taps * * \ingroup filter_blk + * \ingroup pfb_blk * * This block takes in complex inputs and channelizes it to <EM>M</EM> * channels of equal bandwidth. Each of the resulting channels is @@ -110,7 +112,7 @@ class gri_fft_complex; * */ -class gr_pfb_channelizer_ccf : public gr_block +class GR_CORE_API gr_pfb_channelizer_ccf : public gr_block { private: /*! @@ -130,7 +132,7 @@ class gr_pfb_channelizer_ccf : public gr_block * sample rate of a 6/1 oversample ratio is 6000 Hz, or * 6 times the normal 1000 Hz. */ - friend gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, + friend GR_CORE_API gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, const std::vector<float> &taps, float oversample_rate); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc index 937899c0d..633c5be07 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009,2010 Free Software Foundation, Inc. + * Copyright 2009-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,39 +33,47 @@ #include <gr_io_signature.h> #include <gr_math.h> -gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain, +gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, const std::vector<float> &taps, unsigned int filter_size, float init_phase, - float max_rate_deviation) + float max_rate_deviation, + int osps) { - return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_ccf (sps, gain, taps, - filter_size, - init_phase, - max_rate_deviation)); + return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_ccf (sps, loop_bw, taps, + filter_size, + init_phase, + max_rate_deviation, + osps)); } static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (double sps, float gain, +gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (double sps, float loop_bw, const std::vector<float> &taps, unsigned int filter_size, float init_phase, - float max_rate_deviation) + float max_rate_deviation, + int osps) : gr_block ("pfb_clock_sync_ccf", gr_make_io_signature (1, 1, sizeof(gr_complex)), gr_make_io_signaturev (1, 4, iosig)), d_updated (false), d_nfilters(filter_size), - d_max_dev(max_rate_deviation) + d_max_dev(max_rate_deviation), + d_osps(osps), d_error(0) { d_nfilters = filter_size; d_sps = floor(sps); + // Set the damping factor for a critically damped system + d_damping = sqrtf(2.0f)/2.0f; + + // Set the bandwidth, which will then call update_gains() + set_loop_bandwidth(loop_bw); + // Store the last filter between calls to work // The accumulator keeps track of overflow to increment the stride correctly. // set it here to the fractional difference based on the initial phaes - set_alpha(gain); - set_beta(0.25*gain*gain); d_k = init_phase; d_rate = (sps-floor(sps))*(double)d_nfilters; d_rate_i = (int)floor(d_rate); @@ -103,6 +111,100 @@ gr_pfb_clock_sync_ccf::check_topology(int ninputs, int noutputs) return noutputs == 1 || noutputs == 4; } + + +/******************************************************************* + SET FUNCTIONS +*******************************************************************/ + + +void +gr_pfb_clock_sync_ccf::set_loop_bandwidth(float bw) +{ + if(bw < 0) { + throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid bandwidth. Must be >= 0."); + } + + d_loop_bw = bw; + update_gains(); +} + +void +gr_pfb_clock_sync_ccf::set_damping_factor(float df) +{ + if(df < 0 || df > 1.0) { + throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid damping factor. Must be in [0,1]."); + } + + d_damping = df; + update_gains(); +} + +void +gr_pfb_clock_sync_ccf::set_alpha(float alpha) +{ + if(alpha < 0 || alpha > 1.0) { + throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid alpha. Must be in [0,1]."); + } + d_alpha = alpha; +} + +void +gr_pfb_clock_sync_ccf::set_beta(float beta) +{ + if(beta < 0 || beta > 1.0) { + throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid beta. Must be in [0,1]."); + } + d_beta = beta; +} + +/******************************************************************* + GET FUNCTIONS +*******************************************************************/ + + +float +gr_pfb_clock_sync_ccf::get_loop_bandwidth() const +{ + return d_loop_bw; +} + +float +gr_pfb_clock_sync_ccf::get_damping_factor() const +{ + return d_damping; +} + +float +gr_pfb_clock_sync_ccf::get_alpha() const +{ + return d_alpha; +} + +float +gr_pfb_clock_sync_ccf::get_beta() const +{ + return d_beta; +} + +float +gr_pfb_clock_sync_ccf::get_clock_rate() const +{ + return d_rate_f; +} + +/******************************************************************* +*******************************************************************/ + +void +gr_pfb_clock_sync_ccf::update_gains() +{ + float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); + d_alpha = (4*d_damping*d_loop_bw) / denom; + d_beta = (4*d_loop_bw*d_loop_bw) / denom; +} + + void gr_pfb_clock_sync_ccf::set_taps (const std::vector<float> &newtaps, std::vector< std::vector<float> > &ourtaps, @@ -127,13 +229,16 @@ gr_pfb_clock_sync_ccf::set_taps (const std::vector<float> &newtaps, // Partition the filter for(i = 0; i < d_nfilters; i++) { // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0); + //ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0); + ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); for(j = 0; j < d_taps_per_filter; j++) { - ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters]; + //ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters]; + ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; } // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]); + //ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]); + ourfilter[i]->set_taps(ourtaps[i]); } // Set the history to ensure enough input items for each filter @@ -146,58 +251,84 @@ void gr_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps, std::vector<float> &difftaps) { - float maxtap = 1e-20; - difftaps.clear(); - difftaps.push_back(0); //newtaps[0]); - for(unsigned int i = 1; i < newtaps.size()-1; i++) { - float tap = newtaps[i+1] - newtaps[i-1]; - difftaps.push_back(tap); - if(tap > maxtap) { - maxtap = tap; + std::vector<float> diff_filter(3); + diff_filter[0] = -1; + diff_filter[1] = 0; + diff_filter[2] = 1; + + float pwr = 0; + difftaps.push_back(0); + for(unsigned int i = 0; i < newtaps.size()-2; i++) { + float tap = 0; + for(int j = 0; j < 3; j++) { + tap += diff_filter[j]*newtaps[i+j]; + pwr += fabsf(tap); } + difftaps.push_back(tap); } - difftaps.push_back(0);//-newtaps[newtaps.size()-1]); + difftaps.push_back(0); - // Scale the differential taps; helps scale error term to better update state - // FIXME: should this be scaled this way or use the same gain as the taps? for(unsigned int i = 0; i < difftaps.size(); i++) { - difftaps[i] /= maxtap; + difftaps[i] *= pwr; } } -void -gr_pfb_clock_sync_ccf::print_taps() +std::string +gr_pfb_clock_sync_ccf::get_taps_as_string() { int i, j; - printf("[ "); + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; for(i = 0; i < d_nfilters; i++) { - printf("[%.4e, ", d_taps[i][0]); + str << "[" << d_taps[i][0] << ", "; for(j = 1; j < d_taps_per_filter-1; j++) { - printf("%.4e,", d_taps[i][j]); + str << d_taps[i][j] << ", "; } - printf("%.4e],", d_taps[i][j]); + str << d_taps[i][j] << "],"; } - printf(" ]\n"); + str << " ]" << std::endl; + + return str.str(); } -void -gr_pfb_clock_sync_ccf::print_diff_taps() +std::string +gr_pfb_clock_sync_ccf::get_diff_taps_as_string() { int i, j; - printf("[ "); + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; for(i = 0; i < d_nfilters; i++) { - printf("[%.4e, ", d_dtaps[i][0]); + str << "[" << d_dtaps[i][0] << ", "; for(j = 1; j < d_taps_per_filter-1; j++) { - printf("%.4e,", d_dtaps[i][j]); + str << d_dtaps[i][j] << ", "; } - printf("%.4e],", d_dtaps[i][j]); + str << d_dtaps[i][j] << "],"; } - printf(" ]\n"); + str << " ]" << std::endl; + + return str.str(); } +std::vector< std::vector<float> > +gr_pfb_clock_sync_ccf::get_taps() +{ + return d_taps; +} + +std::vector< std::vector<float> > +gr_pfb_clock_sync_ccf::get_diff_taps() +{ + return d_dtaps; +} std::vector<float> -gr_pfb_clock_sync_ccf::channel_taps(int channel) +gr_pfb_clock_sync_ccf::get_channel_taps(int channel) { std::vector<float> taps; for(int i = 0; i < d_taps_per_filter; i++) { @@ -207,7 +338,7 @@ gr_pfb_clock_sync_ccf::channel_taps(int channel) } std::vector<float> -gr_pfb_clock_sync_ccf::diff_channel_taps(int channel) +gr_pfb_clock_sync_ccf::get_diff_channel_taps(int channel) { std::vector<float> taps; for(int i = 0; i < d_taps_per_filter; i++) { @@ -226,7 +357,7 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items, gr_complex *in = (gr_complex *) input_items[0]; gr_complex *out = (gr_complex *) output_items[0]; - float *err = 0, *outrate = 0, *outk = 0; + float *err = NULL, *outrate = NULL, *outk = NULL; if(output_items.size() == 4) { err = (float *) output_items[1]; outrate = (float*)output_items[2]; @@ -239,50 +370,56 @@ gr_pfb_clock_sync_ccf::general_work (int noutput_items, } // We need this many to process one output - int nrequired = ninput_items[0] - d_taps_per_filter; + int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; int i = 0, count = 0; - float error, error_r, error_i; + float error_r, error_i; // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < nrequired)) { - d_filtnum = (int)floor(d_k); - - // Keep the current filter number in [0, d_nfilters] - // If we've run beyond the last filter, wrap around and go to next sample - // If we've go below 0, wrap around and go to previous sample - while(d_filtnum >= d_nfilters) { - d_k -= d_nfilters; - d_filtnum -= d_nfilters; - count += 1; - } - while(d_filtnum < 0) { - d_k += d_nfilters; - d_filtnum += d_nfilters; - count -= 1; + while((i < noutput_items-d_osps) && (count < nrequired)) { + for(int k = 0; k < d_osps; k++) { + d_filtnum = (int)floor(d_k); + + // Keep the current filter number in [0, d_nfilters] + // If we've run beyond the last filter, wrap around and go to next sample + // If we've go below 0, wrap around and go to previous sample + while(d_filtnum >= d_nfilters) { + d_k -= d_nfilters; + d_filtnum -= d_nfilters; + count += 1; + } + while(d_filtnum < 0) { + d_k += d_nfilters; + d_filtnum += d_nfilters; + count -= 1; + } + + out[i+k] = d_filters[d_filtnum]->filter(&in[count+k]); + d_k = d_k + d_rate_i + d_rate_f; // update phase + + if(output_items.size() == 4) { + err[i] = d_error; + outrate[i] = d_rate_f; + outk[i] = d_k; + } } - out[i] = d_filters[d_filtnum]->filter(&in[count]); + // Update the phase and rate estimates for this symbol gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]); - error_r = out[i].real() * diff.real(); - error_i = out[i].imag() * diff.imag(); - error = (error_i + error_r) / 2.0; // average error from I&Q channel - - // Run the control loop to update the current phase (k) and tracking rate - d_k = d_k + d_alpha*error + d_rate_i + d_rate_f; - d_rate_f = d_rate_f + d_beta*error; + error_r = out[i].real() * diff.real(); + error_i = out[i].imag() * diff.imag(); + d_error = (error_i + error_r) / 2.0; // average error from I&Q channel + + // Run the control loop to update the current phase (k) and + // tracking rate estimates based on the error value + d_rate_f = d_rate_f + d_beta*d_error; + d_k = d_k + d_alpha*d_error; // Keep our rate within a good range d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); - i++; + i+=d_osps; count += (int)floor(d_sps); - - if(output_items.size() == 4) { - err[i] = error; - outrate[i] = d_rate_f; - outk[i] = d_k; - } } consume_each(count); 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 684ac85ce..514f580ba 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 @@ -24,15 +24,17 @@ #ifndef INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H #define INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H +#include <gr_core_api.h> #include <gr_block.h> class gr_pfb_clock_sync_ccf; typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr; -gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain, +GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, const std::vector<float> &taps, unsigned int filter_size=32, float init_phase=0, - float max_rate_deviation=1.5); + float max_rate_deviation=1.5, + int osps=1); class gr_fir_ccf; @@ -42,126 +44,158 @@ class gr_fir_ccf; * \brief Timing synchronizer using polyphase filterbanks * * \ingroup filter_blk + * \ingroup pfb_blk * - * This block performs timing synchronization for PAM signals by minimizing the - * derivative of the filtered signal, which in turn maximizes the SNR and - * minimizes ISI. + * This block performs timing synchronization for PAM signals by + * minimizing the derivative of the filtered signal, which in turn + * maximizes the SNR and minimizes ISI. * - * This approach works by setting up two filterbanks; one filterbanke contains the - * signal's pulse shaping matched filter (such as a root raised cosine filter), - * where each branch of the filterbank contains a different phase of the filter. - * The second filterbank contains the derivatives of the filters in the first - * filterbank. Thinking of this in the time domain, the first filterbank contains - * filters that have a sinc shape to them. We want to align the output signal to - * be sampled at exactly the peak of the sinc shape. The derivative of the sinc - * contains a zero at the maximum point of the sinc (sinc(0) = 1, sinc(0)' = 0). - * Furthermore, the region around the zero point is relatively linear. We make - * use of this fact to generate the error signal. + * This approach works by setting up two filterbanks; one filterbank + * contains the signal's pulse shaping matched filter (such as a root + * raised cosine filter), where each branch of the filterbank contains + * a different phase of the filter. The second filterbank contains + * the derivatives of the filters in the first filterbank. Thinking of + * this in the time domain, the first filterbank contains filters that + * have a sinc shape to them. We want to align the output signal to be + * sampled at exactly the peak of the sinc shape. The derivative of + * the sinc contains a zero at the maximum point of the sinc (sinc(0) + * = 1, sinc(0)' = 0). Furthermore, the region around the zero point + * is relatively linear. We make use of this fact to generate the + * error signal. * - * If the signal out of the derivative filters is d_i[n] for the ith filter, and - * the output of the matched filter is x_i[n], we calculate the error as: - * e[n] = (Re{x_i[n]} * Re{d_i[n]} + Im{x_i[n]} * Im{d_i[n]}) / 2.0 - * This equation averages the error in the real and imaginary parts. There are two - * reasons we multiply by the signal itself. First, if the symbol could be positive - * or negative going, but we want the error term to always tell us to go in the - * same direction depending on which side of the zero point we are on. The sign of - * x_i[n] adjusts the error term to do this. Second, the magnitude of x_i[n] scales - * the error term depending on the symbol's amplitude, so larger signals give us - * a stronger error term because we have more confidence in that symbol's value. - * Using the magnitude of x_i[n] instead of just the sign is especially good for - * signals with low SNR. + * If the signal out of the derivative filters is d_i[n] for the ith + * filter, and the output of the matched filter is x_i[n], we + * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + + * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in + * the real and imaginary parts. There are two reasons we multiply by + * the signal itself. First, if the symbol could be positive or + * negative going, but we want the error term to always tell us to go + * in the same direction depending on which side of the zero point we + * are on. The sign of x_i[n] adjusts the error term to do + * this. Second, the magnitude of x_i[n] scales the error term + * depending on the symbol's amplitude, so larger signals give us a + * stronger error term because we have more confidence in that + * symbol's value. Using the magnitude of x_i[n] instead of just the + * sign is especially good for signals with low SNR. * - * The error signal, e[n], gives us a value proportional to how far away from the zero - * point we are in the derivative signal. We want to drive this value to zero, so we - * set up a second order loop. We have two variables for this loop; d_k is the filter - * number in the filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock differences between - * the transmitter and receiver, d_rate represents that difference and would traverse - * the filter phase paths to keep the receiver locked. Thinking of this as a second-order - * PLL, the d_rate is the frequency and d_k is the phase. So we update d_rate and d_k - * using the standard loop equations based on two error signals, d_alpha and d_beta. - * We have these two values set based on each other for a critically damped system, so in - * the block constructor, we just ask for "gain," which is d_alpha while d_beta is - * equal to (gain^2)/4. + * The error signal, e[n], gives us a value proportional to how far + * away from the zero point we are in the derivative signal. We want + * to drive this value to zero, so we set up a second order loop. We + * have two variables for this loop; d_k is the filter number in the + * filterbank we are on and d_rate is the rate which we travel through + * the filters in the steady state. That is, due to the natural clock + * differences between the transmitter and receiver, d_rate represents + * that difference and would traverse the filter phase paths to keep + * the receiver locked. Thinking of this as a second-order PLL, the + * d_rate is the frequency and d_k is the phase. So we update d_rate + * and d_k using the standard loop equations based on two error + * signals, d_alpha and d_beta. We have these two values set based on + * each other for a critically damped system, so in the block + * constructor, we just ask for "gain," which is d_alpha while d_beta + * is equal to (gain^2)/4. * - * The clock sync block needs to know the number of samples per symbol (sps), because it - * only returns a single point representing the sample. The sps can be any positive real - * number and does not need to be an integer. The filter taps must also be specified. The - * taps are generated by first conceiving of the prototype filter that would be the signal's - * matched filter. Then interpolate this by the number of filters in the filterbank. These - * are then distributed among all of the filters. So if the prototype filter was to have - * 45 taps in it, then each path of the filterbank will also have 45 taps. This is easily - * done by building the filter with the sample rate multiplied by the number of filters - * to use. + * The clock sync block needs to know the number of samples per symbol + * (sps), because it only returns a single point representing the + * symbol. The sps can be any positive real number and does not need + * to be an integer. The filter taps must also be specified. The taps + * are generated by first conceiving of the prototype filter that + * would be the signal's matched filter. Then interpolate this by the + * number of filters in the filterbank. These are then distributed + * among all of the filters. So if the prototype filter was to have 45 + * taps in it, then each path of the filterbank will also have 45 + * taps. This is easily done by building the filter with the sample + * rate multiplied by the number of filters to use. * - * The number of filters can also be set and defaults to 32. With 32 filters, you get a - * good enough resolution in the phase to produce very small, almost unnoticeable, ISI. - * Going to 64 filters can reduce this more, but after that there is very little gained - * for the extra complexity. + * The number of filters can also be set and defaults to 32. With 32 + * filters, you get a good enough resolution in the phase to produce + * very small, almost unnoticeable, ISI. Going to 64 filters can + * reduce this more, but after that there is very little gained for + * the extra complexity. * - * The initial phase is another settable parameter and refers to the filter path the - * algorithm initially looks at (i.e., d_k starts at init_phase). This value defaults - * to zero, but it might be useful to start at a different phase offset, such as the mid- - * point of the filters. + * The initial phase is another settable parameter and refers to the + * filter path the algorithm initially looks at (i.e., d_k starts at + * init_phase). This value defaults to zero, but it might be useful to + * start at a different phase offset, such as the mid- point of the + * filters. * - * The final parameter is the max_rate_devitation, which defaults to 1.5. This is how far - * we allow d_rate to swing, positive or negative, from 0. Constraining the rate can help - * keep the algorithm from walking too far away to lock during times when there is no signal. + * The final parameter is the max_rate_devitation, which defaults to + * 1.5. This is how far we allow d_rate to swing, positive or + * negative, from 0. Constraining the rate can help keep the algorithm + * from walking too far away to lock during times when there is no + * signal. * */ -class gr_pfb_clock_sync_ccf : public gr_block +class GR_CORE_API gr_pfb_clock_sync_ccf : public gr_block { private: /*! * Build the polyphase filterbank timing synchronizer. * \param sps (double) The number of samples per symbol in the incoming signal - * \param gain (float) The alpha gain of the control loop; beta = (gain^2)/4 by default. + * \param loop_bw (float) The bandwidth of the control loop; set's alpha and beta. * \param taps (vector<int>) The filter taps. * \param filter_size (uint) The number of filters in the filterbank (default = 32). * \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_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain, + friend GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, const std::vector<float> &taps, unsigned int filter_size, float init_phase, - float max_rate_deviation); - - bool d_updated; - double d_sps; - double d_sample_num; - float d_alpha; - float d_beta; - int d_nfilters; - std::vector<gr_fir_ccf*> d_filters; - std::vector<gr_fir_ccf*> d_diff_filters; + float max_rate_deviation, + int osps); + + bool d_updated; + double d_sps; + double d_sample_num; + float d_loop_bw; + float d_damping; + float d_alpha; + float d_beta; + + int d_nfilters; + int d_taps_per_filter; + std::vector<gr_fir_ccf*> d_filters; + std::vector<gr_fir_ccf*> d_diff_filters; std::vector< std::vector<float> > d_taps; std::vector< std::vector<float> > d_dtaps; - float d_k; - float d_rate; - float d_rate_i; - float d_rate_f; - float d_max_dev; - int d_filtnum; - int d_taps_per_filter; + + float d_k; + float d_rate; + float d_rate_i; + float d_rate_f; + float d_max_dev; + int d_filtnum; + int d_osps; + float d_error; /*! * Build the polyphase filterbank timing synchronizer. */ - gr_pfb_clock_sync_ccf (double sps, float gain, + gr_pfb_clock_sync_ccf (double sps, float loop_bw, const std::vector<float> &taps, unsigned int filter_size, float init_phase, - float max_rate_deviation); + float max_rate_deviation, + int osps); void create_diff_taps(const std::vector<float> &newtaps, std::vector<float> &difftaps); public: ~gr_pfb_clock_sync_ccf (); + + /*! \brief update the system gains from omega and eta + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. + * These two factors can be set separately through their own + * set functions. + */ + void update_gains(); /*! * Resets the filterbank's filter taps with the new prototype filter @@ -171,40 +205,97 @@ public: std::vector<gr_fir_ccf*> &ourfilter); /*! - * Returns the taps of the matched filter + * Returns all of the taps of the matched filter */ - std::vector<float> channel_taps(int channel); + std::vector< std::vector<float> > get_taps(); /*! - * Returns the taps in the derivative filter + * Returns all of the taps of the derivative filter */ - std::vector<float> diff_channel_taps(int channel); + std::vector< std::vector<float> > get_diff_taps(); /*! - * Print all of the filterbank taps to screen. + * Returns the taps of the matched filter for a particular channel */ - void print_taps(); + std::vector<float> get_channel_taps(int channel); /*! - * Print all of the filterbank taps of the derivative filter to screen. + * Returns the taps in the derivative filter for a particular channel */ - void print_diff_taps(); + std::vector<float> get_diff_channel_taps(int channel); /*! - * Set the gain value alpha for the control loop - */ - void set_alpha(float alpha) - { - d_alpha = alpha; - } + * Return the taps as a formatted string for printing + */ + std::string get_taps_as_string(); /*! - * Set the gain value beta for the control loop - */ - void set_beta(float beta) - { - d_beta = beta; - } + * Return the derivative filter taps as a formatted string for printing + */ + std::string get_diff_taps_as_string(); + + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + + /*! + * \brief Set the loop bandwidth + * + * Set the loop filter's bandwidth to \p bw. This should be between + * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive + * number. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param bw (float) new bandwidth + * + */ + void set_loop_bandwidth(float bw); + + /*! + * \brief Set the loop damping factor + * + * Set the loop filter's damping factor to \p df. The damping factor + * should be sqrt(2)/2.0 for critically damped systems. + * Set it to anything else only if you know what you are doing. It must + * be a number between 0 and 1. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param df (float) new damping factor + * + */ + void set_damping_factor(float df); + + /*! + * \brief Set the loop gain alpha + * + * Set's the loop filter's alpha gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param alpha (float) new alpha gain + * + */ + void set_alpha(float alpha); + + /*! + * \brief Set the loop gain beta + * + * Set's the loop filter's beta gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param beta (float) new beta gain + * + */ + void set_beta(float beta); /*! * Set the maximum deviation from 0 d_rate can have @@ -214,6 +305,38 @@ public: d_max_dev = m; } + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the loop bandwidth + */ + float get_loop_bandwidth() const; + + /*! + * \brief Returns the loop damping factor + */ + float get_damping_factor() const; + + /*! + * \brief Returns the loop gain alpha + */ + float get_alpha() const; + + /*! + * \brief Returns the loop gain beta + */ + float get_beta() const; + + /*! + * \brief Returns the current clock rate + */ + float get_clock_rate() const; + + /******************************************************************* + *******************************************************************/ + bool check_topology(int ninputs, int noutputs); int general_work (int noutput_items, diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i index 197984287..92ad1661a 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i @@ -22,20 +22,22 @@ GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_ccf); -gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain, +gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, const std::vector<float> &taps, unsigned int filter_size=32, float init_phase=0, - float max_rate_deviation=1.5); + float max_rate_deviation=1.5, + int osps=1); class gr_pfb_clock_sync_ccf : public gr_block { private: - gr_pfb_clock_sync_ccf (double sps, float gain, + gr_pfb_clock_sync_ccf (double sps, float loop_bw, const std::vector<float> &taps, unsigned int filter_size, float init_phase, - float max_rate_deviation); + float max_rate_deviation, + int osps); public: ~gr_pfb_clock_sync_ccf (); @@ -44,11 +46,22 @@ class gr_pfb_clock_sync_ccf : public gr_block std::vector< std::vector<float> > &ourtaps, std::vector<gr_fir_ccf*> &ourfilter); - std::vector<float> channel_taps(int channel); - std::vector<float> diff_channel_taps(int channel); - void print_taps(); - void print_diff_taps(); + std::vector< std::vector<float> > get_taps(); + std::vector< std::vector<float> > get_diff_taps(); + std::vector<float> get_channel_taps(int channel); + std::vector<float> get_diff_channel_taps(int channel); + std::string get_taps_as_string(); + std::string get_diff_taps_as_string(); + + void set_loop_bandwidth(float bw); + void set_damping_factor(float df); void set_alpha(float alpha); void set_beta(float beta); void set_max_rate_deviation(float m); + + float get_loop_bandwidth() const; + float get_damping_factor() const; + float get_alpha() const; + float get_beta() const; + float get_clock_rate() const; }; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h index fa1279a7c..447d3e59d 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h @@ -24,11 +24,12 @@ #ifndef INCLUDED_GR_PFB_CLOCK_SYNC_FFF_H #define INCLUDED_GR_PFB_CLOCK_SYNC_FFF_H +#include <gr_core_api.h> #include <gr_block.h> class gr_pfb_clock_sync_fff; typedef boost::shared_ptr<gr_pfb_clock_sync_fff> gr_pfb_clock_sync_fff_sptr; -gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, +GR_CORE_API gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, const std::vector<float> &taps, unsigned int filter_size=32, float init_phase=0, @@ -42,75 +43,89 @@ class gr_fir_fff; * \brief Timing synchronizer using polyphase filterbanks * * \ingroup filter_blk + * \ingroup pfb_blk * - * This block performs timing synchronization for PAM signals by minimizing the - * derivative of the filtered signal, which in turn maximizes the SNR and - * minimizes ISI. + * This block performs timing synchronization for PAM signals by + * minimizing the derivative of the filtered signal, which in turn + * maximizes the SNR and minimizes ISI. * - * This approach works by setting up two filterbanks; one filterbanke contains the - * signal's pulse shaping matched filter (such as a root raised cosine filter), - * where each branch of the filterbank contains a different phase of the filter. - * The second filterbank contains the derivatives of the filters in the first - * filterbank. Thinking of this in the time domain, the first filterbank contains - * filters that have a sinc shape to them. We want to align the output signal to - * be sampled at exactly the peak of the sinc shape. The derivative of the sinc - * contains a zero at the maximum point of the sinc (sinc(0) = 1, sinc(0)' = 0). - * Furthermore, the region around the zero point is relatively linear. We make - * use of this fact to generate the error signal. + * This approach works by setting up two filterbanks; one filterbanke + * contains the signal's pulse shaping matched filter (such as a root + * raised cosine filter), where each branch of the filterbank contains + * a different phase of the filter. The second filterbank contains + * the derivatives of the filters in the first filterbank. Thinking of + * this in the time domain, the first filterbank contains filters that + * have a sinc shape to them. We want to align the output signal to be + * sampled at exactly the peak of the sinc shape. The derivative of + * the sinc contains a zero at the maximum point of the sinc (sinc(0) + * = 1, sinc(0)' = 0). Furthermore, the region around the zero point + * is relatively linear. We make use of this fact to generate the + * error signal. * - * If the signal out of the derivative filters is d_i[n] for the ith filter, and - * the output of the matched filter is x_i[n], we calculate the error as: - * e[n] = (Re{x_i[n]} * Re{d_i[n]} + Im{x_i[n]} * Im{d_i[n]}) / 2.0 - * This equation averages the error in the real and imaginary parts. There are two - * reasons we multiply by the signal itself. First, if the symbol could be positive - * or negative going, but we want the error term to always tell us to go in the - * same direction depending on which side of the zero point we are on. The sign of - * x_i[n] adjusts the error term to do this. Second, the magnitude of x_i[n] scales - * the error term depending on the symbol's amplitude, so larger signals give us - * a stronger error term because we have more confidence in that symbol's value. - * Using the magnitude of x_i[n] instead of just the sign is especially good for - * signals with low SNR. + * If the signal out of the derivative filters is d_i[n] for the ith + * filter, and the output of the matched filter is x_i[n], we + * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + + * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in + * the real and imaginary parts. There are two reasons we multiply by + * the signal itself. First, if the symbol could be positive or + * negative going, but we want the error term to always tell us to go + * in the same direction depending on which side of the zero point we + * are on. The sign of x_i[n] adjusts the error term to do + * this. Second, the magnitude of x_i[n] scales the error term + * depending on the symbol's amplitude, so larger signals give us a + * stronger error term because we have more confidence in that + * symbol's value. Using the magnitude of x_i[n] instead of just the + * sign is especially good for signals with low SNR. * - * The error signal, e[n], gives us a value proportional to how far away from the zero - * point we are in the derivative signal. We want to drive this value to zero, so we - * set up a second order loop. We have two variables for this loop; d_k is the filter - * number in the filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock differences between - * the transmitter and receiver, d_rate represents that difference and would traverse - * the filter phase paths to keep the receiver locked. Thinking of this as a second-order - * PLL, the d_rate is the frequency and d_k is the phase. So we update d_rate and d_k - * using the standard loop equations based on two error signals, d_alpha and d_beta. - * We have these two values set based on each other for a critically damped system, so in - * the block constructor, we just ask for "gain," which is d_alpha while d_beta is - * equal to (gain^2)/4. + * The error signal, e[n], gives us a value proportional to how far + * away from the zero point we are in the derivative signal. We want + * to drive this value to zero, so we set up a second order loop. We + * have two variables for this loop; d_k is the filter number in the + * filterbank we are on and d_rate is the rate which we travel through + * the filters in the steady state. That is, due to the natural clock + * differences between the transmitter and receiver, d_rate represents + * that difference and would traverse the filter phase paths to keep + * the receiver locked. Thinking of this as a second-order PLL, the + * d_rate is the frequency and d_k is the phase. So we update d_rate + * and d_k using the standard loop equations based on two error + * signals, d_alpha and d_beta. We have these two values set based on + * each other for a critically damped system, so in the block + * constructor, we just ask for "gain," which is d_alpha while d_beta + * is equal to (gain^2)/4. * - * The clock sync block needs to know the number of samples per second (sps), because it - * only returns a single point representing the sample. The sps can be any positive real - * number and does not need to be an integer. The filter taps must also be specified. The - * taps are generated by first conceiving of the prototype filter that would be the signal's - * matched filter. Then interpolate this by the number of filters in the filterbank. These - * are then distributed among all of the filters. So if the prototype filter was to have - * 45 taps in it, then each path of the filterbank will also have 45 taps. This is easily - * done by building the filter with the sample rate multiplied by the number of filters - * to use. + * The clock sync block needs to know the number of samples per second + * (sps), because it only returns a single point representing the + * sample. The sps can be any positive real number and does not need + * to be an integer. The filter taps must also be specified. The taps + * are generated by first conceiving of the prototype filter that + * would be the signal's matched filter. Then interpolate this by the + * number of filters in the filterbank. These are then distributed + * among all of the filters. So if the prototype filter was to have 45 + * taps in it, then each path of the filterbank will also have 45 + * taps. This is easily done by building the filter with the sample + * rate multiplied by the number of filters to use. * - * The number of filters can also be set and defaults to 32. With 32 filters, you get a - * good enough resolution in the phase to produce very small, almost unnoticeable, ISI. - * Going to 64 filters can reduce this more, but after that there is very little gained - * for the extra complexity. + * The number of filters can also be set and defaults to 32. With 32 + * filters, you get a good enough resolution in the phase to produce + * very small, almost unnoticeable, ISI. Going to 64 filters can + * reduce this more, but after that there is very little gained for + * the extra complexity. * - * The initial phase is another settable parameter and refers to the filter path the - * algorithm initially looks at (i.e., d_k starts at init_phase). This value defaults - * to zero, but it might be useful to start at a different phase offset, such as the mid- - * point of the filters. + * The initial phase is another settable parameter and refers to the + * filter path the algorithm initially looks at (i.e., d_k starts at + * init_phase). This value defaults to zero, but it might be useful to + * start at a different phase offset, such as the mid- point of the + * filters. * - * The final parameter is the max_rate_devitation, which defaults to 1.5. This is how far - * we allow d_rate to swing, positive or negative, from 0. Constraining the rate can help - * keep the algorithm from walking too far away to lock during times when there is no signal. + * The final parameter is the max_rate_devitation, which defaults to + * 1.5. This is how far we allow d_rate to swing, positive or + * negative, from 0. Constraining the rate can help keep the algorithm + * from walking too far away to lock during times when there is no + * signal. * */ -class gr_pfb_clock_sync_fff : public gr_block +class GR_CORE_API gr_pfb_clock_sync_fff : public gr_block { private: /*! @@ -124,7 +139,7 @@ class gr_pfb_clock_sync_fff : public gr_block * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). * */ - friend gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, + friend GR_CORE_API gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, const std::vector<float> &taps, unsigned int filter_size, float init_phase, diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h index 200adee3d..0ae054685 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h @@ -24,11 +24,12 @@ #ifndef INCLUDED_GR_PFB_DECIMATOR_CCF_H #define INCLUDED_GR_PFB_DECIMATOR_CCF_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_pfb_decimator_ccf; typedef boost::shared_ptr<gr_pfb_decimator_ccf> gr_pfb_decimator_ccf_sptr; -gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, +GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, const std::vector<float> &taps, unsigned int channel=0); @@ -41,6 +42,7 @@ class gri_fft_complex; * input, gr_complex output and float taps * * \ingroup filter_blk + * \ingroup pfb_blk * * This block takes in a signal stream and performs interger down- * sampling (decimation) with a polyphase filterbank. The first input @@ -92,7 +94,7 @@ class gri_fft_complex; * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> */ -class gr_pfb_decimator_ccf : public gr_sync_block +class GR_CORE_API gr_pfb_decimator_ccf : public gr_sync_block { private: /*! @@ -101,7 +103,7 @@ class gr_pfb_decimator_ccf : public gr_sync_block * \param taps (vector/list of floats) The prototype filter to populate the filterbank. * \param channel (unsigned integer) Selects the channel to return [default=0]. */ - friend gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, + friend GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, const std::vector<float> &taps, unsigned int channel); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h index d2efc591a..6885881e9 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h @@ -24,11 +24,12 @@ #ifndef INCLUDED_GR_PFB_INTERPOLATOR_CCF_H #define INCLUDED_GR_PFB_INTERPOLATOR_CCF_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_pfb_interpolator_ccf; typedef boost::shared_ptr<gr_pfb_interpolator_ccf> gr_pfb_interpolator_ccf_sptr; -gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, +GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, const std::vector<float> &taps); class gr_fir_ccf; @@ -39,6 +40,7 @@ class gr_fir_ccf; * gr_complex output and float taps * * \ingroup filter_blk + * \ingroup pfb_blk * * This block takes in a signal stream and performs interger up- * sampling (interpolation) with a polyphase filterbank. The first @@ -79,7 +81,7 @@ class gr_fir_ccf; * Inc. 2004.</EM></B> */ -class gr_pfb_interpolator_ccf : public gr_sync_interpolator +class GR_CORE_API gr_pfb_interpolator_ccf : public gr_sync_interpolator { private: /*! @@ -88,7 +90,7 @@ class gr_pfb_interpolator_ccf : public gr_sync_interpolator * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps * should be generated at the interpolated sampling rate. */ - friend gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, + friend GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, const std::vector<float> &taps); std::vector<gr_fir_ccf*> d_filters; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.h index f5b1cbb94..1f772b1dd 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.h @@ -24,12 +24,13 @@ #ifndef INCLUDED_GR_PFB_SYNTHESIS_FILTERBANK_CCF_H #define INCLUDED_GR_PFB_SYNTHESIS_FILTERBANK_CCF_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> #include <gri_fir_filter_with_buffer_ccf.h> class gr_pfb_synthesis_filterbank_ccf; typedef boost::shared_ptr<gr_pfb_synthesis_filterbank_ccf> gr_pfb_synthesis_filterbank_ccf_sptr; -gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf +GR_CORE_API gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf (unsigned int numchans, const std::vector<float> &taps); class gri_fft_complex; @@ -42,9 +43,10 @@ class gri_fft_complex; * gr_complex input, gr_complex output and float taps * * \ingroup filter_blk + * \ingroup pfb_blk */ -class gr_pfb_synthesis_filterbank_ccf : public gr_sync_interpolator +class GR_CORE_API gr_pfb_synthesis_filterbank_ccf : public gr_sync_interpolator { private: /*! @@ -54,7 +56,7 @@ class gr_pfb_synthesis_filterbank_ccf : public gr_sync_interpolator * \param taps (vector/list of floats) The prototype filter to populate the filterbank. */ - friend gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf + friend GR_CORE_API gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf (unsigned int numchans, const std::vector<float> &taps); bool d_updated; diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t index 983b350fa..8f50acc72 100644 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t @@ -29,11 +29,12 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, unsigned decimation, const std::vector<@TAP_TYPE@> &taps); @@ -44,7 +45,7 @@ class @FIR_TYPE@; * \brief Rational Resampling Polyphase FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps * \ingroup filter_blk */ -class @NAME@ : public gr_block +class GR_CORE_API @NAME@ : public gr_block { private: unsigned d_history; @@ -54,7 +55,7 @@ class @NAME@ : public gr_block bool d_updated; std::vector<@FIR_TYPE@ *> d_firs; - friend @SPTR_NAME@ + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, unsigned decimation, const std::vector<@TAP_TYPE@> &taps); diff --git a/gnuradio-core/src/lib/filter/gr_rotator.h b/gnuradio-core/src/lib/filter/gr_rotator.h index cb8f21a40..23c7a2830 100644 --- a/gnuradio-core/src/lib/filter/gr_rotator.h +++ b/gnuradio-core/src/lib/filter/gr_rotator.h @@ -23,9 +23,10 @@ #ifndef _GR_ROTATOR_H_ #define _GR_ROTATOR_H_ +#include <gr_core_api.h> #include <gr_complex.h> -class gr_rotator { +class GR_CORE_API gr_rotator { gr_complex d_phase; gr_complex d_phase_incr; unsigned int d_counter; diff --git a/gnuradio-core/src/lib/filter/gr_sincos.h b/gnuradio-core/src/lib/filter/gr_sincos.h index a8e267951..3d5c99083 100644 --- a/gnuradio-core/src/lib/filter/gr_sincos.h +++ b/gnuradio-core/src/lib/filter/gr_sincos.h @@ -23,14 +23,16 @@ #ifndef INCLUDED_GR_SINCOS_H #define INCLUDED_GR_SINCOS_H +#include <gr_core_api.h> + #ifdef __cplusplus extern "C" { #endif // compute sine and cosine at the same time -void gr_sincos (double x, double *sin, double *cos); -void gr_sincosf (float x, float *sin, float *cos); +GR_CORE_API void gr_sincos (double x, double *sin, double *cos); +GR_CORE_API void gr_sincosf (float x, float *sin, float *cos); #ifdef __cplusplus }; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir.h index 8781065d4..fb52e29e9 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir.h +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir.h @@ -22,6 +22,7 @@ #ifndef _GR_SINGLE_POLE_IIR_H_ #define _GR_SINGLE_POLE_IIR_H_ +#include <gr_core_api.h> #include <stdexcept> #include <gr_complex.h> /*! diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h index 1f1073424..3ce468db2 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SINGLE_POLE_IIR_FILTER_CC_H #define INCLUDED_GR_SINGLE_POLE_IIR_FILTER_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> #include <gr_complex.h> @@ -31,7 +32,7 @@ class gr_single_pole_iir_filter_cc; typedef boost::shared_ptr<gr_single_pole_iir_filter_cc> gr_single_pole_iir_filter_cc_sptr; -gr_single_pole_iir_filter_cc_sptr +GR_CORE_API gr_single_pole_iir_filter_cc_sptr gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen=1); /*! @@ -53,10 +54,10 @@ gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen=1); * Note that some texts define the system function with a + in the denominator. * If you're using that convention, you'll need to negate the feedback tap. */ -class gr_single_pole_iir_filter_cc : public gr_sync_block +class GR_CORE_API gr_single_pole_iir_filter_cc : public gr_sync_block { private: - friend gr_single_pole_iir_filter_cc_sptr + friend GR_CORE_API gr_single_pole_iir_filter_cc_sptr gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen); unsigned int d_vlen; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h index f676e94bc..d376587df 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SINGLE_POLE_IIR_FILTER_FF_H #define INCLUDED_GR_SINGLE_POLE_IIR_FILTER_FF_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> #include <stdexcept> @@ -30,7 +31,7 @@ class gr_single_pole_iir_filter_ff; typedef boost::shared_ptr<gr_single_pole_iir_filter_ff> gr_single_pole_iir_filter_ff_sptr; -gr_single_pole_iir_filter_ff_sptr +GR_CORE_API gr_single_pole_iir_filter_ff_sptr gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen=1); /*! @@ -52,10 +53,10 @@ gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen=1); * Note that some texts define the system function with a + in the denominator. * If you're using that convention, you'll need to negate the feedback tap. */ -class gr_single_pole_iir_filter_ff : public gr_sync_block +class GR_CORE_API gr_single_pole_iir_filter_ff : public gr_sync_block { private: - friend gr_single_pole_iir_filter_ff_sptr + friend GR_CORE_API gr_single_pole_iir_filter_ff_sptr gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen); unsigned int d_vlen; diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h index 3cd9105c7..4db7ba50f 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H #define INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H +#include <gr_core_api.h> #include <gr_complex.h> #include <vector> @@ -32,7 +33,7 @@ class gri_fft_complex; * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps * \ingroup filter_blk */ -class gri_fft_filter_ccc_generic +class GR_CORE_API gri_fft_filter_ccc_generic { private: int d_ntaps; diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h index d1c54f01f..6c96152c0 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_FFT_FILTER_CCC_SSE_H #define INCLUDED_GRI_FFT_FILTER_CCC_SSE_H +#include <gr_core_api.h> #include <gr_complex.h> #include <vector> @@ -32,7 +33,7 @@ class gri_fft_complex; * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps * \ingroup filter_blk */ -class gri_fft_filter_ccc_sse +class GR_CORE_API gri_fft_filter_ccc_sse { private: int d_ntaps; diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h index 6c31632d5..86658043a 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H #define INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H +#include <gr_core_api.h> #include <gr_complex.h> #include <vector> class gri_fft_real_fwd; class gri_fft_real_rev; -class gri_fft_filter_fff_generic +class GR_CORE_API gri_fft_filter_fff_generic { private: int d_ntaps; diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h index 8258bb824..bd87358e2 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GRI_FFT_FILTER_FFF_SSE_H #define INCLUDED_GRI_FFT_FILTER_FFF_SSE_H +#include <gr_core_api.h> #include <gr_complex.h> #include <vector> class gri_fft_real_fwd; class gri_fft_real_rev; -class gri_fft_filter_fff_sse +class GR_CORE_API gri_fft_filter_fff_sse { private: int d_ntaps; diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t index 23d64b65d..f209a8849 100644 --- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t @@ -29,6 +29,7 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <vector> #include <gr_types.h> #include <gr_reverse.h> @@ -42,7 +43,7 @@ * */ -class @NAME@ { +class GR_CORE_API @NAME@ { protected: std::vector<@TAP_TYPE@> d_taps; // reversed taps diff --git a/gnuradio-core/src/lib/filter/gri_goertzel.h b/gnuradio-core/src/lib/filter/gri_goertzel.h index e062f000e..6fb64b942 100644 --- a/gnuradio-core/src/lib/filter/gri_goertzel.h +++ b/gnuradio-core/src/lib/filter/gri_goertzel.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GRI_GOERTZEL_H #define INCLUDED_GRI_GOERTZEL_H +#include <gr_core_api.h> #include <gr_types.h> /*! * \brief Implements Goertzel single-bin DFT calculation * \ingroup misc */ -class gri_goertzel +class GR_CORE_API gri_goertzel { public: gri_goertzel() {} diff --git a/gnuradio-core/src/lib/filter/gri_iir.h b/gnuradio-core/src/lib/filter/gri_iir.h index 5bc67df53..ddd8f9b81 100644 --- a/gnuradio-core/src/lib/filter/gri_iir.h +++ b/gnuradio-core/src/lib/filter/gri_iir.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_IIR_H #define INCLUDED_GRI_IIR_H +#include <gr_core_api.h> #include <vector> #include <stdexcept> diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h index 616520ad6..b2832b3f6 100644 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h +++ b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h @@ -22,6 +22,7 @@ #ifndef _GRI_MMSE_FIR_INTERPOLATOR_H_ #define _GRI_MMSE_FIR_INTERPOLATOR_H_ +#include <gr_core_api.h> #include <vector> class gr_fir_fff; @@ -39,7 +40,7 @@ class gr_fir_fff; * method to 32nd's of a sample. */ -class gri_mmse_fir_interpolator { +class GR_CORE_API gri_mmse_fir_interpolator { public: gri_mmse_fir_interpolator (); ~gri_mmse_fir_interpolator (); diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h index daf8b19b8..2feef114b 100644 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h +++ b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h @@ -22,6 +22,7 @@ #ifndef _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ #define _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ +#include <gr_core_api.h> #include <gr_complex.h> #include <vector> @@ -40,7 +41,7 @@ class gr_fir_ccf; * method to 32nd's of a sample. */ -class gri_mmse_fir_interpolator_cc { +class GR_CORE_API gri_mmse_fir_interpolator_cc { public: gri_mmse_fir_interpolator_cc (); ~gri_mmse_fir_interpolator_cc (); diff --git a/gnuradio-core/src/lib/filter/qa_filter.h b/gnuradio-core/src/lib/filter/qa_filter.h index a51a88238..a10782068 100644 --- a/gnuradio-core/src/lib/filter/qa_filter.h +++ b/gnuradio-core/src/lib/filter/qa_filter.h @@ -23,11 +23,12 @@ #ifndef _QA_FILTER_H_ #define _QA_FILTER_H_ +#include <gruel/attributes.h> #include <cppunit/TestSuite.h> //! collect all the tests for the gr directory -class qa_filter { +class __GR_ATTR_EXPORT qa_filter { public: //! return suite of tests for all of gr directory static CppUnit::TestSuite *suite (); diff --git a/gnuradio-core/src/lib/g72x/.gitignore b/gnuradio-core/src/lib/g72x/.gitignore deleted file mode 100644 index a02b6ff73..000000000 --- a/gnuradio-core/src/lib/g72x/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo diff --git a/gnuradio-core/src/lib/g72x/README b/gnuradio-core/src/lib/g72x/README deleted file mode 100644 index 23b0e7dd5..000000000 --- a/gnuradio-core/src/lib/g72x/README +++ /dev/null @@ -1,94 +0,0 @@ -The files in this directory comprise ANSI-C language reference implementations -of the CCITT (International Telegraph and Telephone Consultative Committee) -G.711, G.721 and G.723 voice compressions. They have been tested on Sun -SPARCstations and passed 82 out of 84 test vectors published by CCITT -(Dec. 20, 1988) for G.721 and G.723. [The two remaining test vectors, -which the G.721 decoder implementation for u-law samples did not pass, -may be in error because they are identical to two other vectors for G.723_40.] - -This source code is released by Sun Microsystems, Inc. to the public domain. -Please give your acknowledgement in product literature if this code is used -in your product implementation. - -Sun Microsystems supports some CCITT audio formats in Solaris 2.0 system -software. However, Sun's implementations have been optimized for higher -performance on SPARCstations. - - -The source files for CCITT conversion routines in this directory are: - - g72x.h header file for g721.c, g723_24.c and g723_40.c - g711.c CCITT G.711 u-law and A-law compression - g72x.c common denominator of G.721 and G.723 ADPCM codes - g721.c CCITT G.721 32Kbps ADPCM coder (with g72x.c) - g723_24.c CCITT G.723 24Kbps ADPCM coder (with g72x.c) - g723_40.c CCITT G.723 40Kbps ADPCM coder (with g72x.c) - - -Simple conversions between u-law, A-law, and 16-bit linear PCM are invoked -as follows: - - unsigned char ucode, acode; - short pcm_val; - - ucode = linear2ulaw(pcm_val); - ucode = alaw2ulaw(acode); - - acode = linear2alaw(pcm_val); - acode = ulaw2alaw(ucode); - - pcm_val = ulaw2linear(ucode); - pcm_val = alaw2linear(acode); - - -The other CCITT compression routines are invoked as follows: - - #include "g72x.h" - - struct g72x_state state; - int sample, code; - - g72x_init_state(&state); - code = {g721,g723_24,g723_40}_encoder(sample, coding, &state); - sample = {g721,g723_24,g723_40}_decoder(code, coding, &state); - -where - coding = AUDIO_ENCODING_ULAW for 8-bit u-law samples - AUDIO_ENCODING_ALAW for 8-bit A-law samples - AUDIO_ENCODING_LINEAR for 16-bit linear PCM samples - - - -This directory also includes the following sample programs: - - encode.c CCITT ADPCM encoder - decode.c CCITT ADPCM decoder - Makefile makefile for the sample programs - - -The sample programs contain examples of how to call the various compression -routines and pack/unpack the bits. The sample programs read byte streams from -stdin and write to stdout. The input/output data is raw data (no file header -or other identifying information is embedded). The sample programs are -invoked as follows: - - encode [-3|4|5] [-a|u|l] <infile >outfile - decode [-3|4|5] [-a|u|l] <infile >outfile -where: - -3 encode to (decode from) G.723 24kbps (3-bit) data - -4 encode to (decode from) G.721 32kbps (4-bit) data [the default] - -5 encode to (decode from) G.723 40kbps (5-bit) data - -a encode from (decode to) A-law data - -u encode from (decode to) u-law data [the default] - -l encode from (decode to) 16-bit linear data - -Examples: - # Read 16-bit linear and output G.721 - encode -4 -l <pcmfile >g721file - - # Read 40Kbps G.723 and output A-law - decode -5 -a <g723file >alawfile - - # Compress and then decompress u-law data using 24Kbps G.723 - encode -3 <ulawin | deoced -3 >ulawout - diff --git a/gnuradio-core/src/lib/g72x/decode.c b/gnuradio-core/src/lib/g72x/decode.c deleted file mode 100644 index cf8c739c5..000000000 --- a/gnuradio-core/src/lib/g72x/decode.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * decode.c - * - * CCITT ADPCM decoder - * - * Usage : decode [-3|4|5] [-a|u|l] < infile > outfile - */ -#include <stdio.h> -#include "g72x.h" - - -/* - * Unpack input codes and pass them back as bytes. - * Returns 1 if there is residual input, returns -1 if eof, else returns 0. - */ -int -unpack_input( - unsigned char *code, - int bits) -{ - static unsigned int in_buffer = 0; - static int in_bits = 0; - unsigned char in_byte; - - if (in_bits < bits) { - if (fread(&in_byte, sizeof (char), 1, stdin) != 1) { - *code = 0; - return (-1); - } - in_buffer |= (in_byte << in_bits); - in_bits += 8; - } - *code = in_buffer & ((1 << bits) - 1); - in_buffer >>= bits; - in_bits -= bits; - return (in_bits > 0); -} - - -main( - int argc, - char **argv) -{ - short sample; - unsigned char code; - int n; - struct g72x_state state; - int out_coding; - int out_size; - int (*dec_routine)(); - int dec_bits; - - g72x_init_state(&state); - out_coding = AUDIO_ENCODING_ULAW; - out_size = sizeof (char); - dec_routine = g721_decoder; - dec_bits = 4; - - /* Process encoding argument, if any */ - while ((argc > 1) && (argv[1][0] == '-')) { - switch (argv[1][1]) { - case '3': - dec_routine = g723_24_decoder; - dec_bits = 3; - break; - case '4': - dec_routine = g721_decoder; - dec_bits = 4; - break; - case '5': - dec_routine = g723_40_decoder; - dec_bits = 5; - break; - case 'u': - out_coding = AUDIO_ENCODING_ULAW; - out_size = sizeof (char); - break; - case 'a': - out_coding = AUDIO_ENCODING_ALAW; - out_size = sizeof (char); - break; - case 'l': - out_coding = AUDIO_ENCODING_LINEAR; - out_size = sizeof (short); - break; - default: -fprintf(stderr, "CCITT ADPCM Decoder -- usage:\n"); -fprintf(stderr, "\tdecode [-3|4|5] [-a|u|l] < infile > outfile\n"); -fprintf(stderr, "where:\n"); -fprintf(stderr, "\t-3\tProcess G.723 24kbps (3-bit) input data\n"); -fprintf(stderr, "\t-4\tProcess G.721 32kbps (4-bit) input data [default]\n"); -fprintf(stderr, "\t-5\tProcess G.723 40kbps (5-bit) input data\n"); -fprintf(stderr, "\t-a\tGenerate 8-bit A-law data\n"); -fprintf(stderr, "\t-u\tGenerate 8-bit u-law data [default]\n"); -fprintf(stderr, "\t-l\tGenerate 16-bit linear PCM data\n"); - exit(1); - } - argc--; - argv++; - } - - /* Read and unpack input codes and process them */ - while (unpack_input(&code, dec_bits) >= 0) { - sample = (*dec_routine)(code, out_coding, &state); - if (out_size == 2) { - fwrite(&sample, out_size, 1, stdout); - } else { - code = (unsigned char)sample; - fwrite(&code, out_size, 1, stdout); - } - } - fclose(stdout); -} diff --git a/gnuradio-core/src/lib/g72x/encode.c b/gnuradio-core/src/lib/g72x/encode.c deleted file mode 100644 index e74482869..000000000 --- a/gnuradio-core/src/lib/g72x/encode.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * encode.c - * - * CCITT ADPCM encoder - * - * Usage : encode [-3|4|5] [-a|u|l] < infile > outfile - */ -#include <stdio.h> -#include "g72x.h" - - -/* - * Pack output codes into bytes and write them to stdout. - * Returns 1 if there is residual output, else returns 0. - */ -int -pack_output( - unsigned code, - int bits) -{ - static unsigned int out_buffer = 0; - static int out_bits = 0; - unsigned char out_byte; - - out_buffer |= (code << out_bits); - out_bits += bits; - if (out_bits >= 8) { - out_byte = out_buffer & 0xff; - out_bits -= 8; - out_buffer >>= 8; - fwrite(&out_byte, sizeof (char), 1, stdout); - } - return (out_bits > 0); -} - - -main( - int argc, - char **argv) -{ - struct g72x_state state; - unsigned char sample_char; - short sample_short; - unsigned char code; - int resid; - int in_coding; - int in_size; - unsigned *in_buf; - int (*enc_routine)(); - int enc_bits; - - g72x_init_state(&state); - - /* Set defaults to u-law input, G.721 output */ - in_coding = AUDIO_ENCODING_ULAW; - in_size = sizeof (char); - in_buf = (unsigned *)&sample_char; - enc_routine = g721_encoder; - enc_bits = 4; - - /* Process encoding argument, if any */ - while ((argc > 1) && (argv[1][0] == '-')) { - switch (argv[1][1]) { - case '3': - enc_routine = g723_24_encoder; - enc_bits = 3; - break; - case '4': - enc_routine = g721_encoder; - enc_bits = 4; - break; - case '5': - enc_routine = g723_40_encoder; - enc_bits = 5; - break; - case 'u': - in_coding = AUDIO_ENCODING_ULAW; - in_size = sizeof (char); - in_buf = (unsigned *)&sample_char; - break; - case 'a': - in_coding = AUDIO_ENCODING_ALAW; - in_size = sizeof (char); - in_buf = (unsigned *)&sample_char; - break; - case 'l': - in_coding = AUDIO_ENCODING_LINEAR; - in_size = sizeof (short); - in_buf = (unsigned *)&sample_short; - break; - default: -fprintf(stderr, "CCITT ADPCM Encoder -- usage:\n"); -fprintf(stderr, "\tencode [-3|4|5] [-a|u|l] < infile > outfile\n"); -fprintf(stderr, "where:\n"); -fprintf(stderr, "\t-3\tGenerate G.723 24kbps (3-bit) data\n"); -fprintf(stderr, "\t-4\tGenerate G.721 32kbps (4-bit) data [default]\n"); -fprintf(stderr, "\t-5\tGenerate G.723 40kbps (5-bit) data\n"); -fprintf(stderr, "\t-a\tProcess 8-bit A-law input data\n"); -fprintf(stderr, "\t-u\tProcess 8-bit u-law input data [default]\n"); -fprintf(stderr, "\t-l\tProcess 16-bit linear PCM input data\n"); - exit(1); - } - argc--; - argv++; - } - - /* Read input file and process */ - while (fread(in_buf, in_size, 1, stdin) == 1) { - code = (*enc_routine)(in_size == 2 ? sample_short : sample_char, - in_coding, &state); - resid = pack_output(code, enc_bits); - } - - /* Write zero codes until all residual codes are written out */ - while (resid) { - resid = pack_output(0, enc_bits); - } - fclose(stdout); -} diff --git a/gnuradio-core/src/lib/g72x/g711.c b/gnuradio-core/src/lib/g72x/g711.c deleted file mode 100644 index d4d60a5c2..000000000 --- a/gnuradio-core/src/lib/g72x/g711.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g711.c - * - * u-law, A-law and linear PCM conversions. - */ -#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ -#define QUANT_MASK (0xf) /* Quantization field mask. */ -#define NSEGS (8) /* Number of A-law segments. */ -#define SEG_SHIFT (4) /* Left shift for segment number. */ -#define SEG_MASK (0x70) /* Segment field mask. */ - -static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF, - 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF}; - -/* copy from CCITT G.711 specifications */ -unsigned char _u2a[128] = { /* u- to A-law conversions */ - 1, 1, 2, 2, 3, 3, 4, 4, - 5, 5, 6, 6, 7, 7, 8, 8, - 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, - 25, 27, 29, 31, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, - 46, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, - 121, 122, 123, 124, 125, 126, 127, 128}; - -unsigned char _a2u[128] = { /* A- to u-law conversions */ - 1, 3, 5, 7, 9, 11, 13, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 32, 33, 33, 34, 34, 35, 35, - 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 48, 49, 49, - 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 64, - 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127}; - -static int -search( - int val, - short *table, - int size) -{ - int i; - - for (i = 0; i < size; i++) { - if (val <= *table++) - return (i); - } - return (size); -} - -/* - * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law - * - * linear2alaw() accepts an 16-bit integer and encodes it as A-law data. - * - * Linear Input Code Compressed Code - * ------------------------ --------------- - * 0000000wxyza 000wxyz - * 0000001wxyza 001wxyz - * 000001wxyzab 010wxyz - * 00001wxyzabc 011wxyz - * 0001wxyzabcd 100wxyz - * 001wxyzabcde 101wxyz - * 01wxyzabcdef 110wxyz - * 1wxyzabcdefg 111wxyz - * - * For further information see John C. Bellamy's Digital Telephony, 1982, - * John Wiley & Sons, pps 98-111 and 472-476. - */ -unsigned char -linear2alaw( - int pcm_val) /* 2's complement (16-bit range) */ -{ - int mask; - int seg; - unsigned char aval; - - if (pcm_val >= 0) { - mask = 0xD5; /* sign (7th) bit = 1 */ - } else { - mask = 0x55; /* sign bit = 0 */ - pcm_val = -pcm_val - 8; - } - - /* Convert the scaled magnitude to segment number. */ - seg = search(pcm_val, seg_end, 8); - - /* Combine the sign, segment, and quantization bits. */ - - if (seg >= 8) /* out of range, return maximum value. */ - return (0x7F ^ mask); - else { - aval = seg << SEG_SHIFT; - if (seg < 2) - aval |= (pcm_val >> 4) & QUANT_MASK; - else - aval |= (pcm_val >> (seg + 3)) & QUANT_MASK; - return (aval ^ mask); - } -} - -/* - * alaw2linear() - Convert an A-law value to 16-bit linear PCM - * - */ -int -alaw2linear( - unsigned char a_val) -{ - int t; - int seg; - - a_val ^= 0x55; - - t = (a_val & QUANT_MASK) << 4; - seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT; - switch (seg) { - case 0: - t += 8; - break; - case 1: - t += 0x108; - break; - default: - t += 0x108; - t <<= seg - 1; - } - return ((a_val & SIGN_BIT) ? t : -t); -} - -#define BIAS (0x84) /* Bias for linear code. */ - -/* - * linear2ulaw() - Convert a linear PCM value to u-law - * - * In order to simplify the encoding process, the original linear magnitude - * is biased by adding 33 which shifts the encoding range from (0 - 8158) to - * (33 - 8191). The result can be seen in the following encoding table: - * - * Biased Linear Input Code Compressed Code - * ------------------------ --------------- - * 00000001wxyza 000wxyz - * 0000001wxyzab 001wxyz - * 000001wxyzabc 010wxyz - * 00001wxyzabcd 011wxyz - * 0001wxyzabcde 100wxyz - * 001wxyzabcdef 101wxyz - * 01wxyzabcdefg 110wxyz - * 1wxyzabcdefgh 111wxyz - * - * Each biased linear code has a leading 1 which identifies the segment - * number. The value of the segment number is equal to 7 minus the number - * of leading 0's. The quantization interval is directly available as the - * four bits wxyz. * The trailing bits (a - h) are ignored. - * - * Ordinarily the complement of the resulting code word is used for - * transmission, and so the code word is complemented before it is returned. - * - * For further information see John C. Bellamy's Digital Telephony, 1982, - * John Wiley & Sons, pps 98-111 and 472-476. - */ -unsigned char -linear2ulaw( - int pcm_val) /* 2's complement (16-bit range) */ -{ - int mask; - int seg; - unsigned char uval; - - /* Get the sign and the magnitude of the value. */ - if (pcm_val < 0) { - pcm_val = BIAS - pcm_val; - mask = 0x7F; - } else { - pcm_val += BIAS; - mask = 0xFF; - } - - /* Convert the scaled magnitude to segment number. */ - seg = search(pcm_val, seg_end, 8); - - /* - * Combine the sign, segment, quantization bits; - * and complement the code word. - */ - if (seg >= 8) /* out of range, return maximum value. */ - return (0x7F ^ mask); - else { - uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF); - return (uval ^ mask); - } - -} - -/* - * ulaw2linear() - Convert a u-law value to 16-bit linear PCM - * - * First, a biased linear code is derived from the code word. An unbiased - * output can then be obtained by subtracting 33 from the biased code. - * - * Note that this function expects to be passed the complement of the - * original code word. This is in keeping with ISDN conventions. - */ -int -ulaw2linear( - unsigned char u_val) -{ - int t; - - /* Complement to obtain normal u-law value. */ - u_val = ~u_val; - - /* - * Extract and bias the quantization bits. Then - * shift up by the segment number and subtract out the bias. - */ - t = ((u_val & QUANT_MASK) << 3) + BIAS; - t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT; - - return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS)); -} - -/* A-law to u-law conversion */ -unsigned char -alaw2ulaw( - unsigned char aval) -{ - aval &= 0xff; - return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) : - (0x7F ^ _a2u[aval ^ 0x55])); -} - -/* u-law to A-law conversion */ -unsigned char -ulaw2alaw( - unsigned char uval) -{ - uval &= 0xff; - return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) : - (0x55 ^ (_u2a[0x7F ^ uval] - 1))); -} diff --git a/gnuradio-core/src/lib/g72x/g721.c b/gnuradio-core/src/lib/g72x/g721.c deleted file mode 100644 index 445f177e8..000000000 --- a/gnuradio-core/src/lib/g72x/g721.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g721.c - * - * Description: - * - * g721_encoder(), g721_decoder() - * - * These routines comprise an implementation of the CCITT G.721 ADPCM - * coding algorithm. Essentially, this implementation is identical to - * the bit level description except for a few deviations which - * take advantage of work station attributes, such as hardware 2's - * complement arithmetic and large memory. Specifically, certain time - * consuming operations such as multiplications are replaced - * with lookup tables and software 2's complement operations are - * replaced with hardware 2's complement. - * - * The deviation from the bit level specification (lookup tables) - * preserves the bit level performance specifications. - * - * As outlined in the G.721 Recommendation, the algorithm is broken - * down into modules. Each section of code below is preceded by - * the name of the module which it is implementing. - * - */ -#include "g72x.h" - -static short qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400}; -/* - * Maps G.721 code word to reconstructed scale factor normalized log - * magnitude values. - */ -static short _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425, - 425, 373, 323, 273, 213, 135, 4, -2048}; - -/* Maps G.721 code word to log of scale factor multiplier. */ -static short _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122, - 1122, 355, 198, 112, 64, 41, 18, -12}; -/* - * Maps G.721 code words to a set of values whose long and short - * term averages are computed and then compared to give an indication - * how stationary (steady state) the signal is. - */ -static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00, - 0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0}; - -/* - * g721_encoder() - * - * Encodes the input vale of linear PCM, A-law or u-law data sl and returns - * the resulting code. -1 is returned for unknown input coding value. - */ -int -g721_encoder( - int sl, - int in_coding, - struct g72x_state *state_ptr) -{ - short sezi, se, sez; /* ACCUM */ - short d; /* SUBTA */ - short sr; /* ADDB */ - short y; /* MIX */ - short dqsez; /* ADDC */ - short dq, i; - - switch (in_coding) { /* linearize input sample to 14-bit PCM */ - case AUDIO_ENCODING_ALAW: - sl = alaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_ULAW: - sl = ulaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_LINEAR: - sl >>= 2; /* 14-bit dynamic range */ - break; - default: - return (-1); - } - - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */ - - d = sl - se; /* estimation difference */ - - /* quantize the prediction difference */ - y = step_size(state_ptr); /* quantizer step size */ - i = quantize(d, y, qtab_721, 7); /* i = ADPCM code */ - - dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */ - - sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */ - - dqsez = sr + sez - se; /* pole prediction diff. */ - - update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); - - return (i); -} - -/* - * g721_decoder() - * - * Description: - * - * Decodes a 4-bit code of G.721 encoded data of i and - * returns the resulting linear PCM, A-law or u-law value. - * return -1 for unknown out_coding value. - */ -int -g721_decoder( - int i, - int out_coding, - struct g72x_state *state_ptr) -{ - short sezi, sei, sez, se; /* ACCUM */ - short y; /* MIX */ - short sr; /* ADDB */ - short dq; - short dqsez; - - i &= 0x0f; /* mask to get proper bits */ - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - y = step_size(state_ptr); /* dynamic quantizer step size */ - - dq = reconstruct(i & 0x08, _dqlntab[i], y); /* quantized diff. */ - - sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq; /* reconst. signal */ - - dqsez = sr - se + sez; /* pole prediction diff. */ - - update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); - - switch (out_coding) { - case AUDIO_ENCODING_ALAW: - return (tandem_adjust_alaw(sr, se, y, i, 8, qtab_721)); - case AUDIO_ENCODING_ULAW: - return (tandem_adjust_ulaw(sr, se, y, i, 8, qtab_721)); - case AUDIO_ENCODING_LINEAR: - return (sr << 2); /* sr was 14-bit dynamic range */ - default: - return (-1); - } -} diff --git a/gnuradio-core/src/lib/g72x/g723_24.c b/gnuradio-core/src/lib/g72x/g723_24.c deleted file mode 100644 index 452f4daeb..000000000 --- a/gnuradio-core/src/lib/g72x/g723_24.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g723_24.c - * - * Description: - * - * g723_24_encoder(), g723_24_decoder() - * - * These routines comprise an implementation of the CCITT G.723 24 Kbps - * ADPCM coding algorithm. Essentially, this implementation is identical to - * the bit level description except for a few deviations which take advantage - * of workstation attributes, such as hardware 2's complement arithmetic. - * - */ -#include "g72x.h" - -/* - * Maps G.723_24 code word to reconstructed scale factor normalized log - * magnitude values. - */ -static short _dqlntab[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048}; - -/* Maps G.723_24 code word to log of scale factor multiplier. */ -static short _witab[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128}; - -/* - * Maps G.723_24 code words to a set of values whose long and short - * term averages are computed and then compared to give an indication - * how stationary (steady state) the signal is. - */ -static short _fitab[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0}; - -static short qtab_723_24[3] = {8, 218, 331}; - -/* - * g723_24_encoder() - * - * Encodes a linear PCM, A-law or u-law input sample and returns its 3-bit code. - * Returns -1 if invalid input coding value. - */ -int -g723_24_encoder( - int sl, - int in_coding, - struct g72x_state *state_ptr) -{ - short sei, sezi, se, sez; /* ACCUM */ - short d; /* SUBTA */ - short y; /* MIX */ - short sr; /* ADDB */ - short dqsez; /* ADDC */ - short dq, i; - - switch (in_coding) { /* linearize input sample to 14-bit PCM */ - case AUDIO_ENCODING_ALAW: - sl = alaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_ULAW: - sl = ulaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_LINEAR: - sl >>= 2; /* sl of 14-bit dynamic range */ - break; - default: - return (-1); - } - - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - d = sl - se; /* d = estimation diff. */ - - /* quantize prediction difference d */ - y = step_size(state_ptr); /* quantizer step size */ - i = quantize(d, y, qtab_723_24, 3); /* i = ADPCM code */ - dq = reconstruct(i & 4, _dqlntab[i], y); /* quantized diff. */ - - sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconstructed signal */ - - dqsez = sr + sez - se; /* pole prediction diff. */ - - update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - return (i); -} - -/* - * g723_24_decoder() - * - * Decodes a 3-bit CCITT G.723_24 ADPCM code and returns - * the resulting 16-bit linear PCM, A-law or u-law sample value. - * -1 is returned if the output coding is unknown. - */ -int -g723_24_decoder( - int i, - int out_coding, - struct g72x_state *state_ptr) -{ - short sezi, sei, sez, se; /* ACCUM */ - short y; /* MIX */ - short sr; /* ADDB */ - short dq; - short dqsez; - - i &= 0x07; /* mask to get proper bits */ - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - y = step_size(state_ptr); /* adaptive quantizer step size */ - dq = reconstruct(i & 0x04, _dqlntab[i], y); /* unquantize pred diff */ - - sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq); /* reconst. signal */ - - dqsez = sr - se + sez; /* pole prediction diff. */ - - update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - switch (out_coding) { - case AUDIO_ENCODING_ALAW: - return (tandem_adjust_alaw(sr, se, y, i, 4, qtab_723_24)); - case AUDIO_ENCODING_ULAW: - return (tandem_adjust_ulaw(sr, se, y, i, 4, qtab_723_24)); - case AUDIO_ENCODING_LINEAR: - return (sr << 2); /* sr was of 14-bit dynamic range */ - default: - return (-1); - } -} diff --git a/gnuradio-core/src/lib/g72x/g723_40.c b/gnuradio-core/src/lib/g72x/g723_40.c deleted file mode 100644 index 4858baf40..000000000 --- a/gnuradio-core/src/lib/g72x/g723_40.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g723_40.c - * - * Description: - * - * g723_40_encoder(), g723_40_decoder() - * - * These routines comprise an implementation of the CCITT G.723 40Kbps - * ADPCM coding algorithm. Essentially, this implementation is identical to - * the bit level description except for a few deviations which - * take advantage of workstation attributes, such as hardware 2's - * complement arithmetic. - * - * The deviation from the bit level specification (lookup tables), - * preserves the bit level performance specifications. - * - * As outlined in the G.723 Recommendation, the algorithm is broken - * down into modules. Each section of code below is preceded by - * the name of the module which it is implementing. - * - */ -#include "g72x.h" - -/* - * Maps G.723_40 code word to ructeconstructed scale factor normalized log - * magnitude values. - */ -static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318, - 358, 395, 429, 459, 488, 514, 539, 566, - 566, 539, 514, 488, 459, 429, 395, 358, - 318, 274, 224, 169, 104, 28, -66, -2048}; - -/* Maps G.723_40 code word to log of scale factor multiplier. */ -static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200, - 4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272, - 22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512, - 3200, 1856, 1312, 1280, 1248, 768, 448, 448}; - -/* - * Maps G.723_40 code words to a set of values whose long and short - * term averages are computed and then compared to give an indication - * how stationary (steady state) the signal is. - */ -static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200, - 0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00, - 0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200, - 0x200, 0x200, 0x200, 0, 0, 0, 0, 0}; - -static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339, - 378, 413, 445, 475, 502, 528, 553}; - -/* - * g723_40_encoder() - * - * Encodes a 16-bit linear PCM, A-law or u-law input sample and retuens - * the resulting 5-bit CCITT G.723 40Kbps code. - * Returns -1 if the input coding value is invalid. - */ -int -g723_40_encoder( - int sl, - int in_coding, - struct g72x_state *state_ptr) -{ - short sei, sezi, se, sez; /* ACCUM */ - short d; /* SUBTA */ - short y; /* MIX */ - short sr; /* ADDB */ - short dqsez; /* ADDC */ - short dq, i; - - switch (in_coding) { /* linearize input sample to 14-bit PCM */ - case AUDIO_ENCODING_ALAW: - sl = alaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_ULAW: - sl = ulaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_LINEAR: - sl >>= 2; /* sl of 14-bit dynamic range */ - break; - default: - return (-1); - } - - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - d = sl - se; /* d = estimation difference */ - - /* quantize prediction difference */ - y = step_size(state_ptr); /* adaptive quantizer step size */ - i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */ - - dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */ - - sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */ - - dqsez = sr + sez - se; /* dqsez = pole prediction diff. */ - - update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - return (i); -} - -/* - * g723_40_decoder() - * - * Decodes a 5-bit CCITT G.723 40Kbps code and returns - * the resulting 16-bit linear PCM, A-law or u-law sample value. - * -1 is returned if the output coding is unknown. - */ -int -g723_40_decoder( - int i, - int out_coding, - struct g72x_state *state_ptr) -{ - short sezi, sei, sez, se; /* ACCUM */ - short y; /* MIX */ - short sr; /* ADDB */ - short dq; - short dqsez; - - i &= 0x1f; /* mask to get proper bits */ - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - y = step_size(state_ptr); /* adaptive quantizer step size */ - dq = reconstruct(i & 0x10, _dqlntab[i], y); /* estimation diff. */ - - sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */ - - dqsez = sr - se + sez; /* pole prediction diff. */ - - update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - switch (out_coding) { - case AUDIO_ENCODING_ALAW: - return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40)); - case AUDIO_ENCODING_ULAW: - return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40)); - case AUDIO_ENCODING_LINEAR: - return (sr << 2); /* sr was of 14-bit dynamic range */ - default: - return (-1); - } -} diff --git a/gnuradio-core/src/lib/g72x/g72x.c b/gnuradio-core/src/lib/g72x/g72x.c deleted file mode 100644 index 9a823c755..000000000 --- a/gnuradio-core/src/lib/g72x/g72x.c +++ /dev/null @@ -1,576 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#include <stdlib.h> -/* - * g72x.c - * - * Common routines for G.721 and G.723 conversions. - */ - -#include "g72x.h" - -static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, - 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000}; - -/* - * quan() - * - * quantizes the input val against the table of size short integers. - * It returns i if table[i - 1] <= val < table[i]. - * - * Using linear search for simple coding. - */ -static int -quan( - int val, - short *table, - int size) -{ - int i; - - for (i = 0; i < size; i++) - if (val < *table++) - break; - return (i); -} - -/* - * fmult() - * - * returns the integer product of the 14-bit integer "an" and - * "floating point" representation (4-bit exponent, 6-bit mantessa) "srn". - */ -static int -fmult( - int an, - int srn) -{ - short anmag, anexp, anmant; - short wanexp, wanmant; - short retval; - - anmag = (an > 0) ? an : ((-an) & 0x1FFF); - anexp = quan(anmag, power2, 15) - 6; - anmant = (anmag == 0) ? 32 : - (anexp >= 0) ? anmag >> anexp : anmag << -anexp; - wanexp = anexp + ((srn >> 6) & 0xF) - 13; - - wanmant = (anmant * (srn & 077) + 0x30) >> 4; - retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) : - (wanmant >> -wanexp); - - return (((an ^ srn) < 0) ? -retval : retval); -} - -/* - * g72x_init_state() - * - * This routine initializes and/or resets the g72x_state structure - * pointed to by 'state_ptr'. - * All the initial state values are specified in the CCITT G.721 document. - */ -void -g72x_init_state( - struct g72x_state *state_ptr) -{ - int cnta; - - state_ptr->yl = 34816; - state_ptr->yu = 544; - state_ptr->dms = 0; - state_ptr->dml = 0; - state_ptr->ap = 0; - for (cnta = 0; cnta < 2; cnta++) { - state_ptr->a[cnta] = 0; - state_ptr->pk[cnta] = 0; - state_ptr->sr[cnta] = 32; - } - for (cnta = 0; cnta < 6; cnta++) { - state_ptr->b[cnta] = 0; - state_ptr->dq[cnta] = 32; - } - state_ptr->td = 0; -} - -/* - * predictor_zero() - * - * computes the estimated signal from 6-zero predictor. - * - */ -int -predictor_zero( - struct g72x_state *state_ptr) -{ - int i; - int sezi; - - sezi = fmult(state_ptr->b[0] >> 2, state_ptr->dq[0]); - for (i = 1; i < 6; i++) /* ACCUM */ - sezi += fmult(state_ptr->b[i] >> 2, state_ptr->dq[i]); - return (sezi); -} -/* - * predictor_pole() - * - * computes the estimated signal from 2-pole predictor. - * - */ -int -predictor_pole( - struct g72x_state *state_ptr) -{ - return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) + - fmult(state_ptr->a[0] >> 2, state_ptr->sr[0])); -} -/* - * step_size() - * - * computes the quantization step size of the adaptive quantizer. - * - */ -int -step_size( - struct g72x_state *state_ptr) -{ - int y; - int dif; - int al; - - if (state_ptr->ap >= 256) - return (state_ptr->yu); - else { - y = state_ptr->yl >> 6; - dif = state_ptr->yu - y; - al = state_ptr->ap >> 2; - if (dif > 0) - y += (dif * al) >> 6; - else if (dif < 0) - y += (dif * al + 0x3F) >> 6; - return (y); - } -} - -/* - * quantize() - * - * Given a raw sample, 'd', of the difference signal and a - * quantization step size scale factor, 'y', this routine returns the - * ADPCM codeword to which that sample gets quantized. The step - * size scale factor division operation is done in the log base 2 domain - * as a subtraction. - */ -int -quantize( - int d, /* Raw difference signal sample */ - int y, /* Step size multiplier */ - short *table, /* quantization table */ - int size) /* table size of short integers */ -{ - short dqm; /* Magnitude of 'd' */ - short exp; /* Integer part of base 2 log of 'd' */ - short mant; /* Fractional part of base 2 log */ - short dl; /* Log of magnitude of 'd' */ - short dln; /* Step size scale factor normalized log */ - int i; - - /* - * LOG - * - * Compute base 2 log of 'd', and store in 'dl'. - */ - dqm = abs(d); - exp = quan(dqm >> 1, power2, 15); - mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */ - dl = (exp << 7) + mant; - - /* - * SUBTB - * - * "Divide" by step size multiplier. - */ - dln = dl - (y >> 2); - - /* - * QUAN - * - * Obtain codword i for 'd'. - */ - i = quan(dln, table, size); - if (d < 0) /* take 1's complement of i */ - return ((size << 1) + 1 - i); - else if (i == 0) /* take 1's complement of 0 */ - return ((size << 1) + 1); /* new in 1988 */ - else - return (i); -} -/* - * reconstruct() - * - * Returns reconstructed difference signal 'dq' obtained from - * codeword 'i' and quantization step size scale factor 'y'. - * Multiplication is performed in log base 2 domain as addition. - */ -int -reconstruct( - int sign, /* 0 for non-negative value */ - int dqln, /* G.72x codeword */ - int y) /* Step size multiplier */ -{ - short dql; /* Log of 'dq' magnitude */ - short dex; /* Integer part of log */ - short dqt; - short dq; /* Reconstructed difference signal sample */ - - dql = dqln + (y >> 2); /* ADDA */ - - if (dql < 0) { - return ((sign) ? -0x8000 : 0); - } else { /* ANTILOG */ - dex = (dql >> 7) & 15; - dqt = 128 + (dql & 127); - dq = (dqt << 7) >> (14 - dex); - return ((sign) ? (dq - 0x8000) : dq); - } -} - - -/* - * update() - * - * updates the state variables for each output code - */ -void -update( - int code_size, /* distinguish 723_40 with others */ - int y, /* quantizer step size */ - int wi, /* scale factor multiplier */ - int fi, /* for long/short term energies */ - int dq, /* quantized prediction difference */ - int sr, /* reconstructed signal */ - int dqsez, /* difference from 2-pole predictor */ - struct g72x_state *state_ptr) /* coder state pointer */ -{ - int cnt; - short mag, exp; /* Adaptive predictor, FLOAT A */ - short a2p = 0; /* LIMC */ - short a1ul; /* UPA1 */ - short pks1; /* UPA2 */ - short fa1; - char tr; /* tone/transition detector */ - short ylint, thr2, dqthr; - short ylfrac, thr1; - short pk0; - - pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */ - - mag = dq & 0x7FFF; /* prediction difference magnitude */ - /* TRANS */ - ylint = state_ptr->yl >> 15; /* exponent part of yl */ - ylfrac = (state_ptr->yl >> 10) & 0x1F; /* fractional part of yl */ - thr1 = (32 + ylfrac) << ylint; /* threshold */ - thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */ - dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */ - if (state_ptr->td == 0) /* signal supposed voice */ - tr = 0; - else if (mag <= dqthr) /* supposed data, but small mag */ - tr = 0; /* treated as voice */ - else /* signal is data (modem) */ - tr = 1; - - /* - * Quantizer scale factor adaptation. - */ - - /* FUNCTW & FILTD & DELAY */ - /* update non-steady state step size multiplier */ - state_ptr->yu = y + ((wi - y) >> 5); - - /* LIMB */ - if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */ - state_ptr->yu = 544; - else if (state_ptr->yu > 5120) - state_ptr->yu = 5120; - - /* FILTE & DELAY */ - /* update steady state step size multiplier */ - state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6); - - /* - * Adaptive predictor coefficients. - */ - if (tr == 1) { /* reset a's and b's for modem signal */ - state_ptr->a[0] = 0; - state_ptr->a[1] = 0; - state_ptr->b[0] = 0; - state_ptr->b[1] = 0; - state_ptr->b[2] = 0; - state_ptr->b[3] = 0; - state_ptr->b[4] = 0; - state_ptr->b[5] = 0; - } else { /* update a's and b's */ - pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */ - - /* update predictor pole a[1] */ - a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7); - if (dqsez != 0) { - fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0]; - if (fa1 < -8191) /* a2p = function of fa1 */ - a2p -= 0x100; - else if (fa1 > 8191) - a2p += 0xFF; - else - a2p += fa1 >> 5; - - if (pk0 ^ state_ptr->pk[1]) - /* LIMC */ - if (a2p <= -12160) - a2p = -12288; - else if (a2p >= 12416) - a2p = 12288; - else - a2p -= 0x80; - else if (a2p <= -12416) - a2p = -12288; - else if (a2p >= 12160) - a2p = 12288; - else - a2p += 0x80; - } - - /* TRIGB & DELAY */ - state_ptr->a[1] = a2p; - - /* UPA1 */ - /* update predictor pole a[0] */ - state_ptr->a[0] -= state_ptr->a[0] >> 8; - if (dqsez != 0){ - if (pks1 == 0) - state_ptr->a[0] += 192; - else - state_ptr->a[0] -= 192; - } - - /* LIMD */ - a1ul = 15360 - a2p; - if (state_ptr->a[0] < -a1ul) - state_ptr->a[0] = -a1ul; - else if (state_ptr->a[0] > a1ul) - state_ptr->a[0] = a1ul; - - /* UPB : update predictor zeros b[6] */ - for (cnt = 0; cnt < 6; cnt++) { - if (code_size == 5) /* for 40Kbps G.723 */ - state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9; - else /* for G.721 and 24Kbps G.723 */ - state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8; - if (dq & 0x7FFF) { /* XOR */ - if ((dq ^ state_ptr->dq[cnt]) >= 0) - state_ptr->b[cnt] += 128; - else - state_ptr->b[cnt] -= 128; - } - } - } - - for (cnt = 5; cnt > 0; cnt--) - state_ptr->dq[cnt] = state_ptr->dq[cnt-1]; - /* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */ - if (mag == 0) { - state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20; - } else { - exp = quan(mag, power2, 15); - state_ptr->dq[0] = (dq >= 0) ? - (exp << 6) + ((mag << 6) >> exp) : - (exp << 6) + ((mag << 6) >> exp) - 0x400; - } - - state_ptr->sr[1] = state_ptr->sr[0]; - /* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */ - if (sr == 0) { - state_ptr->sr[0] = 0x20; - } else if (sr > 0) { - exp = quan(sr, power2, 15); - state_ptr->sr[0] = (exp << 6) + ((sr << 6) >> exp); - } else if (sr > -32768) { - mag = -sr; - exp = quan(mag, power2, 15); - state_ptr->sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400; - } else - state_ptr->sr[0] = 0xFC20; - - /* DELAY A */ - state_ptr->pk[1] = state_ptr->pk[0]; - state_ptr->pk[0] = pk0; - - /* TONE */ - if (tr == 1) /* this sample has been treated as data */ - state_ptr->td = 0; /* next one will be treated as voice */ - else if (a2p < -11776) /* small sample-to-sample correlation */ - state_ptr->td = 1; /* signal may be data */ - else /* signal is voice */ - state_ptr->td = 0; - - /* - * Adaptation speed control. - */ - state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */ - state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */ - - if (tr == 1) - state_ptr->ap = 256; - else if (y < 1536) /* SUBTC */ - state_ptr->ap += (0x200 - state_ptr->ap) >> 4; - else if (state_ptr->td == 1) - state_ptr->ap += (0x200 - state_ptr->ap) >> 4; - else if (abs((state_ptr->dms << 2) - state_ptr->dml) >= - (state_ptr->dml >> 3)) - state_ptr->ap += (0x200 - state_ptr->ap) >> 4; - else - state_ptr->ap += (-state_ptr->ap) >> 4; -} - -/* - * tandem_adjust(sr, se, y, i, sign) - * - * At the end of ADPCM decoding, it simulates an encoder which may be receiving - * the output of this decoder as a tandem process. If the output of the - * simulated encoder differs from the input to this decoder, the decoder output - * is adjusted by one level of A-law or u-law codes. - * - * Input: - * sr decoder output linear PCM sample, - * se predictor estimate sample, - * y quantizer step size, - * i decoder input code, - * sign sign bit of code i - * - * Return: - * adjusted A-law or u-law compressed sample. - */ -int -tandem_adjust_alaw( - int sr, /* decoder output linear PCM sample */ - int se, /* predictor estimate sample */ - int y, /* quantizer step size */ - int i, /* decoder input code */ - int sign, - short *qtab) -{ - unsigned char sp; /* A-law compressed 8-bit code */ - short dx; /* prediction error */ - char id; /* quantized prediction error */ - int sd; /* adjusted A-law decoded sample value */ - int im; /* biased magnitude of i */ - int imx; /* biased magnitude of id */ - - if (sr <= -32768) - sr = -1; - sp = linear2alaw((sr >> 1) << 3); /* short to A-law compression */ - dx = (alaw2linear(sp) >> 2) - se; /* 16-bit prediction error */ - id = quantize(dx, y, qtab, sign - 1); - - if (id == i) { /* no adjustment on sp */ - return (sp); - } else { /* sp adjustment needed */ - /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */ - im = i ^ sign; /* 2's complement to biased unsigned */ - imx = id ^ sign; - - if (imx > im) { /* sp adjusted to next lower value */ - if (sp & 0x80) { - sd = (sp == 0xD5) ? 0x55 : - ((sp ^ 0x55) - 1) ^ 0x55; - } else { - sd = (sp == 0x2A) ? 0x2A : - ((sp ^ 0x55) + 1) ^ 0x55; - } - } else { /* sp adjusted to next higher value */ - if (sp & 0x80) - sd = (sp == 0xAA) ? 0xAA : - ((sp ^ 0x55) + 1) ^ 0x55; - else - sd = (sp == 0x55) ? 0xD5 : - ((sp ^ 0x55) - 1) ^ 0x55; - } - return (sd); - } -} - -int -tandem_adjust_ulaw( - int sr, /* decoder output linear PCM sample */ - int se, /* predictor estimate sample */ - int y, /* quantizer step size */ - int i, /* decoder input code */ - int sign, - short *qtab) -{ - unsigned char sp; /* u-law compressed 8-bit code */ - short dx; /* prediction error */ - char id; /* quantized prediction error */ - int sd; /* adjusted u-law decoded sample value */ - int im; /* biased magnitude of i */ - int imx; /* biased magnitude of id */ - - if (sr <= -32768) - sr = 0; - sp = linear2ulaw(sr << 2); /* short to u-law compression */ - dx = (ulaw2linear(sp) >> 2) - se; /* 16-bit prediction error */ - id = quantize(dx, y, qtab, sign - 1); - if (id == i) { - return (sp); - } else { - /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */ - im = i ^ sign; /* 2's complement to biased unsigned */ - imx = id ^ sign; - if (imx > im) { /* sp adjusted to next lower value */ - if (sp & 0x80) - sd = (sp == 0xFF) ? 0x7E : sp + 1; - else - sd = (sp == 0) ? 0 : sp - 1; - - } else { /* sp adjusted to next higher value */ - if (sp & 0x80) - sd = (sp == 0x80) ? 0x80 : sp - 1; - else - sd = (sp == 0x7F) ? 0xFE : sp + 1; - } - return (sd); - } -} - - - - - - - - - - - - diff --git a/gnuradio-core/src/lib/g72x/g72x.h b/gnuradio-core/src/lib/g72x/g72x.h deleted file mode 100644 index 33807171a..000000000 --- a/gnuradio-core/src/lib/g72x/g72x.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g72x.h - * - * Header file for CCITT conversion routines. - * - */ -#ifndef _G72X_H -#define _G72X_H - -#define AUDIO_ENCODING_ULAW (1) /* ISDN u-law */ -#define AUDIO_ENCODING_ALAW (2) /* ISDN A-law */ -#define AUDIO_ENCODING_LINEAR (3) /* PCM 2's-complement (0-center) */ - -/* - * The following is the definition of the state structure - * used by the G.721/G.723 encoder and decoder to preserve their internal - * state between successive calls. The meanings of the majority - * of the state structure fields are explained in detail in the - * CCITT Recommendation G.721. The field names are essentially indentical - * to variable names in the bit level description of the coding algorithm - * included in this Recommendation. - */ -struct g72x_state { - long yl; /* Locked or steady state step size multiplier. */ - short yu; /* Unlocked or non-steady state step size multiplier. */ - short dms; /* Short term energy estimate. */ - short dml; /* Long term energy estimate. */ - short ap; /* Linear weighting coefficient of 'yl' and 'yu'. */ - - short a[2]; /* Coefficients of pole portion of prediction filter. */ - short b[6]; /* Coefficients of zero portion of prediction filter. */ - short pk[2]; /* - * Signs of previous two samples of a partially - * reconstructed signal. - */ - short dq[6]; /* - * Previous 6 samples of the quantized difference - * signal represented in an internal floating point - * format. - */ - short sr[2]; /* - * Previous 2 samples of the quantized difference - * signal represented in an internal floating point - * format. - */ - char td; /* delayed tone detect, new in 1988 version */ -}; - -/* External function definitions. */ - -extern void g72x_init_state(struct g72x_state *); -extern int g721_encoder( - int sample, - int in_coding, - struct g72x_state *state_ptr); -extern int g721_decoder( - int code, - int out_coding, - struct g72x_state *state_ptr); -extern int g723_24_encoder( - int sample, - int in_coding, - struct g72x_state *state_ptr); -extern int g723_24_decoder( - int code, - int out_coding, - struct g72x_state *state_ptr); -extern int g723_40_encoder( - int sample, - int in_coding, - struct g72x_state *state_ptr); -extern int g723_40_decoder( - int code, - int out_coding, - struct g72x_state *state_ptr); - - -extern int -quantize( - int d, - int y, - short *table, - int size); -extern int reconstruct(int,int,int);void - -extern update( - int code_size, - int y, - int wi, - int fi, - int dq, - int sr, - int dqsez, - struct g72x_state *state_ptr); -extern int -tandem_adjust_alaw( - int sr, - int se, - int y, - int i, - int sign, - short *qtab); - -extern int -tandem_adjust_ulaw( - int sr, - int se, - int y, - int i, - int sign, - short *qtab); - -extern unsigned char -linear2alaw( - int pcm_val); - -extern int -alaw2linear( - unsigned char a_val); - -extern unsigned char -linear2ulaw(int pcm_val); - -extern int ulaw2linear( unsigned char u_val); - -extern int predictor_zero(struct g72x_state *state_ptr); - -extern int predictor_pole( struct g72x_state *state_ptr); -extern int step_size( struct g72x_state *state_ptr); -#endif /* !_G72X_H */ diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt new file mode 100644 index 000000000..cd850ca30 --- /dev/null +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -0,0 +1,294 @@ +# Copyright 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +######################################################################## +# Handle the generated sine table +######################################################################## +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py > + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +include(AddFileDependencies) +ADD_FILE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +######################################################################## +# Handle the generated constants +######################################################################## +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "import time;print time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime())" + OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE +) +message(STATUS "Loading build date ${BUILD_DATE} into gr_constants...") + +message(STATUS "Loading version ${VERSION} into gr_constants...") + +file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${GR_CONF_DIR}" SYSCONFDIR) +file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${GR_PKG_CONF_DIR}" GR_PREFSDIR) + +#double escape for windows backslash path separators +string(REPLACE "\\" "\\\\" prefix ${prefix}) +string(REPLACE "\\" "\\\\" SYSCONFDIR ${SYSCONFDIR}) +string(REPLACE "\\" "\\\\" GR_PREFSDIR ${GR_PREFSDIR}) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.cc.in + ${CMAKE_CURRENT_BINARY_DIR}/gr_constants.cc +@ONLY) + +list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gr_constants.cc) + +######################################################################## +# Append gnuradio-core library sources +######################################################################## +list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fast_atan2f.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fft_vcc_fftw.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss_generic.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_char_to_float.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_char.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_short.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_uchar.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_glfsr.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_interleaved_short_to_complex.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_short_to_float.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_uchar_to_float.cc + ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c +) + +######################################################################## +# Append gnuradio-core test sources +######################################################################## +list(APPEND test_gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/qa_general.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_circular_file.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_cpm.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_firdes.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_nco.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_vco.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_math.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_lfsr.cc +) + +######################################################################## +# Install runtime headers +######################################################################## +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/gr_core_api.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_expj.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fft_vcc_fftw.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_nco.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_vco.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_log2_const.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_math.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_nco.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_simple_framer_sync.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vco.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_cc.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_ff.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_cc.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_ff.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_char_to_float.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_char.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_short.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_float_to_uchar.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_glfsr.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_interleaved_short_to_complex.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_32k.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_short_to_float.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_uchar_to_float.h + ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.h + ${CMAKE_CURRENT_SOURCE_DIR}/random.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +######################################################################## +# Install swig headers +######################################################################## +if(ENABLE_PYTHON) +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/general.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.i + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_cc.i + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc_ff.i + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_cc.i + ${CMAKE_CURRENT_SOURCE_DIR}/gri_agc2_ff.i + ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" +) +endif(ENABLE_PYTHON) + +######################################################################## +# Handle triple-threat files that have cc, h, and i +######################################################################## +set(gr_core_general_triple_threats + complex_vec_test + gr_additive_scrambler_bb + gr_agc_cc + gr_agc_ff + gr_agc2_cc + gr_agc2_ff + gr_align_on_samplenumbers_ss + gr_bin_statistics_f + gr_bytes_to_syms + gr_char_to_float + gr_check_counting_s + gr_check_lfsr_32k_s + gr_complex_to_interleaved_short + gr_complex_to_xxx + gr_conjugate_cc + gr_copy + gr_cpfsk_bc + gr_cpm + gr_ctcss_squelch_ff + gr_decode_ccsds_27_fb + gr_diff_decoder_bb + gr_diff_encoder_bb + gr_diff_phasor_cc + gr_dpll_bb + gr_deinterleave + gr_delay + gr_encode_ccsds_27_bb + gr_fake_channel_coder_pp + gr_feedforward_agc_cc + gr_feval + gr_fft_vcc + gr_fft_vfc + gr_firdes + gr_float_to_char + gr_float_to_complex + gr_float_to_short + gr_float_to_uchar + gr_fmdet_cf + gr_frequency_modulator_fc + gr_framer_sink_1 + gr_glfsr_source_b + gr_glfsr_source_f + gr_head + gr_int_to_float + gr_interleave + gr_interleaved_short_to_complex + gr_iqcomp_cc + gr_keep_one_in_n + gr_kludge_copy + gr_lfsr_32k_source_s + gr_map_bb + gr_nlog10_ff + gr_nop + gr_null_sink + gr_null_source + gr_pa_2x2_phase_combiner + gr_packet_sink + gr_peak_detector2_fb + gr_phase_modulator_fc + gr_pll_carriertracking_cc + gr_pll_freqdet_cf + gr_pll_refout_cc + gr_pn_correlator_cc + gr_prefs + gr_probe_avg_mag_sqrd_c + gr_probe_avg_mag_sqrd_cf + gr_probe_avg_mag_sqrd_f + gr_probe_signal_f + gr_pwr_squelch_cc + gr_pwr_squelch_ff + gr_quadrature_demod_cf + gr_rail_ff + gr_regenerate_bb + gr_remez + gr_rms_cf + gr_rms_ff + gr_repeat + gr_short_to_float + gr_simple_correlator + gr_simple_framer + gr_simple_squelch_cc + gr_skiphead + gr_squash_ff + gr_squelch_base_cc + gr_squelch_base_ff + gr_stream_mux + gr_stream_to_streams + gr_stream_to_vector + gr_streams_to_stream + gr_streams_to_vector + gr_stretch_ff + gr_test + gr_threshold_ff + gr_throttle + gr_transcendental + gr_uchar_to_float + gr_vco_f + gr_vector_to_stream + gr_vector_to_streams + gr_unpack_k_bits_bb + gr_wavelet_ff + gr_wvps_ff + gr_descrambler_bb + gr_scrambler_bb + gr_probe_mpsk_snr_c + gr_probe_density_b + gr_annotator_alltoall + gr_annotator_1to1 + gr_burst_tagger + gr_correlate_access_code_tag_bb +) + +foreach(file_tt ${gr_core_general_triple_threats}) + list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") + if(ENABLE_PYTHON) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") + endif(ENABLE_PYTHON) +endforeach(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 007bedc00..260867931 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -44,24 +44,18 @@ libgeneral_la_SOURCES = \ gr_agc2_ff.cc \ gr_align_on_samplenumbers_ss.cc \ gr_bin_statistics_f.cc \ - gr_binary_slicer_fb.cc \ gr_bytes_to_syms.cc \ gr_char_to_float.cc \ gr_check_counting_s.cc \ gr_check_lfsr_32k_s.cc \ gr_circular_file.cc \ - gr_clock_recovery_mm_cc.cc \ - gr_clock_recovery_mm_ff.cc \ gr_complex_to_interleaved_short.cc \ gr_complex_to_xxx.cc \ gr_conjugate_cc.cc \ gr_copy.cc \ - gr_constellation_decoder_cb.cc \ - gr_correlate_access_code_bb.cc \ - gr_costas_loop_cc.cc \ gr_count_bits.cc \ gr_cpfsk_bc.cc \ - gr_crc32.cc \ + gr_cpm.cc \ gr_ctcss_squelch_ff.cc \ gr_decode_ccsds_27_fb.cc \ gr_deinterleave.cc \ @@ -79,7 +73,6 @@ libgeneral_la_SOURCES = \ gr_fft_vcc_fftw.cc \ gr_fft_vfc.cc \ gr_firdes.cc \ - gr_fll_band_edge_cc.cc \ gr_float_to_char.cc \ gr_float_to_complex.cc \ gr_float_to_short.cc \ @@ -97,22 +90,12 @@ libgeneral_la_SOURCES = \ gr_keep_one_in_n.cc \ gr_kludge_copy.cc \ gr_lfsr_32k_source_s.cc \ - gr_lms_dfe_cc.cc \ - gr_lms_dfe_ff.cc \ gr_map_bb.cc \ gr_misc.cc \ - gr_mpsk_receiver_cc.cc \ gr_nlog10_ff.cc \ gr_nop.cc \ gr_null_sink.cc \ gr_null_source.cc \ - gr_ofdm_frame_acquisition.cc \ - gr_ofdm_cyclic_prefixer.cc \ - gr_ofdm_demapper_vcb.cc \ - gr_ofdm_mapper_bcv.cc \ - gr_ofdm_frame_sink.cc \ - gr_ofdm_insert_preamble.cc \ - gr_ofdm_sampler.cc \ gr_pa_2x2_phase_combiner.cc \ gr_packet_sink.cc \ gr_peak_detector2_fb.cc \ @@ -165,6 +148,7 @@ libgeneral_la_SOURCES = \ gr_wvps_ff.cc \ gri_add_const_ss_generic.cc \ gri_char_to_float.cc \ + gri_control_loop.cc \ gri_debugger_hook.cc \ gri_fft.cc \ gri_float_to_char.cc \ @@ -188,6 +172,7 @@ libgeneral_la_SOURCES = \ libgeneral_qa_la_SOURCES = \ qa_general.cc \ qa_gr_circular_file.cc \ + qa_gr_cpm.cc \ qa_gr_firdes.cc \ qa_gr_fxpt.cc \ qa_gr_fxpt_nco.cc \ @@ -196,6 +181,7 @@ libgeneral_qa_la_SOURCES = \ qa_gri_lfsr.cc grinclude_HEADERS = \ + gr_core_api.h \ complex_vec_test.h \ gr_additive_scrambler_bb.h \ gr_agc_cc.h \ @@ -204,24 +190,18 @@ grinclude_HEADERS = \ gr_agc2_ff.h \ gr_align_on_samplenumbers_ss.h \ gr_bin_statistics_f.h \ - gr_binary_slicer_fb.h \ gr_bytes_to_syms.h \ gr_char_to_float.h \ gr_check_counting_s.h \ gr_check_lfsr_32k_s.h \ gr_circular_file.h \ - gr_clock_recovery_mm_cc.h \ - gr_clock_recovery_mm_ff.h \ gr_complex_to_interleaved_short.h \ gr_complex_to_xxx.h \ gr_conjugate_cc.h \ - gr_constellation_decoder_cb.h \ gr_copy.h \ - gr_correlate_access_code_bb.h \ - gr_costas_loop_cc.h \ gr_count_bits.h \ gr_cpfsk_bc.h \ - gr_crc32.h \ + gr_cpm.h \ gr_ctcss_squelch_ff.h \ gr_decode_ccsds_27_fb.h \ gr_diff_decoder_bb.h \ @@ -239,7 +219,6 @@ grinclude_HEADERS = \ gr_fft_vcc_fftw.h \ gr_fft_vfc.h \ gr_firdes.h \ - gr_fll_band_edge_cc.h \ gr_float_to_char.h \ gr_float_to_complex.h \ gr_float_to_short.h \ @@ -259,25 +238,15 @@ grinclude_HEADERS = \ gr_keep_one_in_n.h \ gr_kludge_copy.h \ gr_lfsr_32k_source_s.h \ - gr_lms_dfe_cc.h \ - gr_lms_dfe_ff.h \ gr_log2_const.h \ gr_map_bb.h \ gr_math.h \ gr_misc.h \ - gr_mpsk_receiver_cc.h \ gr_nco.h \ gr_nlog10_ff.h \ gr_nop.h \ gr_null_sink.h \ gr_null_source.h \ - gr_ofdm_frame_acquisition.h \ - gr_ofdm_cyclic_prefixer.h \ - gr_ofdm_demapper_vcb.h \ - gr_ofdm_mapper_bcv.h \ - gr_ofdm_frame_sink.h \ - gr_ofdm_insert_preamble.h \ - gr_ofdm_sampler.h \ gr_pa_2x2_phase_combiner.h \ gr_packet_sink.h \ gr_peak_detector2_fb.h \ @@ -337,6 +306,7 @@ grinclude_HEADERS = \ gri_agc2_cc.h \ gri_agc2_ff.h \ gri_char_to_float.h \ + gri_control_loop.h \ gri_debugger_hook.h \ gri_fft.h \ gri_float_to_char.h \ @@ -364,6 +334,7 @@ grinclude_HEADERS = \ noinst_HEADERS = \ qa_general.h \ qa_gr_circular_file.h \ + qa_gr_cpm.h \ qa_gr_firdes.h \ qa_gr_fxpt.h \ qa_gr_fxpt_nco.h \ @@ -382,22 +353,16 @@ swiginclude_HEADERS = \ gr_agc2_ff.i \ gr_align_on_samplenumbers_ss.i \ gr_bin_statistics_f.i \ - gr_binary_slicer_fb.i \ gr_bytes_to_syms.i \ gr_char_to_float.i \ gr_check_counting_s.i \ gr_check_lfsr_32k_s.i \ - gr_clock_recovery_mm_cc.i \ - gr_clock_recovery_mm_ff.i \ gr_complex_to_interleaved_short.i \ gr_complex_to_xxx.i \ gr_conjugate_cc.i \ - gr_constellation_decoder_cb.i \ gr_copy.i \ - gr_correlate_access_code_bb.i \ - gr_costas_loop_cc.i \ gr_cpfsk_bc.i \ - gr_crc32.i \ + gr_cpm.i \ gr_ctcss_squelch_ff.i \ gr_decode_ccsds_27_fb.i \ gr_diff_decoder_bb.i \ @@ -413,7 +378,6 @@ swiginclude_HEADERS = \ gr_fft_vcc.i \ gr_fft_vfc.i \ gr_firdes.i \ - gr_fll_band_edge_cc.i \ gr_float_to_char.i \ gr_float_to_complex.i \ gr_float_to_short.i \ @@ -431,21 +395,11 @@ swiginclude_HEADERS = \ gr_keep_one_in_n.i \ gr_kludge_copy.i \ gr_lfsr_32k_source_s.i \ - gr_lms_dfe_cc.i \ - gr_lms_dfe_ff.i \ gr_map_bb.i \ - gr_mpsk_receiver_cc.i \ gr_nlog10_ff.i \ gr_nop.i \ gr_null_sink.i \ gr_null_source.i \ - gr_ofdm_frame_acquisition.i \ - gr_ofdm_cyclic_prefixer.i \ - gr_ofdm_demapper_vcb.i \ - gr_ofdm_mapper_bcv.i \ - gr_ofdm_frame_sink.i \ - gr_ofdm_insert_preamble.i \ - gr_ofdm_sampler.i \ gr_pa_2x2_phase_combiner.i \ gr_packet_sink.i \ gr_peak_detector2_fb.i \ @@ -498,6 +452,7 @@ swiginclude_HEADERS = \ gri_agc_ff.i \ gri_agc2_cc.i \ gri_agc2_ff.i \ + gri_control_loop.i \ gr_descrambler_bb.i \ gr_scrambler_bb.i \ gr_probe_mpsk_snr_c.i \ diff --git a/gnuradio-core/src/lib/general/complex_vec_test.h b/gnuradio-core/src/lib/general/complex_vec_test.h index d13dedf63..be4de41fb 100644 --- a/gnuradio-core/src/lib/general/complex_vec_test.h +++ b/gnuradio-core/src/lib/general/complex_vec_test.h @@ -1,27 +1,28 @@ +#include <gr_core_api.h> #include <vector> #include <complex> -std::vector<std::complex<float> > +GR_CORE_API std::vector<std::complex<float> > complex_vec_test0(); -std::vector<std::complex<float> > +GR_CORE_API std::vector<std::complex<float> > complex_vec_test1(const std::vector<std::complex<float> > &input); -std::complex<float> +GR_CORE_API std::complex<float> complex_scalar_test0(); -std::complex<float> +GR_CORE_API std::complex<float> complex_scalar_test1(std::complex<float> input); -std::vector<int> +GR_CORE_API std::vector<int> int_vec_test0(); -std::vector<int> +GR_CORE_API std::vector<int> int_vec_test1(const std::vector<int> &input); -std::vector<float> +GR_CORE_API std::vector<float> float_vec_test0(); -std::vector<float> +GR_CORE_API std::vector<float> float_vec_test1(const std::vector<float> &input); diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index beedeb0a9..0a3200741 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,6 +22,7 @@ %{ +#include <gri_control_loop.h> #include <gr_nop.h> #include <gr_null_sink.h> #include <gr_null_source.h> @@ -70,7 +71,6 @@ #include <gr_fake_channel_coder_pp.h> #include <gr_throttle.h> #include <gr_transcendental.h> -#include <gr_mpsk_receiver_cc.h> #include <gr_stream_mux.h> #include <gr_stream_to_streams.h> #include <gr_streams_to_stream.h> @@ -78,13 +78,8 @@ #include <gr_vector_to_streams.h> #include <gr_conjugate_cc.h> #include <gr_vco_f.h> -#include <gr_crc32.h> #include <gr_threshold_ff.h> -#include <gr_clock_recovery_mm_ff.h> -#include <gr_clock_recovery_mm_cc.h> #include <gr_packet_sink.h> -#include <gr_lms_dfe_cc.h> -#include <gr_lms_dfe_ff.h> #include <gr_dpll_bb.h> #include <gr_fmdet_cf.h> #include <gr_pll_freqdet_cf.h> @@ -95,14 +90,7 @@ #include <gr_probe_avg_mag_sqrd_cf.h> #include <gr_probe_avg_mag_sqrd_f.h> #include <gr_probe_signal_f.h> -#include <gr_ofdm_frame_acquisition.h> -#include <gr_ofdm_cyclic_prefixer.h> -#include <gr_ofdm_mapper_bcv.h> -#include <gr_ofdm_frame_sink.h> -#include <gr_ofdm_insert_preamble.h> -#include <gr_ofdm_sampler.h> #include <gr_regenerate_bb.h> -#include <gr_costas_loop_cc.h> #include <gr_pa_2x2_phase_combiner.h> #include <gr_kludge_copy.h> #include <gr_prefs.h> @@ -110,10 +98,7 @@ #include <gr_test_types.h> #include <gr_test.h> #include <gr_unpack_k_bits_bb.h> -#include <gr_correlate_access_code_bb.h> #include <gr_diff_phasor_cc.h> -#include <gr_constellation_decoder_cb.h> -#include <gr_binary_slicer_fb.h> #include <gr_diff_encoder_bb.h> #include <gr_diff_decoder_bb.h> #include <gr_framer_sink_1.h> @@ -141,15 +126,16 @@ #include <gr_wavelet_ff.h> #include <gr_wvps_ff.h> #include <gr_copy.h> -#include <gr_fll_band_edge_cc.h> #include <gr_additive_scrambler_bb.h> #include <complex_vec_test.h> #include <gr_annotator_alltoall.h> #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" %include "gr_nop.i" %include "gr_null_sink.i" %include "gr_null_source.i" @@ -198,7 +184,6 @@ %include "gr_fake_channel_coder_pp.i" %include "gr_throttle.i" %include "gr_transcendental.i" -%include "gr_mpsk_receiver_cc.i" %include "gr_stream_mux.i" %include "gr_stream_to_streams.i" %include "gr_streams_to_stream.i" @@ -206,13 +191,8 @@ %include "gr_vector_to_streams.i" %include "gr_conjugate_cc.i" %include "gr_vco_f.i" -%include "gr_crc32.i" %include "gr_threshold_ff.i" -%include "gr_clock_recovery_mm_ff.i" -%include "gr_clock_recovery_mm_cc.i" %include "gr_packet_sink.i" -%include "gr_lms_dfe_cc.i" -%include "gr_lms_dfe_ff.i" %include "gr_dpll_bb.i" %include "gr_fmdet_cf.i" %include "gr_pll_freqdet_cf.i" @@ -223,14 +203,7 @@ %include "gr_probe_avg_mag_sqrd_cf.i" %include "gr_probe_avg_mag_sqrd_f.i" %include "gr_probe_signal_f.i" -%include "gr_ofdm_frame_acquisition.i" -%include "gr_ofdm_cyclic_prefixer.i" -%include "gr_ofdm_mapper_bcv.i" -%include "gr_ofdm_frame_sink.i" -%include "gr_ofdm_insert_preamble.i" -%include "gr_ofdm_sampler.i" %include "gr_regenerate_bb.i" -%include "gr_costas_loop_cc.i" %include "gr_pa_2x2_phase_combiner.i" %include "gr_kludge_copy.i" %include "gr_prefs.i" @@ -238,10 +211,7 @@ %include "gr_test_types.h" %include "gr_test.i" %include "gr_unpack_k_bits_bb.i" -%include "gr_correlate_access_code_bb.i" %include "gr_diff_phasor_cc.i" -%include "gr_constellation_decoder_cb.i" -%include "gr_binary_slicer_fb.i" %include "gr_diff_encoder_bb.i" %include "gr_diff_decoder_bb.i" %include "gr_framer_sink_1.i" @@ -269,10 +239,10 @@ %include "gr_wavelet_ff.i" %include "gr_wvps_ff.i" %include "gr_copy.i" -%include "gr_fll_band_edge_cc.i" %include "gr_additive_scrambler_bb.i" %include "complex_vec_test.i" %include "gr_annotator_alltoall.i" %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_additive_scrambler_bb.h b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h index 6c9493050..4c7c8f87e 100644 --- a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h +++ b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H #define INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include "gri_lfsr.h" class gr_additive_scrambler_bb; typedef boost::shared_ptr<gr_additive_scrambler_bb> gr_additive_scrambler_bb_sptr; -gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count=0); +GR_CORE_API gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count=0); /*! * Scramble an input stream using an LFSR. This block works on the LSB only @@ -48,9 +49,9 @@ gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, * \ingroup coding_blk */ -class gr_additive_scrambler_bb : public gr_sync_block +class GR_CORE_API gr_additive_scrambler_bb : public gr_sync_block { - friend gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count); + friend GR_CORE_API gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count); gri_lfsr d_lfsr; int d_count; diff --git a/gnuradio-core/src/lib/general/gr_agc2_cc.h b/gnuradio-core/src/lib/general/gr_agc2_cc.h index 0eb20afb9..6127c3aa7 100644 --- a/gnuradio-core/src/lib/general/gr_agc2_cc.h +++ b/gnuradio-core/src/lib/general/gr_agc2_cc.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_AGC2_CC_H #define INCLUDED_GR_AGC2_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gri_agc2_cc.h> class gr_agc2_cc; typedef boost::shared_ptr<gr_agc2_cc> gr_agc2_cc_sptr; -gr_agc2_cc_sptr +GR_CORE_API gr_agc2_cc_sptr gr_make_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); /*! @@ -39,9 +40,9 @@ gr_make_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float refere * For Power the absolute value of the complex number is used. */ -class gr_agc2_cc : public gr_sync_block, public gri_agc2_cc +class GR_CORE_API gr_agc2_cc : public gr_sync_block, public gri_agc2_cc { - friend gr_agc2_cc_sptr gr_make_agc2_cc (float attack_rate, float decay_rate, float reference, + friend GR_CORE_API gr_agc2_cc_sptr gr_make_agc2_cc (float attack_rate, float decay_rate, float reference, float gain, float max_gain); gr_agc2_cc (float attack_rate, float decay_rate, float reference, float gain, float max_gain); diff --git a/gnuradio-core/src/lib/general/gr_agc2_ff.h b/gnuradio-core/src/lib/general/gr_agc2_ff.h index ef470765f..269d940d4 100644 --- a/gnuradio-core/src/lib/general/gr_agc2_ff.h +++ b/gnuradio-core/src/lib/general/gr_agc2_ff.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_AGC2_FF_H #define INCLUDED_GR_AGC2_FF_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gri_agc2_ff.h> class gr_agc2_ff; typedef boost::shared_ptr<gr_agc2_ff> gr_agc2_ff_sptr; -gr_agc2_ff_sptr +GR_CORE_API gr_agc2_ff_sptr gr_make_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); /*! @@ -38,9 +39,9 @@ gr_make_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float refere * Power is approximated by absolute value */ -class gr_agc2_ff : public gr_sync_block, public gri_agc2_ff +class GR_CORE_API gr_agc2_ff : public gr_sync_block, public gri_agc2_ff { - friend gr_agc2_ff_sptr gr_make_agc2_ff (float attack_rate, float decay_rate, + friend GR_CORE_API gr_agc2_ff_sptr gr_make_agc2_ff (float attack_rate, float decay_rate, float reference, float gain, float max_gain); gr_agc2_ff (float attack_rate, float decay_rate, float reference, float gain, float max_gain); diff --git a/gnuradio-core/src/lib/general/gr_agc_cc.h b/gnuradio-core/src/lib/general/gr_agc_cc.h index 43a5de6c7..f348fff91 100644 --- a/gnuradio-core/src/lib/general/gr_agc_cc.h +++ b/gnuradio-core/src/lib/general/gr_agc_cc.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_AGC_CC_H #define INCLUDED_GR_AGC_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gri_agc_cc.h> class gr_agc_cc; typedef boost::shared_ptr<gr_agc_cc> gr_agc_cc_sptr; -gr_agc_cc_sptr +GR_CORE_API gr_agc_cc_sptr gr_make_agc_cc (float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); /*! @@ -38,9 +39,9 @@ gr_make_agc_cc (float rate = 1e-4, float reference = 1.0, * For Power the absolute value of the complex number is used. */ -class gr_agc_cc : public gr_sync_block, public gri_agc_cc +class GR_CORE_API gr_agc_cc : public gr_sync_block, public gri_agc_cc { - friend gr_agc_cc_sptr gr_make_agc_cc (float rate, float reference, + friend GR_CORE_API gr_agc_cc_sptr gr_make_agc_cc (float rate, float reference, float gain, float max_gain); gr_agc_cc (float rate, float reference, float gain, float max_gain); diff --git a/gnuradio-core/src/lib/general/gr_agc_ff.h b/gnuradio-core/src/lib/general/gr_agc_ff.h index 7cb167fca..94db9eef5 100644 --- a/gnuradio-core/src/lib/general/gr_agc_ff.h +++ b/gnuradio-core/src/lib/general/gr_agc_ff.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_AGC_FF_H #define INCLUDED_GR_AGC_FF_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gri_agc_ff.h> class gr_agc_ff; typedef boost::shared_ptr<gr_agc_ff> gr_agc_ff_sptr; -gr_agc_ff_sptr +GR_CORE_API gr_agc_ff_sptr gr_make_agc_ff (float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); @@ -39,9 +40,9 @@ gr_make_agc_ff (float rate = 1e-4, float reference = 1.0, * Power is approximated by absolute value */ -class gr_agc_ff : public gr_sync_block, public gri_agc_ff +class GR_CORE_API gr_agc_ff : public gr_sync_block, public gri_agc_ff { - friend gr_agc_ff_sptr gr_make_agc_ff (float rate, float reference, + friend GR_CORE_API gr_agc_ff_sptr gr_make_agc_ff (float rate, float reference, float gain, float max_gain); gr_agc_ff (float rate, float reference, float gain, float max_gain); diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h index 5038e168b..61f70ee96 100644 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h +++ b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H #define INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H +#include <gr_core_api.h> #include <gr_block.h> /*! @@ -45,19 +46,19 @@ class gr_align_on_samplenumbers_ss; typedef boost::shared_ptr<gr_align_on_samplenumbers_ss> gr_align_on_samplenumbers_ss_sptr; -gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan=2, int align_interval=128); +GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan=2, int align_interval=128); -class gr_align_on_samplenumbers_ss : public gr_block +class GR_CORE_API gr_align_on_samplenumbers_ss : public gr_block { int d_align_interval; int d_sample_counter; int d_nchan; bool d_in_presync; unsigned int d_ninputs; - class align_state { + class GR_CORE_API align_state { public: unsigned int ucounter_end; unsigned int ucounter_begin; @@ -72,7 +73,7 @@ class gr_align_on_samplenumbers_ss : public gr_block }; std::vector<align_state> d_state; - friend gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan,int align_interval); + friend GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan,int align_interval); gr_align_on_samplenumbers_ss (int nchan,int align_interval); public: diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 511b356e5..d12bfbf04 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -69,10 +69,10 @@ gr_annotator_1to1::work (int noutput_items, for(int i = 0; i < ninputs; i++) { abs_N = nitems_read(i); - std::vector<pmt::pmt_t> all_tags; + std::vector<gr_tag_t> all_tags; get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); - std::vector<pmt::pmt_t>::iterator itr; + std::vector<gr_tag_t>::iterator itr; for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { d_stored_tags.push_back(*itr); } diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h index 4abc5b051..a62720224 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_ANNOTATOR_1TO1_H #define INCLUDED_GR_ANNOTATOR_1TO1_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_annotator_1to1; typedef boost::shared_ptr<gr_annotator_1to1> gr_annotator_1to1_sptr; // public constructor -gr_annotator_1to1_sptr +GR_CORE_API gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); /*! @@ -45,7 +46,7 @@ gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); * * This block is only meant for testing and showing how to use the tags. */ -class gr_annotator_1to1 : public gr_sync_block +class GR_CORE_API gr_annotator_1to1 : public gr_sync_block { public: ~gr_annotator_1to1 (); @@ -53,7 +54,7 @@ class gr_annotator_1to1 : public gr_sync_block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - std::vector<pmt::pmt_t> data() const + std::vector<gr_tag_t> data() const { return d_stored_tags; } @@ -65,9 +66,9 @@ protected: size_t d_itemsize; uint64_t d_when; uint64_t d_tag_counter; - std::vector<pmt::pmt_t> d_stored_tags; + std::vector<gr_tag_t> d_stored_tags; - friend gr_annotator_1to1_sptr + friend GR_CORE_API gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i index f29ecbf53..2c8149a3c 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,15 +22,4 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); -gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when, - size_t sizeof_stream_item); - -class gr_annotator_1to1 : public gr_sync_block -{ -public: - std::vector<pmt::pmt_t> data() const; - -private: - gr_annotator_1to1 (int when, size_t sizeof_stream_item); -}; - +%include <gr_annotator_1to1.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index 344fd088b..dd31bff78 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -70,10 +70,10 @@ gr_annotator_alltoall::work (int noutput_items, abs_N = nitems_read(i); end_N = abs_N + (uint64_t)(noutput_items); - std::vector<pmt::pmt_t> all_tags; + std::vector<gr_tag_t> all_tags; get_tags_in_range(all_tags, i, abs_N, end_N); - std::vector<pmt::pmt_t>::iterator itr; + std::vector<gr_tag_t>::iterator itr; for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { d_stored_tags.push_back(*itr); } diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h index e1e51ebf3..fe8b736c2 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_ANNOTATOR_ALLTOALL_H #define INCLUDED_GR_ANNOTATOR_ALLTOALL_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_annotator_alltoall; typedef boost::shared_ptr<gr_annotator_alltoall> gr_annotator_alltoall_sptr; // public constructor -gr_annotator_alltoall_sptr +GR_CORE_API gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); /*! @@ -45,7 +46,7 @@ gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); * * This block is only meant for testing and showing how to use the tags. */ -class gr_annotator_alltoall : public gr_sync_block +class GR_CORE_API gr_annotator_alltoall : public gr_sync_block { public: ~gr_annotator_alltoall (); @@ -54,7 +55,7 @@ class gr_annotator_alltoall : public gr_sync_block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - std::vector<pmt::pmt_t> data() const + std::vector<gr_tag_t> data() const { return d_stored_tags; } @@ -66,9 +67,9 @@ protected: size_t d_itemsize; uint64_t d_when; uint64_t d_tag_counter; - std::vector<pmt::pmt_t> d_stored_tags; + std::vector<gr_tag_t> d_stored_tags; - friend gr_annotator_alltoall_sptr + friend GR_CORE_API gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i index f9bf6dd9a..49bd1e446 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,15 +22,4 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); -gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when, - size_t sizeof_stream_item); - -class gr_annotator_alltoall : public gr_sync_block -{ -public: - std::vector<pmt::pmt_t> data() const; - -private: - gr_annotator_alltoall (int when, size_t sizeof_stream_item); -}; - +%include <gr_annotator_alltoall.h> diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h b/gnuradio-core/src/lib/general/gr_bin_statistics_f.h index d8c4c2fae..f7eea7d5f 100644 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h +++ b/gnuradio-core/src/lib/general/gr_bin_statistics_f.h @@ -24,6 +24,7 @@ #define INCLUDED_GR_BIN_STATISTICS_F_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_feval.h> #include <gr_message.h> @@ -33,7 +34,7 @@ class gr_bin_statistics_f; typedef boost::shared_ptr<gr_bin_statistics_f> gr_bin_statistics_f_sptr; -gr_bin_statistics_f_sptr +GR_CORE_API gr_bin_statistics_f_sptr gr_make_bin_statistics_f(unsigned int vlen, // vector length gr_msg_queue_sptr msgq, gr_feval_dd *tune, // callback @@ -44,9 +45,9 @@ gr_make_bin_statistics_f(unsigned int vlen, // vector length * \brief control scanning and record frequency domain statistics * \ingroup sink_blk */ -class gr_bin_statistics_f : public gr_sync_block +class GR_CORE_API gr_bin_statistics_f : public gr_sync_block { - friend gr_bin_statistics_f_sptr + friend GR_CORE_API gr_bin_statistics_f_sptr gr_make_bin_statistics_f(unsigned int vlen, // vector length gr_msg_queue_sptr msgq, gr_feval_dd *tune, // callback diff --git a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.cc b/gnuradio-core/src/lib/general/gr_binary_slicer_fb.cc deleted file mode 100644 index ae8903abb..000000000 --- a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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_binary_slicer_fb.h> -#include <gr_io_signature.h> -#include <stdexcept> - -gr_binary_slicer_fb_sptr -gr_make_binary_slicer_fb () -{ - return gnuradio::get_initial_sptr(new gr_binary_slicer_fb ()); -} - -gr_binary_slicer_fb::gr_binary_slicer_fb () - : gr_sync_block ("binary_slicer_fb", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ -} - -static inline int -slice(float x) -{ - return x < 0 ? 0 : 1; -} - -int -gr_binary_slicer_fb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - - for (int i = 0; i < noutput_items; i++){ - out[i] = slice(in[i]); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.h b/gnuradio-core/src/lib/general/gr_binary_slicer_fb.h deleted file mode 100644 index 2aa4a0828..000000000 --- a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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. - */ - -#ifndef INCLUDED_GR_BINARY_SLICER_FB_H -#define INCLUDED_GR_BINARY_SLICER_FB_H - -#include <gr_sync_block.h> - -class gr_binary_slicer_fb; -typedef boost::shared_ptr<gr_binary_slicer_fb> gr_binary_slicer_fb_sptr; - -gr_binary_slicer_fb_sptr gr_make_binary_slicer_fb (); - -/*! - * \brief slice float binary symbol outputting 1 bit output - * \ingroup converter_blk - * - * x < 0 --> 0 - * x >= 0 --> 1 - */ -class gr_binary_slicer_fb : public gr_sync_block -{ - friend gr_binary_slicer_fb_sptr gr_make_binary_slicer_fb (); - gr_binary_slicer_fb (); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.h b/gnuradio-core/src/lib/general/gr_burst_tagger.h index 8f814bea0..7547ba9cc 100644 --- a/gnuradio-core/src/lib/general/gr_burst_tagger.h +++ b/gnuradio-core/src/lib/general/gr_burst_tagger.h @@ -23,26 +23,27 @@ #ifndef INCLUDED_GR_BURST_TAGGER_H #define INCLUDED_GR_BURST_TAGGER_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_burst_tagger; typedef boost::shared_ptr<gr_burst_tagger> gr_burst_tagger_sptr; -gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); +GR_CORE_API gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); /*! * \brief output[i] = input[i] * \ingroup misc_blk * */ -class gr_burst_tagger : public gr_sync_block +class GR_CORE_API gr_burst_tagger : public gr_sync_block { size_t d_itemsize; bool d_state; pmt::pmt_t d_key; pmt::pmt_t d_id; - friend gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); + friend GR_CORE_API gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); gr_burst_tagger(size_t itemsize); public: diff --git a/gnuradio-core/src/lib/general/gr_bytes_to_syms.h b/gnuradio-core/src/lib/general/gr_bytes_to_syms.h index 1531de02a..33b98d4fd 100644 --- a/gnuradio-core/src/lib/general/gr_bytes_to_syms.h +++ b/gnuradio-core/src/lib/general/gr_bytes_to_syms.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_GR_BYTES_TO_SYMS_H #define INCLUDED_GR_BYTES_TO_SYMS_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_bytes_to_syms; typedef boost::shared_ptr<gr_bytes_to_syms> gr_bytes_to_syms_sptr; -gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); +GR_CORE_API gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); /*! * \brief Convert stream of bytes to stream of +/- 1 symbols @@ -45,9 +46,9 @@ gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc. */ -class gr_bytes_to_syms : public gr_sync_interpolator +class GR_CORE_API gr_bytes_to_syms : public gr_sync_interpolator { - friend gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); + friend GR_CORE_API gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); gr_bytes_to_syms (); diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.h b/gnuradio-core/src/lib/general/gr_char_to_float.h index 482e479d6..b20d2066f 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.h +++ b/gnuradio-core/src/lib/general/gr_char_to_float.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_CHAR_TO_FLOAT_H #define INCLUDED_GR_CHAR_TO_FLOAT_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_char_to_float; typedef boost::shared_ptr<gr_char_to_float> gr_char_to_float_sptr; -gr_char_to_float_sptr +GR_CORE_API gr_char_to_float_sptr gr_make_char_to_float (); /*! @@ -36,9 +37,9 @@ gr_make_char_to_float (); * \ingroup converter_blk */ -class gr_char_to_float : public gr_sync_block +class GR_CORE_API gr_char_to_float : public gr_sync_block { - friend gr_char_to_float_sptr gr_make_char_to_float (); + friend GR_CORE_API gr_char_to_float_sptr gr_make_char_to_float (); gr_char_to_float (); public: diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.h b/gnuradio-core/src/lib/general/gr_check_counting_s.h index da35ab8e2..cd4dcb24e 100644 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.h +++ b/gnuradio-core/src/lib/general/gr_check_counting_s.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_GR_CHECK_COUNTING_S_H #define INCLUDED_GR_CHECK_COUNTING_S_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_check_counting_s; typedef boost::shared_ptr<gr_check_counting_s> gr_check_counting_s_sptr; -gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); +GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); /*! * \brief sink that checks if its input stream consists of a counting sequence. @@ -36,9 +37,9 @@ gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); * * This sink is typically used to test the USRP "Counting Mode" or "Counting mode 32 bit". */ -class gr_check_counting_s : public gr_sync_block +class GR_CORE_API gr_check_counting_s : public gr_sync_block { - friend gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit); + friend GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit); enum state { SEARCHING, // searching for synchronization diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h index e2bff46d2..939675db8 100644 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h +++ b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_CHECK_LFSR_32K_S_H #define INCLUDED_GR_CHECK_LFSR_32K_S_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gri_lfsr_32k.h> @@ -29,7 +30,7 @@ class gr_check_lfsr_32k_s; typedef boost::shared_ptr<gr_check_lfsr_32k_s> gr_check_lfsr_32k_s_sptr; -gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); +GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); /*! * \brief sink that checks if its input stream consists of a lfsr_32k sequence. @@ -38,9 +39,9 @@ gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); * This sink is typically used along with gr_lfsr_32k_source_s to test * the USRP using its digital loopback mode. */ -class gr_check_lfsr_32k_s : public gr_sync_block +class GR_CORE_API gr_check_lfsr_32k_s : public gr_sync_block { - friend gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); + friend GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); enum state { SEARCHING, // searching for synchronization diff --git a/gnuradio-core/src/lib/general/gr_circular_file.h b/gnuradio-core/src/lib/general/gr_circular_file.h index 70f4b4b11..3d3f33a8d 100644 --- a/gnuradio-core/src/lib/general/gr_circular_file.h +++ b/gnuradio-core/src/lib/general/gr_circular_file.h @@ -23,6 +23,8 @@ #ifndef _GR_CIRCULAR_FILE_H_ #define _GR_CIRCULAR_FILE_H_ +#include <gr_core_api.h> + /* * writes input data into a circular buffer on disk. * @@ -35,7 +37,7 @@ * current start of data * */ -class gr_circular_file { +class GR_CORE_API gr_circular_file { int d_fd; int *d_header; unsigned char *d_buffer; @@ -55,4 +57,4 @@ public: void reset_read_pointer (); }; -#endif /* _GR_CIRCULAR_FILE_H_ */ +#endif /* _GR_CIRCULAR_FILE_H_ */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc deleted file mode 100644 index 7c20f7fd9..000000000 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc +++ /dev/null @@ -1,215 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2010 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_io_signature.h> -#include <gr_prefs.h> -#include <gr_clock_recovery_mm_cc.h> -#include <gri_mmse_fir_interpolator_cc.h> -#include <stdexcept> -#include <cstdio> - - -// Public constructor -static const int FUDGE = 16; - -gr_clock_recovery_mm_cc_sptr -gr_make_clock_recovery_mm_cc(float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit) -{ - return gnuradio::get_initial_sptr(new gr_clock_recovery_mm_cc (omega, - gain_omega, - mu, - gain_mu, - omega_relative_limit)); -} - -gr_clock_recovery_mm_cc::gr_clock_recovery_mm_cc (float omega, float gain_omega, float mu, - float gain_mu, float omega_relative_limit) - : gr_block ("clock_recovery_mm_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 2, sizeof (gr_complex))), - d_mu (mu), d_omega(omega), d_gain_omega(gain_omega), - d_omega_relative_limit(omega_relative_limit), - d_gain_mu(gain_mu), d_last_sample(0), d_interp(new gri_mmse_fir_interpolator_cc()), - d_verbose(gr_prefs::singleton()->get_bool("clock_recovery_mm_cc", "verbose", false)), - d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0) -{ - if (omega <= 0.0) - throw std::out_of_range ("clock rate must be > 0"); - if (gain_mu < 0 || gain_omega < 0) - throw std::out_of_range ("Gains must be non-negative"); - - set_omega(omega); // also sets min and max omega - set_relative_rate (1.0 / omega); - set_history(3); // ensure 2 extra input sample is available -} - -gr_clock_recovery_mm_cc::~gr_clock_recovery_mm_cc () -{ - delete d_interp; -} - -void -gr_clock_recovery_mm_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - ninput_items_required[i] = - (int) ceil((noutput_items * d_omega) + d_interp->ntaps()) + FUDGE; -} - -gr_complex -gr_clock_recovery_mm_cc::slicer_0deg (gr_complex sample) -{ - float real=0, imag=0; - - if(sample.real() > 0) - real = 1; - if(sample.imag() > 0) - imag = 1; - return gr_complex(real,imag); -} - -gr_complex -gr_clock_recovery_mm_cc::slicer_45deg (gr_complex sample) -{ - float real= -1, imag = -1; - if(sample.real() > 0) - real=1; - if(sample.imag() > 0) - imag = 1; - return gr_complex(real,imag); -} - -/* - Modified Mueller and Muller clock recovery circuit - Based: - G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller - algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033. -*/ - -int -gr_clock_recovery_mm_cc::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - gr_complex *foptr = (gr_complex *) output_items[1]; - - bool write_foptr = output_items.size() >= 2; - - int ii = 0; // input index - int oo = 0; // output index - int ni = ninput_items[0] - d_interp->ntaps() - FUDGE; // don't use more input than this - - assert(d_mu >= 0.0); - assert(d_mu <= 1.0); - - float mm_val=0; - gr_complex u, x, y; - - // This loop writes the error to the second output, if it exists - if (write_foptr) { - while(oo < noutput_items && ii < ni) { - d_p_2T = d_p_1T; - d_p_1T = d_p_0T; - d_p_0T = d_interp->interpolate (&in[ii], d_mu); - - d_c_2T = d_c_1T; - d_c_1T = d_c_0T; - d_c_0T = slicer_0deg(d_p_0T); - - x = (d_c_0T - d_c_2T) * conj(d_p_1T); - y = (d_p_0T - d_p_2T) * conj(d_c_1T); - u = y - x; - mm_val = u.real(); - out[oo++] = d_p_0T; - - // limit mm_val - mm_val = gr_branchless_clip(mm_val,1.0); - d_omega = d_omega + d_gain_omega * mm_val; - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away - - d_mu = d_mu + d_omega + d_gain_mu * mm_val; - ii += (int)floor(d_mu); - d_mu -= floor(d_mu); - - // write the error signal to the second output - foptr[oo-1] = gr_complex(d_mu,0); - - if (ii < 0) // clamp it. This should only happen with bogus input - ii = 0; - } - } - // This loop does not write to the second output (ugly, but faster) - else { - while(oo < noutput_items && ii < ni) { - d_p_2T = d_p_1T; - d_p_1T = d_p_0T; - d_p_0T = d_interp->interpolate (&in[ii], d_mu); - - d_c_2T = d_c_1T; - d_c_1T = d_c_0T; - d_c_0T = slicer_0deg(d_p_0T); - - x = (d_c_0T - d_c_2T) * conj(d_p_1T); - y = (d_p_0T - d_p_2T) * conj(d_c_1T); - u = y - x; - mm_val = u.real(); - out[oo++] = d_p_0T; - - // limit mm_val - mm_val = gr_branchless_clip(mm_val,1.0); - - d_omega = d_omega + d_gain_omega * mm_val; - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away - - d_mu = d_mu + d_omega + d_gain_mu * mm_val; - ii += (int)floor(d_mu); - d_mu -= floor(d_mu); - - if(d_verbose) { - printf("%f\t%f\n", d_omega, d_mu); - } - - if (ii < 0) // clamp it. This should only happen with bogus input - ii = 0; - } - } - - if (ii > 0){ - if (ii > ninput_items[0]){ - fprintf(stderr, "gr_clock_recovery_mm_cc: ii > ninput_items[0] (%d > %d)\n", - ii, ninput_items[0]); - assert(0); - } - consume_each (ii); - } - - return oo; -} diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.h b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.h deleted file mode 100644 index 04227a145..000000000 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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_CLOCK_RECOVERY_MM_CC_H -#define INCLUDED_GR_CLOCK_RECOVERY_MM_CC_H - -#include <gr_block.h> -#include <gr_complex.h> -#include <gr_math.h> - -class gri_mmse_fir_interpolator_cc; - -class gr_clock_recovery_mm_cc; -typedef boost::shared_ptr<gr_clock_recovery_mm_cc> gr_clock_recovery_mm_cc_sptr; - -// public constructor -gr_clock_recovery_mm_cc_sptr -gr_make_clock_recovery_mm_cc (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit=0.001); - -/*! - * \brief Mueller and Müller (M&M) based clock recovery block with complex input, complex output. - * \ingroup sync_blk - * - * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer. - * The complex version here is based on: - * Modified Mueller and Muller clock recovery circuit - * Based: - * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller - * algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033. - */ -class gr_clock_recovery_mm_cc : public gr_block -{ - public: - ~gr_clock_recovery_mm_cc (); - 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); - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - void set_verbose (bool verbose) { d_verbose = verbose; } - - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_mu (float mu) { d_mu = mu; } - void set_omega (float omega) { - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_relative_limit); - d_max_omega = omega*(1.0 + d_omega_relative_limit); - d_omega_mid = 0.5*(d_min_omega+d_max_omega); - } - -protected: - gr_clock_recovery_mm_cc (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limi); - - private: - float d_mu; - float d_omega; - float d_gain_omega; - float d_min_omega; // minimum allowed omega - float d_max_omega; // maximum allowed omeg - float d_omega_relative_limit; // used to compute min and max omega - float d_omega_mid; - float d_gain_mu; - gr_complex d_last_sample; - gri_mmse_fir_interpolator_cc *d_interp; - bool d_verbose; - - gr_complex d_p_2T; - gr_complex d_p_1T; - gr_complex d_p_0T; - - gr_complex d_c_2T; - gr_complex d_c_1T; - gr_complex d_c_0T; - - gr_complex slicer_0deg (gr_complex sample); - gr_complex slicer_45deg (gr_complex sample); - - friend gr_clock_recovery_mm_cc_sptr - gr_make_clock_recovery_mm_cc (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i deleted file mode 100644 index 27eb70b95..000000000 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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,clock_recovery_mm_cc); - -gr_clock_recovery_mm_cc_sptr -gr_make_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit) throw(std::exception); - -class gr_clock_recovery_mm_cc : public gr_sync_block -{ - private: - gr_clock_recovery_mm_cc (float omega, float gain_omega, float mu, - float gain_mu, float omega_relative_limit); - -public: - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_mu (float omega) { d_mu = mu; } - void set_omega (float omega) { d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_relative_limit); - d_max_omega = omega*(1.0 + d_omega_relative_limit); - } - void set_verbose (bool verbose) { d_verbose = verbose; } -}; diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.cc b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.cc deleted file mode 100644 index bb5a27071..000000000 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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_io_signature.h> -#include <gr_clock_recovery_mm_ff.h> -#include <gri_mmse_fir_interpolator.h> -#include <stdexcept> - -#define DEBUG_CR_MM_FF 0 // must be defined as 0 or 1 - -// Public constructor - -gr_clock_recovery_mm_ff_sptr -gr_make_clock_recovery_mm_ff(float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit) -{ - return gnuradio::get_initial_sptr(new gr_clock_recovery_mm_ff (omega, - gain_omega, - mu, - gain_mu, - omega_relative_limit)); -} - -gr_clock_recovery_mm_ff::gr_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit) - : gr_block ("clock_recovery_mm_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_mu (mu), d_gain_omega(gain_omega), d_gain_mu(gain_mu), - d_last_sample(0), d_interp(new gri_mmse_fir_interpolator()), - d_logfile(0), d_omega_relative_limit(omega_relative_limit) -{ - if (omega < 1) - throw std::out_of_range ("clock rate must be > 0"); - if (gain_mu < 0 || gain_omega < 0) - throw std::out_of_range ("Gains must be non-negative"); - - set_omega(omega); // also sets min and max omega - set_relative_rate (1.0 / omega); - - if (DEBUG_CR_MM_FF) - d_logfile = fopen("cr_mm_ff.dat", "wb"); -} - -gr_clock_recovery_mm_ff::~gr_clock_recovery_mm_ff () -{ - delete d_interp; - - if (DEBUG_CR_MM_FF && d_logfile){ - fclose(d_logfile); - d_logfile = 0; - } -} - -void -gr_clock_recovery_mm_ff::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - ninput_items_required[i] = - (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); -} - -static inline float -slice(float x) -{ - return x < 0 ? -1.0F : 1.0F; -} - -/* - * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer. - * - * See "Digital Communication Receivers: Synchronization, Channel - * Estimation and Signal Processing" by Heinrich Meyr, Marc Moeneclaey, & Stefan Fechtel. - * ISBN 0-471-50275-8. - */ -int -gr_clock_recovery_mm_ff::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - int ii = 0; // input index - int oo = 0; // output index - int ni = ninput_items[0] - d_interp->ntaps(); // don't use more input than this - float mm_val; - - while (oo < noutput_items && ii < ni ){ - - // produce output sample - out[oo] = d_interp->interpolate (&in[ii], d_mu); - mm_val = slice(d_last_sample) * out[oo] - slice(out[oo]) * d_last_sample; - d_last_sample = out[oo]; - - d_omega = d_omega + d_gain_omega * mm_val; - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away - d_mu = d_mu + d_omega + d_gain_mu * mm_val; - - ii += (int) floor(d_mu); - d_mu = d_mu - floor(d_mu); - oo++; - - if (DEBUG_CR_MM_FF && d_logfile){ - fwrite(&d_omega, sizeof(d_omega), 1, d_logfile); - } - } - - consume_each (ii); - - return oo; -} diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.h b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.h deleted file mode 100644 index d2ec6d3e6..000000000 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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_CLOCK_RECOVERY_MM_FF_H -#define INCLUDED_GR_CLOCK_RECOVERY_MM_FF_H - -#include <gr_block.h> -#include <gr_math.h> -#include <stdio.h> - -class gri_mmse_fir_interpolator; - -class gr_clock_recovery_mm_ff; -typedef boost::shared_ptr<gr_clock_recovery_mm_ff> gr_clock_recovery_mm_ff_sptr; - -// public constructor -gr_clock_recovery_mm_ff_sptr -gr_make_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit=0.001); - -/*! - * \brief Mueller and Müller (M&M) based clock recovery block with float input, float output. - * \ingroup sync_blk - * - * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer. - * - * See "Digital Communication Receivers: Synchronization, Channel - * Estimation and Signal Processing" by Heinrich Meyr, Marc Moeneclaey, & Stefan Fechtel. - * ISBN 0-471-50275-8. - */ -class gr_clock_recovery_mm_ff : public gr_block -{ - public: - ~gr_clock_recovery_mm_ff (); - 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); - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_mu (float mu) { d_mu = mu; } - void set_omega (float omega){ - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_relative_limit); - d_max_omega = omega*(1.0 + d_omega_relative_limit); - d_omega_mid = 0.5*(d_min_omega+d_max_omega); - } - -protected: - gr_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit); - - private: - float d_mu; // fractional sample position [0.0, 1.0] - float d_omega; // nominal frequency - float d_min_omega; // minimum allowed omega - float d_omega_mid; // average omega - float d_max_omega; // maximum allowed omega - float d_gain_omega; // gain for adjusting omega - float d_gain_mu; // gain for adjusting mu - float d_last_sample; - gri_mmse_fir_interpolator *d_interp; - FILE *d_logfile; - float d_omega_relative_limit; // used to compute min and max omega - - friend gr_clock_recovery_mm_ff_sptr - gr_make_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i deleted file mode 100644 index 1b2437000..000000000 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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,clock_recovery_mm_ff); - -gr_clock_recovery_mm_ff_sptr -gr_make_clock_recovery_mm_ff (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit=0.001) throw(std::exception); - -class gr_clock_recovery_mm_ff : public gr_sync_block -{ - private: - gr_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit); - -public: - float mu() const; - float omega() const; - float gain_mu() const; - float gain_omega() const; - - void set_gain_mu (float gain_mu); - void set_gain_omega (float gain_omega); - void set_mu (float omega); - void set_omega (float omega); -}; diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h index 0a91eddd6..a3e2d38ad 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h +++ b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_COMPLEX_TO_INTERLEAVED_SHORT_H #define INCLUDED_GR_COMPLEX_TO_INTERLEAVED_SHORT_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_complex_to_interleaved_short; typedef boost::shared_ptr<gr_complex_to_interleaved_short> gr_complex_to_interleaved_short_sptr; -gr_complex_to_interleaved_short_sptr +GR_CORE_API gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short (); /*! @@ -37,9 +38,9 @@ gr_make_complex_to_interleaved_short (); * \ingroup converter_blk */ -class gr_complex_to_interleaved_short : public gr_sync_interpolator +class GR_CORE_API gr_complex_to_interleaved_short : public gr_sync_interpolator { - friend gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short (); + friend GR_CORE_API gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short (); gr_complex_to_interleaved_short (); public: diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h index 1851c67d9..166403259 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_COMPLEX_TO_XXX_H #define INCLUDED_GR_COMPLEX_TO_XXX_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_complex.h> @@ -40,21 +41,21 @@ typedef boost::shared_ptr<gr_complex_to_mag> gr_complex_to_mag_sptr; typedef boost::shared_ptr<gr_complex_to_mag_squared> gr_complex_to_mag_squared_sptr; typedef boost::shared_ptr<gr_complex_to_arg> gr_complex_to_arg_sptr; -gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen=1); -gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen=1); -gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen=1); -gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen=1); -gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen=1); -gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen=1); +GR_CORE_API gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen=1); +GR_CORE_API gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen=1); +GR_CORE_API gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen=1); +GR_CORE_API gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen=1); +GR_CORE_API gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen=1); +GR_CORE_API gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen=1); /*! * \brief convert a stream of gr_complex to 1 or 2 streams of float * \ingroup converter_blk * \param vlen vector len (default 1) */ -class gr_complex_to_float : public gr_sync_block +class GR_CORE_API gr_complex_to_float : public gr_sync_block { - friend gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen); + friend GR_CORE_API gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen); gr_complex_to_float (unsigned int vlen); unsigned int d_vlen; @@ -70,9 +71,9 @@ class gr_complex_to_float : public gr_sync_block * \ingroup converter_blk * \param vlen vector len (default 1) */ -class gr_complex_to_real : public gr_sync_block +class GR_CORE_API gr_complex_to_real : public gr_sync_block { - friend gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen); + friend GR_CORE_API gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen); gr_complex_to_real (unsigned int vlen); unsigned int d_vlen; @@ -88,9 +89,9 @@ class gr_complex_to_real : public gr_sync_block * \ingroup converter_blk * \param vlen vector len (default 1) */ -class gr_complex_to_imag : public gr_sync_block +class GR_CORE_API gr_complex_to_imag : public gr_sync_block { - friend gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen); + friend GR_CORE_API gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen); gr_complex_to_imag (unsigned int vlen); unsigned int d_vlen; @@ -106,9 +107,9 @@ class gr_complex_to_imag : public gr_sync_block * \ingroup converter_blk * \param vlen vector len (default 1) */ -class gr_complex_to_mag : public gr_sync_block +class GR_CORE_API gr_complex_to_mag : public gr_sync_block { - friend gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen); + friend GR_CORE_API gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen); gr_complex_to_mag (unsigned int vlen); unsigned int d_vlen; @@ -124,9 +125,9 @@ class gr_complex_to_mag : public gr_sync_block * \ingroup converter_blk * \param vlen vector len (default 1) */ -class gr_complex_to_mag_squared : public gr_sync_block +class GR_CORE_API gr_complex_to_mag_squared : public gr_sync_block { - friend gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen); + friend GR_CORE_API gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen); gr_complex_to_mag_squared (unsigned int vlen); unsigned int d_vlen; @@ -142,9 +143,9 @@ class gr_complex_to_mag_squared : public gr_sync_block * \ingroup converter_blk * \param vlen vector len (default 1) */ -class gr_complex_to_arg : public gr_sync_block +class GR_CORE_API gr_complex_to_arg : public gr_sync_block { - friend gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen); + friend GR_CORE_API gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen); gr_complex_to_arg (unsigned int vlen); unsigned int d_vlen; diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_conjugate_cc.h index 783019adb..16e76e153 100644 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.h +++ b/gnuradio-core/src/lib/general/gr_conjugate_cc.h @@ -25,20 +25,21 @@ #ifndef INCLUDED_GR_CONJUGATE_CC_H #define INCLUDED_GR_CONJUGATE_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_conjugate_cc; typedef boost::shared_ptr<gr_conjugate_cc> gr_conjugate_cc_sptr; -gr_conjugate_cc_sptr gr_make_conjugate_cc (); +GR_CORE_API gr_conjugate_cc_sptr gr_make_conjugate_cc (); /*! * \brief output = complex conjugate of input * \ingroup math_blk */ -class gr_conjugate_cc : public gr_sync_block +class GR_CORE_API gr_conjugate_cc : public gr_sync_block { - friend gr_conjugate_cc_sptr gr_make_conjugate_cc (); + friend GR_CORE_API gr_conjugate_cc_sptr gr_make_conjugate_cc (); gr_conjugate_cc (); diff --git a/gnuradio-core/src/lib/general/gr_constants.h b/gnuradio-core/src/lib/general/gr_constants.h index 449d41c17..3d21fe1d6 100644 --- a/gnuradio-core/src/lib/general/gr_constants.h +++ b/gnuradio-core/src/lib/general/gr_constants.h @@ -22,31 +22,32 @@ #ifndef INCLUDED_GR_CONSTANTS_H #define INCLUDED_GR_CONSTANTS_H +#include <gr_core_api.h> #include <string> /*! * \brief return ./configure --prefix argument. Typically /usr/local */ -const std::string gr_prefix(); +GR_CORE_API const std::string gr_prefix(); /*! * \brief return ./configure --sysconfdir argument. Typically $prefix/etc or /etc */ -const std::string gr_sysconfdir(); +GR_CORE_API const std::string gr_sysconfdir(); /*! * \brief return preferences file directory. Typically $sysconfdir/etc/conf.d */ -const std::string gr_prefsdir(); +GR_CORE_API const std::string gr_prefsdir(); /*! * \brief return date/time of build, as set when 'bootstrap' is run */ -const std::string gr_build_date(); +GR_CORE_API const std::string gr_build_date(); /*! * \brief return version string defined in configure.ac */ -const std::string gr_version(); +GR_CORE_API const std::string gr_version(); #endif /* INCLUDED_GR_CONSTANTS_H */ diff --git a/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.cc b/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.cc deleted file mode 100644 index 5b87f1430..000000000 --- a/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_constellation_decoder_cb.h> -#include <gr_io_signature.h> -#include <stdexcept> - -#include <cstdio> -#include <iostream> -using std::cout; -using std::endl; - -static const bool compute_EVM = false; - -gr_constellation_decoder_cb_sptr -gr_make_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out) -{ - return gr_constellation_decoder_cb_sptr - (new gr_constellation_decoder_cb(sym_position, sym_value_out)); -} - -gr_constellation_decoder_cb:: -gr_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out) - : gr_sync_block ("constellation_decoder_cb", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ - if (!set_constellation(sym_position,sym_value_out)) - throw std::invalid_argument("constellation_decoder_cb"); -} - - -gr_constellation_decoder_cb::~gr_constellation_decoder_cb(){} - - -bool -gr_constellation_decoder_cb::set_constellation(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out) -{ - if (sym_position.size() != sym_value_out.size()) - return false; - - if (sym_position.size()<1) - return false; - - d_sym_position = sym_position; - d_sym_value_out = sym_value_out; - return true; -} - - -int -gr_constellation_decoder_cb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex const *in = (const gr_complex *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - unsigned int table_size = d_sym_value_out.size(); - unsigned int min_index = 0; - float min_euclid_dist = 0; - float euclid_dist = 0; - double total_error = 0; - - for(int i = 0; i < noutput_items; i++){ - min_euclid_dist = norm(in[i] - d_sym_position[0]); - min_index = 0; - for (unsigned int j = 1; j < table_size; j++){ - euclid_dist = norm(in[i] - d_sym_position[j]); - if (euclid_dist < min_euclid_dist){ - min_euclid_dist = euclid_dist; - min_index = j; - } - } - - out[i] = d_sym_value_out[min_index]; - - if (compute_EVM) - total_error += sqrtf(min_euclid_dist); - } - - if (compute_EVM){ - double mean = total_error / noutput_items; - double rms = sqrt(mean * mean); - fprintf(stderr, "EVM = %8.4f\n", rms); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.h b/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.h deleted file mode 100644 index fd7079c12..000000000 --- a/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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. - */ - -#ifndef INCLUDED_GR_CONSTELLATION_DECODER_CB_H -#define INCLUDED_GR_CONSTELLATION_DECODER_CB_H - -#include <gr_sync_block.h> -#include <vector> - -class gr_constellation_decoder_cb; -typedef boost::shared_ptr<gr_constellation_decoder_cb> gr_constellation_decoder_cb_sptr; - -gr_constellation_decoder_cb_sptr - gr_make_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - -/*! - * \brief Constellation Decoder - * \ingroup coding_blk - * - */ -class gr_constellation_decoder_cb : public gr_sync_block -{ - - private: - std::vector<gr_complex> d_sym_position; - std::vector<unsigned char> d_sym_value_out; - - friend gr_constellation_decoder_cb_sptr - gr_make_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, const std::vector<unsigned char> &sym_value_out); - - gr_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); //constructor - - public: - bool set_constellation(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - - ~gr_constellation_decoder_cb(); //destructor - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.i b/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.i deleted file mode 100644 index 8d9c9b56e..000000000 --- a/gnuradio-core/src/lib/general/gr_constellation_decoder_cb.i +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- 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,constellation_decoder_cb) - -gr_constellation_decoder_cb_sptr - gr_make_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - -class gr_constellation_decoder_cb : public gr_sync_block -{ - private: - gr_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - - friend gr_constellation_decoder_cb_sptr - gr_make_constellation_decoder_cb (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - - public: - int set_constellation(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - ~gr_constellation_decoder_cb(); -}; diff --git a/gnuradio-core/src/lib/general/gr_copy.h b/gnuradio-core/src/lib/general/gr_copy.h index d99aef8b7..7fb13bf68 100644 --- a/gnuradio-core/src/lib/general/gr_copy.h +++ b/gnuradio-core/src/lib/general/gr_copy.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_COPY_H #define INCLUDED_GR_COPY_H +#include <gr_core_api.h> #include <gr_block.h> class gr_copy; typedef boost::shared_ptr<gr_copy> gr_copy_sptr; -gr_copy_sptr gr_make_copy(size_t itemsize); +GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); /*! * \brief output[i] = input[i] @@ -38,12 +39,12 @@ gr_copy_sptr gr_make_copy(size_t itemsize); * When disabled, this block drops its input on the floor. * */ -class gr_copy : public gr_block +class GR_CORE_API gr_copy : public gr_block { size_t d_itemsize; bool d_enabled; - friend gr_copy_sptr gr_make_copy(size_t itemsize); + friend GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); gr_copy(size_t itemsize); public: diff --git a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i b/gnuradio-core/src/lib/general/gr_core_api.h index e786c70f5..74c802857 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i +++ b/gnuradio-core/src/lib/general/gr_core_api.h @@ -1,36 +1,33 @@ -/* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. - * + * Copyright 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. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_mapper_bcv) +#ifndef INCLUDED_GR_CORE_API_H +#define INCLUDED_GR_CORE_API_H -gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (unsigned int bits_per_symbol, - unsigned int vlen); +#include <gruel/attributes.h> -class gr_ofdm_mapper_bcv : public gr_sync_decimator -{ - protected: - gr_ofdm_mapper_bcv (unsigned int bits_per_symbol, - unsigned int vlen); +#ifdef gnuradio_core_EXPORTS +# define GR_CORE_API __GR_ATTR_EXPORT +#else +# define GR_CORE_API __GR_ATTR_IMPORT +#endif - public: -}; +#endif /* INCLUDED_GR_CORE_API_H */ diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc deleted file mode 100644 index 15f673411..000000000 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <gr_count_bits.h> -#include <cstdio> - - -#define VERBOSE 0 - - -gr_correlate_access_code_bb_sptr -gr_make_correlate_access_code_bb (const std::string &access_code, int threshold) -{ - return gnuradio::get_initial_sptr(new gr_correlate_access_code_bb (access_code, threshold)); -} - - -gr_correlate_access_code_bb::gr_correlate_access_code_bb ( - const std::string &access_code, int threshold) - : gr_sync_block ("correlate_access_code_bb", - gr_make_io_signature (1, 1, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(char))), - d_data_reg(0), d_flag_reg(0), d_flag_bit(0), d_mask(0), - d_threshold(threshold) - -{ - if (!set_access_code(access_code)){ - fprintf(stderr, "gr_correlate_access_code_bb: access_code is > 64 bits\n"); - throw std::out_of_range ("access_code is > 64 bits"); - } -} - -gr_correlate_access_code_bb::~gr_correlate_access_code_bb () -{ -} - -bool -gr_correlate_access_code_bb::set_access_code( - const std::string &access_code) -{ - unsigned len = access_code.length(); // # of bytes in string - if (len > 64) - return false; - - // set len top bits to 1. - d_mask = ((~0ULL) >> (64 - len)) << (64 - len); - - d_flag_bit = 1LL << (64 - len); // Where we or-in new flag values. - // new data always goes in 0x0000000000000001 - d_access_code = 0; - for (unsigned i=0; i < 64; i++){ - d_access_code <<= 1; - if (i < len) - d_access_code |= access_code[i] & 1; // look at LSB only - } - - return true; -} - -int -gr_correlate_access_code_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]; - - for (int i = 0; i < noutput_items; i++){ - - // compute output value - unsigned int t = 0; - - t |= ((d_data_reg >> 63) & 0x1) << 0; - t |= ((d_flag_reg >> 63) & 0x1) << 1; // flag bit - out[i] = t; - - // 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); - -#if VERBOSE - if(new_flag) { - fprintf(stderr, "access code found: %llx\n", d_access_code); - } - else { - fprintf(stderr, "%llx ==> %llx\n", d_access_code, d_data_reg); - } -#endif - - // shift in new data and new flag - d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); - d_flag_reg = (d_flag_reg << 1); - if (new_flag) { - d_flag_reg |= d_flag_bit; - } - } - - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h deleted file mode 100644 index 581713c14..000000000 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#ifndef INCLUDED_GR_CORRELATE_ACCESS_CODE_BB_H -#define INCLUDED_GR_CORRELATE_ACCESS_CODE_BB_H - -#include <gr_sync_block.h> -#include <string> - -class gr_correlate_access_code_bb; -typedef boost::shared_ptr<gr_correlate_access_code_bb> gr_correlate_access_code_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 - */ -gr_correlate_access_code_bb_sptr -gr_make_correlate_access_code_bb (const std::string &access_code, int threshold); - -/*! - * \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: 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_bb : public gr_sync_block -{ - friend gr_correlate_access_code_bb_sptr - gr_make_correlate_access_code_bb (const std::string &access_code, int threshold); - 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_flag_reg; // keep track of decisions - unsigned long long d_flag_bit; // mask containing 1 bit which is location of new flag - 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 - - protected: - gr_correlate_access_code_bb(const std::string &access_code, int threshold); - - public: - ~gr_correlate_access_code_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_BB_H */ diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i deleted file mode 100644 index bec4282f1..000000000 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.i +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- 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_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_bb_sptr -gr_make_correlate_access_code_bb (const std::string &access_code, int threshold) - 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_bb : public gr_sync_block -{ - friend gr_correlate_access_code_bb_sptr - gr_make_correlate_access_code_bb (const std::string &access_code, int threshold); - protected: - gr_correlate_access_code_bb(const std::string &access_code, int threshold); - - public: - ~gr_correlate_access_code_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_correlate_access_code_tag_bb.h b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h index 1067bbc56..e543f5cfb 100644 --- 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 @@ -23,6 +23,7 @@ #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> @@ -34,7 +35,7 @@ typedef boost::shared_ptr<gr_correlate_access_code_tag_bb> gr_correlate_access_c * \param threshold maximum number of bits that may be wrong * \param tag_name key of the tag inserted into the tag stream */ -gr_correlate_access_code_tag_bb_sptr +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); @@ -49,9 +50,9 @@ gr_make_correlate_access_code_tag_bb (const std::string &access_code, int thresh * name [tag_name], specified in the constructor. Used for searching * an input data stream for preambles, etc. */ -class gr_correlate_access_code_tag_bb : public gr_sync_block +class GR_CORE_API gr_correlate_access_code_tag_bb : public gr_sync_block { - friend gr_correlate_access_code_tag_bb_sptr + 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: diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc deleted file mode 100644 index f3bfd0951..000000000 --- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 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_costas_loop_cc.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_sincos.h> -#include <math.h> - -#define M_TWOPI (2*M_PI) - -gr_costas_loop_cc_sptr -gr_make_costas_loop_cc (float alpha, float beta, - float max_freq, float min_freq, - int order - ) throw (std::invalid_argument) -{ - return gnuradio::get_initial_sptr(new gr_costas_loop_cc (alpha, beta, - max_freq, min_freq, - order)); -} - -gr_costas_loop_cc::gr_costas_loop_cc (float alpha, float beta, - float max_freq, float min_freq, - int order - ) throw (std::invalid_argument) - : gr_sync_block ("costas_loop_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 2, sizeof (gr_complex))), - d_alpha(alpha), d_beta(beta), - d_max_freq(max_freq), d_min_freq(min_freq), - d_phase(0), d_freq((max_freq+min_freq)/2), - d_order(order), d_phase_detector(0) -{ - switch(d_order) { - case 2: - d_phase_detector = &gr_costas_loop_cc::phase_detector_2; - break; - - case 4: - d_phase_detector = &gr_costas_loop_cc::phase_detector_4; - break; - - default: - throw std::invalid_argument("order must be 2 or 4"); - break; - } -} - - -float -gr_costas_loop_cc::phase_detector_4(gr_complex sample) const -{ - - return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - - (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); -} - -float -gr_costas_loop_cc::phase_detector_2(gr_complex sample) const -{ - return (sample.real()*sample.imag()); -} - -void -gr_costas_loop_cc::set_alpha(float alpha) -{ - d_alpha = alpha; -} - -void -gr_costas_loop_cc::set_beta(float beta) -{ - d_beta = beta; -} - -int -gr_costas_loop_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - gr_complex *optr = (gr_complex *) output_items[0]; - gr_complex *foptr = (gr_complex *) output_items[1]; - - bool write_foptr = output_items.size() >= 2; - - float error; - gr_complex nco_out; - - if (write_foptr) { - - for (int i = 0; i < noutput_items; i++){ - nco_out = gr_expj(-d_phase); - optr[i] = iptr[i] * nco_out; - - error = (*this.*d_phase_detector)(optr[i]); - if (error > 1) - error = 1; - else if (error < -1) - error = -1; - - d_freq = d_freq + d_beta * error; - d_phase = d_phase + d_freq + d_alpha * error; - - while(d_phase>M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase<-M_TWOPI) - d_phase += M_TWOPI; - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; - - foptr[i] = gr_complex(d_freq,0); - } - } else { - for (int i = 0; i < noutput_items; i++){ - nco_out = gr_expj(-d_phase); - optr[i] = iptr[i] * nco_out; - - error = (*this.*d_phase_detector)(optr[i]); - if (error > 1) - error = 1; - else if (error < -1) - error = -1; - - d_freq = d_freq + d_beta * error; - d_phase = d_phase + d_freq + d_alpha * error; - - while(d_phase>M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase<-M_TWOPI) - d_phase += M_TWOPI; - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; - - } - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.h b/gnuradio-core/src/lib/general/gr_costas_loop_cc.h deleted file mode 100644 index 3b4aab86c..000000000 --- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- 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. - */ - - -#ifndef INCLUDED_GR_COSTAS_LOOP_CC_H -#define INCLUDED_GR_COSTAS_LOOP_CC_H - -#include <gr_sync_block.h> -#include <stdexcept> -#include <fstream> - - -/*! \brief A Costas loop carrier recovery module. - * \ingroup sync_blk - * - * The Costas loop locks to the center frequency of a signal and - * downconverts it to baseband. The second (order=2) order loop is - * used for BPSK where the real part of the output signal is the - * baseband BPSK signal and the imaginary part is the error - * signal. When order=4, it can be used for quadrature modulations - * where both I and Q (real and imaginary) are outputted. - * - * More details can be found online: - * - * J. Feigin, "Practical Costas loop design: Designing a simple and inexpensive - * BPSK Costas loop carrier recovery circuit," RF signal processing, pp. 20-36, - * 2002. - * - * http://rfdesign.com/images/archive/0102Feigin20.pdf - * - * \param alpha the loop gain used for phase adjustment - * \param beta the loop gain for frequency adjustments - * \param max_freq the maximum frequency deviation (radians/sample) the loop can handle - * \param min_freq the minimum frequency deviation (radians/sample) the loop can handle - * \param order the loop order, either 2 or 4 - */ -class gr_costas_loop_cc; -typedef boost::shared_ptr<gr_costas_loop_cc> gr_costas_loop_cc_sptr; - - -gr_costas_loop_cc_sptr -gr_make_costas_loop_cc (float alpha, float beta, - float max_freq, float min_freq, - int order - ) throw (std::invalid_argument); - - -/*! - * \brief Carrier tracking PLL for QPSK - * \ingroup sync_blk - * input: complex; output: complex - * <br>The Costas loop can have two output streams: - * stream 1 is the baseband I and Q; - * stream 2 is the normalized frequency of the loop - * - * \p order must be 2 or 4. - */ -class gr_costas_loop_cc : public gr_sync_block -{ - friend gr_costas_loop_cc_sptr gr_make_costas_loop_cc (float alpha, float beta, - float max_freq, float min_freq, - int order - ) throw (std::invalid_argument); - - float d_alpha, d_beta, d_max_freq, d_min_freq, d_phase, d_freq; - int d_order; - - gr_costas_loop_cc (float alpha, float beta, - float max_freq, float min_freq, - int order - ) throw (std::invalid_argument); - - /*! \brief the phase detector circuit for fourth-order loops - * \param sample complex sample - * \return the phase error - */ - float phase_detector_4(gr_complex sample) const; // for QPSK - - /*! \brief the phase detector circuit for second-order loops - * \param sample a complex sample - * \return the phase error - */ - float phase_detector_2(gr_complex sample) const; // for BPSK - - - float (gr_costas_loop_cc::*d_phase_detector)(gr_complex sample) const; - -public: - - /*! \brief set the first order gain - * \param alpha - */ - void set_alpha(float alpha); - - /*! \brief get the first order gain - * - */ - float alpha() const { return d_alpha; } - - /*! \brief set the second order gain - * \param beta - */ - void set_beta(float beta); - - /*! \brief get the second order gain - * - */ - float beta() const { return d_beta; } - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! \brief returns the current NCO frequency in radians/sample - * - */ - float freq() const { return d_freq; } -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_count_bits.h b/gnuradio-core/src/lib/general/gr_count_bits.h index a8b52d3ac..f0cec2a11 100644 --- a/gnuradio-core/src/lib/general/gr_count_bits.h +++ b/gnuradio-core/src/lib/general/gr_count_bits.h @@ -23,9 +23,11 @@ #ifndef _GR_COUNT_BITS_H_ #define _GR_COUNT_BITS_H_ -unsigned int gr_count_bits8(unsigned int x); // return number of set bits in the low 8 bits of x -unsigned int gr_count_bits16(unsigned int x); // return number of set bits in the low 16 bits of x -unsigned int gr_count_bits32(unsigned int x); // return number of set bits in the low 32 bits of x -unsigned int gr_count_bits64(unsigned long long int x); +#include <gr_core_api.h> + +GR_CORE_API unsigned int gr_count_bits8(unsigned int x); // return number of set bits in the low 8 bits of x +GR_CORE_API unsigned int gr_count_bits16(unsigned int x); // return number of set bits in the low 16 bits of x +GR_CORE_API unsigned int gr_count_bits32(unsigned int x); // return number of set bits in the low 32 bits of x +GR_CORE_API unsigned int gr_count_bits64(unsigned long long int x); #endif /* _GR_COUNT_BITS_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.h b/gnuradio-core/src/lib/general/gr_cpfsk_bc.h index 29bcfed65..4afba4fb4 100644 --- a/gnuradio-core/src/lib/general/gr_cpfsk_bc.h +++ b/gnuradio-core/src/lib/general/gr_cpfsk_bc.h @@ -20,13 +20,14 @@ #ifndef INCLUDED_GR_CPFSK_BC_H #define INCLUDED_GR_CPFSK_BC_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_cpfsk_bc; typedef boost::shared_ptr<gr_cpfsk_bc> gr_cpfsk_bc_sptr; -gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); +GR_CORE_API gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); /*! * \brief Perform continuous phase 2-level frequency shift keying modulation @@ -38,10 +39,10 @@ gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); * \param samples_per_sym number of output samples per input bit */ -class gr_cpfsk_bc : public gr_sync_interpolator +class GR_CORE_API gr_cpfsk_bc : public gr_sync_interpolator { private: - friend gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); + friend GR_CORE_API gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); gr_cpfsk_bc(float k, float ampl, int samples_per_sym); diff --git a/gnuradio-core/src/lib/general/gr_cpm.cc b/gnuradio-core/src/lib/general/gr_cpm.cc new file mode 100644 index 000000000..94a428c58 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_cpm.cc @@ -0,0 +1,218 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * 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. + */ + +// Calculate the taps for the CPM phase responses + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <cmath> +#include <cfloat> +#include <gr_cpm.h> + +//gives us erf on compilers without it +#include <boost/math/special_functions/erf.hpp> +namespace bm = boost::math; + +#ifndef M_TWOPI +# define M_TWOPI (2*M_PI) +#endif + +//! Normalised sinc function, sinc(x)=sin(pi*x)/pi*x +inline double +sinc(double x) +{ + if (x == 0) { + return 1.0; + } + + return sin(M_PI * x) / (M_PI * x); +} + + +//! Taps for L-RC CPM (Raised cosine of length L symbols) +std::vector<float> +generate_cpm_lrc_taps(unsigned samples_per_sym, unsigned L) +{ + std::vector<float> taps(samples_per_sym * L, 1.0/L/samples_per_sym); + for (unsigned i = 0; i < samples_per_sym * L; i++) { + taps[i] *= 1 - cos(M_TWOPI * i / L / samples_per_sym); + } + + return taps; +} + + +/*! Taps for L-SRC CPM (Spectral raised cosine of length L symbols). + * + * L-SRC has a time-continuous phase response function of + * + * g(t) = 1/LT * sinc(2t/LT) * cos(beta * 2pi t / LT) / (1 - (4beta / LT * t)^2) + * + * which is the Fourier transform of a cos-rolloff function with rolloff + * beta, and looks like a sinc-function, multiplied with a rolloff term. + * We return the main lobe of the sinc, i.e., everything between the + * zero crossings. + * The time-discrete IR is thus + * + * g(k) = 1/Ls * sinc(2k/Ls) * cos(beta * pi k / Ls) / (1 - (4beta / Ls * k)^2) + * where k = 0...Ls-1 + * and s = samples per symbol. + */ +std::vector<float> +generate_cpm_lsrc_taps(unsigned samples_per_sym, unsigned L, double beta) +{ + double Ls = (double) L * samples_per_sym; + std::vector<double> taps_d(L * samples_per_sym, 0.0); + std::vector<float> taps(L * samples_per_sym, 0.0); + + double sum = 0; + for (unsigned i = 0; i < samples_per_sym * L; i++) { + double k = i - Ls/2; // Causal to acausal + + taps_d[i] = 1.0 / Ls * sinc(2.0 * k / Ls); + + // For k = +/-Ls/4*beta, the rolloff term's cos-function becomes zero + // and the whole thing converges to PI/4 (to prove this, use de + // l'hopital's rule). + if (fabs(fabs(k) - Ls/4/beta) < 2*DBL_EPSILON) { + taps_d[i] *= M_PI_4; + } else { + double tmp = 4.0 * beta * k / Ls; + taps_d[i] *= cos(beta * M_TWOPI * k / Ls) / (1 - tmp * tmp); + } + sum += taps_d[i]; + } + for (unsigned i = 0; i < samples_per_sym * L; i++) { + taps[i] = (float) taps_d[i] / sum; + } + + return taps; +} + + +//! Taps for L-REC CPM (Rectangular pulse shape of length L symbols) +std::vector<float> +generate_cpm_lrec_taps(unsigned samples_per_sym, unsigned L) +{ + return std::vector<float>(samples_per_sym * L, 1.0/L/samples_per_sym); +} + + +//! Helper function for TFM +double tfm_g0(double k, double sps) +{ + if (fabs(k) < 2 * DBL_EPSILON) { + return 1.145393004159143; // 1 + pi^2/48 / sqrt(2) + } + + const double pi2_24 = 0.411233516712057; // pi^2/24 + double f = M_PI * k / sps; + return sinc(k/sps) - pi2_24 * (2 * sin(f) - 2*f*cos(f) - f*f*sin(f)) / (f*f*f); +} + + +//! Taps for TFM CPM (Tamed frequency modulation) +// +// See [2, Chapter 2.7.2]. +// +// [2]: Anderson, Aulin and Sundberg; Digital Phase Modulation +std::vector<float> +generate_cpm_tfm_taps(unsigned sps, unsigned L) +{ + unsigned causal_shift = sps * L / 2; + std::vector<double> taps_d(sps * L, 0.0); + std::vector<float> taps(sps * L, 0.0); + + double sum = 0; + for (unsigned i = 0; i < sps * L; i++) { + double k = (double)(((int)i) - ((int)causal_shift)); // Causal to acausal + + taps_d[i] = tfm_g0(k - sps, sps) + + 2 * tfm_g0(k, sps) + + tfm_g0(k + sps, sps); + sum += taps_d[i]; + } + for (unsigned i = 0; i < sps * L; i++) { + taps[i] = (float) taps_d[i] / sum; + } + + return taps; +} + + +//! Taps for Gaussian CPM. Phase response is truncated after \p L symbols. +// \p bt sets the 3dB-time-bandwidth product. +// +// Note: for h = 0.5, this is the phase response for GMSK. +// +// This C99-compatible formula for the taps is taken straight +// from [1, Chapter 9.2.3]. +// A version in Q-notation can be found in [2, Chapter 2.7.2]. +// +// [1]: Karl-Dirk Kammeyer; Nachrichtenübertragung, 4th Edition. +// [2]: Anderson, Aulin and Sundberg; Digital Phase Modulation +// +std::vector<float> +generate_cpm_gaussian_taps(unsigned samples_per_sym, unsigned L, double bt) +{ + double Ls = (double) L * samples_per_sym; + std::vector<double> taps_d(L * samples_per_sym, 0.0); + std::vector<float> taps(L * samples_per_sym, 0.0); + + // alpha = sqrt(2/ln(2)) * pi * BT + double alpha = 5.336446256636997 * bt; + for (unsigned i = 0; i < samples_per_sym * L; i++) { + double k = i - Ls/2; // Causal to acausal + taps_d[i] = (bm::erf(alpha * (k / samples_per_sym + 0.5)) - + bm::erf(alpha * (k / samples_per_sym - 0.5))) + * 0.5 / samples_per_sym; + taps[i] = (float) taps_d[i]; + } + + return taps; +} + + +std::vector<float> +gr_cpm::phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta) +{ + switch (type) { + case LRC: + return generate_cpm_lrc_taps(samples_per_sym, L); + + case LSRC: + return generate_cpm_lsrc_taps(samples_per_sym, L, beta); + + case LREC: + return generate_cpm_lrec_taps(samples_per_sym, L); + + case TFM: + return generate_cpm_tfm_taps(samples_per_sym, L); + + case GAUSSIAN: + return generate_cpm_gaussian_taps(samples_per_sym, L, beta); + + default: + return generate_cpm_lrec_taps(samples_per_sym, 1); + } +} + diff --git a/gnuradio-core/src/lib/general/gr_cpm.h b/gnuradio-core/src/lib/general/gr_cpm.h new file mode 100644 index 000000000..ef2ff8414 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_cpm.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * 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_CPM_H +#define INCLUDED_GR_CPM_H + +#include <gr_core_api.h> +#include <vector> + +class GR_CORE_API gr_cpm +{ + public: + enum cpm_type { + LRC, + LSRC, + LREC, + TFM, + GAUSSIAN, + GENERIC = 999 + }; + + /*! \brief Return the taps for an interpolating FIR filter (gr_interp_fir_filter_fff). + * + * These taps represent the phase response \f$g(k)\f$ for use in a CPM modulator, + * see also gr_cpmmod_bc. + * + * \param type The CPM type (Rectangular, Raised Cosine, Spectral Raised Cosine, + * Tamed FM or Gaussian). + * \param samples_per_sym Samples per symbol. + * \param L The length of the phase response in symbols. + * \param beta For Spectral Raised Cosine, this is the rolloff factor. For Gaussian + * phase responses, this the 3dB-time-bandwidth product. For all other + * cases, it is ignored. + * + * Output: returns a vector of length \a K = \p samples_per_sym x \p L. + * This can be used directly in an interpolating FIR filter such as + * gr_interp_fir_filter_fff with interpolation factor \p samples_per_sym. + * + * All phase responses are normalised s.t. \f$ \sum_{k=0}^{K-1} g(k) = 1\f$; this will cause + * a maximum phase change of \f$ h \cdot \pi\f$ between two symbols, where \a h is the + * modulation index. + * + * The following phase responses can be generated: + * - LREC: Rectangular phase response. + * - LRC: Raised cosine phase response, looks like 1 - cos(x). + * - LSRC: Spectral raised cosine. This requires a rolloff factor beta. + * The phase response is the Fourier transform of raised cosine + * function. + * - TFM: Tamed frequency modulation. This scheme minimizes phase change for + * rapidly varying input symbols. + * - GAUSSIAN: A Gaussian phase response. For a modulation index h = 1/2, this + * results in GMSK. + * + * A short description of all these phase responses can be found in [1]. + * + * [1]: Anderson, Aulin and Sundberg; Digital Phase Modulation + */ + static std::vector<float> + phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta=0.3); +}; + +#endif /* INCLUDED_GR_CPM_H */ + diff --git a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i b/gnuradio-core/src/lib/general/gr_cpm.i index 9fd8521a2..f01aba34e 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i +++ b/gnuradio-core/src/lib/general/gr_cpm.i @@ -1,6 +1,6 @@ -/* -*- c++ -*- */ +/* -*- C++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. + * Copyright 2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,15 +20,21 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_cyclic_prefixer) +%rename(cpm) gr_cpm; -gr_ofdm_cyclic_prefixer_sptr -gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - -class gr_ofdm_cyclic_prefixer : public gr_sync_interpolator +class gr_cpm { - protected: - gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - public: + enum cpm_type { + LRC, + LSRC, + LREC, + TFM, + GAUSSIAN, + GENERIC = 999 + }; + + static std::vector<float> + phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta=0.3); }; + diff --git a/gnuradio-core/src/lib/general/gr_crc32.cc b/gnuradio-core/src/lib/general/gr_crc32.cc deleted file mode 100644 index d4e843528..000000000 --- a/gnuradio-core/src/lib/general/gr_crc32.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -/* - * See also ISO 3309 [ISO-3309] or ITU-T V.42 [ITU-V42] for a formal specification. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_crc32.h> - - -// Automatically generated CRC function -// polynomial: 0x104C11DB7 -unsigned int -gr_update_crc32(unsigned int crc, const unsigned char *data, size_t len) -{ - static const unsigned int table[256] = { - 0x00000000U,0x04C11DB7U,0x09823B6EU,0x0D4326D9U, - 0x130476DCU,0x17C56B6BU,0x1A864DB2U,0x1E475005U, - 0x2608EDB8U,0x22C9F00FU,0x2F8AD6D6U,0x2B4BCB61U, - 0x350C9B64U,0x31CD86D3U,0x3C8EA00AU,0x384FBDBDU, - 0x4C11DB70U,0x48D0C6C7U,0x4593E01EU,0x4152FDA9U, - 0x5F15ADACU,0x5BD4B01BU,0x569796C2U,0x52568B75U, - 0x6A1936C8U,0x6ED82B7FU,0x639B0DA6U,0x675A1011U, - 0x791D4014U,0x7DDC5DA3U,0x709F7B7AU,0x745E66CDU, - 0x9823B6E0U,0x9CE2AB57U,0x91A18D8EU,0x95609039U, - 0x8B27C03CU,0x8FE6DD8BU,0x82A5FB52U,0x8664E6E5U, - 0xBE2B5B58U,0xBAEA46EFU,0xB7A96036U,0xB3687D81U, - 0xAD2F2D84U,0xA9EE3033U,0xA4AD16EAU,0xA06C0B5DU, - 0xD4326D90U,0xD0F37027U,0xDDB056FEU,0xD9714B49U, - 0xC7361B4CU,0xC3F706FBU,0xCEB42022U,0xCA753D95U, - 0xF23A8028U,0xF6FB9D9FU,0xFBB8BB46U,0xFF79A6F1U, - 0xE13EF6F4U,0xE5FFEB43U,0xE8BCCD9AU,0xEC7DD02DU, - 0x34867077U,0x30476DC0U,0x3D044B19U,0x39C556AEU, - 0x278206ABU,0x23431B1CU,0x2E003DC5U,0x2AC12072U, - 0x128E9DCFU,0x164F8078U,0x1B0CA6A1U,0x1FCDBB16U, - 0x018AEB13U,0x054BF6A4U,0x0808D07DU,0x0CC9CDCAU, - 0x7897AB07U,0x7C56B6B0U,0x71159069U,0x75D48DDEU, - 0x6B93DDDBU,0x6F52C06CU,0x6211E6B5U,0x66D0FB02U, - 0x5E9F46BFU,0x5A5E5B08U,0x571D7DD1U,0x53DC6066U, - 0x4D9B3063U,0x495A2DD4U,0x44190B0DU,0x40D816BAU, - 0xACA5C697U,0xA864DB20U,0xA527FDF9U,0xA1E6E04EU, - 0xBFA1B04BU,0xBB60ADFCU,0xB6238B25U,0xB2E29692U, - 0x8AAD2B2FU,0x8E6C3698U,0x832F1041U,0x87EE0DF6U, - 0x99A95DF3U,0x9D684044U,0x902B669DU,0x94EA7B2AU, - 0xE0B41DE7U,0xE4750050U,0xE9362689U,0xEDF73B3EU, - 0xF3B06B3BU,0xF771768CU,0xFA325055U,0xFEF34DE2U, - 0xC6BCF05FU,0xC27DEDE8U,0xCF3ECB31U,0xCBFFD686U, - 0xD5B88683U,0xD1799B34U,0xDC3ABDEDU,0xD8FBA05AU, - 0x690CE0EEU,0x6DCDFD59U,0x608EDB80U,0x644FC637U, - 0x7A089632U,0x7EC98B85U,0x738AAD5CU,0x774BB0EBU, - 0x4F040D56U,0x4BC510E1U,0x46863638U,0x42472B8FU, - 0x5C007B8AU,0x58C1663DU,0x558240E4U,0x51435D53U, - 0x251D3B9EU,0x21DC2629U,0x2C9F00F0U,0x285E1D47U, - 0x36194D42U,0x32D850F5U,0x3F9B762CU,0x3B5A6B9BU, - 0x0315D626U,0x07D4CB91U,0x0A97ED48U,0x0E56F0FFU, - 0x1011A0FAU,0x14D0BD4DU,0x19939B94U,0x1D528623U, - 0xF12F560EU,0xF5EE4BB9U,0xF8AD6D60U,0xFC6C70D7U, - 0xE22B20D2U,0xE6EA3D65U,0xEBA91BBCU,0xEF68060BU, - 0xD727BBB6U,0xD3E6A601U,0xDEA580D8U,0xDA649D6FU, - 0xC423CD6AU,0xC0E2D0DDU,0xCDA1F604U,0xC960EBB3U, - 0xBD3E8D7EU,0xB9FF90C9U,0xB4BCB610U,0xB07DABA7U, - 0xAE3AFBA2U,0xAAFBE615U,0xA7B8C0CCU,0xA379DD7BU, - 0x9B3660C6U,0x9FF77D71U,0x92B45BA8U,0x9675461FU, - 0x8832161AU,0x8CF30BADU,0x81B02D74U,0x857130C3U, - 0x5D8A9099U,0x594B8D2EU,0x5408ABF7U,0x50C9B640U, - 0x4E8EE645U,0x4A4FFBF2U,0x470CDD2BU,0x43CDC09CU, - 0x7B827D21U,0x7F436096U,0x7200464FU,0x76C15BF8U, - 0x68860BFDU,0x6C47164AU,0x61043093U,0x65C52D24U, - 0x119B4BE9U,0x155A565EU,0x18197087U,0x1CD86D30U, - 0x029F3D35U,0x065E2082U,0x0B1D065BU,0x0FDC1BECU, - 0x3793A651U,0x3352BBE6U,0x3E119D3FU,0x3AD08088U, - 0x2497D08DU,0x2056CD3AU,0x2D15EBE3U,0x29D4F654U, - 0xC5A92679U,0xC1683BCEU,0xCC2B1D17U,0xC8EA00A0U, - 0xD6AD50A5U,0xD26C4D12U,0xDF2F6BCBU,0xDBEE767CU, - 0xE3A1CBC1U,0xE760D676U,0xEA23F0AFU,0xEEE2ED18U, - 0xF0A5BD1DU,0xF464A0AAU,0xF9278673U,0xFDE69BC4U, - 0x89B8FD09U,0x8D79E0BEU,0x803AC667U,0x84FBDBD0U, - 0x9ABC8BD5U,0x9E7D9662U,0x933EB0BBU,0x97FFAD0CU, - 0xAFB010B1U,0xAB710D06U,0xA6322BDFU,0xA2F33668U, - 0xBCB4666DU,0xB8757BDAU,0xB5365D03U,0xB1F740B4U, - }; - - while (len > 0) - { - crc = table[*data ^ ((crc >> 24) & 0xff)] ^ (crc << 8); - data++; - len--; - } - return crc; -} - -unsigned int -gr_update_crc32(unsigned int crc, const std::string s) -{ - return gr_update_crc32(crc, (const unsigned char *) s.data(), s.size()); -} - -unsigned int -gr_crc32(const unsigned char *buf, size_t len) -{ - return gr_update_crc32(0xffffffff, buf, len) ^ 0xffffffff; -} - -unsigned int -gr_crc32(const std::string s) -{ - return gr_crc32((const unsigned char *) s.data(), s.size()); -} diff --git a/gnuradio-core/src/lib/general/gr_crc32.h b/gnuradio-core/src/lib/general/gr_crc32.h deleted file mode 100644 index 87a8d15f2..000000000 --- a/gnuradio-core/src/lib/general/gr_crc32.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_CRC32_H -#define INCLUDED_GR_CRC32_H - -#include <string> -#include <gr_types.h> - -/*! - * \brief update running CRC-32 - * \ingroup misc - * - * Update a running CRC with the bytes buf[0..len-1] The CRC should be - * initialized to all 1's, and the transmitted value is the 1's - * complement of the final running CRC. The resulting CRC should be - * transmitted in big endian order. - */ -unsigned int -gr_update_crc32(unsigned int crc, const unsigned char *buf, size_t len); - -unsigned int -gr_update_crc32(unsigned int crc, const std::string buf); - -unsigned int -gr_crc32(const unsigned char *buf, size_t len); - -unsigned int -gr_crc32(const std::string buf); - -#endif /* INCLUDED_CRC32_H */ diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h index 49df785ff..664c40846 100644 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h +++ b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h @@ -23,20 +23,21 @@ #ifndef INCLUDED_GR_CTCSS_SQUELCH_FF_H #define INCLUDED_GR_CTCSS_SQUELCH_FF_H +#include <gr_core_api.h> #include <gr_squelch_base_ff.h> #include <gri_goertzel.h> class gr_ctcss_squelch_ff; typedef boost::shared_ptr<gr_ctcss_squelch_ff> gr_ctcss_squelch_ff_sptr; -gr_ctcss_squelch_ff_sptr +GR_CORE_API gr_ctcss_squelch_ff_sptr gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.01, int len=0, int ramp=0, bool gate=false); /*! * \brief gate or zero output if ctcss tone not present * \ingroup level_blk */ -class gr_ctcss_squelch_ff : public gr_squelch_base_ff +class GR_CORE_API gr_ctcss_squelch_ff : public gr_squelch_base_ff { private: float d_freq; @@ -48,7 +49,7 @@ private: gri_goertzel d_goertzel_c; gri_goertzel d_goertzel_r; - friend gr_ctcss_squelch_ff_sptr gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); + friend GR_CORE_API gr_ctcss_squelch_ff_sptr gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); int find_tone(float freq); diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h index 50a6c9d89..3db250101 100644 --- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h +++ b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h @@ -20,17 +20,18 @@ #ifndef INCLUDED_GR_DECODE_CCSDS_27_FB_H #define INCLUDED_GR_DECODE_CCSDS_27_FB_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> extern "C" { -#include "../viterbi/viterbi.h" +#include <viterbi.h> } class gr_decode_ccsds_27_fb; typedef boost::shared_ptr<gr_decode_ccsds_27_fb> gr_decode_ccsds_27_fb_sptr; -gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); +GR_CORE_API gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); /*! \brief A rate 1/2, k=7 convolutional decoder for the CCSDS standard * \ingroup ecc @@ -51,10 +52,10 @@ gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); * from the corresponding inputs. */ -class gr_decode_ccsds_27_fb : public gr_sync_decimator +class GR_CORE_API gr_decode_ccsds_27_fb : public gr_sync_decimator { private: - friend gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); + friend GR_CORE_API gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); gr_decode_ccsds_27_fb(); diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.h b/gnuradio-core/src/lib/general/gr_deinterleave.h index 59c310bdc..3dd913911 100644 --- a/gnuradio-core/src/lib/general/gr_deinterleave.h +++ b/gnuradio-core/src/lib/general/gr_deinterleave.h @@ -23,20 +23,21 @@ #ifndef INCLUDED_GR_DEINTERLEAVE_H #define INCLUDED_GR_DEINTERLEAVE_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_deinterleave; typedef boost::shared_ptr<gr_deinterleave> gr_deinterleave_sptr; -gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); +GR_CORE_API gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); /*! * \brief deinterleave a single input into N outputs * \ingroup slicedice_blk */ -class gr_deinterleave : public gr_sync_decimator +class GR_CORE_API gr_deinterleave : public gr_sync_decimator { - friend gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); + friend GR_CORE_API gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); size_t d_itemsize; diff --git a/gnuradio-core/src/lib/general/gr_delay.h b/gnuradio-core/src/lib/general/gr_delay.h index d7e8252a2..14de9af1f 100644 --- a/gnuradio-core/src/lib/general/gr_delay.h +++ b/gnuradio-core/src/lib/general/gr_delay.h @@ -23,20 +23,21 @@ #ifndef INCLUDED_GR_DELAY_H #define INCLUDED_GR_DELAY_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_delay; typedef boost::shared_ptr<gr_delay> gr_delay_sptr; -gr_delay_sptr gr_make_delay (size_t itemsize, int delay); +GR_CORE_API gr_delay_sptr gr_make_delay (size_t itemsize, int delay); /*! * \brief delay the input by a certain number of samples * \ingroup misc_blk */ -class gr_delay : public gr_sync_block +class GR_CORE_API gr_delay : public gr_sync_block { - friend gr_delay_sptr gr_make_delay (size_t itemsize, int delay); + friend GR_CORE_API gr_delay_sptr gr_make_delay (size_t itemsize, int delay); gr_delay (size_t itemsize, int delay); diff --git a/gnuradio-core/src/lib/general/gr_descrambler_bb.h b/gnuradio-core/src/lib/general/gr_descrambler_bb.h index 19787690c..d7a49b5f1 100644 --- a/gnuradio-core/src/lib/general/gr_descrambler_bb.h +++ b/gnuradio-core/src/lib/general/gr_descrambler_bb.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_DESCRAMBLER_BB_H #define INCLUDED_GR_DESCRAMBLER_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include "gri_lfsr.h" class gr_descrambler_bb; typedef boost::shared_ptr<gr_descrambler_bb> gr_descrambler_bb_sptr; -gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); +GR_CORE_API gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); /*! * Descramble an input stream using an LFSR. This block works on the LSB only @@ -42,9 +43,9 @@ gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); * \ingroup coding_blk */ -class gr_descrambler_bb : public gr_sync_block +class GR_CORE_API gr_descrambler_bb : public gr_sync_block { - friend gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); + friend GR_CORE_API gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len); gri_lfsr d_lfsr; diff --git a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h index 6fd08ec4b..0337c3dbd 100644 --- a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h +++ b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_DIFF_DECODER_BB_H #define INCLUDED_GR_DIFF_DECODER_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_diff_decoder_bb; typedef boost::shared_ptr<gr_diff_decoder_bb> gr_diff_decoder_bb_sptr; -gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); +GR_CORE_API gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); /*! * \brief y[0] = (x[0] - x[-1]) % M @@ -36,9 +37,9 @@ gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); * * Differential decoder */ -class gr_diff_decoder_bb : public gr_sync_block +class GR_CORE_API gr_diff_decoder_bb : public gr_sync_block { - friend gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); + friend GR_CORE_API gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus); gr_diff_decoder_bb(unsigned int modulus); unsigned int d_modulus; diff --git a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h index 50aff73cf..c99e226da 100644 --- a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h +++ b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_DIFF_ENCODER_BB_H #define INCLUDED_GR_DIFF_ENCODER_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_diff_encoder_bb; typedef boost::shared_ptr<gr_diff_encoder_bb> gr_diff_encoder_bb_sptr; -gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); +GR_CORE_API gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); /*! * \brief y[0] = (x[0] + y[-1]) % M @@ -36,9 +37,9 @@ gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); * * Differential encoder */ -class gr_diff_encoder_bb : public gr_sync_block +class GR_CORE_API gr_diff_encoder_bb : public gr_sync_block { - friend gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); + friend GR_CORE_API gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus); gr_diff_encoder_bb(unsigned int modulus); unsigned int d_last_out; diff --git a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h index 1070ba183..8af2699a7 100644 --- a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h +++ b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_DIFF_PHASOR_CC_H #define INCLUDED_GR_DIFF_PHASOR_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> /*! @@ -32,12 +33,12 @@ class gr_diff_phasor_cc; typedef boost::shared_ptr<gr_diff_phasor_cc> gr_diff_phasor_cc_sptr; -gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc (); +GR_CORE_API gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc (); -class gr_diff_phasor_cc : public gr_sync_block +class GR_CORE_API gr_diff_phasor_cc : public gr_sync_block { - friend gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc (); + friend GR_CORE_API gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc (); gr_diff_phasor_cc (); //constructor diff --git a/gnuradio-core/src/lib/general/gr_dpll_bb.h b/gnuradio-core/src/lib/general/gr_dpll_bb.h index e6b5fc0fa..8e748dddb 100644 --- a/gnuradio-core/src/lib/general/gr_dpll_bb.h +++ b/gnuradio-core/src/lib/general/gr_dpll_bb.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_DPLL_BB_H #define INCLUDED_GR_DPLL_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_dpll_bb; typedef boost::shared_ptr<gr_dpll_bb> gr_dpll_bb_sptr; -gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); +GR_CORE_API gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); /*! * \brief Detect the peak of a signal @@ -37,9 +38,9 @@ gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); * If a peak is detected, this block outputs a 1, * or it outputs 0's. */ -class gr_dpll_bb : public gr_sync_block +class GR_CORE_API gr_dpll_bb : public gr_sync_block { - friend gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); + friend GR_CORE_API gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); gr_dpll_bb (float period, float gain); diff --git a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h index 86832ee05..e24ae9151 100644 --- a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h +++ b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h @@ -20,13 +20,14 @@ #ifndef INCLUDED_GR_ENCODE_CCSDS_27_BB_H #define INCLUDED_GR_ENCODE_CCSDS_27_BB_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_encode_ccsds_27_bb; typedef boost::shared_ptr<gr_encode_ccsds_27_bb> gr_encode_ccsds_27_bb_sptr; -gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); +GR_CORE_API gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); /*! \brief A rate 1/2, k=7 convolutional encoder for the CCSDS standard * \ingroup ecc @@ -44,10 +45,10 @@ gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); * There is no provision to "flush" the encoder. */ -class gr_encode_ccsds_27_bb : public gr_sync_interpolator +class GR_CORE_API gr_encode_ccsds_27_bb : public gr_sync_interpolator { private: - friend gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); + friend GR_CORE_API gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); gr_encode_ccsds_27_bb(); unsigned char d_encstate; diff --git a/gnuradio-core/src/lib/general/gr_expj.h b/gnuradio-core/src/lib/general/gr_expj.h index 7adf3a0c6..6f1d56eb3 100644 --- a/gnuradio-core/src/lib/general/gr_expj.h +++ b/gnuradio-core/src/lib/general/gr_expj.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_EXPJ_H #define INCLUDED_GR_EXPJ_H +#include <gr_core_api.h> #include <gr_sincos.h> #include <gr_types.h> diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h index 480fb8e78..2560c6105 100644 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h +++ b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H #define INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_fake_channel_encoder_pp; typedef boost::shared_ptr<gr_fake_channel_encoder_pp> gr_fake_channel_encoder_pp_sptr; -gr_fake_channel_encoder_pp_sptr +GR_CORE_API gr_fake_channel_encoder_pp_sptr gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); /*! @@ -37,14 +38,14 @@ gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); * * input: stream of byte vectors; output: stream of byte vectors */ -class gr_fake_channel_encoder_pp : public gr_sync_block +class GR_CORE_API gr_fake_channel_encoder_pp : public gr_sync_block { int d_input_vlen; int d_output_vlen; gr_fake_channel_encoder_pp(int input_vlen, int output_vlen); - friend gr_fake_channel_encoder_pp_sptr + friend GR_CORE_API gr_fake_channel_encoder_pp_sptr gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); public: @@ -60,7 +61,7 @@ public: class gr_fake_channel_decoder_pp; typedef boost::shared_ptr<gr_fake_channel_decoder_pp> gr_fake_channel_decoder_pp_sptr; -gr_fake_channel_decoder_pp_sptr +GR_CORE_API gr_fake_channel_decoder_pp_sptr gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); /*! @@ -69,14 +70,14 @@ gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); * * input: stream of byte vectors; output: stream of byte vectors */ -class gr_fake_channel_decoder_pp : public gr_sync_block +class GR_CORE_API gr_fake_channel_decoder_pp : public gr_sync_block { int d_input_vlen; int d_output_vlen; gr_fake_channel_decoder_pp(int input_vlen, int output_vlen); - friend gr_fake_channel_decoder_pp_sptr + friend GR_CORE_API gr_fake_channel_decoder_pp_sptr gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); public: diff --git a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h index 8c600d3d1..a97dbd958 100644 --- a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h +++ b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h @@ -23,21 +23,22 @@ #ifndef INCLUDED_GR_FEEDFORWARD_AGC_CC_H #define INCLUDED_GR_FEEDFORWARD_AGC_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_feedforward_agc_cc; typedef boost::shared_ptr<gr_feedforward_agc_cc> gr_feedforward_agc_cc_sptr; -gr_feedforward_agc_cc_sptr +GR_CORE_API gr_feedforward_agc_cc_sptr gr_make_feedforward_agc_cc(int nsamples, float reference = 1.0); /*! * \brief Non-causal AGC which computes required gain based on max absolute value over nsamples * \ingroup level_blk */ -class gr_feedforward_agc_cc : public gr_sync_block +class GR_CORE_API gr_feedforward_agc_cc : public gr_sync_block { - friend gr_feedforward_agc_cc_sptr + friend GR_CORE_API gr_feedforward_agc_cc_sptr gr_make_feedforward_agc_cc(int nsamples, float reference); int d_nsamples; diff --git a/gnuradio-core/src/lib/general/gr_feval.h b/gnuradio-core/src/lib/general/gr_feval.h index cc4209af0..a0e448ebf 100644 --- a/gnuradio-core/src/lib/general/gr_feval.h +++ b/gnuradio-core/src/lib/general/gr_feval.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FEVAL_H #define INCLUDED_GR_FEVAL_H +#include <gr_core_api.h> #include <gr_complex.h> /*! @@ -37,7 +38,7 @@ * Use calleval to invoke eval (this kludge is required to allow a * python specific "shim" to be inserted. */ -class gr_feval_dd +class GR_CORE_API gr_feval_dd { protected: /*! @@ -65,7 +66,7 @@ public: * Use calleval to invoke eval (this kludge is required to allow a * python specific "shim" to be inserted. */ -class gr_feval_cc +class GR_CORE_API gr_feval_cc { protected: /*! @@ -93,7 +94,7 @@ public: * Use calleval to invoke eval (this kludge is required to allow a * python specific "shim" to be inserted. */ -class gr_feval_ll +class GR_CORE_API gr_feval_ll { protected: /*! @@ -121,7 +122,7 @@ public: * Use calleval to invoke eval (this kludge is required to allow a * python specific "shim" to be inserted. */ -class gr_feval +class GR_CORE_API gr_feval { protected: /*! @@ -139,9 +140,9 @@ public: /*! * \brief trivial examples / test cases showing C++ calling Python code */ -double gr_feval_dd_example(gr_feval_dd *f, double x); -gr_complex gr_feval_cc_example(gr_feval_cc *f, gr_complex x); -long gr_feval_ll_example(gr_feval_ll *f, long x); -void gr_feval_example(gr_feval *f); +GR_CORE_API double gr_feval_dd_example(gr_feval_dd *f, double x); +GR_CORE_API gr_complex gr_feval_cc_example(gr_feval_cc *f, gr_complex x); +GR_CORE_API long gr_feval_ll_example(gr_feval_ll *f, long x); +GR_CORE_API void gr_feval_example(gr_feval *f); #endif /* INCLUDED_GR_FEVAL_H */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.h b/gnuradio-core/src/lib/general/gr_fft_vcc.h index 2ab9241ec..a7c8e1162 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.h +++ b/gnuradio-core/src/lib/general/gr_fft_vcc.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FFT_VCC_H #define INCLUDED_GR_FFT_VCC_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_fft_vcc; typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr; -gr_fft_vcc_sptr +GR_CORE_API gr_fft_vcc_sptr gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift=false); /*! @@ -37,10 +38,10 @@ gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, b * * Abstract base class */ -class gr_fft_vcc : public gr_sync_block +class GR_CORE_API gr_fft_vcc : public gr_sync_block { protected: - friend gr_fft_vcc_sptr + friend GR_CORE_API gr_fft_vcc_sptr gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift); unsigned int d_fft_size; diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h index c026162ee..8535d133c 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h +++ b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h @@ -23,11 +23,12 @@ #ifndef INCLUDED_GR_FFT_VCC_FFTW_H #define INCLUDED_GR_FFT_VCC_FFTW_H +#include <gr_core_api.h> #include <gr_fft_vcc.h> class gri_fft_complex; -gr_fft_vcc_sptr +GR_CORE_API gr_fft_vcc_sptr gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &window, bool shift=false); /*! @@ -36,9 +37,9 @@ gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &wind * * Concrete class that uses FFTW. */ -class gr_fft_vcc_fftw : public gr_fft_vcc +class GR_CORE_API gr_fft_vcc_fftw : public gr_fft_vcc { - friend gr_fft_vcc_sptr + friend GR_CORE_API gr_fft_vcc_sptr gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &window, bool shift); gri_fft_complex *d_fft; diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.h b/gnuradio-core/src/lib/general/gr_fft_vfc.h index 074574477..6cf6b9037 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.h +++ b/gnuradio-core/src/lib/general/gr_fft_vfc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_FFT_VFC_H #define INCLUDED_GR_FFT_VFC_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gri_fft_complex; @@ -30,7 +31,7 @@ class gri_fft_complex; class gr_fft_vfc; typedef boost::shared_ptr<gr_fft_vfc> gr_fft_vfc_sptr; -gr_fft_vfc_sptr +GR_CORE_API gr_fft_vfc_sptr gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window); /*! @@ -38,9 +39,9 @@ gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window); * \ingroup dft_blk */ -class gr_fft_vfc : public gr_sync_block +class GR_CORE_API gr_fft_vfc : public gr_sync_block { - friend gr_fft_vfc_sptr + friend GR_CORE_API gr_fft_vfc_sptr gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window); unsigned int d_fft_size; diff --git a/gnuradio-core/src/lib/general/gr_firdes.h b/gnuradio-core/src/lib/general/gr_firdes.h index de775bd07..83fa7e119 100644 --- a/gnuradio-core/src/lib/general/gr_firdes.h +++ b/gnuradio-core/src/lib/general/gr_firdes.h @@ -23,6 +23,7 @@ #ifndef _GR_FIRDES_H_ #define _GR_FIRDES_H_ +#include <gr_core_api.h> #include <vector> #include <cmath> #include <gr_complex.h> @@ -32,7 +33,7 @@ * \ingroup filter_design */ -class gr_firdes { +class GR_CORE_API gr_firdes { public: enum win_type { diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc deleted file mode 100644 index c32398e6d..000000000 --- a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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_fll_band_edge_cc.h> -#include <gr_fir_ccc.h> -#include <gr_fir_util.h> -#include <gri_fft.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_math.h> -#include <cstdio> - -#define M_TWOPI (2*M_PI) - -float sinc(float x) -{ - if(x == 0) - return 1; - else - return sin(M_PI*x)/(M_PI*x); -} - - - -gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float gain_alpha, float gain_beta) -{ - return gnuradio::get_initial_sptr(new gr_fll_band_edge_cc (samps_per_sym, rolloff, - filter_size, gain_alpha, gain_beta)); -} - - -static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(gr_complex)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -gr_fll_band_edge_cc::gr_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float alpha, float beta) - : gr_sync_block ("fll_band_edge_cc", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signaturev (1, 4, iosig)), - d_alpha(alpha), d_beta(beta), d_updated (false) -{ - // base this on the number of samples per symbol - d_max_freq = M_TWOPI * (2.0/samps_per_sym); - d_min_freq = -M_TWOPI * (2.0/samps_per_sym); - - d_freq = 0; - d_phase = 0; - - set_alpha(alpha); - - design_filter(samps_per_sym, rolloff, filter_size); -} - -gr_fll_band_edge_cc::~gr_fll_band_edge_cc () -{ - delete d_filter_lower; - delete d_filter_upper; -} - -void -gr_fll_band_edge_cc::set_alpha(float alpha) -{ - //float eta = sqrt(2.0)/2.0; - //float theta = alpha; - //d_alpha = (4*eta*theta) / (1.0 + 2.0*eta*theta + theta*theta); - //d_beta = (4*theta*theta) / (1.0 + 2.0*eta*theta + theta*theta); - d_alpha = alpha; -} - -void -gr_fll_band_edge_cc::design_filter(float samps_per_sym, float rolloff, int filter_size) -{ - int M = rint(filter_size / samps_per_sym); - float power = 0; - std::vector<float> bb_taps; - for(int i = 0; i < filter_size; i++) { - float k = -M + i*2.0/samps_per_sym; - float tap = sinc(rolloff*k - 0.5) + sinc(rolloff*k + 0.5); - power += tap; - - bb_taps.push_back(tap); - } - - int N = (bb_taps.size() - 1.0)/2.0; - std::vector<gr_complex> taps_lower; - std::vector<gr_complex> taps_upper; - for(unsigned int i = 0; i < bb_taps.size(); i++) { - float tap = bb_taps[i] / power; - - float k = (-N + (int)i)/(2.0*samps_per_sym); - - gr_complex t1 = tap * gr_expj(-2*M_PI*(1+rolloff)*k); - gr_complex t2 = tap * gr_expj(2*M_PI*(1+rolloff)*k); - - taps_lower.push_back(t1); - taps_upper.push_back(t2); - } - - std::vector<gr_complex> vtaps(0, taps_lower.size()); - d_filter_upper = gr_fir_util::create_gr_fir_ccc(vtaps); - d_filter_lower = gr_fir_util::create_gr_fir_ccc(vtaps); - - d_filter_lower->set_taps(taps_lower); - d_filter_upper->set_taps(taps_upper); - - d_updated = true; - - // Set the history to ensure enough input items for each filter - set_history(filter_size+1); - -} - -void -gr_fll_band_edge_cc::print_taps() -{ - unsigned int i; - std::vector<gr_complex> taps_upper = d_filter_upper->get_taps(); - std::vector<gr_complex> taps_lower = d_filter_lower->get_taps(); - - printf("Upper Band-edge: ["); - for(i = 0; i < taps_upper.size(); i++) { - printf(" %.4e + %.4ej,", taps_upper[i].real(), taps_upper[i].imag()); - } - printf("]\n\n"); - - printf("Lower Band-edge: ["); - for(i = 0; i < taps_lower.size(); i++) { - printf(" %.4e + %.4ej,", taps_lower[i].real(), taps_lower[i].imag()); - } - printf("]\n\n"); -} - -int -gr_fll_band_edge_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - float *frq = NULL; - float *phs = NULL; - gr_complex *err = NULL; - if(output_items.size() > 2) { - frq = (float *) output_items[1]; - phs = (float *) output_items[2]; - err = (gr_complex *) output_items[3]; - } - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i; - gr_complex nco_out; - gr_complex out_upper, out_lower; - float error; - float avg_k = 0.1; - for(i = 0; i < noutput_items; i++) { - nco_out = gr_expj(d_phase); - out[i] = in[i] * nco_out; - - out_upper = (d_filter_upper->filter(&out[i])); - out_lower = (d_filter_lower->filter(&out[i])); - error = -real((out_upper + out_lower) * conj(out_upper - out_lower)); - d_error = avg_k*error + avg_k*d_error; // average error - - d_freq = d_freq + d_beta * d_error; - d_phase = d_phase + d_freq + d_alpha * d_error; - - if(d_phase > M_PI) - d_phase -= M_TWOPI; - else if(d_phase < -M_PI) - d_phase += M_TWOPI; - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; - - if(output_items.size() > 2) { - frq[i] = d_freq; - phs[i] = d_phase; - err[i] = d_error; - } - } - - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h deleted file mode 100644 index db060793e..000000000 --- a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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_FLL_BAND_EDGE_CC_H -#define INCLUDED_GR_FLL_BAND_EDGE_CC_H - -#include <gr_sync_block.h> - -class gr_fll_band_edge_cc; -typedef boost::shared_ptr<gr_fll_band_edge_cc> gr_fll_band_edge_cc_sptr; -gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float alpha, float beta); - -class gr_fir_ccc; -class gri_fft_complex; - -/*! - * \class gr_fll_band_edge_cc - * \brief Frequency Lock Loop using band-edge filters - * - * \ingroup general - * - * The frequency lock loop derives a band-edge filter that covers the upper and lower bandwidths - * of a digitally-modulated signal. The bandwidth range is determined by the excess bandwidth - * (e.g., rolloff factor) of the modulated signal. The placement in frequency of the band-edges - * is determined by the oversampling ratio (number of samples per symbol) and the excess bandwidth. - * The size of the filters should be fairly large so as to average over a number of symbols. - * - * The FLL works by filtering the upper and lower band edges into x_u(t) and x_l(t), respectively. - * These are combined to form cc(t) = x_u(t) + x_l(t) and ss(t) = x_u(t) - x_l(t). Combining - * these to form the signal e(t) = Re{cc(t) \\times ss(t)^*} (where ^* is the complex conjugate) - * provides an error signal at the DC term that is directly proportional to the carrier frequency. - * We then make a second-order loop using the error signal that is the running average of e(t). - * - * In theory, the band-edge filter is the derivative of the matched filter in frequency, - * (H_be(f) = \\frac{H(f)}{df}. In practice, this comes down to a quarter sine wave at the point - * of the matched filter's rolloff (if it's a raised-cosine, the derivative of a cosine is a sine). - * Extend this sine by another quarter wave to make a half wave around the band-edges is equivalent - * in time to the sum of two sinc functions. The baseband filter fot the band edges is therefore - * derived from this sum of sincs. The band edge filters are then just the baseband signal - * modulated to the correct place in frequency. All of these calculations are done in the - * 'design_filter' function. - * - * Note: We use FIR filters here because the filters have to have a flat phase response over the - * entire frequency range to allow their comparisons to be valid. - */ - -class gr_fll_band_edge_cc : public gr_sync_block -{ - private: - /*! - * Build the FLL - * \param samps_per_sym (float) Number of samples per symbol of signal - * \param rolloff (float) Rolloff factor of signal - * \param filter_size (int) Size (in taps) of the filter - * \param alpha (float) Loop gain 1 - * \param beta (float) Loop gain 2 - */ - friend gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float alpha, float beta); - - float d_alpha; - float d_beta; - float d_max_freq; - float d_min_freq; - - gr_fir_ccc* d_filter_upper; - gr_fir_ccc* d_filter_lower; - bool d_updated; - float d_error; - float d_freq; - float d_phase; - - /*! - * Build the FLL - * \param samps_per_sym (float) number of samples per symbol - * \param rolloff (float) Rolloff (excess bandwidth) of signal filter - * \param filter_size (int) number of filter taps to generate - * \param alpha (float) Alpha gain in the control loop - * \param beta (float) Beta gain in the control loop - */ - gr_fll_band_edge_cc(float samps_per_sym, float rolloff, - int filter_size, float alpha, float beta); - -public: - ~gr_fll_band_edge_cc (); - - /*! - * Design the band-edge filter based on the number of samples per symbol, - * filter rolloff factor, and the filter size - * \param samps_per_sym (float) Number of samples per symbol of signal - * \param rolloff (float) Rolloff factor of signal - * \param filter_size (int) Size (in taps) of the filter - */ - void design_filter(float samps_per_sym, float rolloff, int filter_size); - - /*! - * Set the alpha gainvalue - * \param alpha (float) new gain value - */ - void set_alpha(float alpha); - - /*! - * Set the beta gain value - * \param beta (float) new gain value - */ - void set_beta(float beta) { d_beta = beta; } - - /*! - * Print the taps to screen. - */ - void print_taps(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.h b/gnuradio-core/src/lib/general/gr_float_to_char.h index e65072bf0..434e2e9d0 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.h +++ b/gnuradio-core/src/lib/general/gr_float_to_char.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FLOAT_TO_CHAR_H #define INCLUDED_GR_FLOAT_TO_CHAR_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_float_to_char; typedef boost::shared_ptr<gr_float_to_char> gr_float_to_char_sptr; -gr_float_to_char_sptr +GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char (); /*! @@ -36,9 +37,9 @@ gr_make_float_to_char (); * \ingroup converter_blk */ -class gr_float_to_char : public gr_sync_block +class GR_CORE_API gr_float_to_char : public gr_sync_block { - friend gr_float_to_char_sptr gr_make_float_to_char (); + friend GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char (); gr_float_to_char (); public: diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.h b/gnuradio-core/src/lib/general/gr_float_to_complex.h index f6cc24852..596b595f3 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.h +++ b/gnuradio-core/src/lib/general/gr_float_to_complex.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_FLOAT_TO_COMPLEX_H #define INCLUDED_GR_FLOAT_TO_COMPLEX_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_complex.h> class gr_float_to_complex; typedef boost::shared_ptr<gr_float_to_complex> gr_float_to_complex_sptr; -gr_float_to_complex_sptr +GR_CORE_API gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen = 1); /*! @@ -37,9 +38,9 @@ gr_make_float_to_complex (size_t vlen = 1); * \ingroup converter_blk */ -class gr_float_to_complex : public gr_sync_block +class GR_CORE_API gr_float_to_complex : public gr_sync_block { - friend gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen); + friend GR_CORE_API gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen); gr_float_to_complex (size_t vlen); size_t d_vlen; diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.h b/gnuradio-core/src/lib/general/gr_float_to_short.h index e85343929..010d61141 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.h +++ b/gnuradio-core/src/lib/general/gr_float_to_short.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FLOAT_TO_SHORT_H #define INCLUDED_GR_FLOAT_TO_SHORT_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_float_to_short; typedef boost::shared_ptr<gr_float_to_short> gr_float_to_short_sptr; -gr_float_to_short_sptr +GR_CORE_API gr_float_to_short_sptr gr_make_float_to_short (); /*! @@ -36,9 +37,9 @@ gr_make_float_to_short (); * \ingroup converter_blk */ -class gr_float_to_short : public gr_sync_block +class GR_CORE_API gr_float_to_short : public gr_sync_block { - friend gr_float_to_short_sptr gr_make_float_to_short (); + friend GR_CORE_API gr_float_to_short_sptr gr_make_float_to_short (); gr_float_to_short (); public: diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.h b/gnuradio-core/src/lib/general/gr_float_to_uchar.h index 3bca9c555..fca8eb07b 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.h +++ b/gnuradio-core/src/lib/general/gr_float_to_uchar.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FLOAT_TO_UCHAR_H #define INCLUDED_GR_FLOAT_TO_UCHAR_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_float_to_uchar; typedef boost::shared_ptr<gr_float_to_uchar> gr_float_to_uchar_sptr; -gr_float_to_uchar_sptr +GR_CORE_API gr_float_to_uchar_sptr gr_make_float_to_uchar (); /*! @@ -36,9 +37,9 @@ gr_make_float_to_uchar (); * \ingroup converter_blk */ -class gr_float_to_uchar : public gr_sync_block +class GR_CORE_API gr_float_to_uchar : public gr_sync_block { - friend gr_float_to_uchar_sptr gr_make_float_to_uchar (); + friend GR_CORE_API gr_float_to_uchar_sptr gr_make_float_to_uchar (); gr_float_to_uchar (); public: diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.h b/gnuradio-core/src/lib/general/gr_fmdet_cf.h index 792646bef..7bf3baa3f 100644 --- a/gnuradio-core/src/lib/general/gr_fmdet_cf.h +++ b/gnuradio-core/src/lib/general/gr_fmdet_cf.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FMDET_CF_H #define INCLUDED_GR_FMDET_CF_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_fmdet_cf; typedef boost::shared_ptr<gr_fmdet_cf> gr_fmdet_cf_sptr; -gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl); +GR_CORE_API gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl); class gr_fir_ccf; @@ -43,9 +44,9 @@ class gr_fir_ccf; * normalization by the magnitude of the sample */ -class gr_fmdet_cf : public gr_sync_block +class GR_CORE_API gr_fmdet_cf : public gr_sync_block { - friend gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, + friend GR_CORE_API gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl); gr_complex d_S1,d_S2,d_S3,d_S4; diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.h b/gnuradio-core/src/lib/general/gr_framer_sink_1.h index 3f2e8aa88..95ad6ced7 100644 --- a/gnuradio-core/src/lib/general/gr_framer_sink_1.h +++ b/gnuradio-core/src/lib/general/gr_framer_sink_1.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_FRAMER_SINK_1_H #define INCLUDED_GR_FRAMER_SINK_1_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_msg_queue.h> class gr_framer_sink_1; typedef boost::shared_ptr<gr_framer_sink_1> gr_framer_sink_1_sptr; -gr_framer_sink_1_sptr +GR_CORE_API gr_framer_sink_1_sptr gr_make_framer_sink_1 (gr_msg_queue_sptr target_queue); /*! @@ -50,9 +51,9 @@ gr_make_framer_sink_1 (gr_msg_queue_sptr target_queue); * the first bit of the packet. That is, this bit is the first * one after the access code. */ -class gr_framer_sink_1 : public gr_sync_block +class GR_CORE_API gr_framer_sink_1 : public gr_sync_block { - friend gr_framer_sink_1_sptr + friend GR_CORE_API gr_framer_sink_1_sptr gr_make_framer_sink_1 (gr_msg_queue_sptr target_queue); private: diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h index 55f8412ce..932e7da36 100644 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h +++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FREQUENCY_MODULATOR_FC_H #define INCLUDED_GR_FREQUENCY_MODULATOR_FC_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_frequency_modulator_fc; typedef boost::shared_ptr<gr_frequency_modulator_fc> gr_frequency_modulator_fc_sptr; -gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity); +GR_CORE_API gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity); /*! * \brief Frequency modulator block @@ -36,19 +37,19 @@ gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivit * * float input; complex baseband output */ -class gr_frequency_modulator_fc : public gr_sync_block +class GR_CORE_API gr_frequency_modulator_fc : public gr_sync_block { double d_sensitivity; double d_phase; - friend gr_frequency_modulator_fc_sptr + friend GR_CORE_API gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity); gr_frequency_modulator_fc (double sensitivity); public: void set_sensitivity(float sens) { d_sensitivity = sens; } - float get_sensitivity() { return d_sensitivity; } + float sensitivity() const { return d_sensitivity; } int work (int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i index 04d9a41ba..7dfb82f1f 100644 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i +++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i @@ -30,5 +30,5 @@ class gr_frequency_modulator_fc : public gr_sync_block gr_frequency_modulator_fc (double sensitivity); public: void set_sensitivity(float sens) { d_sensitivity = sens; } - float get_sensitivity() { return d_sensitivity; } + float sensitivity() const { return d_sensitivity; } }; diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h index c98d31b27..5cf736dfb 100644 --- a/gnuradio-core/src/lib/general/gr_fxpt.h +++ b/gnuradio-core/src/lib/general/gr_fxpt.h @@ -22,10 +22,11 @@ #ifndef INCLUDED_GR_FXPT_H #define INCLUDED_GR_FXPT_H +#include <gr_core_api.h> #include <gr_types.h> /*! - * \brief fixed point sine and cosine and friends. + * \brief fixed point sine and cosine and friend GR_CORE_APIs. * \ingroup misc * * fixed pt radians @@ -35,7 +36,7 @@ * 2**31-1 pi - epsilon * */ -class gr_fxpt +class GR_CORE_API gr_fxpt { static const int WORDBITS = 32; static const int NBITS = 10; diff --git a/gnuradio-core/src/lib/general/gr_fxpt_nco.h b/gnuradio-core/src/lib/general/gr_fxpt_nco.h index ca0d54f02..5597efb4f 100644 --- a/gnuradio-core/src/lib/general/gr_fxpt_nco.h +++ b/gnuradio-core/src/lib/general/gr_fxpt_nco.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FXPT_NCO_H #define INCLUDED_GR_FXPT_NCO_H +#include <gr_core_api.h> #include <gr_fxpt.h> #include <gr_complex.h> @@ -29,7 +30,7 @@ * \brief Numerically Controlled Oscillator (NCO) * \ingroup misc */ -class gr_fxpt_nco { +class GR_CORE_API gr_fxpt_nco { gr_uint32 d_phase; gr_int32 d_phase_inc; diff --git a/gnuradio-core/src/lib/general/gr_fxpt_vco.h b/gnuradio-core/src/lib/general/gr_fxpt_vco.h index 1ff968b79..a77a31311 100644 --- a/gnuradio-core/src/lib/general/gr_fxpt_vco.h +++ b/gnuradio-core/src/lib/general/gr_fxpt_vco.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_FXPT_VCO_H #define INCLUDED_GR_FXPT_VCO_H +#include <gr_core_api.h> #include <gr_fxpt.h> #include <gr_complex.h> @@ -29,7 +30,7 @@ * \brief Voltage Controlled Oscillator (VCO) * \ingroup misc */ -class gr_fxpt_vco { +class GR_CORE_API gr_fxpt_vco { gr_int32 d_phase; public: diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_b.h b/gnuradio-core/src/lib/general/gr_glfsr_source_b.h index cff8df11b..bd66912ed 100644 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_b.h +++ b/gnuradio-core/src/lib/general/gr_glfsr_source_b.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_GLFSR_SOURCE_B_H #define INCLUDED_GR_GLFSR_SOURCE_B_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gri_glfsr; @@ -30,16 +31,16 @@ class gri_glfsr; class gr_glfsr_source_b; typedef boost::shared_ptr<gr_glfsr_source_b> gr_glfsr_source_b_sptr; -gr_glfsr_source_b_sptr gr_make_glfsr_source_b(int degree, bool repeat=true, int mask=0, int seed=1); +GR_CORE_API gr_glfsr_source_b_sptr gr_make_glfsr_source_b(int degree, bool repeat=true, int mask=0, int seed=1); /*! * \brief Galois LFSR pseudo-random source * \ingroup source_blk */ -class gr_glfsr_source_b : public gr_sync_block +class GR_CORE_API gr_glfsr_source_b : public gr_sync_block { private: - friend gr_glfsr_source_b_sptr + friend GR_CORE_API gr_glfsr_source_b_sptr gr_make_glfsr_source_b(int degree, bool repeat, int mask, int seed); gri_glfsr *d_glfsr; diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_f.h b/gnuradio-core/src/lib/general/gr_glfsr_source_f.h index 007970806..2dd09c5ac 100644 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_f.h +++ b/gnuradio-core/src/lib/general/gr_glfsr_source_f.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_GLFSR_SOURCE_F_H #define INCLUDED_GR_GLFSR_SOURCE_F_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gri_glfsr; @@ -30,16 +31,16 @@ class gri_glfsr; class gr_glfsr_source_f; typedef boost::shared_ptr<gr_glfsr_source_f> gr_glfsr_source_f_sptr; -gr_glfsr_source_f_sptr gr_make_glfsr_source_f(int degree, bool repeat=true, int mask=0, int seed=1); +GR_CORE_API gr_glfsr_source_f_sptr gr_make_glfsr_source_f(int degree, bool repeat=true, int mask=0, int seed=1); /*! * \brief Galois LFSR pseudo-random source generating float outputs -1.0 - 1.0 * \ingroup source_blk */ -class gr_glfsr_source_f : public gr_sync_block +class GR_CORE_API gr_glfsr_source_f : public gr_sync_block { private: - friend gr_glfsr_source_f_sptr + friend GR_CORE_API gr_glfsr_source_f_sptr gr_make_glfsr_source_f(int degree, bool repeat, int mask, int seed); gri_glfsr *d_glfsr; diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h index f7eee1064..f66d43308 100644 --- a/gnuradio-core/src/lib/general/gr_head.h +++ b/gnuradio-core/src/lib/general/gr_head.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_HEAD_H #define INCLUDED_GR_HEAD_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <stddef.h> // size_t @@ -36,9 +37,9 @@ typedef boost::shared_ptr<gr_head> gr_head_sptr; * Useful for building test cases */ -class gr_head : public gr_sync_block +class GR_CORE_API gr_head : public gr_sync_block { - friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); + friend GR_CORE_API gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); gr_head (size_t sizeof_stream_item, unsigned long long nitems); unsigned long long d_nitems; @@ -52,7 +53,7 @@ class gr_head : public gr_sync_block void reset() { d_ncopied_items = 0; } }; -gr_head_sptr +GR_CORE_API gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h index cf1223be5..9af381ba9 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.h +++ b/gnuradio-core/src/lib/general/gr_int_to_float.h @@ -23,22 +23,23 @@ #ifndef INCLUDED_GR_INT_TO_FLOAT_H #define INCLUDED_GR_INT_TO_FLOAT_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_int_to_float; typedef boost::shared_ptr<gr_int_to_float> gr_int_to_float_sptr; -gr_int_to_float_sptr +GR_CORE_API gr_int_to_float_sptr gr_make_int_to_float (); /*! - * \brief Convert stream of short to a stream of float + * \brief Convert stream of int to a stream of float * \ingroup converter_blk */ -class gr_int_to_float : public gr_sync_block +class GR_CORE_API gr_int_to_float : public gr_sync_block { - friend gr_int_to_float_sptr gr_make_int_to_float (); + friend GR_CORE_API gr_int_to_float_sptr gr_make_int_to_float (); gr_int_to_float (); public: diff --git a/gnuradio-core/src/lib/general/gr_interleave.h b/gnuradio-core/src/lib/general/gr_interleave.h index faffdd757..ef7bce07a 100644 --- a/gnuradio-core/src/lib/general/gr_interleave.h +++ b/gnuradio-core/src/lib/general/gr_interleave.h @@ -23,20 +23,21 @@ #ifndef INCLUDED_GR_INTERLEAVE_H #define INCLUDED_GR_INTERLEAVE_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_interleave; typedef boost::shared_ptr<gr_interleave> gr_interleave_sptr; -gr_interleave_sptr gr_make_interleave (size_t itemsize); +GR_CORE_API gr_interleave_sptr gr_make_interleave (size_t itemsize); /*! * \brief interleave N inputs to a single output * \ingroup slicedice_blk */ -class gr_interleave : public gr_sync_interpolator +class GR_CORE_API gr_interleave : public gr_sync_interpolator { - friend gr_interleave_sptr gr_make_interleave (size_t itemsize); + friend GR_CORE_API gr_interleave_sptr gr_make_interleave (size_t itemsize); size_t d_itemsize; diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h index c79a9370f..40f1636bd 100644 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h +++ b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_INTERLEAVED_SHORT_TO_COMPLEX_H #define INCLUDED_GR_INTERLEAVED_SHORT_TO_COMPLEX_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_interleaved_short_to_complex; typedef boost::shared_ptr<gr_interleaved_short_to_complex> gr_interleaved_short_to_complex_sptr; -gr_interleaved_short_to_complex_sptr +GR_CORE_API gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex (); /*! @@ -37,9 +38,9 @@ gr_make_interleaved_short_to_complex (); * \ingroup converter_blk */ -class gr_interleaved_short_to_complex : public gr_sync_decimator +class GR_CORE_API gr_interleaved_short_to_complex : public gr_sync_decimator { - friend gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex (); + friend GR_CORE_API gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex (); gr_interleaved_short_to_complex (); public: diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h b/gnuradio-core/src/lib/general/gr_iqcomp_cc.h index f4c6cf8ea..c01e2a6ba 100644 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h +++ b/gnuradio-core/src/lib/general/gr_iqcomp_cc.h @@ -24,20 +24,21 @@ #ifndef INCLUDED_GR_IQCOMP_CC_H #define INCLUDED_GR_IQCOMP_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_iqcomp_cc; typedef boost::shared_ptr<gr_iqcomp_cc> gr_iqcomp_cc_sptr; -gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); +GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); /*! * \brief * \ingroup misc_blk */ -class gr_iqcomp_cc : public gr_sync_block +class GR_CORE_API gr_iqcomp_cc : public gr_sync_block { - friend gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); + friend GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); float d_mu, d_wi, d_wq; gr_iqcomp_cc (float mu); 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 8bccefa95..3f98a003b 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 @@ -91,15 +91,13 @@ gr_keep_one_in_n::general_work (int noutput_items, // 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; + std::vector<gr_tag_t> tags; + std::vector<gr_tag_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)); + gr_tag_t new_tag = *t; + new_tag.offset *= d_decim_rate; + add_item_tag(0, new_tag); } consume_each (ni); 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 ba573618e..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 @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_KEEP_ONE_IN_N_H #define INCLUDED_GR_KEEP_ONE_IN_N_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_keep_one_in_n; typedef boost::shared_ptr<gr_keep_one_in_n> gr_keep_one_in_n_sptr; -gr_keep_one_in_n_sptr +GR_CORE_API gr_keep_one_in_n_sptr gr_make_keep_one_in_n (size_t item_size, int n); @@ -36,9 +37,9 @@ gr_make_keep_one_in_n (size_t item_size, int n); * \brief decimate a stream, keeping one item out of every n. * \ingroup slicedice_blk */ -class gr_keep_one_in_n : public gr_block +class GR_CORE_API gr_keep_one_in_n : public gr_block { - friend gr_keep_one_in_n_sptr + friend GR_CORE_API gr_keep_one_in_n_sptr gr_make_keep_one_in_n (size_t item_size, int n); int d_n; diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.h b/gnuradio-core/src/lib/general/gr_kludge_copy.h index 90fd047df..5c1e461a8 100644 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.h +++ b/gnuradio-core/src/lib/general/gr_kludge_copy.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_KLUDGE_COPY_H #define INCLUDED_GR_KLUDGE_COPY_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_kludge_copy; typedef boost::shared_ptr<gr_kludge_copy> gr_kludge_copy_sptr; -gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); +GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); /*! * \brief output[i] = input[i] @@ -36,11 +37,11 @@ gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); * * This is a short term kludge to work around a problem with the hierarchical block impl. */ -class gr_kludge_copy : public gr_sync_block +class GR_CORE_API gr_kludge_copy : public gr_sync_block { size_t d_itemsize; - friend gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); + friend GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); gr_kludge_copy(size_t itemsize); public: diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h index f8497e4cb..aa7ad7b1f 100644 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h +++ b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_LFSR_32K_SOURCE_S_H #define INCLUDED_GR_LFSR_32K_SOURCE_S_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gri_lfsr_32k.h> class gr_lfsr_32k_source_s; typedef boost::shared_ptr<gr_lfsr_32k_source_s> gr_lfsr_32k_source_s_sptr; -gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); +GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); /*! * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts) @@ -38,9 +39,9 @@ gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); * This source is typically used along with gr_check_lfsr_32k_s to test * the USRP using its digital loopback mode. */ -class gr_lfsr_32k_source_s : public gr_sync_block +class GR_CORE_API gr_lfsr_32k_source_s : public gr_sync_block { - friend gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); + friend GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.cc b/gnuradio-core/src/lib/general/gr_lms_dfe_cc.cc deleted file mode 100644 index 8659386d5..000000000 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.cc +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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_lms_dfe_cc.h> -#include <gr_io_signature.h> -#include <gr_misc.h> -#include <iostream> - -gr_complex -gr_lms_dfe_cc::slicer_0deg (gr_complex sample) -{ - gr_complex out; - if(fabs(real(sample))>fabs(imag(sample))) { - if(real(sample) > 0) - out = gr_complex(1,0); - else - out = gr_complex(-1,0); - } - else { - if(imag(sample) > 0) - out = gr_complex(0,1); - else - out = gr_complex(0,-1); - } - return out; -} - -gr_complex -gr_lms_dfe_cc::slicer_45deg (gr_complex sample) -{ - gr_complex out; - if(real(sample) > 0) - out = gr_complex(1,0); - else - out = gr_complex(-1,0); - if(imag(sample) > 0) - out += gr_complex(0,1); - else - out += gr_complex(0,-1); - return out; -} - -gr_lms_dfe_cc_sptr -gr_make_lms_dfe_cc (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps) -{ - return gnuradio::get_initial_sptr(new gr_lms_dfe_cc (lambda_ff, lambda_fb, - num_fftaps, num_fbtaps)); -} - -gr_lms_dfe_cc::gr_lms_dfe_cc (float lambda_ff, float lambda_fb , - unsigned int num_fftaps, unsigned int num_fbtaps) - : gr_sync_block ("lms_dfe_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_lambda_ff (lambda_ff), d_lambda_fb (lambda_fb), - d_ff_delayline(gr_rounduppow2(num_fftaps)), - d_fb_delayline(gr_rounduppow2(num_fbtaps)), - d_ff_taps(num_fftaps),d_fb_taps(num_fbtaps), - d_ff_index(0), d_fb_index(0) -{ - gr_zero_vector(d_ff_taps); - d_ff_taps [d_ff_taps.size()/2] = 1; - - gr_zero_vector(d_fb_taps); - gr_zero_vector(d_ff_delayline); - gr_zero_vector(d_fb_delayline); -} - -int -gr_lms_dfe_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (const gr_complex *) input_items[0]; - gr_complex *optr = (gr_complex *) output_items[0]; - - gr_complex acc, decision, error; - unsigned int i; - - unsigned int ff_mask = d_ff_delayline.size() - 1; // size is power of 2 - unsigned int fb_mask = d_fb_delayline.size() - 1; - - int size = noutput_items; - while (size-- > 0){ - acc = 0; - d_ff_delayline[d_ff_index] = *iptr++; - - // Compute output - for (i=0; i < d_ff_taps.size(); i++) - acc += conj(d_ff_delayline[(i+d_ff_index) & ff_mask]) * d_ff_taps[i]; - - for (i=0; i < d_fb_taps.size(); i++) - acc -= conj(d_fb_delayline[(i+d_fb_index) & fb_mask]) * d_fb_taps[i]; - - decision = slicer_45deg(acc); - error = decision - acc; - - // Update taps - for (i=0; i < d_ff_taps.size(); i++) - d_ff_taps[i] += d_lambda_ff * conj(error) * d_ff_delayline[(i+d_ff_index) & ff_mask]; - - for (i=0; i < d_fb_taps.size(); i++) - d_fb_taps[i] -= d_lambda_fb * conj(error) * d_fb_delayline[(i+d_fb_index) & fb_mask]; - - d_fb_index = (d_fb_index - 1) & fb_mask; // Decrement index - d_ff_index = (d_ff_index - 1) & ff_mask; // Decrement index - - d_fb_delayline[d_fb_index] = decision; // Save decision in feedback - - *optr++ = acc; // Output decision - } - - if (0){ - std::cout << "FF Taps\t"; - for(i=0;i<d_ff_taps.size();i++) - std::cout << d_ff_taps[i] << "\t"; - std::cout << std::endl << "FB Taps\t"; - for(i=0;i<d_fb_taps.size();i++) - std::cout << d_fb_taps[i] << "\t"; - std::cout << std::endl; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.h b/gnuradio-core/src/lib/general/gr_lms_dfe_cc.h deleted file mode 100644 index 7b3a2c84e..000000000 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_LMS_DFE_CC_H -#define INCLUDED_GR_LMS_DFE_CC_H - -#include <gr_sync_block.h> - -class gr_lms_dfe_cc; -typedef boost::shared_ptr<gr_lms_dfe_cc> gr_lms_dfe_cc_sptr; - -gr_lms_dfe_cc_sptr gr_make_lms_dfe_cc (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - -/*! - * \brief Least-Mean-Square Decision Feedback Equalizer (complex in/out) - * \ingroup eq_blk - */ -class gr_lms_dfe_cc : public gr_sync_block -{ - friend gr_lms_dfe_cc_sptr gr_make_lms_dfe_cc (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - - float d_lambda_ff; - float d_lambda_fb; - std::vector<gr_complex> d_ff_delayline; - std::vector<gr_complex> d_fb_delayline; - std::vector<gr_complex> d_ff_taps; - std::vector<gr_complex> d_fb_taps; - unsigned int d_ff_index; - unsigned int d_fb_index; - - gr_lms_dfe_cc (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - gr_complex slicer_0deg(gr_complex baud); - gr_complex slicer_45deg(gr_complex baud); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.i b/gnuradio-core/src/lib/general/gr_lms_dfe_cc.i deleted file mode 100644 index 9a9f22b6e..000000000 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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,lms_dfe_cc) - -gr_lms_dfe_cc_sptr gr_make_lms_dfe_cc (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - -class gr_lms_dfe_cc : public gr_sync_block -{ - private: - gr_lms_dfe_cc (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - gr_complex slicer_0deg(gr_complex baud); - gr_complex slicer_45deg(gr_complex baud); - gr_complex conjg(gr_complex val); -}; diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.cc b/gnuradio-core/src/lib/general/gr_lms_dfe_ff.cc deleted file mode 100644 index 8a5e22c2f..000000000 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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_lms_dfe_ff.h> -#include <gr_io_signature.h> -#include <gr_misc.h> -#include <iostream> - -float -slice(float val) -{ - if (val>0) - return 1; - else - return -1; -} - -gr_lms_dfe_ff_sptr -gr_make_lms_dfe_ff (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps) -{ - return gnuradio::get_initial_sptr(new gr_lms_dfe_ff (lambda_ff,lambda_fb,num_fftaps,num_fbtaps)); -} - -gr_lms_dfe_ff::gr_lms_dfe_ff (float lambda_ff, float lambda_fb , - unsigned int num_fftaps, unsigned int num_fbtaps) - : gr_sync_block ("lms_dfe_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_lambda_ff (lambda_ff), d_lambda_fb (lambda_fb), - d_ff_delayline(gr_rounduppow2(num_fftaps)), - d_fb_delayline(gr_rounduppow2(num_fbtaps)), - d_ff_taps(num_fftaps), d_fb_taps(num_fbtaps), - d_ff_index(0), d_fb_index(0) -{ - gr_zero_vector(d_ff_taps); - d_ff_taps [d_ff_taps.size()/2] = 1; - - gr_zero_vector(d_fb_taps); - gr_zero_vector(d_ff_delayline); - gr_zero_vector(d_fb_delayline); -} - -int -gr_lms_dfe_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *iptr = (const float *) input_items[0]; - float *optr = (float *) output_items[0]; - - float acc, decision, error; - unsigned int i; - - unsigned int ff_mask = d_ff_delayline.size() - 1; // size is power of 2 - unsigned int fb_mask = d_fb_delayline.size() - 1; - - int size = noutput_items; - while(size-- > 0) { - acc = 0; - d_ff_delayline[d_ff_index] = *iptr++; - - // Compute output - for (i=0; i < d_ff_taps.size(); i++) - acc += d_ff_delayline[(i+d_ff_index) & ff_mask] * d_ff_taps[i]; - - for (i=0; i < d_fb_taps.size(); i++) - acc -= d_fb_delayline[(i+d_fb_index) & fb_mask] * d_fb_taps[i]; - - decision = slice(acc); - error = decision - acc; - - // Update taps - for (i=0; i < d_ff_taps.size(); i++) - d_ff_taps[i] += d_lambda_ff * error * d_ff_delayline[(i+d_ff_index) & ff_mask]; - - for (i=0; i < d_fb_taps.size(); i++) - d_fb_taps[i] -= d_lambda_fb * error * d_fb_delayline[(i+d_fb_index) & fb_mask]; - - d_fb_index = (d_fb_index - 1) & fb_mask; // Decrement index - d_ff_index = (d_ff_index - 1) & ff_mask; // Decrement index - - d_fb_delayline[d_fb_index] = decision; // Save decision in feedback - - *optr++ = acc; // Output decision - } - - if (0){ - std::cout << "FF Taps\t"; - for(i=0;i<d_ff_taps.size();i++) - std::cout << d_ff_taps[i] << "\t"; - std::cout << std::endl << "FB Taps\t"; - for(i=0;i<d_fb_taps.size();i++) - std::cout << d_fb_taps[i] << "\t"; - std::cout << std::endl; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.h b/gnuradio-core/src/lib/general/gr_lms_dfe_ff.h deleted file mode 100644 index dd610c470..000000000 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_LMS_DFE_FF_H -#define INCLUDED_GR_LMS_DFE_FF_H - -#include <gr_sync_block.h> - -class gr_lms_dfe_ff; -typedef boost::shared_ptr<gr_lms_dfe_ff> gr_lms_dfe_ff_sptr; - -gr_lms_dfe_ff_sptr gr_make_lms_dfe_ff (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - -/*! - * \brief Least-Mean-Square Decision Feedback Equalizer (float in/out) - * \ingroup eq_blk - */ -class gr_lms_dfe_ff : public gr_sync_block -{ - friend gr_lms_dfe_ff_sptr gr_make_lms_dfe_ff (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - - float d_lambda_ff; - float d_lambda_fb; - std::vector<float> d_ff_delayline; - std::vector<float> d_fb_delayline; - std::vector<float> d_ff_taps; - std::vector<float> d_fb_taps; - unsigned int d_ff_index; - unsigned int d_fb_index; - - gr_lms_dfe_ff (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.i b/gnuradio-core/src/lib/general/gr_lms_dfe_ff.i deleted file mode 100644 index 3ca488b52..000000000 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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,lms_dfe_ff) - -gr_lms_dfe_ff_sptr gr_make_lms_dfe_ff (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); - -class gr_lms_dfe_ff : public gr_sync_block -{ - private: - gr_lms_dfe_ff (float lambda_ff, float lambda_fb, - unsigned int num_fftaps, unsigned int num_fbtaps); -}; diff --git a/gnuradio-core/src/lib/general/gr_log2_const.h b/gnuradio-core/src/lib/general/gr_log2_const.h index 4ea420920..8e4a0860b 100644 --- a/gnuradio-core/src/lib/general/gr_log2_const.h +++ b/gnuradio-core/src/lib/general/gr_log2_const.h @@ -27,6 +27,7 @@ #ifndef INCLUDED_GR_LOG2_CONST_H #define INCLUDED_GR_LOG2_CONST_H +#include <gr_core_api.h> #include <assert.h> template<unsigned int k> static inline int gr_log2_const() { assert(0); return 0; } diff --git a/gnuradio-core/src/lib/general/gr_map_bb.h b/gnuradio-core/src/lib/general/gr_map_bb.h index 4986ab181..0820c6a16 100644 --- a/gnuradio-core/src/lib/general/gr_map_bb.h +++ b/gnuradio-core/src/lib/general/gr_map_bb.h @@ -22,21 +22,22 @@ #ifndef INCLUDED_GR_MAP_BB_H #define INCLUDED_GR_MAP_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_map_bb; typedef boost::shared_ptr<gr_map_bb> gr_map_bb_sptr; -gr_map_bb_sptr gr_make_map_bb(const std::vector<int> &map); +GR_CORE_API gr_map_bb_sptr gr_make_map_bb(const std::vector<int> &map); /*! * \brief output[i] = map[input[i]] * \ingroup coding_blk */ -class gr_map_bb : public gr_sync_block +class GR_CORE_API gr_map_bb : public gr_sync_block { - friend gr_map_bb_sptr gr_make_map_bb(const std::vector<int> &map); + friend GR_CORE_API gr_map_bb_sptr gr_make_map_bb(const std::vector<int> &map); unsigned char d_map[0x100]; diff --git a/gnuradio-core/src/lib/general/gr_math.h b/gnuradio-core/src/lib/general/gr_math.h index f5935c1da..9c61942cd 100644 --- a/gnuradio-core/src/lib/general/gr_math.h +++ b/gnuradio-core/src/lib/general/gr_math.h @@ -27,6 +27,7 @@ #ifndef _GR_MATH_H_ #define _GR_MATH_H_ +#include <gr_core_api.h> #include <gr_complex.h> static inline bool @@ -51,7 +52,7 @@ gr_is_power_of_2(long x) * to zero. This routine calculates the arc tangent with an average * error of +/- 0.045 degrees. */ -float gr_fast_atan2f(float y, float x); +GR_CORE_API float gr_fast_atan2f(float y, float x); static inline float gr_fast_atan2f(gr_complex z) { diff --git a/gnuradio-core/src/lib/general/gr_misc.h b/gnuradio-core/src/lib/general/gr_misc.h index 55cc7eda6..78f7e18ac 100644 --- a/gnuradio-core/src/lib/general/gr_misc.h +++ b/gnuradio-core/src/lib/general/gr_misc.h @@ -23,16 +23,17 @@ #ifndef INCLUDED_GR_MISC_H #define INCLUDED_GR_MISC_H +#include <gr_core_api.h> #include <gr_types.h> unsigned int gr_rounduppow2(unsigned int n); // FIXME should be template -void gr_zero_vector(std::vector<float> &v); -void gr_zero_vector(std::vector<double> &v); -void gr_zero_vector(std::vector<int> &v); -void gr_zero_vector(std::vector<gr_complex> &v); +GR_CORE_API void gr_zero_vector(std::vector<float> &v); +GR_CORE_API void gr_zero_vector(std::vector<double> &v); +GR_CORE_API void gr_zero_vector(std::vector<int> &v); +GR_CORE_API void gr_zero_vector(std::vector<gr_complex> &v); #endif /* INCLUDED_GR_MISC_H */ diff --git a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc deleted file mode 100644 index bc51c6769..000000000 --- a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc +++ /dev/null @@ -1,322 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2007,2010 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_io_signature.h> -#include <gr_prefs.h> -#include <gr_mpsk_receiver_cc.h> -#include <stdexcept> -#include <gr_math.h> -#include <gr_expj.h> -#include <gri_mmse_fir_interpolator_cc.h> - - -#define M_TWOPI (2*M_PI) -#define VERBOSE_MM 0 // Used for debugging symbol timing loop -#define VERBOSE_COSTAS 0 // Used for debugging phase and frequency tracking - -// Public constructor - -gr_mpsk_receiver_cc_sptr -gr_make_mpsk_receiver_cc(unsigned int M, float theta, - float alpha, float beta, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel) -{ - return gnuradio::get_initial_sptr(new gr_mpsk_receiver_cc (M, theta, - alpha, beta, - fmin, fmax, - mu, gain_mu, - omega, gain_omega, omega_rel)); -} - -gr_mpsk_receiver_cc::gr_mpsk_receiver_cc (unsigned int M, float theta, - float alpha, float beta, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel) - : gr_block ("mpsk_receiver_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_M(M), d_theta(theta), - d_alpha(alpha), d_beta(beta), d_freq(0), d_max_freq(fmax), d_min_freq(fmin), d_phase(0), - d_current_const_point(0), - d_mu(mu), d_gain_mu(gain_mu), d_gain_omega(gain_omega), - d_omega_rel(omega_rel), d_max_omega(0), d_min_omega(0), - d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0) -{ - d_interp = new gri_mmse_fir_interpolator_cc(); - d_dl_idx = 0; - - set_omega(omega); - - if (omega <= 0.0) - throw std::out_of_range ("clock rate must be > 0"); - if (gain_mu < 0 || gain_omega < 0) - throw std::out_of_range ("Gains must be non-negative"); - - assert(d_interp->ntaps() <= DLLEN); - - // zero double length delay line. - for (unsigned int i = 0; i < 2 * DLLEN; i++) - d_dl[i] = gr_complex(0.0,0.0); - - // build the constellation vector from M - make_constellation(); - - // Select a phase detector and a decision maker for the modulation order - switch(d_M) { - case 2: // optimized algorithms for BPSK - d_phase_error_detector = &gr_mpsk_receiver_cc::phase_error_detector_bpsk; //bpsk; - d_decision = &gr_mpsk_receiver_cc::decision_bpsk; - break; - - case 4: // optimized algorithms for QPSK - d_phase_error_detector = &gr_mpsk_receiver_cc::phase_error_detector_qpsk; //qpsk; - d_decision = &gr_mpsk_receiver_cc::decision_qpsk; - break; - - default: // generic algorithms for any M (power of 2?) but not pretty - d_phase_error_detector = &gr_mpsk_receiver_cc::phase_error_detector_generic; - d_decision = &gr_mpsk_receiver_cc::decision_generic; - break; - } -} - -gr_mpsk_receiver_cc::~gr_mpsk_receiver_cc () -{ - delete d_interp; -} - -void -gr_mpsk_receiver_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - ninput_items_required[i] = (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); -} - -// FIXME add these back in an test difference in performance -float -gr_mpsk_receiver_cc::phase_error_detector_qpsk(gr_complex sample) const -{ - float phase_error = 0; - if(fabsf(sample.real()) > fabsf(sample.imag())) { - if(sample.real() > 0) - phase_error = -sample.imag(); - else - phase_error = sample.imag(); - } - else { - if(sample.imag() > 0) - phase_error = sample.real(); - else - phase_error = -sample.real(); - } - - return phase_error; -} - -float -gr_mpsk_receiver_cc::phase_error_detector_bpsk(gr_complex sample) const -{ - return -(sample.real()*sample.imag()); -} - -float gr_mpsk_receiver_cc::phase_error_detector_generic(gr_complex sample) const -{ - //return gr_fast_atan2f(sample*conj(d_constellation[d_current_const_point])); - return -arg(sample*conj(d_constellation[d_current_const_point])); -} - -unsigned int -gr_mpsk_receiver_cc::decision_bpsk(gr_complex sample) const -{ - return (gr_branchless_binary_slicer(sample.real()) ^ 1); - //return gr_binary_slicer(sample.real()) ^ 1; -} - -unsigned int -gr_mpsk_receiver_cc::decision_qpsk(gr_complex sample) const -{ - unsigned int index; - - //index = gr_branchless_quad_0deg_slicer(sample); - index = gr_quad_0deg_slicer(sample); - return index; -} - -unsigned int -gr_mpsk_receiver_cc::decision_generic(gr_complex sample) const -{ - unsigned int min_m = 0; - float min_s = 65535; - - // Develop all possible constellation points and find the one that minimizes - // the Euclidean distance (error) with the sample - for(unsigned int m=0; m < d_M; m++) { - gr_complex diff = norm(d_constellation[m] - sample); - - if(fabs(diff.real()) < min_s) { - min_s = fabs(diff.real()); - min_m = m; - } - } - // Return the index of the constellation point that minimizes the error - return min_m; -} - - -void -gr_mpsk_receiver_cc::make_constellation() -{ - for(unsigned int m=0; m < d_M; m++) { - d_constellation.push_back(gr_expj((M_TWOPI/d_M)*m)); - } -} - -void -gr_mpsk_receiver_cc::mm_sampler(const gr_complex symbol) -{ - gr_complex sample, nco; - - d_mu--; // skip a number of symbols between sampling - d_phase += d_freq; // increment the phase based on the frequency of the rotation - - // Keep phase clamped and not walk to infinity - while(d_phase > M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase < -M_TWOPI) - d_phase += M_TWOPI; - - nco = gr_expj(d_phase+d_theta); // get the NCO value for derotating the current sample - sample = nco*symbol; // get the downconverted symbol - - // Fill up the delay line for the interpolator - d_dl[d_dl_idx] = sample; - d_dl[(d_dl_idx + DLLEN)] = sample; // put this in the second half of the buffer for overflows - d_dl_idx = (d_dl_idx+1) % DLLEN; // Keep the delay line index in bounds -} - -void -gr_mpsk_receiver_cc::mm_error_tracking(gr_complex sample) -{ - gr_complex u, x, y; - float mm_error = 0; - - // Make sample timing corrections - - // set the delayed samples - d_p_2T = d_p_1T; - d_p_1T = d_p_0T; - d_p_0T = sample; - d_c_2T = d_c_1T; - d_c_1T = d_c_0T; - - d_current_const_point = (*this.*d_decision)(d_p_0T); // make a decision on the sample value - d_c_0T = d_constellation[d_current_const_point]; - - x = (d_c_0T - d_c_2T) * conj(d_p_1T); - y = (d_p_0T - d_p_2T) * conj(d_c_1T); - u = y - x; - mm_error = u.real(); // the error signal is in the real part - mm_error = gr_branchless_clip(mm_error, 1.0); // limit mm_val - - d_omega = d_omega + d_gain_omega * mm_error; // update omega based on loop error - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_rel); // make sure we don't walk away - - d_mu += d_omega + d_gain_mu * mm_error; // update mu based on loop error - -#if VERBOSE_MM - printf("mm: mu: %f omega: %f mm_error: %f sample: %f+j%f constellation: %f+j%f\n", - d_mu, d_omega, mm_error, sample.real(), sample.imag(), - d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag()); -#endif -} - - -void -gr_mpsk_receiver_cc::phase_error_tracking(gr_complex sample) -{ - float phase_error = 0; - - // Make phase and frequency corrections based on sampled value - phase_error = (*this.*d_phase_error_detector)(sample); - - d_freq += d_beta*phase_error; // adjust frequency based on error - d_phase += d_freq + d_alpha*phase_error; // adjust phase based on error - - // Make sure we stay within +-2pi - while(d_phase > M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase < -M_TWOPI) - d_phase += M_TWOPI; - - // Limit the frequency range - d_freq = gr_branchless_clip(d_freq, d_max_freq); - -#if VERBOSE_COSTAS - printf("cl: phase_error: %f phase: %f freq: %f sample: %f+j%f constellation: %f+j%f\n", - phase_error, d_phase, d_freq, sample.real(), sample.imag(), - d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag()); -#endif -} - -int -gr_mpsk_receiver_cc::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int i=0, o=0; - - while((o < noutput_items) && (i < ninput_items[0])) { - while((d_mu > 1) && (i < ninput_items[0])) { - mm_sampler(in[i]); // puts symbols into a buffer and adjusts d_mu - i++; - } - - if(i < ninput_items[0]) { - gr_complex interp_sample = d_interp->interpolate(&d_dl[d_dl_idx], d_mu); - - mm_error_tracking(interp_sample); // corrects M&M sample time - phase_error_tracking(interp_sample); // corrects phase and frequency offsets - - out[o++] = interp_sample; - } - } - - #if 0 - printf("ninput_items: %d noutput_items: %d consuming: %d returning: %d\n", - ninput_items[0], noutput_items, i, o); - #endif - - consume_each(i); - return o; -} diff --git a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h deleted file mode 100644 index f17b68aa0..000000000 --- a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h +++ /dev/null @@ -1,316 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007 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_MPSK_RECEIVER_CC_H -#define INCLUDED_GR_MPSK_RECEIVER_CC_H - -#include <gruel/attributes.h> -#include <gr_block.h> -#include <gr_complex.h> -#include <fstream> - -class gri_mmse_fir_interpolator_cc; - -class gr_mpsk_receiver_cc; -typedef boost::shared_ptr<gr_mpsk_receiver_cc> gr_mpsk_receiver_cc_sptr; - -// public constructor -gr_mpsk_receiver_cc_sptr -gr_make_mpsk_receiver_cc (unsigned int M, float theta, - float alpha, float beta, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); - -/*! - * \brief This block takes care of receiving M-PSK modulated signals through phase, frequency, and symbol - * synchronization. - * \ingroup sync_blk - * \ingroup demod_blk - * - * This block takes care of receiving M-PSK modulated signals through phase, frequency, and symbol - * synchronization. It performs carrier frequency and phase locking as well as symbol timing recovery. - * It works with (D)BPSK, (D)QPSK, and (D)8PSK as tested currently. It should also work for OQPSK and - * PI/4 DQPSK. - * - * The phase and frequency synchronization are based on a Costas loop that finds the error of the incoming - * signal point compared to its nearest constellation point. The frequency and phase of the NCO are - * updated according to this error. There are optimized phase error detectors for BPSK and QPSK, but 8PSK - * is done using a brute-force computation of the constellation points to find the minimum. - * - * The symbol synchronization is done using a modified Mueller and Muller circuit from the paper: - * - * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller - * algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033. - * - * This circuit interpolates the downconverted sample (using the NCO developed by the Costas loop) - * every mu samples, then it finds the sampling error based on this and the past symbols and the decision - * made on the samples. Like the phase error detector, there are optimized decision algorithms for BPSK - * and QPKS, but 8PSK uses another brute force computation against all possible symbols. The modifications - * to the M&M used here reduce self-noise. - * - */ - -class gr_mpsk_receiver_cc : public gr_block -{ - public: - ~gr_mpsk_receiver_cc (); - 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); - - - // Member functions related to the symbol tracking portion of the receiver - //! (M&M) Returns current value of mu - float mu() const { return d_mu;} - - //! (M&M) Returns current value of omega - float omega() const { return d_omega;} - - //! (M&M) Returns mu gain factor - float gain_mu() const { return d_gain_mu;} - - //! (M&M) Returns omega gain factor - float gain_omega() const { return d_gain_omega;} - - //! (M&M) Sets value of mu - void set_mu (float mu) { d_mu = mu; } - - //! (M&M) Sets value of omega and its min and max values - void set_omega (float omega) { - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_rel); - d_max_omega = omega*(1.0 + d_omega_rel); - d_omega_mid = 0.5*(d_min_omega+d_max_omega); - } - - //! (M&M) Sets value for mu gain factor - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - - //! (M&M) Sets value for omega gain factor - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - - - - // Member function related to the phase/frequency tracking portion of the receiver - //! (CL) Returns the value for alpha (the phase gain term) - float alpha() const { return d_alpha; } - - //! (CL) Returns the value of beta (the frequency gain term) - float beta() const { return d_beta; } - - //! (CL) Returns the current value of the frequency of the NCO in the Costas loop - float freq() const { return d_freq; } - - //! (CL) Returns the current value of the phase of the NCO in the Costal loop - float phase() const { return d_phase; } - - //! (CL) Sets the value for alpha (the phase gain term) - void set_alpha(float alpha) { d_alpha = alpha; } - - //! (CL) Setss the value of beta (the frequency gain term) - void set_beta(float beta) { d_beta = beta; } - - //! (CL) Sets the current value of the frequency of the NCO in the Costas loop - void set_freq(float freq) { d_freq = freq; } - - //! (CL) Setss the current value of the phase of the NCO in the Costal loop - void set_phase(float phase) { d_phase = phase; } - - -protected: - - /*! - * \brief Constructor to synchronize incoming M-PSK symbols - * - * \param M modulation order of the M-PSK modulation - * \param theta any constant phase rotation from the real axis of the constellation - * \param alpha gain parameter to adjust the phase in the Costas loop (~0.01) - * \param beta gain parameter to adjust the frequency in the Costas loop (~alpha^2/4) - * \param fmin minimum normalized frequency value the loop can achieve - * \param fmax maximum normalized frequency value the loop can achieve - * \param mu initial parameter for the interpolator [0,1] - * \param gain_mu gain parameter of the M&M error signal to adjust mu (~0.05) - * \param omega initial value for the number of symbols between samples (~number of samples/symbol) - * \param gain_omega gain parameter to adjust omega based on the error (~omega^2/4) - * \param omega_rel sets the maximum (omega*(1+omega_rel)) and minimum (omega*(1+omega_rel)) omega (~0.005) - * - * The constructor also chooses which phase detector and decision maker to use in the work loop based on the - * value of M. - */ - gr_mpsk_receiver_cc (unsigned int M, float theta, - float alpha, float beta, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); - - void make_constellation(); - void mm_sampler(const gr_complex symbol); - void mm_error_tracking(gr_complex sample); - void phase_error_tracking(gr_complex sample); - - -/*! - * \brief Phase error detector for MPSK modulations. - * - * \param sample the I&Q sample from which to determine the phase error - * - * This function determines the phase error for any MPSK signal by creating a set of PSK constellation points - * and doing a brute-force search to see which point minimizes the Euclidean distance. This point is then used - * to derotate the sample to the real-axis and a atan (using the fast approximation function) to determine the - * phase difference between the incoming sample and the real constellation point - * - * This should be cleaned up and made more efficient. - * - * \returns the approximated phase error. - */ - float phase_error_detector_generic(gr_complex sample) const; // generic for M but more costly - - /*! - * \brief Phase error detector for BPSK modulation. - * - * \param sample the I&Q sample from which to determine the phase error - * - * This function determines the phase error using a simple BPSK phase error detector by multiplying the real - * and imaginary (the error signal) components together. As the imaginary part goes to 0, so does this error. - * - * \returns the approximated phase error. - */ - float phase_error_detector_bpsk(gr_complex sample) const; // optimized for BPSK - - /*! - * \brief Phase error detector for QPSK modulation. - * - * \param sample the I&Q sample from which to determine the phase error - * - * This function determines the phase error using the limiter approach in a standard 4th order Costas loop - * - * \returns the approximated phase error. - */ - float phase_error_detector_qpsk(gr_complex sample) const; - - - - /*! - * \brief Decision maker for a generic MPSK constellation. - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This decision maker is a generic implementation that does a brute-force search - * for the constellation point that minimizes the error between it and the incoming signal. - * - * \returns the index to d_constellation that minimizes the error/ - */ - unsigned int decision_generic(gr_complex sample) const; - - - /*! - * \brief Decision maker for BPSK constellation. - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This decision maker is a simple slicer function that makes a decision on the symbol based on its - * placement on the real axis of greater than 0 or less than 0; the quadrature component is always 0. - * - * \returns the index to d_constellation that minimizes the error/ - */ - unsigned int decision_bpsk(gr_complex sample) const; - - - /*! - * \brief Decision maker for QPSK constellation. - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This decision maker is a simple slicer function that makes a decision on the symbol based on its - * placement versus both axes and returns which quadrant the symbol is in. - * - * \returns the index to d_constellation that minimizes the error/ - */ - unsigned int decision_qpsk(gr_complex sample) const; - - private: - unsigned int d_M; - float d_theta; - - // Members related to carrier and phase tracking - float d_alpha; - float d_beta; - float d_freq, d_max_freq, d_min_freq; - float d_phase; - -/*! - * \brief Decision maker function pointer - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This is a function pointer that is set in the constructor to point to the proper decision function - * for the specified constellation order. - * - * \return index into d_constellation point that is the closest to the recieved sample - */ - unsigned int (gr_mpsk_receiver_cc::*d_decision)(gr_complex sample) const; // pointer to decision function - - - std::vector<gr_complex> d_constellation; - unsigned int d_current_const_point; - - // Members related to symbol timing - float d_mu, d_gain_mu; - float d_omega, d_gain_omega, d_omega_rel, d_max_omega, d_min_omega, d_omega_mid; - gr_complex d_p_2T, d_p_1T, d_p_0T; - gr_complex d_c_2T, d_c_1T, d_c_0T; - - /*! - * \brief Phase error detector function pointer - * - * \param sample the I&Q sample from which to determine the phase error - * - * This is a function pointer that is set in the constructor to point to the proper phase error detector - * function for the specified constellation order. - */ - float (gr_mpsk_receiver_cc::*d_phase_error_detector)(gr_complex sample) const; - - - //! get interpolated value - gri_mmse_fir_interpolator_cc *d_interp; - - //! delay line length. - static const unsigned int DLLEN = 8; - - //! delay line plus some length for overflow protection - __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN]; - - //! index to delay line - unsigned int d_dl_idx; - - friend gr_mpsk_receiver_cc_sptr - gr_make_mpsk_receiver_cc (unsigned int M, float theta, - float alpha, float beta, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.i b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.i deleted file mode 100644 index 88cb43e04..000000000 --- a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.i +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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,mpsk_receiver_cc); - -gr_mpsk_receiver_cc_sptr gr_make_mpsk_receiver_cc (unsigned int M, float theta, - float alpha, float beta, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); -class gr_mpsk_receiver_cc : public gr_block -{ - private: - gr_mpsk_receiver_cc (unsigned int M,float theta, - float alpha, float beta, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); -public: - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - void set_mu (float mu) { d_mu = mu; } - void set_omega (float omega) { - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_rel); - d_max_omega = omega*(1.0 + d_omega_rel); - } - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - float alpha() const { return d_alpha; } - float beta() const { return d_beta; } - float freq() const { return d_freq; } - float phase() const { return d_phase; } - void set_alpha(float alpha) { d_alpha = alpha; } - void set_beta(float beta) { d_beta = beta; } - void set_freq(float freq) { d_freq = freq; } - void set_phase(float phase) { d_phase = phase; } -}; diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.h b/gnuradio-core/src/lib/general/gr_nlog10_ff.h index 1cb50f3ca..cea56f87e 100644 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.h +++ b/gnuradio-core/src/lib/general/gr_nlog10_ff.h @@ -22,20 +22,21 @@ #ifndef INCLUDED_GR_NLOG10_FF_H #define INCLUDED_GR_NLOG10_FF_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_nlog10_ff; typedef boost::shared_ptr<gr_nlog10_ff> gr_nlog10_ff_sptr; -gr_nlog10_ff_sptr gr_make_nlog10_ff (float n=1.0, unsigned vlen=1, float k=0); +GR_CORE_API gr_nlog10_ff_sptr gr_make_nlog10_ff (float n=1.0, unsigned vlen=1, float k=0); /*! * \brief output = n*log10(input) + k * \ingroup math_blk */ -class gr_nlog10_ff : public gr_sync_block +class GR_CORE_API gr_nlog10_ff : public gr_sync_block { - friend gr_nlog10_ff_sptr gr_make_nlog10_ff (float n, unsigned vlen, float k); + friend GR_CORE_API gr_nlog10_ff_sptr gr_make_nlog10_ff (float n, unsigned vlen, float k); unsigned int d_vlen; float d_n; diff --git a/gnuradio-core/src/lib/general/gr_nop.h b/gnuradio-core/src/lib/general/gr_nop.h index 354c2f9fc..b8398befc 100644 --- a/gnuradio-core/src/lib/general/gr_nop.h +++ b/gnuradio-core/src/lib/general/gr_nop.h @@ -23,22 +23,23 @@ #ifndef INCLUDED_GR_NOP_H #define INCLUDED_GR_NOP_H +#include <gr_core_api.h> #include <gr_block.h> #include <stddef.h> // size_t class gr_nop; typedef boost::shared_ptr<gr_nop> gr_nop_sptr; -gr_nop_sptr +GR_CORE_API gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); /*! * \brief Does nothing. Used for testing only. * \ingroup misc_blk */ -class gr_nop : public gr_block +class GR_CORE_API gr_nop : public gr_block { - friend gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); + friend GR_CORE_API gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); gr_nop (size_t sizeof_stream_item); protected: diff --git a/gnuradio-core/src/lib/general/gr_null_sink.h b/gnuradio-core/src/lib/general/gr_null_sink.h index 6d00382a5..c6c4f36fb 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.h +++ b/gnuradio-core/src/lib/general/gr_null_sink.h @@ -23,23 +23,23 @@ #ifndef INCLUDED_GR_NULL_SINK_H #define INCLUDED_GR_NULL_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <stddef.h> // size_t class gr_null_sink; typedef boost::shared_ptr<gr_null_sink> gr_null_sink_sptr; -gr_null_sink_sptr +GR_CORE_API gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); - /*! * \brief Bit bucket * \ingroup sink_blk */ -class gr_null_sink : public gr_sync_block +class GR_CORE_API gr_null_sink : public gr_sync_block { - friend gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); + friend GR_CORE_API gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); gr_null_sink (size_t sizeof_stream_item); public: diff --git a/gnuradio-core/src/lib/general/gr_null_source.h b/gnuradio-core/src/lib/general/gr_null_source.h index b1a46a195..33687fbaa 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.h +++ b/gnuradio-core/src/lib/general/gr_null_source.h @@ -23,21 +23,22 @@ #ifndef INCLUDED_GR_NULL_SOURCE_H #define INCLUDED_GR_NULL_SOURCE_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_null_source; typedef boost::shared_ptr<gr_null_source> gr_null_source_sptr; -gr_null_source_sptr +GR_CORE_API gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); /*! * \brief A source of zeros. * \ingroup source_blk */ -class gr_null_source : public gr_sync_block +class GR_CORE_API gr_null_source : public gr_sync_block { - friend gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); + friend GR_CORE_API gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); gr_null_source (size_t sizeof_stream_item); diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h index 12ae6a8f6..6d532d50f 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h +++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h @@ -24,13 +24,14 @@ #define INCLUDED_GR_OFDM_BPSK_DEMAPPER_H +#include <gr_core_api.h> #include <gr_block.h> #include <vector> class gr_ofdm_bpsk_demapper; typedef boost::shared_ptr<gr_ofdm_bpsk_demapper> gr_ofdm_bpsk_demapper_sptr; -gr_ofdm_bpsk_demapper_sptr +GR_CORE_API gr_ofdm_bpsk_demapper_sptr gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); @@ -39,9 +40,9 @@ gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); * and demodulate to a stream of bits. Simple BPSK version. * \ingroup ofdm_blk */ -class gr_ofdm_bpsk_demapper : public gr_block +class GR_CORE_API gr_ofdm_bpsk_demapper : public gr_block { - friend gr_ofdm_bpsk_demapper_sptr + friend GR_CORE_API gr_ofdm_bpsk_demapper_sptr gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); protected: diff --git a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc deleted file mode 100644 index fb40a3035..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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_ofdm_cyclic_prefixer.h> -#include <gr_io_signature.h> - -gr_ofdm_cyclic_prefixer_sptr -gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_cyclic_prefixer (input_size, output_size)); -} - -gr_ofdm_cyclic_prefixer::gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) - : gr_sync_interpolator ("ofdm_cyclic_prefixer", - gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - output_size), - d_input_size(input_size), - d_output_size(output_size) - -{ -} - -int -gr_ofdm_cyclic_prefixer::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - size_t cp_size = d_output_size - d_input_size; - unsigned int i=0, j=0; - - j = cp_size; - for(i=0; i < d_input_size; i++,j++) { - out[j] = in[i]; - } - - j = d_input_size - cp_size; - for(i=0; i < cp_size; i++, j++) { - out[i] = in[j]; - } - - return d_output_size; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h deleted file mode 100644 index eab91cd11..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,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. - */ - -#ifndef INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H -#define INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H - -#include <gr_sync_interpolator.h> -#include <stdio.h> - -class gr_ofdm_cyclic_prefixer; -typedef boost::shared_ptr<gr_ofdm_cyclic_prefixer> gr_ofdm_cyclic_prefixer_sptr; - -gr_ofdm_cyclic_prefixer_sptr -gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - - -/*! - * \brief adds a cyclic prefix vector to an input size long ofdm - * symbol(vector) and converts vector to a stream output_size long. - * \ingroup ofdm_blk - */ -class gr_ofdm_cyclic_prefixer : public gr_sync_interpolator -{ - friend gr_ofdm_cyclic_prefixer_sptr - gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - - protected: - gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - private: - size_t d_input_size; - size_t d_output_size; -}; - -#endif /* INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc deleted file mode 100644 index 4da7690b1..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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_ofdm_demapper_vcb.h> -#include <gr_io_signature.h> - -gr_ofdm_demapper_vcb::~gr_ofdm_demapper_vcb(void) -{ -} - -gr_ofdm_demapper_vcb::gr_ofdm_demapper_vcb (unsigned bits_per_symbol,unsigned int vlen) - : gr_sync_decimator ("ofdm_demapper_vcb", - gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof(unsigned char)), - bits_per_symbol) -{ -} - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h deleted file mode 100644 index 979e1996b..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- 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. - */ - -#ifndef INCLUDED_GR_OFDM_DEMAPPER_VCB_H -#define INCLUDED_GR_OFDM_DEMAPPER_VCB_H - -#include <gr_sync_decimator.h> - -class gr_ofdm_demapper_vcb; -typedef boost::shared_ptr<gr_ofdm_demapper_vcb> gr_ofdm_demapper_vcb_sptr; - -gr_ofdm_demapper_vcb_sptr -gr_make_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen); - - -/*! - * \brief take a stream of vectors in from an FFT and demodulate to a stream of - * bits. Abstract class must be subclassed with specific mapping. - * - * \ingroup demodulation_blk - * \ingroup ofdm_blk - */ -class gr_ofdm_demapper_vcb : public gr_sync_decimator -{ - friend gr_ofdm_demapper_vcb_sptr - gr_make_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen); - -protected: - gr_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen); - -public: - ~gr_ofdm_demapper_vcb(void); -}; - - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc deleted file mode 100644 index 201375597..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008,2010 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_ofdm_frame_acquisition.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_math.h> -#include <cstdio> - -#define VERBOSE 0 -#define M_TWOPI (2*M_PI) -#define MAX_NUM_SYMBOLS 1000 - -gr_ofdm_frame_acquisition_sptr -gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_frame_acquisition (occupied_carriers, fft_length, cplen, - known_symbol, max_fft_shift_len)); -} - -gr_ofdm_frame_acquisition::gr_ofdm_frame_acquisition (unsigned occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len) - : gr_block ("ofdm_frame_acquisition", - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*fft_length, sizeof(char)*fft_length), - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char))), - d_occupied_carriers(occupied_carriers), - d_fft_length(fft_length), - d_cplen(cplen), - d_freq_shift_len(max_fft_shift_len), - d_known_symbol(known_symbol), - d_coarse_freq(0), - d_phase_count(0) -{ - d_symbol_phase_diff.resize(d_fft_length); - d_known_phase_diff.resize(d_occupied_carriers); - d_hestimate.resize(d_occupied_carriers); - - unsigned int i = 0, j = 0; - - std::fill(d_known_phase_diff.begin(), d_known_phase_diff.end(), 0); - for(i = 0; i < d_known_symbol.size()-2; i+=2) { - d_known_phase_diff[i] = norm(d_known_symbol[i] - d_known_symbol[i+2]); - } - - d_phase_lut = new gr_complex[(2*d_freq_shift_len+1) * MAX_NUM_SYMBOLS]; - for(i = 0; i <= 2*d_freq_shift_len; i++) { - for(j = 0; j < MAX_NUM_SYMBOLS; j++) { - d_phase_lut[j + i*MAX_NUM_SYMBOLS] = gr_expj(-M_TWOPI*d_cplen/d_fft_length*(i-d_freq_shift_len)*j); - } - } -} - -gr_ofdm_frame_acquisition::~gr_ofdm_frame_acquisition(void) -{ - delete [] d_phase_lut; -} - -void -gr_ofdm_frame_acquisition::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = 1; -} - -gr_complex -gr_ofdm_frame_acquisition::coarse_freq_comp(int freq_delta, int symbol_count) -{ - // return gr_complex(cos(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count), - // sin(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count)); - - return gr_expj(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count); - - //return d_phase_lut[MAX_NUM_SYMBOLS * (d_freq_shift_len + freq_delta) + symbol_count]; -} - -void -gr_ofdm_frame_acquisition::correlate(const gr_complex *symbol, int zeros_on_left) -{ - unsigned int i,j; - - std::fill(d_symbol_phase_diff.begin(), d_symbol_phase_diff.end(), 0); - for(i = 0; i < d_fft_length-2; i++) { - d_symbol_phase_diff[i] = norm(symbol[i] - symbol[i+2]); - } - - // sweep through all possible/allowed frequency offsets and select the best - int index = 0; - float max = 0, sum=0; - for(i = zeros_on_left - d_freq_shift_len; i < zeros_on_left + d_freq_shift_len; i++) { - sum = 0; - for(j = 0; j < d_occupied_carriers; j++) { - sum += (d_known_phase_diff[j] * d_symbol_phase_diff[i+j]); - } - if(sum > max) { - max = sum; - index = i; - } - } - - // set the coarse frequency offset relative to the edge of the occupied tones - d_coarse_freq = index - zeros_on_left; -} - -void -gr_ofdm_frame_acquisition::calculate_equalizer(const gr_complex *symbol, int zeros_on_left) -{ - unsigned int i=0; - - // Set first tap of equalizer - d_hestimate[0] = d_known_symbol[0] / - (coarse_freq_comp(d_coarse_freq,1)*symbol[zeros_on_left+d_coarse_freq]); - - // set every even tap based on known symbol - // linearly interpolate between set carriers to set zero-filled carriers - // FIXME: is this the best way to set this? - for(i = 2; i < d_occupied_carriers; i+=2) { - d_hestimate[i] = d_known_symbol[i] / - (coarse_freq_comp(d_coarse_freq,1)*(symbol[i+zeros_on_left+d_coarse_freq])); - d_hestimate[i-1] = (d_hestimate[i] + d_hestimate[i-2]) / gr_complex(2.0, 0.0); - } - - // with even number of carriers; last equalizer tap is wrong - if(!(d_occupied_carriers & 1)) { - d_hestimate[d_occupied_carriers-1] = d_hestimate[d_occupied_carriers-2]; - } - - if(VERBOSE) { - fprintf(stderr, "Equalizer setting:\n"); - for(i = 0; i < d_occupied_carriers; i++) { - gr_complex sym = coarse_freq_comp(d_coarse_freq,1)*symbol[i+zeros_on_left+d_coarse_freq]; - gr_complex output = sym * d_hestimate[i]; - fprintf(stderr, "sym: %+.4f + j%+.4f ks: %+.4f + j%+.4f eq: %+.4f + j%+.4f ==> %+.4f + j%+.4f\n", - sym .real(), sym.imag(), - d_known_symbol[i].real(), d_known_symbol[i].imag(), - d_hestimate[i].real(), d_hestimate[i].imag(), - output.real(), output.imag()); - } - fprintf(stderr, "\n"); - } -} - -int -gr_ofdm_frame_acquisition::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *symbol = (const gr_complex *)input_items[0]; - const char *signal_in = (const char *)input_items[1]; - - gr_complex *out = (gr_complex *) output_items[0]; - char *signal_out = (char *) output_items[1]; - - int unoccupied_carriers = d_fft_length - d_occupied_carriers; - int zeros_on_left = (int)ceil(unoccupied_carriers/2.0); - - if(signal_in[0]) { - d_phase_count = 1; - correlate(symbol, zeros_on_left); - calculate_equalizer(symbol, zeros_on_left); - signal_out[0] = 1; - } - else { - signal_out[0] = 0; - } - - for(unsigned int i = 0; i < d_occupied_carriers; i++) { - out[i] = d_hestimate[i]*coarse_freq_comp(d_coarse_freq,d_phase_count) - *symbol[i+zeros_on_left+d_coarse_freq]; - } - - d_phase_count++; - if(d_phase_count == MAX_NUM_SYMBOLS) { - d_phase_count = 1; - } - - consume_each(1); - return 1; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h b/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h deleted file mode 100644 index 5db8dbb7f..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006, 2007 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_OFDM_FRAME_ACQUISITION_H -#define INCLUDED_GR_OFDM_FRAME_ACQUISITION_H - - -#include <gr_block.h> -#include <vector> - -class gr_ofdm_frame_acquisition; -typedef boost::shared_ptr<gr_ofdm_frame_acquisition> gr_ofdm_frame_acquisition_sptr; - -gr_ofdm_frame_acquisition_sptr -gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len=10); - -/*! - * \brief take a vector of complex constellation points in from an FFT - * and performs a correlation and equalization. - * \ingroup demodulation_blk - * \ingroup ofdm_blk - * - * This block takes the output of an FFT of a received OFDM symbol and finds the - * start of a frame based on two known symbols. It also looks at the surrounding - * bins in the FFT output for the correlation in case there is a large frequency - * shift in the data. This block assumes that the fine frequency shift has already - * been corrected and that the samples fall in the middle of one FFT bin. - * - * It then uses one of those known - * symbols to estimate the channel response over all subcarriers and does a simple - * 1-tap equalization on all subcarriers. This corrects for the phase and amplitude - * distortion caused by the channel. - */ - -class gr_ofdm_frame_acquisition : public gr_block -{ - /*! - * \brief Build an OFDM correlator and equalizer. - * \param occupied_carriers The number of subcarriers with data in the received symbol - * \param fft_length The size of the FFT vector (occupied_carriers + unused carriers) - * \param cplen The length of the cycle prefix - * \param known_symbol A vector of complex numbers representing a known symbol at the - * start of a frame (usually a BPSK PN sequence) - * \param max_fft_shift_len Set's the maximum distance you can look between bins for correlation - */ - friend gr_ofdm_frame_acquisition_sptr - gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len); - -protected: - gr_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len); - - private: - unsigned char slicer(gr_complex x); - void correlate(const gr_complex *symbol, int zeros_on_left); - void calculate_equalizer(const gr_complex *symbol, int zeros_on_left); - gr_complex coarse_freq_comp(int freq_delta, int count); - - unsigned int d_occupied_carriers; // !< \brief number of subcarriers with data - unsigned int d_fft_length; // !< \brief length of FFT vector - unsigned int d_cplen; // !< \brief length of cyclic prefix in samples - unsigned int d_freq_shift_len; // !< \brief number of surrounding bins to look at for correlation - std::vector<gr_complex> d_known_symbol; // !< \brief known symbols at start of frame - std::vector<float> d_known_phase_diff; // !< \brief factor used in correlation from known symbol - std::vector<float> d_symbol_phase_diff; // !< \brief factor used in correlation from received symbol - std::vector<gr_complex> d_hestimate; // !< channel estimate - int d_coarse_freq; // !< \brief search distance in number of bins - unsigned int d_phase_count; // !< \brief accumulator for coarse freq correction - float d_snr_est; // !< an estimation of the signal to noise ratio - - gr_complex *d_phase_lut; // !< look-up table for coarse frequency compensation - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - public: - /*! - * \brief Return an estimate of the SNR of the channel - */ - float snr() { return d_snr_est; } - - ~gr_ofdm_frame_acquisition(void); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i b/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i deleted file mode 100644 index 0fd0bc58b..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006, 2007 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. - */ - -#include <vector> - -GR_SWIG_BLOCK_MAGIC(gr,ofdm_frame_acquisition); - -gr_ofdm_frame_acquisition_sptr -gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len=4); - -class gr_ofdm_frame_acquisition : public gr_sync_decimator -{ - protected: - gr_ofdm_frame_acquisition (unsigned int occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len); - - public: - float snr() { return d_snr_est; } - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc index 279945766..40574b4e9 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2010 Free Software Foundation, Inc. + * Copyright 2007,2008,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,7 +24,7 @@ #include "config.h" #endif -#include <gr_ofdm_frame_sink.h> +#include <gr_ofdm_frame_sink2.h> #include <gr_io_signature.h> #include <gr_expj.h> #include <gr_math.h> @@ -33,11 +33,12 @@ #include <stdexcept> #include <iostream> #include <string.h> +#include <gr_constellation.h> #define VERBOSE 0 inline void -gr_ofdm_frame_sink::enter_search() +gr_ofdm_frame_sink2::enter_search() { if (VERBOSE) fprintf(stderr, "@ enter_search\n"); @@ -47,7 +48,7 @@ gr_ofdm_frame_sink::enter_search() } inline void -gr_ofdm_frame_sink::enter_have_sync() +gr_ofdm_frame_sink2::enter_have_sync() { if (VERBOSE) fprintf(stderr, "@ enter_have_sync\n"); @@ -68,7 +69,7 @@ gr_ofdm_frame_sink::enter_have_sync() } inline void -gr_ofdm_frame_sink::enter_have_header() +gr_ofdm_frame_sink2::enter_have_header() { d_state = STATE_HAVE_HEADER; @@ -85,24 +86,7 @@ gr_ofdm_frame_sink::enter_have_header() } -unsigned char gr_ofdm_frame_sink::slicer(const gr_complex x) -{ - unsigned int table_size = d_sym_value_out.size(); - unsigned int min_index = 0; - float min_euclid_dist = norm(x - d_sym_position[0]); - float euclid_dist = 0; - - for (unsigned int j = 1; j < table_size; j++){ - euclid_dist = norm(x - d_sym_position[j]); - if (euclid_dist < min_euclid_dist){ - min_euclid_dist = euclid_dist; - min_index = j; - } - } - return d_sym_value_out[min_index]; -} - -unsigned int gr_ofdm_frame_sink::demapper(const gr_complex *in, +unsigned int gr_ofdm_frame_sink2::demapper(const gr_complex *in, unsigned char *out) { unsigned int i=0, bytes_produced=0; @@ -129,9 +113,9 @@ unsigned int gr_ofdm_frame_sink::demapper(const gr_complex *in, d_derotated_output[i] = sigrot; } - unsigned char bits = slicer(sigrot); + unsigned char bits = d_constell->decision_maker(&sigrot); - gr_complex closest_sym = d_sym_position[bits]; + gr_complex closest_sym = d_constell->points()[bits]; accum_error += sigrot * conj(closest_sym); @@ -178,30 +162,32 @@ unsigned int gr_ofdm_frame_sink::demapper(const gr_complex *in, } -gr_ofdm_frame_sink_sptr -gr_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, +gr_ofdm_frame_sink2_sptr +gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, float phase_gain, float freq_gain) { - return gnuradio::get_initial_sptr(new gr_ofdm_frame_sink(sym_position, sym_value_out, + return gnuradio::get_initial_sptr(new gr_ofdm_frame_sink2(constell, target_queue, occupied_carriers, phase_gain, freq_gain)); } -gr_ofdm_frame_sink::gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, +gr_ofdm_frame_sink2::gr_ofdm_frame_sink2(gr_constellation_sptr constell, gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, float phase_gain, float freq_gain) - : gr_sync_block ("ofdm_frame_sink", + : gr_sync_block ("ofdm_frame_sink2", gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char)), gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers)), + d_constell(constell), d_target_queue(target_queue), d_occupied_carriers(occupied_carriers), d_byte_offset(0), d_partial_byte(0), d_resid(0), d_nresid(0),d_phase(0),d_freq(0),d_phase_gain(phase_gain),d_freq_gain(freq_gain), d_eq_gain(0.05) { + if (d_constell->dimensionality() != 1) + throw std::runtime_error ("This receiver only works with constellations of dimension 1."); + std::string carriers = "FE7F"; // A bit hacky to fill out carriers to occupied_carriers length @@ -259,36 +245,19 @@ gr_ofdm_frame_sink::gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_positi d_dfe.resize(occupied_carriers); fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); - set_sym_value_out(sym_position, sym_value_out); - + d_nbits = d_constell->bits_per_symbol(); + enter_search(); } -gr_ofdm_frame_sink::~gr_ofdm_frame_sink () +gr_ofdm_frame_sink2::~gr_ofdm_frame_sink2 () { delete [] d_bytes_out; } -bool -gr_ofdm_frame_sink::set_sym_value_out(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out) -{ - if (sym_position.size() != sym_value_out.size()) - return false; - - if (sym_position.size()<1) - return false; - - d_sym_position = sym_position; - d_sym_value_out = sym_value_out; - d_nbits = (unsigned long)ceil(log10(float(d_sym_value_out.size())) / log10(2.0)); - - return true; -} - int -gr_ofdm_frame_sink::work (int noutput_items, +gr_ofdm_frame_sink2::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h index c419b8673..9595303b1 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,18 +20,19 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_OFDM_FRAME_SINK_H -#define INCLUDED_GR_OFDM_FRAME_SINK_H +#ifndef INCLUDED_GR_OFDM_FRAME_SINK2_H +#define INCLUDED_GR_OFDM_FRAME_SINK2_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_msg_queue.h> +#include <gr_constellation.h> -class gr_ofdm_frame_sink; -typedef boost::shared_ptr<gr_ofdm_frame_sink> gr_ofdm_frame_sink_sptr; +class gr_ofdm_frame_sink2; +typedef boost::shared_ptr<gr_ofdm_frame_sink2> gr_ofdm_frame_sink2_sptr; -gr_ofdm_frame_sink_sptr -gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, +GR_CORE_API gr_ofdm_frame_sink2_sptr +gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, gr_msg_queue_sptr target_queue, unsigned int occupied_tones, float phase_gain=0.25, float freq_gain=0.25*0.25/4.0); @@ -45,11 +46,10 @@ gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, * we want to be able to pass in a reference to an object to do the demapping and slicing * for a given modulation type. */ -class gr_ofdm_frame_sink : public gr_sync_block +class GR_CORE_API gr_ofdm_frame_sink2 : public gr_sync_block { - friend gr_ofdm_frame_sink_sptr - gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, + friend GR_CORE_API gr_ofdm_frame_sink2_sptr + gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, gr_msg_queue_sptr target_queue, unsigned int occupied_tones, float phase_gain, float freq_gain); @@ -77,8 +77,7 @@ class gr_ofdm_frame_sink : public gr_sync_block gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out - std::vector<gr_complex> d_sym_position; - std::vector<unsigned char> d_sym_value_out; + gr_constellation_sptr d_constell; std::vector<gr_complex> d_dfe; unsigned int d_nbits; @@ -93,8 +92,7 @@ class gr_ofdm_frame_sink : public gr_sync_block std::vector<int> d_subcarrier_map; protected: - gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, + gr_ofdm_frame_sink2(gr_constellation_sptr constell, gr_msg_queue_sptr target_queue, unsigned int occupied_tones, float phase_gain, float freq_gain); @@ -112,15 +110,12 @@ class gr_ofdm_frame_sink : public gr_sync_block unsigned int demapper(const gr_complex *in, unsigned char *out); - bool set_sym_value_out(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - public: - ~gr_ofdm_frame_sink(); + ~gr_ofdm_frame_sink2(); int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); }; -#endif /* INCLUDED_GR_OFDM_FRAME_SINK_H */ +#endif /* INCLUDED_GR_OFDM_FRAME_SINK2_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.i b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i index 38ab50e97..8fa320089 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.i +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,22 +20,20 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_frame_sink); +GR_SWIG_BLOCK_MAGIC(gr,ofdm_frame_sink2); -gr_ofdm_frame_sink_sptr -gr_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, +gr_ofdm_frame_sink2_sptr +gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, gr_msg_queue_sptr target_queue, unsigned int occupied_tones, float phase_gain=0.25, float freq_gain=0.25*0.25/4); -class gr_ofdm_frame_sink : public gr_sync_block +class gr_ofdm_frame_sink2 : public gr_sync_block { protected: - gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, + gr_ofdm_frame_sink2(gr_constellation_sptr constell, gr_msg_queue_sptr target_queue, unsigned int occupied_tones, float phase_gain, float freq_gain); public: - ~gr_ofdm_frame_sink(); + ~gr_ofdm_frame_sink2(); }; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc b/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc deleted file mode 100644 index ed10c94a8..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_ofdm_insert_preamble.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> -#include <string.h> - -gr_ofdm_insert_preamble_sptr -gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_insert_preamble(fft_length, - preamble)); -} - -gr_ofdm_insert_preamble::gr_ofdm_insert_preamble - (int fft_length, - const std::vector<std::vector<gr_complex> > &preamble) - : gr_block("ofdm_insert_preamble", - gr_make_io_signature2(2, 2, - sizeof(gr_complex)*fft_length, - sizeof(char)), - gr_make_io_signature2(1, 2, - sizeof(gr_complex)*fft_length, - sizeof(char))), - d_fft_length(fft_length), - d_preamble(preamble), - d_state(ST_IDLE), - d_nsymbols_output(0), - d_pending_flag(0) -{ - // sanity check preamble symbols - for (size_t i = 0; i < d_preamble.size(); i++){ - if (d_preamble[i].size() != (size_t) d_fft_length) - throw std::invalid_argument("gr_ofdm_insert_preamble: invalid length for preamble symbol"); - } - - enter_idle(); -} - - -gr_ofdm_insert_preamble::~gr_ofdm_insert_preamble() -{ -} - -int -gr_ofdm_insert_preamble::general_work (int noutput_items, - gr_vector_int &ninput_items_v, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ninput_items = std::min(ninput_items_v[0], ninput_items_v[1]); - const gr_complex *in_sym = (const gr_complex *) input_items[0]; - const unsigned char *in_flag = (const unsigned char *) input_items[1]; - - gr_complex *out_sym = (gr_complex *) output_items[0]; - unsigned char *out_flag = 0; - if (output_items.size() == 2) - out_flag = (unsigned char *) output_items[1]; - - - int no = 0; // number items output - int ni = 0; // number items read from input - - -#define write_out_flag() \ - do { if (out_flag) \ - out_flag[no] = d_pending_flag; \ - d_pending_flag = 0; \ - } while(0) - - - while (no < noutput_items && ni < ninput_items){ - switch(d_state){ - case ST_IDLE: - if (in_flag[ni] & 0x1) // this is first symbol of new payload - enter_preamble(); - else - ni++; // eat one input symbol - break; - - case ST_PREAMBLE: - assert(in_flag[ni] & 0x1); - if (d_nsymbols_output >= (int) d_preamble.size()){ - // we've output all the preamble - enter_first_payload(); - } - else { - memcpy(&out_sym[no * d_fft_length], - &d_preamble[d_nsymbols_output][0], - d_fft_length*sizeof(gr_complex)); - - write_out_flag(); - no++; - d_nsymbols_output++; - } - break; - - case ST_FIRST_PAYLOAD: - // copy first payload symbol from input to output - memcpy(&out_sym[no * d_fft_length], - &in_sym[ni * d_fft_length], - d_fft_length * sizeof(gr_complex)); - - write_out_flag(); - no++; - ni++; - enter_payload(); - break; - - case ST_PAYLOAD: - if (in_flag[ni] & 0x1){ // this is first symbol of a new payload - enter_preamble(); - break; - } - - // copy a symbol from input to output - memcpy(&out_sym[no * d_fft_length], - &in_sym[ni * d_fft_length], - d_fft_length * sizeof(gr_complex)); - - write_out_flag(); - no++; - ni++; - break; - - default: - std::cerr << "gr_ofdm_insert_preamble: (can't happen) invalid state, resetting\n"; - enter_idle(); - } - } - - consume_each(ni); - return no; -} - -void -gr_ofdm_insert_preamble::enter_idle() -{ - d_state = ST_IDLE; - d_nsymbols_output = 0; - d_pending_flag = 0; -} - -void -gr_ofdm_insert_preamble::enter_preamble() -{ - d_state = ST_PREAMBLE; - d_nsymbols_output = 0; - d_pending_flag = 1; -} - -void -gr_ofdm_insert_preamble::enter_first_payload() -{ - d_state = ST_FIRST_PAYLOAD; -} - -void -gr_ofdm_insert_preamble::enter_payload() -{ - d_state = ST_PAYLOAD; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.h b/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.h deleted file mode 100644 index 57c1af013..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_GR_OFDM_INSERT_PREAMBLE_H -#define INCLUDED_GR_OFDM_INSERT_PREAMBLE_H - -#include <gr_block.h> -#include <vector> - -class gr_ofdm_insert_preamble; -typedef boost::shared_ptr<gr_ofdm_insert_preamble> gr_ofdm_insert_preamble_sptr; - -gr_ofdm_insert_preamble_sptr -gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - -/*! - * \brief insert "pre-modulated" preamble symbols before each payload. - * \ingroup sync_blk - * \ingroup ofdm_blk - * - * <pre> - * input 1: stream of vectors of gr_complex [fft_length] - * These are the modulated symbols of the payload. - * - * input 2: stream of char. The LSB indicates whether the corresponding - * symbol on input 1 is the first symbol of the payload or not. - * It's a 1 if the corresponding symbol is the first symbol, - * otherwise 0. - * - * N.B., this implies that there must be at least 1 symbol in the payload. - * - * - * output 1: stream of vectors of gr_complex [fft_length] - * These include the preamble symbols and the payload symbols. - * - * output 2: stream of char. The LSB indicates whether the corresponding - * symbol on input 1 is the first symbol of a packet (i.e., the - * first symbol of the preamble.) It's a 1 if the corresponding - * symbol is the first symbol, otherwise 0. - * </pre> - * - * \param fft_length length of each symbol in samples. - * \param preamble vector of symbols that represent the pre-modulated preamble. - */ - -class gr_ofdm_insert_preamble : public gr_block -{ - friend gr_ofdm_insert_preamble_sptr - gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - -protected: - gr_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - -private: - enum state_t { - ST_IDLE, - ST_PREAMBLE, - ST_FIRST_PAYLOAD, - ST_PAYLOAD - }; - - int d_fft_length; - const std::vector<std::vector<gr_complex> > d_preamble; - state_t d_state; - int d_nsymbols_output; - int d_pending_flag; - - void enter_idle(); - void enter_preamble(); - void enter_first_payload(); - void enter_payload(); - - -public: - ~gr_ofdm_insert_preamble(); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_OFDM_INSERT_PREAMBLE_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.i b/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.i deleted file mode 100644 index e33bd63a0..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 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,ofdm_insert_preamble); - -gr_ofdm_insert_preamble_sptr -gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - - -class gr_ofdm_insert_preamble : public gr_block -{ - protected: - gr_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc deleted file mode 100644 index cc4aba0cb..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008,2010 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_ofdm_mapper_bcv.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <string.h> - -gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_mapper_bcv (constellation, msgq_limit, - occupied_carriers, fft_length)); -} - -// Consumes 1 packet and produces as many OFDM symbols of fft_length to hold the full packet -gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) - : gr_sync_block ("ofdm_mapper_bcv", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature2 (1, 2, sizeof(gr_complex)*fft_length, sizeof(char))), - d_constellation(constellation), - d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), - d_occupied_carriers(occupied_carriers), - d_fft_length(fft_length), - d_bit_offset(0), - d_pending_flag(0), - d_resid(0), - d_nresid(0) -{ - if (!(d_occupied_carriers <= d_fft_length)) - throw std::invalid_argument("gr_ofdm_mapper_bcv: occupied carriers must be <= fft_length"); - - // this is not the final form of this solution since we still use the occupied_tones concept, - // which would get us into trouble if the number of carriers we seek is greater than the occupied carriers. - // Eventually, we will get rid of the occupied_carriers concept. - std::string carriers = "FE7F"; - - // A bit hacky to fill out carriers to occupied_carriers length - int diff = (d_occupied_carriers - 4*carriers.length()); - while(diff > 7) { - carriers.insert(0, "f"); - carriers.insert(carriers.length(), "f"); - diff -= 8; - } - - // if there's extras left to be processed - // divide remaining to put on either side of current map - // all of this is done to stick with the concept of a carrier map string that - // can be later passed by the user, even though it'd be cleaner to just do this - // on the carrier map itself - int diff_left=0; - int diff_right=0; - - // dictionary to convert from integers to ascii hex representation - char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - if(diff > 0) { - char c[2] = {0,0}; - - diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer - carriers.insert(0, c); - - diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer - carriers.insert(carriers.length(), c); - } - - // find out how many zeros to pad on the sides; the difference between the fft length and the subcarrier - // mapping size in chunks of four. This is the number to pack on the left and this number plus any - // residual nulls (if odd) will be packed on the right. - diff = (d_fft_length/4 - carriers.length())/2; - - unsigned int i,j,k; - for(i = 0; i < carriers.length(); i++) { - char c = carriers[i]; // get the current hex character from the string - for(j = 0; j < 4; j++) { // walk through all four bits - k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; // convert to int and extract next bit - if(k) { // if bit is a 1, - d_subcarrier_map.push_back(4*(i+diff) + j); // use this subcarrier - } - } - } - - // make sure we stay in the limit currently imposed by the occupied_carriers - if(d_subcarrier_map.size() > d_occupied_carriers) { - throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); - } - - d_nbits = (unsigned long)ceil(log10(float(d_constellation.size())) / log10(2.0)); -} - -gr_ofdm_mapper_bcv::~gr_ofdm_mapper_bcv(void) -{ -} - -int gr_ofdm_mapper_bcv::randsym() -{ - return (rand() % d_constellation.size()); -} - -int -gr_ofdm_mapper_bcv::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *)output_items[0]; - - unsigned int i=0; - - //printf("OFDM BPSK Mapper: ninput_items: %d noutput_items: %d\n", ninput_items[0], noutput_items); - - if(d_eof) { - return -1; - } - - if(!d_msg) { - d_msg = d_msgq->delete_head(); // block, waiting for a message - d_msg_offset = 0; - d_bit_offset = 0; - d_pending_flag = 1; // new packet, write start of packet flag - - if((d_msg->length() == 0) && (d_msg->type() == 1)) { - d_msg.reset(); - return -1; // We're done; no more messages coming. - } - } - - char *out_flag = 0; - if(output_items.size() == 2) - out_flag = (char *) output_items[1]; - - - // Build a single symbol: - // Initialize all bins to 0 to set unused carriers - memset(out, 0, d_fft_length*sizeof(gr_complex)); - - i = 0; - unsigned char bits = 0; - //while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) { - while((d_msg_offset < d_msg->length()) && (i < d_subcarrier_map.size())) { - - // need new data to process - if(d_bit_offset == 0) { - d_msgbytes = d_msg->msg()[d_msg_offset]; - //printf("mod message byte: %x\n", d_msgbytes); - } - - if(d_nresid > 0) { - // take the residual bits, fill out nbits with info from the new byte, and put them in the symbol - d_resid |= (((1 << d_nresid)-1) & d_msgbytes) << (d_nbits - d_nresid); - bits = d_resid; - - out[d_subcarrier_map[i]] = d_constellation[bits]; - i++; - - d_bit_offset += d_nresid; - d_nresid = 0; - d_resid = 0; - //printf("mod bit(r): %x resid: %x nresid: %d bit_offset: %d\n", - // bits, d_resid, d_nresid, d_bit_offset); - } - else { - if((8 - d_bit_offset) >= d_nbits) { // test to make sure we can fit nbits - // take the nbits number of bits at a time from the byte to add to the symbol - bits = ((1 << d_nbits)-1) & (d_msgbytes >> d_bit_offset); - d_bit_offset += d_nbits; - - out[d_subcarrier_map[i]] = d_constellation[bits]; - i++; - } - else { // if we can't fit nbits, store them for the next - // saves d_nresid bits of this message where d_nresid < d_nbits - unsigned int extra = 8-d_bit_offset; - d_resid = ((1 << extra)-1) & (d_msgbytes >> d_bit_offset); - d_bit_offset += extra; - d_nresid = d_nbits - extra; - } - - } - - if(d_bit_offset == 8) { - d_bit_offset = 0; - d_msg_offset++; - } - } - - // Ran out of data to put in symbol - if (d_msg_offset == d_msg->length()) { - if(d_nresid > 0) { - d_resid |= 0x00; - bits = d_resid; - d_nresid = 0; - d_resid = 0; - } - - //while(i < d_occupied_carriers) { // finish filling out the symbol - while(i < d_subcarrier_map.size()) { // finish filling out the symbol - out[d_subcarrier_map[i]] = d_constellation[randsym()]; - - i++; - } - - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); // finished packet, free message - assert(d_bit_offset == 0); - } - - if (out_flag) - out_flag[0] = d_pending_flag; - d_pending_flag = 0; - - return 1; // produced symbol -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h deleted file mode 100644 index 5a21b90af..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 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_OFDM_MAPPER_BCV_H -#define INCLUDED_GR_OFDM_MAPPER_BCV_H - -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_ofdm_mapper_bcv; -typedef boost::shared_ptr<gr_ofdm_mapper_bcv> gr_ofdm_mapper_bcv_sptr; - -gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - -/*! - * \brief take a stream of bytes in and map to a vector of complex - * constellation points suitable for IFFT input to be used in an ofdm - * modulator. Abstract class must be subclassed with specific mapping. - * \ingroup modulation_blk - * \ingroup ofdm_blk - */ - -class gr_ofdm_mapper_bcv : public gr_sync_block -{ - friend gr_ofdm_mapper_bcv_sptr - gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - protected: - gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - - private: - std::vector<gr_complex> d_constellation; - gr_msg_queue_sptr d_msgq; - gr_message_sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - - unsigned int d_occupied_carriers; - unsigned int d_fft_length; - unsigned int d_bit_offset; - int d_pending_flag; - - unsigned long d_nbits; - unsigned char d_msgbytes; - - unsigned char d_resid; - unsigned int d_nresid; - - std::vector<int> d_subcarrier_map; - - int randsym(); - - public: - ~gr_ofdm_mapper_bcv(void); - - gr_msg_queue_sptr msgq() const { return d_msgq; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i deleted file mode 100644 index 3850220ba..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 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,ofdm_mapper_bcv); - -gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, - unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length) throw(std::exception); - - -class gr_ofdm_mapper_bcv : public gr_sync_block -{ - protected: - gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, - unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length); - - public: - gr_msg_queue_sptr msgq(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc b/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc deleted file mode 100644 index f9a53c87f..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2010 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_ofdm_sampler.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <cstdio> - -gr_ofdm_sampler_sptr -gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_sampler (fft_length, symbol_length, timeout)); -} - -gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout) - : gr_block ("ofdm_sampler", - gr_make_io_signature2 (2, 2, sizeof (gr_complex), sizeof(char)), - gr_make_io_signature2 (2, 2, sizeof (gr_complex)*fft_length, sizeof(char)*fft_length)), - d_state(STATE_NO_SIG), d_timeout_max(timeout), d_fft_length(fft_length), d_symbol_length(symbol_length) -{ - set_relative_rate(1.0/(double) fft_length); // buffer allocator hint -} - -void -gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - // FIXME do we need more - //int nreqd = (noutput_items-1) * d_symbol_length + d_fft_length; - int nreqd = d_symbol_length + d_fft_length; - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = nreqd; -} - - -int -gr_ofdm_sampler::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (const gr_complex *) input_items[0]; - const char *trigger = (const char *) input_items[1]; - - gr_complex *optr = (gr_complex *) output_items[0]; - char *outsig = (char *) output_items[1]; - - //FIXME: we only process a single OFDM symbol at a time; after the preamble, we can - // process a few at a time as long as we always look out for the next preamble. - - unsigned int index=d_fft_length; // start one fft length into the input so we can always look back this far - - outsig[0] = 0; // set output to no signal by default - - // Search for a preamble trigger signal during the next symbol length - while((d_state != STATE_PREAMBLE) && (index <= (d_symbol_length+d_fft_length))) { - if(trigger[index]) { - outsig[0] = 1; // tell the next block there is a preamble coming - d_state = STATE_PREAMBLE; - } - else - index++; - } - - unsigned int i, pos, ret; - switch(d_state) { - case(STATE_PREAMBLE): - // When we found a preamble trigger, get it and set the symbol boundary here - for(i = (index - d_fft_length + 1); i <= index; i++) { - *optr++ = iptr[i]; - } - - d_timeout = d_timeout_max; // tell the system to expect at least this many symbols for a frame - d_state = STATE_FRAME; - consume_each(index - d_fft_length + 1); // consume up to one fft_length away to keep the history - ret = 1; - break; - - case(STATE_FRAME): - // use this state when we have processed a preamble and are getting the rest of the frames - //FIXME: we could also have a power squelch system here to enter STATE_NO_SIG if no power is received - - // skip over fft length history and cyclic prefix - pos = d_symbol_length; // keeps track of where we are in the input buffer - while(pos < d_symbol_length + d_fft_length) { - *optr++ = iptr[pos++]; - } - - if(d_timeout-- == 0) { - printf("TIMEOUT\n"); - d_state = STATE_NO_SIG; - } - - consume_each(d_symbol_length); // jump up by 1 fft length and the cyclic prefix length - ret = 1; - break; - - case(STATE_NO_SIG): - default: - consume_each(index-d_fft_length); // consume everything we've gone through so far leaving the fft length history - ret = 0; - break; - } - - return ret; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.h b/gnuradio-core/src/lib/general/gr_ofdm_sampler.h deleted file mode 100644 index d059636ed..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_sampler.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 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_OFDM_SAMPLER_H -#define INCLUDED_GR_OFDM_SAMPLER_H - -#include <gr_sync_block.h> - -class gr_ofdm_sampler; -typedef boost::shared_ptr<gr_ofdm_sampler> gr_ofdm_sampler_sptr; - -gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout=1000); - -/*! - * \brief does the rest of the OFDM stuff - * \ingroup ofdm_blk - */ -class gr_ofdm_sampler : public gr_block -{ - friend gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); - - gr_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); - - private: - enum state_t {STATE_NO_SIG, STATE_PREAMBLE, STATE_FRAME}; - - state_t d_state; - unsigned int d_timeout_max; - unsigned int d_timeout; - unsigned int d_fft_length; - unsigned int d_symbol_length; - - public: - 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); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.i b/gnuradio-core/src/lib/general/gr_ofdm_sampler.i deleted file mode 100644 index 601330b07..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_sampler.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 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,ofdm_sampler) - - gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout=1000); - -class gr_ofdm_sampler : public gr_sync_block -{ - private: - gr_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); -}; diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h index ec163911a..abb23e002 100644 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h +++ b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_GR_PA_2X2_PHASE_COMBINER_H #define INCLUDED_GR_PA_2X2_PHASE_COMBINER_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_pa_2x2_phase_combiner; typedef boost::shared_ptr<gr_pa_2x2_phase_combiner> gr_pa_2x2_phase_combiner_sptr; -gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner (); +GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner (); /*! * \brief pa_2x2 phase combiner @@ -40,7 +41,7 @@ gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner (); * * dx and dy are lambda/2. */ -class gr_pa_2x2_phase_combiner : public gr_sync_block +class GR_CORE_API gr_pa_2x2_phase_combiner : public gr_sync_block { static const int NM = 4; @@ -48,7 +49,7 @@ class gr_pa_2x2_phase_combiner : public gr_sync_block gr_complex d_phase[NM]; gr_pa_2x2_phase_combiner (); - friend gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); + friend GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); public: float theta() const { return d_theta; } diff --git a/gnuradio-core/src/lib/general/gr_packet_sink.h b/gnuradio-core/src/lib/general/gr_packet_sink.h index 73c5d6c52..89a95f3e3 100644 --- a/gnuradio-core/src/lib/general/gr_packet_sink.h +++ b/gnuradio-core/src/lib/general/gr_packet_sink.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_PACKET_SINK_H #define INCLUDED_GR_PACKET_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_msg_queue.h> class gr_packet_sink; typedef boost::shared_ptr<gr_packet_sink> gr_packet_sink_sptr; -gr_packet_sink_sptr +GR_CORE_API gr_packet_sink_sptr gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, gr_msg_queue_sptr target_queue, int threshold = -1 // -1 -> use default @@ -38,9 +39,9 @@ gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, * \brief process received bits looking for packet sync, header, and process bits into packet * \ingroup sink_blk */ -class gr_packet_sink : public gr_sync_block +class GR_CORE_API gr_packet_sink : public gr_sync_block { - friend gr_packet_sink_sptr + friend GR_CORE_API gr_packet_sink_sptr gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, gr_msg_queue_sptr target_queue, int threshold); diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h index 58a006246..5bb97fc5d 100644 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h +++ b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_gr_peak_detector2_FB_H #define INCLUDED_gr_peak_detector2_FB_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_peak_detector2_fb; typedef boost::shared_ptr<gr_peak_detector2_fb> gr_peak_detector2_fb_sptr; -gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise = 7, +GR_CORE_API gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise = 7, int look_ahead = 1000, float alpha = 0.001); @@ -49,9 +50,9 @@ gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise * \param alpha The gain value of a single-pole moving average filter */ -class gr_peak_detector2_fb : public gr_sync_block +class GR_CORE_API gr_peak_detector2_fb : public gr_sync_block { - friend gr_peak_detector2_fb_sptr + friend GR_CORE_API gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); gr_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha); diff --git a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h index 50157534b..dd6e300a8 100644 --- a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h +++ b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h @@ -23,24 +23,25 @@ #ifndef INCLUDED_GR_PHASE_MODULATOR_FC_H #define INCLUDED_GR_PHASE_MODULATOR_FC_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_phase_modulator_fc; typedef boost::shared_ptr<gr_phase_modulator_fc> gr_phase_modulator_fc_sptr; -gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity); +GR_CORE_API gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity); /*! * \brief Phase modulator block * \ingroup modulation_blk * output=complex(cos(in*sensitivity),sin(in*sensitivity)) */ -class gr_phase_modulator_fc : public gr_sync_block +class GR_CORE_API gr_phase_modulator_fc : public gr_sync_block { double d_sensitivity; double d_phase; - friend gr_phase_modulator_fc_sptr + friend GR_CORE_API gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity); gr_phase_modulator_fc (double sensitivity); diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc index 1668f71f0..e8ec1e235 100644 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc +++ b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2010 Free Software Foundation, Inc. + * Copyright 2006,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,22 +30,24 @@ #include <math.h> #include <gr_math.h> -#define M_TWOPI (2*M_PI) +#ifndef M_TWOPI +#define M_TWOPI (2.0f*M_PI) +#endif gr_pll_carriertracking_cc_sptr -gr_make_pll_carriertracking_cc (float alpha, float beta, float max_freq, float min_freq) +gr_make_pll_carriertracking_cc (float loop_bw, float max_freq, float min_freq) { - return gnuradio::get_initial_sptr(new gr_pll_carriertracking_cc (alpha, beta, max_freq, min_freq)); + return gnuradio::get_initial_sptr(new gr_pll_carriertracking_cc (loop_bw, max_freq, min_freq)); } -gr_pll_carriertracking_cc::gr_pll_carriertracking_cc (float alpha, float beta, float max_freq, float min_freq) +gr_pll_carriertracking_cc::gr_pll_carriertracking_cc (float loop_bw, + float max_freq, + float min_freq) : gr_sync_block ("pll_carriertracking_cc", gr_make_io_signature (1, 1, sizeof (gr_complex)), gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_alpha(alpha), d_beta(beta), - d_max_freq(max_freq), d_min_freq(min_freq), - d_phase(0), d_freq((max_freq+min_freq)/2), - d_locksig(0),d_lock_threshold(0),d_squelch_enable(false) + gri_control_loop(loop_bw, max_freq, min_freq), + d_locksig(0), d_lock_threshold(0), d_squelch_enable(false) { } @@ -72,7 +74,7 @@ gr_pll_carriertracking_cc::phase_detector(gr_complex sample,float ref_phase) bool gr_pll_carriertracking_cc::lock_detector(void) { - return (fabs(d_locksig) > d_lock_threshold); + return (fabsf(d_locksig) > d_lock_threshold); } bool @@ -99,19 +101,16 @@ gr_pll_carriertracking_cc::work (int noutput_items, float t_imag, t_real; for (int i = 0; i < noutput_items; i++){ - gr_sincosf(d_phase,&t_imag,&t_real); - optr[i] = iptr[i] * gr_complex(t_real,-t_imag); + gr_sincosf(d_phase, &t_imag, &t_real); + optr[i] = iptr[i] * gr_complex(t_real, -t_imag); error = phase_detector(iptr[i],d_phase); - - d_freq = d_freq + d_beta * error; - d_phase = mod_2pi(d_phase + d_freq + d_alpha * error); - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; - d_locksig = d_locksig * (1.0 - d_alpha) + + + advance_loop(error); + phase_wrap(); + frequency_limit(); + + d_locksig = d_locksig * (1.0 - d_alpha) + \ d_alpha*(iptr[i].real() * t_real + iptr[i].imag() * t_imag); if ((d_squelch_enable) && !lock_detector()) diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h index 195f06016..db74bb101 100644 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h +++ b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,206 Free Software Foundation, Inc. + * Copyright 2004,2006,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,13 +23,16 @@ #ifndef INCLUDED_GR_PLL_CARRIERTRACKING_CC_H #define INCLUDED_GR_PLL_CARRIERTRACKING_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> +#include <gri_control_loop.h> class gr_pll_carriertracking_cc; typedef boost::shared_ptr<gr_pll_carriertracking_cc> gr_pll_carriertracking_cc_sptr; -gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float alpha, float beta, - float max_freq, float min_freq); +GR_CORE_API gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float loop_bw, + float max_freq, + float min_freq); /*! * \brief Implements a PLL which locks to the input frequency and outputs the * input signal mixed with that carrier. @@ -41,19 +44,20 @@ gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float alpha, floa * the input and outputs that signal, downconverted to DC * * All settings max_freq and min_freq are in terms of radians per sample, - * NOT HERTZ. Alpha is the phase gain (first order, units of radians per radian) - * and beta is the frequency gain (second order, units of radians per sample per radian) + * NOT HERTZ. The loop bandwidth determins the lock range and should be set + * around pi/200 -- 2pi/100. * \sa gr_pll_freqdet_cf, gr_pll_carriertracking_cc */ -class gr_pll_carriertracking_cc : public gr_sync_block +class GR_CORE_API gr_pll_carriertracking_cc : public gr_sync_block, public gri_control_loop { - friend gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float alpha, float beta, - float max_freq, float min_freq); + friend GR_CORE_API gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float loop_bw, + float max_freq, + float min_freq); - float d_alpha,d_beta,d_max_freq,d_min_freq,d_phase,d_freq,d_locksig,d_lock_threshold; + float d_locksig,d_lock_threshold; bool d_squelch_enable; - gr_pll_carriertracking_cc (float alpha, float beta, float max_freq, float min_freq); + gr_pll_carriertracking_cc (float loop_bw, float max_freq, float min_freq); int work (int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.i b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.i index 3e84fccbe..d309111b2 100644 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.i +++ b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,13 +23,14 @@ GR_SWIG_BLOCK_MAGIC(gr,pll_carriertracking_cc); gr_pll_carriertracking_cc_sptr -gr_make_pll_carriertracking_cc (float alpha, float beta, - float max_freq, float min_freq); +gr_make_pll_carriertracking_cc (float loop_bw, + float max_freq, + float min_freq); -class gr_pll_carriertracking_cc : public gr_sync_block +class gr_pll_carriertracking_cc : public gr_sync_block, public gri_control_loop { private: - gr_pll_carriertracking_cc (float alpha, float beta, float max_freq, float min_freq); + gr_pll_carriertracking_cc (float loop_bw, float max_freq, float min_freq); public: bool lock_detector(void); bool squelch_enable(bool); diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc index 997ba4042..aa0d67855 100644 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc +++ b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,8 +20,6 @@ * Boston, MA 02110-1301, USA. */ -// WARNING: this file is machine generated. Edits will be over written - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -31,21 +29,21 @@ #include <math.h> #include <gr_math.h> -#define M_TWOPI (2*M_PI) +#ifndef M_TWOPI +#define M_TWOPI (2.0f*M_PI) +#endif gr_pll_freqdet_cf_sptr -gr_make_pll_freqdet_cf (float alpha, float beta, float max_freq, float min_freq) +gr_make_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq) { - return gnuradio::get_initial_sptr(new gr_pll_freqdet_cf (alpha, beta, max_freq, min_freq)); + return gnuradio::get_initial_sptr(new gr_pll_freqdet_cf (loop_bw, max_freq, min_freq)); } -gr_pll_freqdet_cf::gr_pll_freqdet_cf (float alpha, float beta, float max_freq, float min_freq) +gr_pll_freqdet_cf::gr_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq) : gr_sync_block ("pll_freqdet_cf", gr_make_io_signature (1, 1, sizeof (gr_complex)), gr_make_io_signature (1, 1, sizeof (float))), - d_alpha(alpha), d_beta(beta), - d_max_freq(max_freq), d_min_freq(min_freq), - d_phase(0), d_freq((max_freq+min_freq)/2) + gri_control_loop(loop_bw, max_freq, min_freq) { } @@ -70,8 +68,8 @@ gr_pll_freqdet_cf::phase_detector(gr_complex sample,float ref_phase) int gr_pll_freqdet_cf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { const gr_complex *iptr = (gr_complex *) input_items[0]; float *optr = (float *) output_items[0]; @@ -84,13 +82,9 @@ gr_pll_freqdet_cf::work (int noutput_items, error = phase_detector(*iptr++,d_phase); - d_freq = d_freq + d_beta * error; - d_phase = mod_2pi(d_phase + d_freq + d_alpha * error); - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; + advance_loop(error); + phase_wrap(); + frequency_limit(); } return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h index 0581c8724..336f3fd31 100644 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h +++ b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,13 +23,16 @@ #ifndef INCLUDED_GR_PLL_FREQDET_CF_H #define INCLUDED_GR_PLL_FREQDET_CF_H +#include <gr_core_api.h> #include <gr_sync_block.h> +#include <gri_control_loop.h> class gr_pll_freqdet_cf; typedef boost::shared_ptr<gr_pll_freqdet_cf> gr_pll_freqdet_cf_sptr; -gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float alpha, float beta, - float max_freq, float min_freq); +GR_CORE_API gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float loop_bw, + float max_freq, + float min_freq); /*! * \brief Implements a PLL which locks to the input frequency and outputs * an estimate of that frequency. Useful for FM Demod. @@ -40,24 +43,24 @@ gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float alpha, float beta, * This PLL locks onto a [possibly noisy] reference carrier on * the input and outputs an estimate of that frequency in radians per sample. * All settings max_freq and min_freq are in terms of radians per sample, - * NOT HERTZ. Alpha is the phase gain (first order, units of radians per radian) - * and beta is the frequency gain (second order, units of radians per sample per radian) + * NOT HERTZ. The loop bandwidth determins the lock range and should be set + * around pi/200 -- 2pi/100. * \sa gr_pll_refout_cc, gr_pll_carriertracking_cc */ -class gr_pll_freqdet_cf : public gr_sync_block +class GR_CORE_API gr_pll_freqdet_cf : public gr_sync_block, public gri_control_loop { - friend gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float alpha, float beta, - float max_freq, float min_freq); + friend GR_CORE_API gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float loop_bw, + float max_freq, + float min_freq); - float d_alpha,d_beta,d_max_freq,d_min_freq,d_phase,d_freq; - gr_pll_freqdet_cf (float alpha, float beta, float max_freq, float min_freq); + float mod_2pi (float in); + gr_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq); int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); private: - float mod_2pi (float in); float phase_detector(gr_complex sample,float ref_phase); }; diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.i b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.i index b730f037a..f93e6e37e 100644 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.i +++ b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,11 +22,12 @@ GR_SWIG_BLOCK_MAGIC(gr,pll_freqdet_cf) - gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float alpha, float beta, - float max_freq, float min_freq); + gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float loop_bw, + float max_freq, + float min_freq); -class gr_pll_freqdet_cf : public gr_sync_block +class gr_pll_freqdet_cf : public gr_sync_block, public gri_control_loop { private: - gr_pll_freqdet_cf (float alpha, float beta, float max_freq, float min_freq); + gr_pll_freqdet_cf (float loop_bw, float max_freq, float min_freq); }; diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc b/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc index d01f28e45..dfd5079da 100644 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc +++ b/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,8 +20,6 @@ * Boston, MA 02110-1301, USA. */ -// WARNING: this file is machine generated. Edits will be over written - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -32,21 +30,21 @@ #include <math.h> #include <gr_math.h> -#define M_TWOPI (2*M_PI) +#ifndef M_TWOPI +#define M_TWOPI (2.0f*M_PI) +#endif gr_pll_refout_cc_sptr -gr_make_pll_refout_cc (float alpha, float beta, float max_freq, float min_freq) +gr_make_pll_refout_cc (float loop_bw, float max_freq, float min_freq) { - return gnuradio::get_initial_sptr(new gr_pll_refout_cc (alpha, beta, max_freq, min_freq)); + return gnuradio::get_initial_sptr(new gr_pll_refout_cc (loop_bw, max_freq, min_freq)); } -gr_pll_refout_cc::gr_pll_refout_cc (float alpha, float beta, float max_freq, float min_freq) +gr_pll_refout_cc::gr_pll_refout_cc (float loop_bw, float max_freq, float min_freq) : gr_sync_block ("pll_refout_cc", gr_make_io_signature (1, 1, sizeof (gr_complex)), gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_alpha(alpha), d_beta(beta), - d_max_freq(max_freq), d_min_freq(min_freq), - d_phase(0), d_freq((max_freq+min_freq)/2) + gri_control_loop(loop_bw, max_freq, min_freq) { } @@ -87,13 +85,9 @@ gr_pll_refout_cc::work (int noutput_items, error = phase_detector(*iptr++,d_phase); - d_freq = d_freq + d_beta * error; - d_phase = mod_2pi(d_phase + d_freq + d_alpha * error); - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; + advance_loop(error); + phase_wrap(); + frequency_limit(); } return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.h b/gnuradio-core/src/lib/general/gr_pll_refout_cc.h index 3263c957f..dcbeb1efa 100644 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.h +++ b/gnuradio-core/src/lib/general/gr_pll_refout_cc.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,18 +20,18 @@ * Boston, MA 02110-1301, USA. */ - - #ifndef INCLUDED_GR_PLL_REFOUT_CC_H #define INCLUDED_GR_PLL_REFOUT_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> +#include <gri_control_loop.h> class gr_pll_refout_cc; typedef boost::shared_ptr<gr_pll_refout_cc> gr_pll_refout_cc_sptr; -gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float alpha, float beta, - float max_freq, float min_freq); +GR_CORE_API gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float loop_bw, + float max_freq, float min_freq); /*! * \brief Implements a PLL which locks to the input frequency and outputs a carrier * \ingroup sync_blk @@ -43,24 +43,23 @@ gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float alpha, float beta, * aligned to it. * * All settings max_freq and min_freq are in terms of radians per sample, - * NOT HERTZ. Alpha is the phase gain (first order, units of radians per radian) - * and beta is the frequency gain (second order, units of radians per sample per radian) + * NOT HERTZ. The loop bandwidth determins the lock range and should be set + * around pi/200 -- 2pi/100. * \sa gr_pll_freqdet_cf, gr_pll_carriertracking_cc */ -class gr_pll_refout_cc : public gr_sync_block +class GR_CORE_API gr_pll_refout_cc : public gr_sync_block, public gri_control_loop { - friend gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float alpha, float beta, - float max_freq, float min_freq); + friend GR_CORE_API gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float loop_bw, + float max_freq, float min_freq); - float d_alpha,d_beta,d_max_freq,d_min_freq,d_phase,d_freq; - gr_pll_refout_cc (float alpha, float beta, float max_freq, float min_freq); + gr_pll_refout_cc (float loop_bw, float max_freq, float min_freq); int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); private: float mod_2pi (float in); - float phase_detector(gr_complex sample,float ref_phase); + float phase_detector(gr_complex sample, float ref_phase); }; #endif diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.i b/gnuradio-core/src/lib/general/gr_pll_refout_cc.i index 026a684ed..834ea1e36 100644 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.i +++ b/gnuradio-core/src/lib/general/gr_pll_refout_cc.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,11 +22,11 @@ GR_SWIG_BLOCK_MAGIC(gr,pll_refout_cc) - gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float alpha, float beta, - float max_freq, float min_freq); +gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float loop_bw, + float max_freq, float min_freq); -class gr_pll_refout_cc : public gr_sync_block +class gr_pll_refout_cc : public gr_sync_block, public gri_control_loop { private: - gr_pll_refout_cc (float alpha, float beta, float max_freq, float min_freq); + gr_pll_refout_cc (float loop_bw, float max_freq, float min_freq); }; diff --git a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h index 73bb7aa8c..75e2d1c7b 100644 --- a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h +++ b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_PN_CORRELATOR_CC_H #define INCLUDED_GR_PN_CORRELATOR_CC_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> #include <gri_glfsr.h> class gr_pn_correlator_cc; typedef boost::shared_ptr<gr_pn_correlator_cc> gr_pn_correlator_cc_sptr; -gr_pn_correlator_cc_sptr +GR_CORE_API gr_pn_correlator_cc_sptr gr_make_pn_correlator_cc(int degree, int mask=0, int seed=1); /*! * \brief PN code sequential search correlator @@ -39,9 +40,9 @@ gr_make_pn_correlator_cc(int degree, int mask=0, int seed=1); * reference PN code, one sample per PN code period */ -class gr_pn_correlator_cc : public gr_sync_decimator +class GR_CORE_API gr_pn_correlator_cc : public gr_sync_decimator { - friend gr_pn_correlator_cc_sptr gr_make_pn_correlator_cc(int degree, int mask, int seed); + friend GR_CORE_API gr_pn_correlator_cc_sptr gr_make_pn_correlator_cc(int degree, int mask, int seed); int d_len; float d_pn; diff --git a/gnuradio-core/src/lib/general/gr_prefs.h b/gnuradio-core/src/lib/general/gr_prefs.h index 4396d727c..8ceb5b465 100644 --- a/gnuradio-core/src/lib/general/gr_prefs.h +++ b/gnuradio-core/src/lib/general/gr_prefs.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_PREFS_H #define INCLUDED_GR_PREFS_H +#include <gr_core_api.h> #include <string> /*! @@ -32,7 +33,7 @@ * via the magic of SWIG directors. */ -class gr_prefs +class GR_CORE_API gr_prefs { public: static gr_prefs *singleton(); diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h index ee8872010..e857686a8 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_PROBE_AVG_MAG_SQRD_C_H #define INCLUDED_GR_PROBE_AVG_MAG_SQRD_C_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> class gr_probe_avg_mag_sqrd_c; typedef boost::shared_ptr<gr_probe_avg_mag_sqrd_c> gr_probe_avg_mag_sqrd_c_sptr; -gr_probe_avg_mag_sqrd_c_sptr +GR_CORE_API gr_probe_avg_mag_sqrd_c_sptr gr_make_probe_avg_mag_sqrd_c (double threshold_db, double alpha = 0.0001); /*! @@ -41,14 +42,14 @@ gr_make_probe_avg_mag_sqrd_c (double threshold_db, double alpha = 0.0001); * The level and indication as to whether the level exceeds threshold * can be retrieved with the level and unmuted accessors. */ -class gr_probe_avg_mag_sqrd_c : public gr_sync_block +class GR_CORE_API gr_probe_avg_mag_sqrd_c : public gr_sync_block { double d_threshold; gr_single_pole_iir<double,double,double> d_iir; bool d_unmuted; double d_level; - friend gr_probe_avg_mag_sqrd_c_sptr + friend GR_CORE_API gr_probe_avg_mag_sqrd_c_sptr gr_make_probe_avg_mag_sqrd_c (double threshold_db, double alpha); gr_probe_avg_mag_sqrd_c (double threshold_db, double alpha); diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h index 6c536ca5b..a85afcf3b 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H #define INCLUDED_GR_PROBE_AVG_MAG_SQRD_CF_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> class gr_probe_avg_mag_sqrd_cf; typedef boost::shared_ptr<gr_probe_avg_mag_sqrd_cf> gr_probe_avg_mag_sqrd_cf_sptr; -gr_probe_avg_mag_sqrd_cf_sptr +GR_CORE_API gr_probe_avg_mag_sqrd_cf_sptr gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha = 0.0001); /*! @@ -43,14 +44,14 @@ gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha = 0.0001); * can be retrieved with the level and unmuted accessors. * */ -class gr_probe_avg_mag_sqrd_cf : public gr_sync_block +class GR_CORE_API gr_probe_avg_mag_sqrd_cf : public gr_sync_block { double d_threshold; gr_single_pole_iir<double,double,double> d_iir; bool d_unmuted; double d_level; - friend gr_probe_avg_mag_sqrd_cf_sptr + friend GR_CORE_API gr_probe_avg_mag_sqrd_cf_sptr gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha); gr_probe_avg_mag_sqrd_cf (double threshold_db, double alpha); diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h index b31e54f6b..4181ccf46 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_PROBE_AVG_MAG_SQRD_F_H #define INCLUDED_GR_PROBE_AVG_MAG_SQRD_F_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> class gr_probe_avg_mag_sqrd_f; typedef boost::shared_ptr<gr_probe_avg_mag_sqrd_f> gr_probe_avg_mag_sqrd_f_sptr; -gr_probe_avg_mag_sqrd_f_sptr +GR_CORE_API gr_probe_avg_mag_sqrd_f_sptr gr_make_probe_avg_mag_sqrd_f (double threshold_db, double alpha = 0.0001); /*! @@ -41,14 +42,14 @@ gr_make_probe_avg_mag_sqrd_f (double threshold_db, double alpha = 0.0001); * The level and indication as to whether the level exceeds threshold * can be retrieved with the level and unmuted accessors. */ -class gr_probe_avg_mag_sqrd_f : public gr_sync_block +class GR_CORE_API gr_probe_avg_mag_sqrd_f : public gr_sync_block { double d_threshold; gr_single_pole_iir<double,double,double> d_iir; bool d_unmuted; double d_level; - friend gr_probe_avg_mag_sqrd_f_sptr + friend GR_CORE_API gr_probe_avg_mag_sqrd_f_sptr gr_make_probe_avg_mag_sqrd_f (double threshold_db, double alpha); gr_probe_avg_mag_sqrd_f (double threshold_db, double alpha); diff --git a/gnuradio-core/src/lib/general/gr_probe_density_b.h b/gnuradio-core/src/lib/general/gr_probe_density_b.h index 92b98d193..0af30c665 100644 --- a/gnuradio-core/src/lib/general/gr_probe_density_b.h +++ b/gnuradio-core/src/lib/general/gr_probe_density_b.h @@ -20,13 +20,14 @@ #ifndef INCLUDED_GR_PROBE_DENSITY_B_H #define INCLUDED_GR_PROBE_DENSITY_B_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_probe_density_b; typedef boost::shared_ptr<gr_probe_density_b> gr_probe_density_b_sptr; -gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); +GR_CORE_API gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); /*! * This block maintains a running average of the input stream and @@ -40,10 +41,10 @@ gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); * */ -class gr_probe_density_b : public gr_sync_block +class GR_CORE_API gr_probe_density_b : public gr_sync_block { private: - friend gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); + friend GR_CORE_API gr_probe_density_b_sptr gr_make_probe_density_b(double alpha); double d_alpha; double d_beta; diff --git a/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.h b/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.h index 279a4a5b8..870e46701 100644 --- a/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.h +++ b/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_GR_PROBE_MPSK_SNR_C_H #define INCLUDED_GR_PROBE_MPSK_SNR_C_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_probe_mpsk_snr_c; typedef boost::shared_ptr<gr_probe_mpsk_snr_c> gr_probe_mpsk_snr_c_sptr; -gr_probe_mpsk_snr_c_sptr +GR_CORE_API gr_probe_mpsk_snr_c_sptr gr_make_probe_mpsk_snr_c(double alpha = 0.0001); /*! @@ -46,7 +47,7 @@ gr_make_probe_mpsk_snr_c(double alpha = 0.0001); * This SNR estimator is inaccurate below about 7dB SNR. * */ -class gr_probe_mpsk_snr_c : public gr_sync_block +class GR_CORE_API gr_probe_mpsk_snr_c : public gr_sync_block { double d_alpha; double d_beta; @@ -54,7 +55,7 @@ class gr_probe_mpsk_snr_c : public gr_sync_block double d_noise_variance; // Factory function returning shared pointer of this class - friend gr_probe_mpsk_snr_c_sptr + friend GR_CORE_API gr_probe_mpsk_snr_c_sptr gr_make_probe_mpsk_snr_c(double alpha); // Private constructor diff --git a/gnuradio-core/src/lib/general/gr_probe_signal_f.h b/gnuradio-core/src/lib/general/gr_probe_signal_f.h index 9605bb685..b99c76976 100644 --- a/gnuradio-core/src/lib/general/gr_probe_signal_f.h +++ b/gnuradio-core/src/lib/general/gr_probe_signal_f.h @@ -22,23 +22,24 @@ #ifndef INCLUDED_GR_PROBE_SIGNAL_F_H #define INCLUDED_GR_PROBE_SIGNAL_F_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_probe_signal_f; typedef boost::shared_ptr<gr_probe_signal_f> gr_probe_signal_f_sptr; -gr_probe_signal_f_sptr +GR_CORE_API gr_probe_signal_f_sptr gr_make_probe_signal_f (); /*! * \brief Sink that allows a sample to be grabbed from Python. * \ingroup sink_blk */ -class gr_probe_signal_f : public gr_sync_block +class GR_CORE_API gr_probe_signal_f : public gr_sync_block { float d_level; - friend gr_probe_signal_f_sptr + friend GR_CORE_API gr_probe_signal_f_sptr gr_make_probe_signal_f(); gr_probe_signal_f(); diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h index 9c519f383..2a008d92d 100644 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h +++ b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_PWR_SQUELCH_CC_H #define INCLUDED_GR_PWR_SQUELCH_CC_H +#include <gr_core_api.h> #include <cmath> #include <gr_squelch_base_cc.h> #include <gr_single_pole_iir.h> @@ -30,21 +31,21 @@ class gr_pwr_squelch_cc; typedef boost::shared_ptr<gr_pwr_squelch_cc> gr_pwr_squelch_cc_sptr; -gr_pwr_squelch_cc_sptr +GR_CORE_API gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double alpha = 0.0001, int ramp=0, bool gate=false); /*! * \brief gate or zero output when input power below threshold * \ingroup level_blk */ -class gr_pwr_squelch_cc : public gr_squelch_base_cc +class GR_CORE_API gr_pwr_squelch_cc : public gr_squelch_base_cc { private: double d_threshold; double d_pwr; gr_single_pole_iir<double,double,double> d_iir; - friend gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); + friend GR_CORE_API gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); gr_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); protected: diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h index 6952dbce2..27a7306b3 100644 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h +++ b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_PWR_SQUELCH_FF_H #define INCLUDED_GR_PWR_SQUELCH_FF_H +#include <gr_core_api.h> #include <cmath> #include <gr_squelch_base_ff.h> #include <gr_single_pole_iir.h> @@ -30,21 +31,21 @@ class gr_pwr_squelch_ff; typedef boost::shared_ptr<gr_pwr_squelch_ff> gr_pwr_squelch_ff_sptr; -gr_pwr_squelch_ff_sptr +GR_CORE_API gr_pwr_squelch_ff_sptr gr_make_pwr_squelch_ff(double db, double alpha = 0.0001, int ramp=0, bool gate=false); /*! * \brief gate or zero output when input power below threshold * \ingroup level_blk */ -class gr_pwr_squelch_ff : public gr_squelch_base_ff +class GR_CORE_API gr_pwr_squelch_ff : public gr_squelch_base_ff { private: double d_threshold; double d_pwr; gr_single_pole_iir<double,double,double> d_iir; - friend gr_pwr_squelch_ff_sptr gr_make_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); + friend GR_CORE_API gr_pwr_squelch_ff_sptr gr_make_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); gr_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); protected: diff --git a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h index df6de93d5..755f2839a 100644 --- a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h +++ b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h @@ -23,11 +23,12 @@ #ifndef INCLUDED_GR_QUADRATURE_DEMOD_CF_H #define INCLUDED_GR_QUADRATURE_DEMOD_CF_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_quadrature_demod_cf; typedef boost::shared_ptr<gr_quadrature_demod_cf> gr_quadrature_demod_cf_sptr; -gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); +GR_CORE_API gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); /*! * \brief quadrature demodulator: complex in, float out @@ -36,9 +37,9 @@ gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); * This can be used to demod FM, FSK, GMSK, etc. * The input is complex baseband. */ -class gr_quadrature_demod_cf : public gr_sync_block +class GR_CORE_API gr_quadrature_demod_cf : public gr_sync_block { - friend gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); + friend GR_CORE_API gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain); gr_quadrature_demod_cf (float gain); float d_gain; diff --git a/gnuradio-core/src/lib/general/gr_rail_ff.h b/gnuradio-core/src/lib/general/gr_rail_ff.h index d9e19a964..225bdf36e 100644 --- a/gnuradio-core/src/lib/general/gr_rail_ff.h +++ b/gnuradio-core/src/lib/general/gr_rail_ff.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_RAIL_FF_H_ # define INCLUDED_GR_RAIL_FF_H_ +#include <gr_core_api.h> #include <gr_sync_block.h> /*! @@ -33,11 +34,11 @@ class gr_rail_ff; typedef boost::shared_ptr<gr_rail_ff> gr_rail_ff_sptr; -gr_rail_ff_sptr gr_make_rail_ff(float lo, float hi); +GR_CORE_API gr_rail_ff_sptr gr_make_rail_ff(float lo, float hi); -class gr_rail_ff : public gr_sync_block +class GR_CORE_API gr_rail_ff : public gr_sync_block { - friend gr_rail_ff_sptr gr_make_rail_ff (float lo, float hi); + friend GR_CORE_API gr_rail_ff_sptr gr_make_rail_ff (float lo, float hi); float d_lo, d_hi; // the constant gr_rail_ff(float lo, float hi); diff --git a/gnuradio-core/src/lib/general/gr_random.h b/gnuradio-core/src/lib/general/gr_random.h index e5002fd33..13dbbfb04 100644 --- a/gnuradio-core/src/lib/general/gr_random.h +++ b/gnuradio-core/src/lib/general/gr_random.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_RANDOM_H #define INCLUDED_GR_RANDOM_H +#include <gr_core_api.h> #include <gr_complex.h> /*! * \brief pseudo random number generator * \ingroup math_blk */ -class gr_random { +class GR_CORE_API gr_random { protected: static const int NTAB = 32; long d_seed; diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.h b/gnuradio-core/src/lib/general/gr_regenerate_bb.h index db511b228..67cfedac7 100644 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.h +++ b/gnuradio-core/src/lib/general/gr_regenerate_bb.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_REGENERATE_BB_H #define INCLUDED_GR_REGENERATE_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_regenerate_bb; typedef boost::shared_ptr<gr_regenerate_bb> gr_regenerate_bb_sptr; -gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen=500); +GR_CORE_API gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen=500); /*! * \brief Detect the peak of a signal and repeat every period samples @@ -40,7 +41,7 @@ gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen= * * Note that if max_regen=(-1)/ULONG_MAX then the regeneration will run forever. */ -class gr_regenerate_bb : public gr_sync_block +class GR_CORE_API gr_regenerate_bb : public gr_sync_block { /*! * \brief Make a regenerate block @@ -48,7 +49,7 @@ class gr_regenerate_bb : public gr_sync_block * \param max_regen The maximum number of regenerations to perform; if set to * ULONG_MAX, it will regenerate continuously. */ - friend gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen); + friend GR_CORE_API gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen); gr_regenerate_bb (int period, unsigned int max_regen); diff --git a/gnuradio-core/src/lib/general/gr_remez.h b/gnuradio-core/src/lib/general/gr_remez.h index 85e1516a5..f7b8a72a3 100644 --- a/gnuradio-core/src/lib/general/gr_remez.h +++ b/gnuradio-core/src/lib/general/gr_remez.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_REMEZ_H #define INCLUDED_GR_REMEZ_H +#include <gr_core_api.h> #include <gr_types.h> #include <string> #include <stdexcept> @@ -51,7 +52,7 @@ * \throws std::runtime_error if args are invalid or calculation fails to converge. */ -std::vector<double> +GR_CORE_API std::vector<double> gr_remez (int order, const std::vector<double> &bands, const std::vector<double> &l, diff --git a/gnuradio-core/src/lib/general/gr_repeat.h b/gnuradio-core/src/lib/general/gr_repeat.h index f323fc375..b90f2f51d 100644 --- a/gnuradio-core/src/lib/general/gr_repeat.h +++ b/gnuradio-core/src/lib/general/gr_repeat.h @@ -22,23 +22,24 @@ #ifndef INCLUDED_GR_REPEAT_H #define INCLUDED_GR_REPEAT_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_repeat; typedef boost::shared_ptr<gr_repeat> gr_repeat_sptr; -gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); +GR_CORE_API gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); /*! * \brief Repeat a sample 'interp' times in output stream * \ingroup misc_blk */ -class gr_repeat : public gr_sync_interpolator +class GR_CORE_API gr_repeat : public gr_sync_interpolator { private: - friend gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); + friend GR_CORE_API gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); gr_repeat(size_t itemsize, int interp); diff --git a/gnuradio-core/src/lib/general/gr_reverse.h b/gnuradio-core/src/lib/general/gr_reverse.h index d79d34e91..43d84fda7 100644 --- a/gnuradio-core/src/lib/general/gr_reverse.h +++ b/gnuradio-core/src/lib/general/gr_reverse.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_REVERSE_H #define INCLUDED_GR_REVERSE_H +#include <gr_core_api.h> #include <vector> #include <gr_complex.h> diff --git a/gnuradio-core/src/lib/general/gr_rms_cf.h b/gnuradio-core/src/lib/general/gr_rms_cf.h index 86c4bdbac..f1bd9802c 100644 --- a/gnuradio-core/src/lib/general/gr_rms_cf.h +++ b/gnuradio-core/src/lib/general/gr_rms_cf.h @@ -22,25 +22,26 @@ #ifndef INCLUDED_GR_RMS_CF_H #define INCLUDED_GR_RMS_CF_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> class gr_rms_cf; typedef boost::shared_ptr<gr_rms_cf> gr_rms_cf_sptr; -gr_rms_cf_sptr +GR_CORE_API gr_rms_cf_sptr gr_make_rms_cf (double alpha = 0.0001); /*! * \brief RMS average power * \ingroup math_blk */ -class gr_rms_cf : public gr_sync_block +class GR_CORE_API gr_rms_cf : public gr_sync_block { gr_single_pole_iir<double,double,double> d_iir; bool d_unmuted; - friend gr_rms_cf_sptr + friend GR_CORE_API gr_rms_cf_sptr gr_make_rms_cf (double alpha); gr_rms_cf (double alpha); diff --git a/gnuradio-core/src/lib/general/gr_rms_ff.h b/gnuradio-core/src/lib/general/gr_rms_ff.h index ed1635eb1..0bbd53b70 100644 --- a/gnuradio-core/src/lib/general/gr_rms_ff.h +++ b/gnuradio-core/src/lib/general/gr_rms_ff.h @@ -22,25 +22,26 @@ #ifndef INCLUDED_GR_RMS_FF_H #define INCLUDED_GR_RMS_FF_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> class gr_rms_ff; typedef boost::shared_ptr<gr_rms_ff> gr_rms_ff_sptr; -gr_rms_ff_sptr +GR_CORE_API gr_rms_ff_sptr gr_make_rms_ff (double alpha = 0.0001); /*! * \brief RMS average power * \ingroup math_blk */ -class gr_rms_ff : public gr_sync_block +class GR_CORE_API gr_rms_ff : public gr_sync_block { gr_single_pole_iir<double,double,double> d_iir; bool d_unmuted; - friend gr_rms_ff_sptr + friend GR_CORE_API gr_rms_ff_sptr gr_make_rms_ff (double alpha); gr_rms_ff (double alpha); diff --git a/gnuradio-core/src/lib/general/gr_scrambler_bb.h b/gnuradio-core/src/lib/general/gr_scrambler_bb.h index 7efe8b598..79905933d 100644 --- a/gnuradio-core/src/lib/general/gr_scrambler_bb.h +++ b/gnuradio-core/src/lib/general/gr_scrambler_bb.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_SCRAMBLER_BB_H #define INCLUDED_GR_SCRAMBLER_BB_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include "gri_lfsr.h" class gr_scrambler_bb; typedef boost::shared_ptr<gr_scrambler_bb> gr_scrambler_bb_sptr; -gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); +GR_CORE_API gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); /*! * Scramble an input stream using an LFSR. This block works on the LSB only @@ -42,9 +43,9 @@ gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); * \ingroup coding_blk */ -class gr_scrambler_bb : public gr_sync_block +class GR_CORE_API gr_scrambler_bb : public gr_sync_block { - friend gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); + friend GR_CORE_API gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len); gri_lfsr d_lfsr; diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.h b/gnuradio-core/src/lib/general/gr_short_to_float.h index ccb19d9f2..b40c966ea 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.h +++ b/gnuradio-core/src/lib/general/gr_short_to_float.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_SHORT_TO_FLOAT_H #define INCLUDED_GR_SHORT_TO_FLOAT_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_short_to_float; typedef boost::shared_ptr<gr_short_to_float> gr_short_to_float_sptr; -gr_short_to_float_sptr +GR_CORE_API gr_short_to_float_sptr gr_make_short_to_float (); /*! @@ -36,9 +37,9 @@ gr_make_short_to_float (); * \ingroup converter_blk */ -class gr_short_to_float : public gr_sync_block +class GR_CORE_API gr_short_to_float : public gr_sync_block { - friend gr_short_to_float_sptr gr_make_short_to_float (); + friend GR_CORE_API gr_short_to_float_sptr gr_make_short_to_float (); gr_short_to_float (); public: diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.cc b/gnuradio-core/src/lib/general/gr_simple_correlator.cc index 01c007122..bdfa73ef3 100644 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.cc +++ b/gnuradio-core/src/lib/general/gr_simple_correlator.cc @@ -50,6 +50,7 @@ gr_simple_correlator::gr_simple_correlator (int payload_bytesize) d_state (ST_LOOKING), d_osi (0), d_bblen ((payload_bytesize + GRSF_PAYLOAD_OVERHEAD) * GRSF_BITS_PER_BYTE), d_bitbuf (new unsigned char [d_bblen]), + d_pktbuf (new unsigned char [d_bblen/GRSF_BITS_PER_BYTE]), d_bbi (0) { d_avbi = 0; @@ -71,6 +72,7 @@ gr_simple_correlator::~gr_simple_correlator () fclose(d_debug_fp); #endif delete [] d_bitbuf; + delete [] d_pktbuf; } @@ -184,10 +186,9 @@ gr_simple_correlator::general_work (int noutput_items, d_bbi++; if (d_bbi >= d_bblen){ // printf ("got whole packet\n"); - unsigned char pktbuf[d_bblen/GRSF_BITS_PER_BYTE]; - packit (pktbuf, d_bitbuf, d_bbi); - printf ("seqno %3d\n", pktbuf[0]); - memcpy (out, &pktbuf[GRSF_PAYLOAD_OVERHEAD], d_payload_bytesize); + packit (d_pktbuf, d_bitbuf, d_bbi); + printf ("seqno %3d\n", d_pktbuf[0]); + memcpy (out, &d_pktbuf[GRSF_PAYLOAD_OVERHEAD], d_payload_bytesize); enter_looking (); consume_each (n + 1); return d_payload_bytesize; diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.h b/gnuradio-core/src/lib/general/gr_simple_correlator.h index b21d38a04..4c5f060cd 100644 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.h +++ b/gnuradio-core/src/lib/general/gr_simple_correlator.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SIMPLE_CORRELATOR_H #define INCLUDED_GR_SIMPLE_CORRELATOR_H +#include <gr_core_api.h> #include <gr_block.h> #include <assert.h> @@ -31,13 +32,13 @@ class gr_simple_correlator; typedef boost::shared_ptr<gr_simple_correlator> gr_simple_correlator_sptr; -gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize); +GR_CORE_API gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize); /*! * \brief inverse of gr_simple_framer (more or less) * \ingroup sync_blk */ -class gr_simple_correlator : public gr_block +class GR_CORE_API gr_simple_correlator : public gr_block { static const int OVERSAMPLE = 8; enum state_t { ST_LOOKING, ST_UNDER_THRESHOLD, ST_LOCKED }; @@ -50,6 +51,7 @@ class gr_simple_correlator : public gr_block unsigned long long int d_shift_reg[OVERSAMPLE]; int d_bblen; // length of bitbuf unsigned char *d_bitbuf; // demodulated bits + unsigned char *d_pktbuf; // temp packet buf int d_bbi; // bitbuf index static const int AVG_PERIOD = 512; // must be power of 2 (for freq offset correction) @@ -62,7 +64,7 @@ class gr_simple_correlator : public gr_block FILE *d_debug_fp; // binary log file #endif - friend gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize); + friend GR_CORE_API gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize); gr_simple_correlator (int payload_bytesize); diff --git a/gnuradio-core/src/lib/general/gr_simple_framer.h b/gnuradio-core/src/lib/general/gr_simple_framer.h index d930da33b..15f392e4a 100644 --- a/gnuradio-core/src/lib/general/gr_simple_framer.h +++ b/gnuradio-core/src/lib/general/gr_simple_framer.h @@ -23,25 +23,26 @@ #ifndef INCLUDED_GR_SIMPLE_FRAMER_H #define INCLUDED_GR_SIMPLE_FRAMER_H +#include <gr_core_api.h> #include <gr_block.h> class gr_simple_framer; typedef boost::shared_ptr<gr_simple_framer> gr_simple_framer_sptr; -gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); +GR_CORE_API gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); /*! * \brief add sync field, seq number and command field to payload * \ingroup sync_blk */ -class gr_simple_framer : public gr_block +class GR_CORE_API gr_simple_framer : public gr_block { int d_seqno; int d_payload_bytesize; int d_input_block_size; // bytes int d_output_block_size; // bytes - friend gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); + friend GR_CORE_API gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); gr_simple_framer (int payload_bytesize); public: diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h index 30744f6fb..590b86de8 100644 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h +++ b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h @@ -22,26 +22,27 @@ #ifndef INCLUDED_GR_SIMPLE_SQUELCH_CC_H #define INCLUDED_GR_SIMPLE_SQUELCH_CC_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_single_pole_iir.h> class gr_simple_squelch_cc; typedef boost::shared_ptr<gr_simple_squelch_cc> gr_simple_squelch_cc_sptr; -gr_simple_squelch_cc_sptr +GR_CORE_API gr_simple_squelch_cc_sptr gr_make_simple_squelch_cc (double threshold_db, double alpha = 0.0001); /*! * \brief simple squelch block based on average signal power and threshold in dB. * \ingroup level_blk */ -class gr_simple_squelch_cc : public gr_sync_block +class GR_CORE_API gr_simple_squelch_cc : public gr_sync_block { double d_threshold; gr_single_pole_iir<double,double,double> d_iir; bool d_unmuted; - friend gr_simple_squelch_cc_sptr + friend GR_CORE_API gr_simple_squelch_cc_sptr gr_make_simple_squelch_cc (double threshold_db, double alpha); gr_simple_squelch_cc (double threshold_db, double alpha); diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h index 933c126e3..2beaaeab0 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ b/gnuradio-core/src/lib/general/gr_skiphead.h @@ -23,12 +23,16 @@ #ifndef INCLUDED_GR_SKIPHEAD_H #define INCLUDED_GR_SKIPHEAD_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <stddef.h> // size_t class gr_skiphead; typedef boost::shared_ptr<gr_skiphead> gr_skiphead_sptr; +GR_CORE_API gr_skiphead_sptr +gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); + /*! * \brief skips the first N items, from then on copies items to the output @@ -37,9 +41,9 @@ typedef boost::shared_ptr<gr_skiphead> gr_skiphead_sptr; * Useful for building test cases and sources which have metadata or junk at the start */ -class gr_skiphead : public gr_block +class GR_CORE_API gr_skiphead : public gr_block { - friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); + friend GR_CORE_API gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); uint64_t d_nitems_to_skip; @@ -53,8 +57,4 @@ class gr_skiphead : public gr_block gr_vector_void_star &output_items); }; -gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - - #endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_squash_ff.h b/gnuradio-core/src/lib/general/gr_squash_ff.h index ee3426cae..f7fea1648 100644 --- a/gnuradio-core/src/lib/general/gr_squash_ff.h +++ b/gnuradio-core/src/lib/general/gr_squash_ff.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SQUASH_FF_H_ # define INCLUDED_GR_SQUASH_FF_H_ +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_interp.h> @@ -36,12 +37,12 @@ class gr_squash_ff; typedef boost::shared_ptr<gr_squash_ff> gr_squash_ff_sptr; -gr_squash_ff_sptr gr_make_squash_ff(const std::vector<float> &igrid, +GR_CORE_API gr_squash_ff_sptr gr_make_squash_ff(const std::vector<float> &igrid, const std::vector<float> &ogrid); -class gr_squash_ff : public gr_sync_block +class GR_CORE_API gr_squash_ff : public gr_sync_block { - friend gr_squash_ff_sptr gr_make_squash_ff(const std::vector<float> &igrid, + friend GR_CORE_API gr_squash_ff_sptr gr_make_squash_ff(const std::vector<float> &igrid, const std::vector<float> &ogrid); size_t d_inum; diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_cc.h b/gnuradio-core/src/lib/general/gr_squelch_base_cc.h index 51e2e14e5..7c15e0121 100644 --- a/gnuradio-core/src/lib/general/gr_squelch_base_cc.h +++ b/gnuradio-core/src/lib/general/gr_squelch_base_cc.h @@ -23,9 +23,10 @@ #ifndef INCLUDED_GR_SQUELCH_BASE_CC_H #define INCLUDED_GR_SQUELCH_BASE_CC_H +#include <gr_core_api.h> #include <gr_block.h> -class gr_squelch_base_cc : public gr_block +class GR_CORE_API gr_squelch_base_cc : public gr_block { private: int d_ramp; diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_ff.h b/gnuradio-core/src/lib/general/gr_squelch_base_ff.h index 2ca108c75..92a064e63 100644 --- a/gnuradio-core/src/lib/general/gr_squelch_base_ff.h +++ b/gnuradio-core/src/lib/general/gr_squelch_base_ff.h @@ -23,9 +23,10 @@ #ifndef INCLUDED_GR_SQUELCH_BASE_FF_H #define INCLUDED_GR_SQUELCH_BASE_FF_H +#include <gr_core_api.h> #include <gr_block.h> -class gr_squelch_base_ff : public gr_block +class GR_CORE_API gr_squelch_base_ff : public gr_block { private: int d_ramp; diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.h b/gnuradio-core/src/lib/general/gr_stream_mux.h index 29829339e..68415ab1d 100644 --- a/gnuradio-core/src/lib/general/gr_stream_mux.h +++ b/gnuradio-core/src/lib/general/gr_stream_mux.h @@ -24,6 +24,7 @@ #define INCLUDED_GR_STREAM_MUX_H +#include <gr_core_api.h> #include <gr_block.h> #include <vector> @@ -45,7 +46,7 @@ typedef boost::shared_ptr<gr_stream_mux> gr_stream_mux_sptr; -gr_stream_mux_sptr +GR_CORE_API gr_stream_mux_sptr gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths); @@ -60,9 +61,9 @@ gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths); * [N0, N1, N2, ..., Nm, N0, N1, ...] */ -class gr_stream_mux : public gr_block +class GR_CORE_API gr_stream_mux : public gr_block { - friend gr_stream_mux_sptr + friend GR_CORE_API gr_stream_mux_sptr gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths); protected: diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.h b/gnuradio-core/src/lib/general/gr_stream_to_streams.h index 2fdd39e4a..905d3c556 100644 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.h +++ b/gnuradio-core/src/lib/general/gr_stream_to_streams.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_GR_STREAM_TO_STREAMS_H #define INCLUDED_GR_STREAM_TO_STREAMS_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_stream_to_streams; typedef boost::shared_ptr<gr_stream_to_streams> gr_stream_to_streams_sptr; -gr_stream_to_streams_sptr +GR_CORE_API gr_stream_to_streams_sptr gr_make_stream_to_streams (size_t item_size, size_t nstreams); @@ -38,9 +39,9 @@ gr_make_stream_to_streams (size_t item_size, size_t nstreams); * Converts a stream of N items into N streams of 1 item. * Repeat ad infinitum. */ -class gr_stream_to_streams : public gr_sync_decimator +class GR_CORE_API gr_stream_to_streams : public gr_sync_decimator { - friend gr_stream_to_streams_sptr + friend GR_CORE_API gr_stream_to_streams_sptr gr_make_stream_to_streams (size_t item_size, size_t nstreams); protected: diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.h b/gnuradio-core/src/lib/general/gr_stream_to_vector.h index 2cb03f6a8..77272b96b 100644 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.h +++ b/gnuradio-core/src/lib/general/gr_stream_to_vector.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_STREAM_TO_VECTOR_H #define INCLUDED_GR_STREAM_TO_VECTOR_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_stream_to_vector; typedef boost::shared_ptr<gr_stream_to_vector> gr_stream_to_vector_sptr; -gr_stream_to_vector_sptr +GR_CORE_API gr_stream_to_vector_sptr gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); @@ -36,9 +37,9 @@ gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); * \brief convert a stream of items into a stream of blocks containing nitems_per_block * \ingroup slicedice_blk */ -class gr_stream_to_vector : public gr_sync_decimator +class GR_CORE_API gr_stream_to_vector : public gr_sync_decimator { - friend gr_stream_to_vector_sptr + friend GR_CORE_API gr_stream_to_vector_sptr gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); protected: diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.h b/gnuradio-core/src/lib/general/gr_streams_to_stream.h index 044af6cd2..8207fed42 100644 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.h +++ b/gnuradio-core/src/lib/general/gr_streams_to_stream.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_GR_STREAMS_TO_STREAM_H #define INCLUDED_GR_STREAMS_TO_STREAM_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_streams_to_stream; typedef boost::shared_ptr<gr_streams_to_stream> gr_streams_to_stream_sptr; -gr_streams_to_stream_sptr +GR_CORE_API gr_streams_to_stream_sptr gr_make_streams_to_stream (size_t item_size, size_t nstreams); @@ -38,9 +39,9 @@ gr_make_streams_to_stream (size_t item_size, size_t nstreams); * Convert N streams of 1 item into 1 stream of N items. * Repeat ad infinitum. */ -class gr_streams_to_stream : public gr_sync_interpolator +class GR_CORE_API gr_streams_to_stream : public gr_sync_interpolator { - friend gr_streams_to_stream_sptr + friend GR_CORE_API gr_streams_to_stream_sptr gr_make_streams_to_stream (size_t item_size, size_t nstreams); protected: diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.h b/gnuradio-core/src/lib/general/gr_streams_to_vector.h index 1b2e3ebf7..6a05ac90a 100644 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.h +++ b/gnuradio-core/src/lib/general/gr_streams_to_vector.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_STREAMS_TO_VECTOR_H #define INCLUDED_GR_STREAMS_TO_VECTOR_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_streams_to_vector; typedef boost::shared_ptr<gr_streams_to_vector> gr_streams_to_vector_sptr; -gr_streams_to_vector_sptr +GR_CORE_API gr_streams_to_vector_sptr gr_make_streams_to_vector (size_t item_size, size_t nstreams); @@ -36,9 +37,9 @@ gr_make_streams_to_vector (size_t item_size, size_t nstreams); * \brief convert N streams of items to 1 stream of vector length N * \ingroup slicedice_blk */ -class gr_streams_to_vector : public gr_sync_block +class GR_CORE_API gr_streams_to_vector : public gr_sync_block { - friend gr_streams_to_vector_sptr + friend GR_CORE_API gr_streams_to_vector_sptr gr_make_streams_to_vector (size_t item_size, size_t nstreams); protected: diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.h b/gnuradio-core/src/lib/general/gr_stretch_ff.h index e75e1969f..578634dd8 100644 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.h +++ b/gnuradio-core/src/lib/general/gr_stretch_ff.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_STRETCH_FF_H_ # define INCLUDED_GR_STRETCH_FF_H_ +#include <gr_core_api.h> #include <gr_sync_block.h> /*! @@ -36,11 +37,11 @@ class gr_stretch_ff; typedef boost::shared_ptr<gr_stretch_ff> gr_stretch_ff_sptr; -gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); +GR_CORE_API gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); -class gr_stretch_ff : public gr_sync_block +class GR_CORE_API gr_stretch_ff : public gr_sync_block { - friend gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); + friend GR_CORE_API gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen); float d_lo; // the constant size_t d_vlen; diff --git a/gnuradio-core/src/lib/general/gr_test.h b/gnuradio-core/src/lib/general/gr_test.h index 5438ac701..78e39d518 100644 --- a/gnuradio-core/src/lib/general/gr_test.h +++ b/gnuradio-core/src/lib/general/gr_test.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_TEST_H #define INCLUDED_GR_TEST_H +#include <gr_core_api.h> #include <gr_block.h> #include <string> #include "gr_test_types.h" @@ -31,7 +32,7 @@ class gr_test; typedef boost::shared_ptr<gr_test> gr_test_sptr; // public constructor -gr_test_sptr gr_make_test (const std::string &name=std::string("gr_test"), +GR_CORE_API gr_test_sptr gr_make_test (const std::string &name=std::string("gr_test"), int min_inputs=1, int max_inputs=1, unsigned int sizeof_input_item=1, int min_outputs=1, int max_outputs=1, unsigned int sizeof_output_item=1, unsigned int history=1,unsigned int output_multiple=1,double relative_rate=1.0, @@ -50,7 +51,7 @@ gr_test_sptr gr_make_test (const std::string &name=std::string("gr_test"), * The runtime system should detect this and create large enough buffers * all through the signal chain. */ -class gr_test : public gr_block { +class GR_CORE_API gr_test : public gr_block { public: @@ -183,7 +184,7 @@ int general_work (int noutput_items, - friend gr_test_sptr gr_make_test (const std::string &name,int min_inputs, int max_inputs, unsigned int sizeof_input_item, + friend GR_CORE_API gr_test_sptr gr_make_test (const std::string &name,int min_inputs, int max_inputs, unsigned int sizeof_input_item, int min_outputs, int max_outputs, unsigned int sizeof_output_item, unsigned int history,unsigned int output_multiple,double relative_rate, bool fixed_rate,gr_consume_type_t cons_type, gr_produce_type_t prod_type); diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.h b/gnuradio-core/src/lib/general/gr_threshold_ff.h index 65b677a77..3bf3058cd 100644 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.h +++ b/gnuradio-core/src/lib/general/gr_threshold_ff.h @@ -23,20 +23,21 @@ #ifndef INCLUDED_GR_THRESHOLD_FF_H #define INCLUDED_GR_THRESHOLD_FF_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_threshold_ff; typedef boost::shared_ptr<gr_threshold_ff> gr_threshold_ff_sptr; -gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state=0); +GR_CORE_API gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state=0); /*! * \brief Please fix my documentation * \ingroup misc_blk */ -class gr_threshold_ff : public gr_sync_block +class GR_CORE_API gr_threshold_ff : public gr_sync_block { - friend gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state); + friend GR_CORE_API gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state); float d_lo,d_hi; // the constant float d_last_state; diff --git a/gnuradio-core/src/lib/general/gr_throttle.h b/gnuradio-core/src/lib/general/gr_throttle.h index a82821f77..0b6ada995 100644 --- a/gnuradio-core/src/lib/general/gr_throttle.h +++ b/gnuradio-core/src/lib/general/gr_throttle.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_THROTTLE_H #define INCLUDED_GR_THROTTLE_H +#include <gr_core_api.h> #include <gr_sync_block.h> /*! @@ -35,7 +36,7 @@ * controlling the rate of samples. That should be controlled by a * source or sink tied to sample clock. E.g., a USRP or audio card. */ -class gr_throttle : virtual public gr_sync_block +class GR_CORE_API gr_throttle : virtual public gr_sync_block { public: typedef boost::shared_ptr<gr_throttle> sptr; @@ -44,6 +45,6 @@ public: virtual void set_sample_rate(double rate) = 0; }; -gr_throttle::sptr gr_make_throttle(size_t itemsize, double samples_per_sec); +GR_CORE_API gr_throttle::sptr gr_make_throttle(size_t itemsize, double samples_per_sec); #endif /* INCLUDED_GR_THROTTLE_H */ diff --git a/gnuradio-core/src/lib/general/gr_transcendental.h b/gnuradio-core/src/lib/general/gr_transcendental.h index 1b237c44a..25c6eb75d 100644 --- a/gnuradio-core/src/lib/general/gr_transcendental.h +++ b/gnuradio-core/src/lib/general/gr_transcendental.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_TRANSCENDENTAL_H #define INCLUDED_GR_TRANSCENDENTAL_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <string> @@ -35,12 +36,12 @@ * * output[i] = trans_fcn(input[i]) */ -class gr_transcendental : virtual public gr_sync_block{ +class GR_CORE_API gr_transcendental : virtual public gr_sync_block{ public: typedef boost::shared_ptr<gr_transcendental> sptr; }; -gr_transcendental::sptr gr_make_transcendental( +GR_CORE_API gr_transcendental::sptr gr_make_transcendental( const std::string &name, const std::string &type = "float" ); diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.h b/gnuradio-core/src/lib/general/gr_uchar_to_float.h index 3b83c893f..8e8836c2c 100644 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.h +++ b/gnuradio-core/src/lib/general/gr_uchar_to_float.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_UCHAR_TO_FLOAT_H #define INCLUDED_GR_UCHAR_TO_FLOAT_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_uchar_to_float; typedef boost::shared_ptr<gr_uchar_to_float> gr_uchar_to_float_sptr; -gr_uchar_to_float_sptr +GR_CORE_API gr_uchar_to_float_sptr gr_make_uchar_to_float (); /*! @@ -36,9 +37,9 @@ gr_make_uchar_to_float (); * \ingroup converter_blk */ -class gr_uchar_to_float : public gr_sync_block +class GR_CORE_API gr_uchar_to_float : public gr_sync_block { - friend gr_uchar_to_float_sptr gr_make_uchar_to_float (); + friend GR_CORE_API gr_uchar_to_float_sptr gr_make_uchar_to_float (); gr_uchar_to_float (); public: diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h index e2be2c59c..056c69dc1 100644 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h +++ b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h @@ -23,11 +23,12 @@ #ifndef INCLUDED_GR_UNPACK_K_BITS_BB_H #define INCLUDED_GR_UNPACK_K_BITS_BB_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_unpack_k_bits_bb; typedef boost::shared_ptr<gr_unpack_k_bits_bb> gr_unpack_k_bits_bb_sptr; -gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); +GR_CORE_API gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); class gr_unpack_k_bits_bb; @@ -35,10 +36,10 @@ class gr_unpack_k_bits_bb; * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB. * \ingroup converter_blk */ -class gr_unpack_k_bits_bb : public gr_sync_interpolator +class GR_CORE_API gr_unpack_k_bits_bb : public gr_sync_interpolator { private: - friend gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); + friend GR_CORE_API gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k); gr_unpack_k_bits_bb (unsigned k); diff --git a/gnuradio-core/src/lib/general/gr_vco_f.h b/gnuradio-core/src/lib/general/gr_vco_f.h index 2bdf60899..b7524d581 100644 --- a/gnuradio-core/src/lib/general/gr_vco_f.h +++ b/gnuradio-core/src/lib/general/gr_vco_f.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_VCO_F_H #define INCLUDED_GR_VCO_F_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_fxpt_vco.h> @@ -37,7 +38,7 @@ class gr_vco_f; typedef boost::shared_ptr<gr_vco_f> gr_vco_f_sptr; -gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); +GR_CORE_API gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); /*! * \brief VCO - Voltage controlled oscillator @@ -45,9 +46,9 @@ gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amp * * input: float stream of control voltages; output: float oscillator output */ -class gr_vco_f : public gr_sync_block +class GR_CORE_API gr_vco_f : public gr_sync_block { - friend gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); + friend GR_CORE_API gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude); /*! * \brief VCO - Voltage controlled oscillator diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.h b/gnuradio-core/src/lib/general/gr_vector_to_stream.h index de6cc2a8b..d2fa8c7ab 100644 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.h +++ b/gnuradio-core/src/lib/general/gr_vector_to_stream.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_VECTOR_TO_STREAM_H #define INCLUDED_GR_VECTOR_TO_STREAM_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_vector_to_stream; typedef boost::shared_ptr<gr_vector_to_stream> gr_vector_to_stream_sptr; -gr_vector_to_stream_sptr +GR_CORE_API gr_vector_to_stream_sptr gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); @@ -36,9 +37,9 @@ gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); * \brief convert a stream of blocks of nitems_per_block items into a stream of items * \ingroup slicedice_blk */ -class gr_vector_to_stream : public gr_sync_interpolator +class GR_CORE_API gr_vector_to_stream : public gr_sync_interpolator { - friend gr_vector_to_stream_sptr + friend GR_CORE_API gr_vector_to_stream_sptr gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); protected: diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.h b/gnuradio-core/src/lib/general/gr_vector_to_streams.h index d5ba7acf9..04ac941a1 100644 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.h +++ b/gnuradio-core/src/lib/general/gr_vector_to_streams.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_VECTOR_TO_STREAMS_H #define INCLUDED_GR_VECTOR_TO_STREAMS_H +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class gr_vector_to_streams; typedef boost::shared_ptr<gr_vector_to_streams> gr_vector_to_streams_sptr; -gr_vector_to_streams_sptr +GR_CORE_API gr_vector_to_streams_sptr gr_make_vector_to_streams (size_t item_size, size_t nstreams); @@ -36,9 +37,9 @@ gr_make_vector_to_streams (size_t item_size, size_t nstreams); * \brief Convert 1 stream of vectors of length N to N streams of items * \ingroup slicedice_blk */ -class gr_vector_to_streams : public gr_sync_block +class GR_CORE_API gr_vector_to_streams : public gr_sync_block { - friend gr_vector_to_streams_sptr + friend GR_CORE_API gr_vector_to_streams_sptr gr_make_vector_to_streams (size_t item_size, size_t nstreams); protected: diff --git a/gnuradio-core/src/lib/general/gr_wavelet_ff.h b/gnuradio-core/src/lib/general/gr_wavelet_ff.h index dcfb595e5..107a50fe2 100644 --- a/gnuradio-core/src/lib/general/gr_wavelet_ff.h +++ b/gnuradio-core/src/lib/general/gr_wavelet_ff.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_WAVELET_FF_H #define INCLUDED_GR_WAVELET_FF_H +#include <gr_core_api.h> #include <iostream> #include <gr_sync_block.h> @@ -31,7 +32,7 @@ class gr_wavelet_ff; typedef boost::shared_ptr<gr_wavelet_ff> gr_wavelet_ff_sptr; -gr_wavelet_ff_sptr +GR_CORE_API gr_wavelet_ff_sptr gr_make_wavelet_ff(int size = 1024, int order = 20, bool forward = true); @@ -41,7 +42,7 @@ gr_make_wavelet_ff(int size = 1024, * \ingroup wavelet_blk */ -class gr_wavelet_ff : public gr_sync_block +class GR_CORE_API gr_wavelet_ff : public gr_sync_block { int d_size; int d_order; @@ -50,7 +51,7 @@ class gr_wavelet_ff : public gr_sync_block gsl_wavelet_workspace *d_workspace; double *d_temp; - friend gr_wavelet_ff_sptr + friend GR_CORE_API gr_wavelet_ff_sptr gr_make_wavelet_ff(int size, int order, bool forward); diff --git a/gnuradio-core/src/lib/general/gr_wvps_ff.h b/gnuradio-core/src/lib/general/gr_wvps_ff.h index af122d0fc..7c8f26066 100644 --- a/gnuradio-core/src/lib/general/gr_wvps_ff.h +++ b/gnuradio-core/src/lib/general/gr_wvps_ff.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_WVPS_FF_H #define INCLUDED_GR_WVPS_FF_H +#include <gr_core_api.h> #include <gr_sync_decimator.h> class gr_wvps_ff; typedef boost::shared_ptr<gr_wvps_ff> gr_wvps_ff_sptr; -gr_wvps_ff_sptr +GR_CORE_API gr_wvps_ff_sptr gr_make_wvps_ff(int ilen); @@ -36,9 +37,9 @@ gr_make_wvps_ff(int ilen); * \brief computes the Wavelet Power Spectrum from a set of wavelet coefficients * \ingroup wavelet_blk */ -class gr_wvps_ff : public gr_sync_block +class GR_CORE_API gr_wvps_ff : public gr_sync_block { - friend gr_wvps_ff_sptr + friend GR_CORE_API gr_wvps_ff_sptr gr_make_wvps_ff(int ilen); int d_ilen; diff --git a/gnuradio-core/src/lib/general/gri_agc2_cc.h b/gnuradio-core/src/lib/general/gri_agc2_cc.h index 441d1e459..b0a027aad 100644 --- a/gnuradio-core/src/lib/general/gri_agc2_cc.h +++ b/gnuradio-core/src/lib/general/gri_agc2_cc.h @@ -23,6 +23,7 @@ #ifndef _GRI_AGC2_CC_H_ #define _GRI_AGC2_CC_H_ +#include <gr_core_api.h> #include <math.h> /*! @@ -30,7 +31,7 @@ * * For Power the absolute value of the complex number is used. */ -class gri_agc2_cc { +class GR_CORE_API gri_agc2_cc { public: gri_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, diff --git a/gnuradio-core/src/lib/general/gri_agc2_ff.h b/gnuradio-core/src/lib/general/gri_agc2_ff.h index a06dab78c..ee70c2537 100644 --- a/gnuradio-core/src/lib/general/gri_agc2_ff.h +++ b/gnuradio-core/src/lib/general/gri_agc2_ff.h @@ -23,6 +23,7 @@ #ifndef _GRI_AGC2_FF_H_ #define _GRI_AGC2_FF_H_ +#include <gr_core_api.h> #include <math.h> /*! @@ -31,7 +32,7 @@ * Power is approximated by absolute value */ -class gri_agc2_ff { +class GR_CORE_API gri_agc2_ff { public: gri_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, diff --git a/gnuradio-core/src/lib/general/gri_agc_cc.h b/gnuradio-core/src/lib/general/gri_agc_cc.h index bc31d9a3d..74dfdf1dc 100644 --- a/gnuradio-core/src/lib/general/gri_agc_cc.h +++ b/gnuradio-core/src/lib/general/gri_agc_cc.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_AGC_CC_H #define INCLUDED_GRI_AGC_CC_H +#include <gr_core_api.h> #include <math.h> /*! @@ -31,7 +32,7 @@ * For Power the absolute value of the complex number is used. */ -class gri_agc_cc { +class GR_CORE_API gri_agc_cc { public: gri_agc_cc (float rate = 1e-4, float reference = 1.0, diff --git a/gnuradio-core/src/lib/general/gri_agc_ff.h b/gnuradio-core/src/lib/general/gri_agc_ff.h index de609a8d4..753bbe275 100644 --- a/gnuradio-core/src/lib/general/gri_agc_ff.h +++ b/gnuradio-core/src/lib/general/gri_agc_ff.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_AGC_FF_H #define INCLUDED_GRI_AGC_FF_H +#include <gr_core_api.h> #include <math.h> /*! @@ -30,7 +31,7 @@ * * Power is approximated by absolute value */ -class gri_agc_ff { +class GR_CORE_API gri_agc_ff { public: gri_agc_ff (float rate = 1e-4, float reference = 1.0, diff --git a/gnuradio-core/src/lib/general/gri_char_to_float.h b/gnuradio-core/src/lib/general/gri_char_to_float.h index f4703bef7..890d482b5 100644 --- a/gnuradio-core/src/lib/general/gri_char_to_float.h +++ b/gnuradio-core/src/lib/general/gri_char_to_float.h @@ -23,10 +23,12 @@ #ifndef INCLUDED_GRI_CHAR_TO_FLOAT_H #define INCLUDED_GRI_CHAR_TO_FLOAT_H +#include <gr_core_api.h> + /* * convert array of chars to floats */ -void gri_char_to_float (const char *in, float *out, int nsamples); +GR_CORE_API void gri_char_to_float (const char *in, float *out, int nsamples); -#endif /* INCLUDED_GRI_CHAR_TO_FLOAT_H */ +#endif /* INCLUDED_GRI_CHAR_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_control_loop.cc b/gnuradio-core/src/lib/general/gri_control_loop.cc new file mode 100644 index 000000000..4c64bb922 --- /dev/null +++ b/gnuradio-core/src/lib/general/gri_control_loop.cc @@ -0,0 +1,187 @@ +/* -*- c++ -*- */ +/* + * Copyright 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 <gri_control_loop.h> +#include <gr_math.h> +#include <stdexcept> + +#define M_TWOPI (2.0f*M_PI) + +gri_control_loop::gri_control_loop(float loop_bw, + float max_freq, float min_freq) + : d_phase(0), d_freq(0), d_max_freq(max_freq), d_min_freq(min_freq) +{ + // Set the damping factor for a critically damped system + d_damping = sqrtf(2.0f)/2.0f; + + // Set the bandwidth, which will then call update_gains() + set_loop_bandwidth(loop_bw); +} + +gri_control_loop::~gri_control_loop() +{ +} + +void +gri_control_loop::update_gains() +{ + float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); + d_alpha = (4*d_damping*d_loop_bw) / denom; + d_beta = (4*d_loop_bw*d_loop_bw) / denom; +} + +void +gri_control_loop::advance_loop(float error) +{ + d_freq = d_freq + d_beta * error; + d_phase = d_phase + d_freq + d_alpha * error; +} + + +void +gri_control_loop::phase_wrap() +{ + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; +} + +void +gri_control_loop::frequency_limit() +{ + if (d_freq > d_max_freq) + d_freq = d_max_freq; + else if (d_freq < d_min_freq) + d_freq = d_min_freq; +} + +/******************************************************************* + SET FUNCTIONS +*******************************************************************/ + +void +gri_control_loop::set_loop_bandwidth(float bw) +{ + if(bw < 0) { + throw std::out_of_range ("gri_control_loop: invalid bandwidth. Must be >= 0."); + } + + d_loop_bw = bw; + update_gains(); +} + +void +gri_control_loop::set_damping_factor(float df) +{ + if(df < 0 || df > 1.0) { + throw std::out_of_range ("gri_control_loop: invalid damping factor. Must be in [0,1]."); + } + + d_damping = df; + update_gains(); +} + +void +gri_control_loop::set_alpha(float alpha) +{ + if(alpha < 0 || alpha > 1.0) { + throw std::out_of_range ("gri_control_loop: invalid alpha. Must be in [0,1]."); + } + d_alpha = alpha; +} + +void +gri_control_loop::set_beta(float beta) +{ + if(beta < 0 || beta > 1.0) { + throw std::out_of_range ("gri_control_loop: invalid beta. Must be in [0,1]."); + } + d_beta = beta; +} + +void +gri_control_loop::set_frequency(float freq) +{ + if(freq > d_max_freq) + d_freq = d_min_freq; + else if(freq < d_min_freq) + d_freq = d_max_freq; + else + d_freq = freq; +} + +void +gri_control_loop::set_phase(float phase) +{ + d_phase = phase; + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; +} + + +/******************************************************************* + GET FUNCTIONS +*******************************************************************/ + + +float +gri_control_loop::get_loop_bandwidth() const +{ + return d_loop_bw; +} + +float +gri_control_loop::get_damping_factor() const +{ + return d_damping; +} + +float +gri_control_loop::get_alpha() const +{ + return d_alpha; +} + +float +gri_control_loop::get_beta() const +{ + return d_beta; +} + +float +gri_control_loop::get_frequency() const +{ + return d_freq; +} + +float +gri_control_loop::get_phase() const +{ + return d_phase; +} diff --git a/gnuradio-core/src/lib/general/gri_control_loop.h b/gnuradio-core/src/lib/general/gri_control_loop.h new file mode 100644 index 000000000..3aeac58f7 --- /dev/null +++ b/gnuradio-core/src/lib/general/gri_control_loop.h @@ -0,0 +1,203 @@ +/* -*- c++ -*- */ +/* + * Copyright 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 GRI_CONTROL_LOOP +#define GRI_CONTROL_LOOP + +#include <gr_core_api.h> + +class GR_CORE_API gri_control_loop +{ + protected: + float d_phase, d_freq; + float d_max_freq, d_min_freq; + float d_damping, d_loop_bw; + float d_alpha, d_beta; + + public: + gri_control_loop(float loop_bw, float max_freq, float min_freq); + virtual ~gri_control_loop(); + + /*! \brief update the system gains from the loop bandwidth and damping factor + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. + * These two factors can be set separately through their own + * set functions. + */ + void update_gains(); + + /*! \brief update the system gains from the loop bandwidth and damping factor + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. + * These two factors can be set separately through their own + * set functions. + */ + void advance_loop(float error); + + /*! \brief Keep the phase between -2pi and 2pi + * + * This function keeps the phase between -2pi and 2pi. If the phase + * is greater than 2pi by d, it wraps around to be -2pi+d; similarly if + * it is less than -2pi by d, it wraps around to 2pi-d. + * + * This function should be called after advance_loop to keep the phase + * in a good operating region. It is set as a separate method in case + * another way is desired as this is fairly heavy-handed. + */ + void phase_wrap(); + + /*! \brief Keep the frequency between d_min_freq and d_max_freq + * + * This function keeps the frequency between d_min_freq and d_max_freq. + * If the frequency is greater than d_max_freq, it is set to d_max_freq. + * If the frequency is less than d_min_freq, it is set to d_min_freq. + * + * This function should be called after advance_loop to keep the frequency + * in the specified region. It is set as a separate method in case + * another way is desired as this is fairly heavy-handed. + */ + void frequency_limit(); + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Set the loop bandwidth + * + * Set the loop filter's bandwidth to \p bw. This should be between + * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive + * number. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param bw (float) new bandwidth + * + */ + void set_loop_bandwidth(float bw); + + /*! + * \brief Set the loop damping factor + * + * Set the loop filter's damping factor to \p df. The damping factor + * should be sqrt(2)/2.0 for critically damped systems. + * Set it to anything else only if you know what you are doing. It must + * be a number between 0 and 1. + * + * When a new damping factor is set, the gains, alpha and beta, of the loop + * are recalculated by a call to update_gains(). + * + * \param df (float) new damping factor + * + */ + void set_damping_factor(float df); + + /*! + * \brief Set the loop gain alpha + * + * Set's the loop filter's alpha gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param alpha (float) new alpha gain + * + */ + void set_alpha(float alpha); + + /*! + * \brief Set the loop gain beta + * + * Set's the loop filter's beta gain parameter. + * + * This value should really only be set by adjusting the loop bandwidth + * and damping factor. + * + * \param beta (float) new beta gain + * + */ + void set_beta(float beta); + + /*! + * \brief Set the Costas loop's frequency. + * + * Set's the Costas Loop's frequency. While this is normally updated by the + * inner loop of the algorithm, it could be useful to manually initialize, + * set, or reset this under certain circumstances. + * + * \param freq (float) new frequency + * + */ + void set_frequency(float freq); + + /*! + * \brief Set the Costas loop's phase. + * + * Set's the Costas Loop's phase. While this is normally updated by the + * inner loop of the algorithm, it could be useful to manually initialize, + * set, or reset this under certain circumstances. + * + * \param phase (float) new phase + * + */ + void set_phase(float phase); + + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the loop bandwidth + */ + float get_loop_bandwidth() const; + + /*! + * \brief Returns the loop damping factor + */ + float get_damping_factor() const; + + /*! + * \brief Returns the loop gain alpha + */ + float get_alpha() const; + + /*! + * \brief Returns the loop gain beta + */ + float get_beta() const; + + /*! + * \brief Get the Costas loop's frequency estimate + */ + float get_frequency() const; + + /*! + * \brief Get the Costas loop's phase estimate + */ + float get_phase() const; +}; + +#endif /* GRI_CONTROL_LOOP */ diff --git a/gnuradio-core/src/lib/general/gri_control_loop.i b/gnuradio-core/src/lib/general/gri_control_loop.i new file mode 100644 index 000000000..67f8838cb --- /dev/null +++ b/gnuradio-core/src/lib/general/gri_control_loop.i @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 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. + */ + + +class gri_control_loop +{ + public: + gri_control_loop(float loop_bw, float max_freq, float min_freq); + virtual ~gri_control_loop(); + + void update_gains(); + void advance_loop(float error); + void phase_wrap(); + void frequency_limit(); + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + void set_loop_bandwidth(float bw); + void set_damping_factor(float df); + void set_alpha(float alpha); + void set_beta(float beta); + void set_frequency(float freq); + void set_phase(float phase); + + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + float get_loop_bandwidth() const; + float get_damping_factor() const; + float get_alpha() const; + float get_beta() const; + float get_frequency() const; + float get_phase() const; +}; diff --git a/gnuradio-core/src/lib/general/gri_debugger_hook.h b/gnuradio-core/src/lib/general/gri_debugger_hook.h index 60c90685e..cf227af8f 100644 --- a/gnuradio-core/src/lib/general/gri_debugger_hook.h +++ b/gnuradio-core/src/lib/general/gri_debugger_hook.h @@ -23,6 +23,8 @@ #ifndef INCLUDED_GRI_DEBUGGER_HOOK_H #define INCLUDED_GRI_DEBUGGER_HOOK_H -void gri_debugger_hook (); +#include <gr_core_api.h> -#endif /* INCLUDED_GRI_DEBUGGER_HOOK_H */ +GR_CORE_API void gri_debugger_hook (); + +#endif /* INCLUDED_GRI_DEBUGGER_HOOK_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc index f20b15ca0..0df1af25d 100644 --- a/gnuradio-core/src/lib/general/gri_fft.cc +++ b/gnuradio-core/src/lib/general/gri_fft.cc @@ -23,6 +23,19 @@ #include <gri_fft.h> #include <gr_sys_paths.h> #include <fftw3.h> + +#ifdef _MSC_VER //http://www.fftw.org/install/windows.html#DLLwisdom +static void my_fftw_write_char(char c, void *f) { fputc(c, (FILE *) f); } +#define fftw_export_wisdom_to_file(f) fftw_export_wisdom(my_fftw_write_char, (void*) (f)) +#define fftwf_export_wisdom_to_file(f) fftwf_export_wisdom(my_fftw_write_char, (void*) (f)) +#define fftwl_export_wisdom_to_file(f) fftwl_export_wisdom(my_fftw_write_char, (void*) (f)) + +static int my_fftw_read_char(void *f) { return fgetc((FILE *) f); } +#define fftw_import_wisdom_from_file(f) fftw_import_wisdom(my_fftw_read_char, (void*) (f)) +#define fftwf_import_wisdom_from_file(f) fftwf_import_wisdom(my_fftw_read_char, (void*) (f)) +#define fftwl_import_wisdom_from_file(f) fftwl_import_wisdom(my_fftw_read_char, (void*) (f)) +#endif //_MSC_VER + #include <gr_complex.h> #include <stdlib.h> #include <string.h> diff --git a/gnuradio-core/src/lib/general/gri_fft.h b/gnuradio-core/src/lib/general/gri_fft.h index 9ffcc5a50..91a82fb55 100644 --- a/gnuradio-core/src/lib/general/gri_fft.h +++ b/gnuradio-core/src/lib/general/gri_fft.h @@ -26,6 +26,7 @@ * Wrappers for FFTW single precision 1d dft */ +#include <gr_core_api.h> #include <gr_complex.h> #include <boost/thread.hpp> @@ -33,7 +34,7 @@ * \brief Export reference to planner mutex for those apps that * want to use FFTW w/o using the gri_fftw* classes. */ -class gri_fft_planner { +class GR_CORE_API gri_fft_planner { public: typedef boost::mutex::scoped_lock scoped_lock; /*! @@ -46,7 +47,7 @@ public: * \brief FFT: complex in, complex out * \ingroup misc */ -class gri_fft_complex { +class GR_CORE_API gri_fft_complex { int d_fft_size; gr_complex *d_inbuf; gr_complex *d_outbuf; @@ -77,7 +78,7 @@ public: * \brief FFT: real in, complex out * \ingroup misc */ -class gri_fft_real_fwd { +class GR_CORE_API gri_fft_real_fwd { int d_fft_size; float *d_inbuf; gr_complex *d_outbuf; @@ -108,7 +109,7 @@ public: * \brief FFT: complex in, float out * \ingroup misc */ -class gri_fft_real_rev { +class GR_CORE_API gri_fft_real_rev { int d_fft_size; gr_complex *d_inbuf; float *d_outbuf; diff --git a/gnuradio-core/src/lib/general/gri_float_to_char.h b/gnuradio-core/src/lib/general/gri_float_to_char.h index 95cc8ea8d..184592a69 100644 --- a/gnuradio-core/src/lib/general/gri_float_to_char.h +++ b/gnuradio-core/src/lib/general/gri_float_to_char.h @@ -23,10 +23,11 @@ #ifndef INCLUDED_GRI_FLOAT_TO_CHAR_H #define INCLUDED_GRI_FLOAT_TO_CHAR_H +#include <gr_core_api.h> + /*! * convert array of floats to chars with rounding and saturation. */ -void gri_float_to_char (const float *in, char *out, int nsamples); +GR_CORE_API void gri_float_to_char (const float *in, char *out, int nsamples); #endif /* INCLUDED_GRI_FLOAT_TO_CHAR_H */ - diff --git a/gnuradio-core/src/lib/general/gri_float_to_short.h b/gnuradio-core/src/lib/general/gri_float_to_short.h index e36e25de6..6d814b2b3 100644 --- a/gnuradio-core/src/lib/general/gri_float_to_short.h +++ b/gnuradio-core/src/lib/general/gri_float_to_short.h @@ -23,10 +23,11 @@ #ifndef INCLUDED_GRI_FLOAT_TO_SHORT_H #define INCLUDED_GRI_FLOAT_TO_SHORT_H +#include <gr_core_api.h> + /*! * convert array of floats to shorts with rounding and saturation. */ -void gri_float_to_short (const float *in, short *out, int nsamples); +GR_CORE_API void gri_float_to_short (const float *in, short *out, int nsamples); #endif /* INCLUDED_GRI_FLOAT_TO_SHORT_H */ - diff --git a/gnuradio-core/src/lib/general/gri_float_to_uchar.h b/gnuradio-core/src/lib/general/gri_float_to_uchar.h index e413e725f..ff549333e 100644 --- a/gnuradio-core/src/lib/general/gri_float_to_uchar.h +++ b/gnuradio-core/src/lib/general/gri_float_to_uchar.h @@ -23,10 +23,11 @@ #ifndef INCLUDED_GRI_FLOAT_TO_UCHAR_H #define INCLUDED_GRI_FLOAT_TO_UCHAR_H +#include <gr_core_api.h> + /*! * convert array of floats to unsigned chars with rounding and saturation. */ -void gri_float_to_uchar (const float *in, unsigned char *out, int nsamples); +GR_CORE_API void gri_float_to_uchar (const float *in, unsigned char *out, int nsamples); #endif /* INCLUDED_GRI_FLOAT_TO_UCHAR_H */ - diff --git a/gnuradio-core/src/lib/general/gri_glfsr.h b/gnuradio-core/src/lib/general/gri_glfsr.h index 7dd5f8660..e6d28cf45 100644 --- a/gnuradio-core/src/lib/general/gri_glfsr.h +++ b/gnuradio-core/src/lib/general/gri_glfsr.h @@ -23,6 +23,8 @@ #ifndef INCLUDED_GRI_GLFSR_H #define INCLUDED_GRI_GLFSR_H +#include <gr_core_api.h> + /*! * \brief Galois Linear Feedback Shift Register using specified polynomial mask * \ingroup misc @@ -30,7 +32,7 @@ * Generates a maximal length pseudo-random sequence of length 2^degree-1 */ -class gri_glfsr +class GR_CORE_API gri_glfsr { private: int d_shift_register; @@ -52,4 +54,4 @@ class gri_glfsr int mask() const { return d_mask; } }; -#endif /* INCLUDED_GRI_GLFSR_H */ +#endif /* INCLUDED_GRI_GLFSR_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h b/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h index 09d915f7a..107e2f778 100644 --- a/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h +++ b/gnuradio-core/src/lib/general/gri_interleaved_short_to_complex.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H #define INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H +#include <gr_core_api.h> #include <gr_complex.h> /* @@ -30,7 +31,7 @@ * the shorts contains real, imaginary, real, imaginary... * nsamples is the number of shorts; it must be even. */ -void gri_interleaved_short_to_complex (const short *in, gr_complex *out, int nsamples); +GR_CORE_API void gri_interleaved_short_to_complex (const short *in, gr_complex *out, int nsamples); #endif /* INCLUDED_GRI_INTERLEAVED_SHORT_TO_COMPLEX_H */ diff --git a/gnuradio-core/src/lib/general/gri_lfsr.h b/gnuradio-core/src/lib/general/gri_lfsr.h index f691e36ec..dc9358572 100644 --- a/gnuradio-core/src/lib/general/gri_lfsr.h +++ b/gnuradio-core/src/lib/general/gri_lfsr.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_LFSR_H #define INCLUDED_GRI_LFSR_H +#include <gr_core_api.h> #include <stdexcept> #include <stdint.h> @@ -81,7 +82,7 @@ * */ -class gri_lfsr +class GR_CORE_API gri_lfsr { private: uint32_t d_shift_register; diff --git a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h b/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h index 798f2faad..7405ffbaa 100644 --- a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h +++ b/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h @@ -23,6 +23,8 @@ #ifndef INCLUDED_GRI_LFSR_15_1_0_H #define INCLUDED_GRI_LFSR_15_1_0_H +#include <gr_core_api.h> + /*! * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1 * \ingroup misc @@ -30,7 +32,7 @@ * Generates a maximal length pseudo-random sequence of length 2^15 - 1 bits. */ -class gri_lfsr_15_1_0 { +class GR_CORE_API gri_lfsr_15_1_0 { unsigned long d_sr; // shift register public: @@ -55,4 +57,4 @@ class gri_lfsr_15_1_0 { } }; -#endif /* INCLUDED_GRI_LFSR_15_1_0_H */ +#endif /* INCLUDED_GRI_LFSR_15_1_0_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_lfsr_32k.h b/gnuradio-core/src/lib/general/gri_lfsr_32k.h index 33e7ae3a1..5c0396b50 100644 --- a/gnuradio-core/src/lib/general/gri_lfsr_32k.h +++ b/gnuradio-core/src/lib/general/gri_lfsr_32k.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GRI_LFSR_32k_H #define INCLUDED_GRI_LFSR_32k_H +#include <gr_core_api.h> #include <gri_lfsr_15_1_0.h> /*! @@ -33,7 +34,7 @@ * of the sequence. */ -class gri_lfsr_32k { +class GR_CORE_API gri_lfsr_32k { gri_lfsr_15_1_0 d_lfsr; unsigned int d_count; diff --git a/gnuradio-core/src/lib/general/gri_short_to_float.h b/gnuradio-core/src/lib/general/gri_short_to_float.h index ce4193062..51767efab 100644 --- a/gnuradio-core/src/lib/general/gri_short_to_float.h +++ b/gnuradio-core/src/lib/general/gri_short_to_float.h @@ -23,10 +23,12 @@ #ifndef INCLUDED_GRI_SHORT_TO_FLOAT_H #define INCLUDED_GRI_SHORT_TO_FLOAT_H +#include <gr_core_api.h> + /* * convert array of shorts to floats */ -void gri_short_to_float (const short *in, float *out, int nsamples); +GR_CORE_API void gri_short_to_float (const short *in, float *out, int nsamples); -#endif /* INCLUDED_GRI_SHORT_TO_FLOAT_H */ +#endif /* INCLUDED_GRI_SHORT_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/gri_uchar_to_float.h b/gnuradio-core/src/lib/general/gri_uchar_to_float.h index 7a9f11ba6..9f342989d 100644 --- a/gnuradio-core/src/lib/general/gri_uchar_to_float.h +++ b/gnuradio-core/src/lib/general/gri_uchar_to_float.h @@ -23,10 +23,12 @@ #ifndef INCLUDED_GRI_UCHAR_TO_FLOAT_H #define INCLUDED_GRI_UCHAR_TO_FLOAT_H +#include <gr_core_api.h> + /* * convert array of unsigned chars to floats */ -void gri_uchar_to_float (const unsigned char *in, float *out, int nsamples); +GR_CORE_API void gri_uchar_to_float (const unsigned char *in, float *out, int nsamples); -#endif /* INCLUDED_GRI_UCHAR_TO_FLOAT_H */ +#endif /* INCLUDED_GRI_UCHAR_TO_FLOAT_H */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/general/malloc16.c b/gnuradio-core/src/lib/general/malloc16.c index 331751499..2cc6135e7 100644 --- a/gnuradio-core/src/lib/general/malloc16.c +++ b/gnuradio-core/src/lib/general/malloc16.c @@ -7,7 +7,6 @@ #include "malloc16.h" #include <string.h> -#include <strings.h> void *malloc16Align(int size){ void *p; diff --git a/gnuradio-core/src/lib/general/malloc16.h b/gnuradio-core/src/lib/general/malloc16.h index fc97f267d..6b1a3fb08 100644 --- a/gnuradio-core/src/lib/general/malloc16.h +++ b/gnuradio-core/src/lib/general/malloc16.h @@ -20,15 +20,17 @@ * Boston, MA 02110-1301, USA. */ +#include <gr_core_api.h> + #ifdef __cplusplus extern "C" { #endif #include <stdlib.h> -void *malloc16Align(int size); -void *calloc16Align(size_t nmemb,size_t size); -void free16Align(void *p); +GR_CORE_API void *malloc16Align(int size); +GR_CORE_API void *calloc16Align(size_t nmemb,size_t size); +GR_CORE_API void free16Align(void *p); #ifdef __cplusplus } diff --git a/gnuradio-core/src/lib/general/qa_general.cc b/gnuradio-core/src/lib/general/qa_general.cc index 6984d798c..b9080f362 100644 --- a/gnuradio-core/src/lib/general/qa_general.cc +++ b/gnuradio-core/src/lib/general/qa_general.cc @@ -28,6 +28,7 @@ #include <qa_general.h> #include <qa_gr_firdes.h> #include <qa_gr_circular_file.h> +#include <qa_gr_cpm.h> #include <qa_gr_fxpt.h> #include <qa_gr_fxpt_nco.h> #include <qa_gr_fxpt_vco.h> @@ -41,6 +42,7 @@ qa_general::suite () s->addTest (qa_gr_firdes::suite ()); s->addTest (qa_gr_circular_file::suite ()); + s->addTest (qa_gr_cpm::suite ()); s->addTest (qa_gr_fxpt::suite ()); s->addTest (qa_gr_fxpt_nco::suite ()); s->addTest (qa_gr_fxpt_vco::suite ()); diff --git a/gnuradio-core/src/lib/general/qa_general.h b/gnuradio-core/src/lib/general/qa_general.h index 577c9d7fb..7da188266 100644 --- a/gnuradio-core/src/lib/general/qa_general.h +++ b/gnuradio-core/src/lib/general/qa_general.h @@ -23,11 +23,12 @@ #ifndef _QA_GENERAL_H_ #define _QA_GENERAL_H_ +#include <gruel/attributes.h> #include <cppunit/TestSuite.h> //! collect all the tests for the gr directory -class qa_general { +class __GR_ATTR_EXPORT qa_general { public: //! return suite of tests for all of gr directory static CppUnit::TestSuite *suite (); diff --git a/gnuradio-core/src/lib/general/qa_gr_cpm.cc b/gnuradio-core/src/lib/general/qa_gr_cpm.cc new file mode 100644 index 000000000..cc32d1117 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_cpm.cc @@ -0,0 +1,140 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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. + */ + +#include <qa_gr_cpm.h> +#include <gr_cpm.h> +#include <cppunit/TestAssert.h> + +const double DELTA = 1e-5; +const int L = 5; +const int samples_per_sym = 4; +const float taps_lrc[20] = { + 0, 0.002447174185242, 0.009549150281253, 0.020610737385376, + 0.034549150281253, 0.050000000000000, 0.065450849718747, 0.079389262614624, + 0.090450849718747, 0.097552825814758, 0.100000000000000, 0.097552825814758, + 0.090450849718747, 0.079389262614624, 0.065450849718747, 0.050000000000000, + 0.034549150281253, 0.020610737385376, 0.009549150281253, 0.002447174185242 +}; + + +const float taps_lsrc[20] = { // beta = 0.2 + 0.000000000000000, 0.009062686687436, 0.019517618142920, 0.030875041875917, + 0.042552315421249, 0.053912556756416, 0.064308860403517, 0.073130584159352, + 0.079847961304114, 0.084051371489937, 0.085482007518284, 0.084051371489937, + 0.079847961304114, 0.073130584159352, 0.064308860403517, 0.053912556756416, + 0.042552315421249, 0.030875041875917, 0.019517618142920, 0.009062686687436 +}; + + +const float taps_tfm[20] = { + -0.003946522220317, -0.005147757690530, -0.003171631690177, 0.003959659609805, + 0.017498721302356, 0.037346982678383, 0.062251889790391, 0.087364237065604, + 0.110049050955117, 0.125677762224511, 0.132288693729399, 0.125677762224511, + 0.110049050955117, 0.087364237065604, 0.062251889790391, 0.037346982678383, + 0.017498721302356, 0.003959659609805, -0.003171631690177, -0.005147757690530 +}; + + +const float taps_gaussian[20] = { // BT = 0.3 + 0.000000743866524, 0.000009286258371, 0.000085441834550, 0.000581664421923, + 0.002945540765422, 0.011178079812344, 0.032117220937421, 0.070841188736816, + 0.122053715366673, 0.167389736919915, 0.185594670675172, 0.167389736919915, + 0.122053715366673, 0.070841188736816, 0.032117220937421, 0.011178079812344, + 0.002945540765422, 0.000581664421923, 0.000085441834550, 0.000009286258371 +}; + + +// Check LREC phase response +void +qa_gr_cpm::t1 () +{ + std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LREC, samples_per_sym, L)); + + for (int i = 0; i < L * samples_per_sym; i++) { + CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], 0.05, DELTA); + } +} + + +// Check LRC phase response +void +qa_gr_cpm::t2 () +{ + std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LRC, samples_per_sym, L)); + float sum = 0; + + for (int i = 0; i < L * samples_per_sym; i++) { + CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_lrc[i], DELTA); + sum += taps[i]; + } + + CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); +} + + +// Check LSRC phase response +void +qa_gr_cpm::t3 () +{ + std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LSRC, samples_per_sym, L, 0.2)); + float sum = 0; + + for (int i = 0; i < L * samples_per_sym; i++) { + CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_lsrc[i], DELTA); + sum += taps[i]; + } + + CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); +} + + +// Check the TFM phase response +void +qa_gr_cpm::t4 () +{ + std::vector<float> taps(gr_cpm::phase_response(gr_cpm::TFM, samples_per_sym, L)); + float sum = 0; + + for (int i = 0; i < L * samples_per_sym; i++) { + CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_tfm[i], DELTA); + sum += taps[i]; + } + + CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); +} + + +// Check the Gaussian phase response +void +qa_gr_cpm::t5 () +{ + std::vector<float> taps(gr_cpm::phase_response(gr_cpm::GAUSSIAN, samples_per_sym, L, 0.3)); + float sum = 0; + + for (int i = 0; i < L * samples_per_sym; i++) { + CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_gaussian[i], DELTA); + sum += taps[i]; + } + + CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA); +} + diff --git a/gnuradio-core/src/lib/runtime/gr_tag_info.cc b/gnuradio-core/src/lib/general/qa_gr_cpm.h index f15329f9b..741cb2860 100644 --- a/gnuradio-core/src/lib/runtime/gr_tag_info.cc +++ b/gnuradio-core/src/lib/general/qa_gr_cpm.h @@ -19,20 +19,31 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +#ifndef _QA_GR_CPM_H +#define _QA_GR_CPM_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> -#include <gr_tag_info.h> -#include <gruel/pmt.h> +class qa_gr_cpm : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gr_cpm); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST (t4); + CPPUNIT_TEST (t5); + CPPUNIT_TEST_SUITE_END (); + + private: + void t1 (); + void t2 (); + void t3 (); + void t4 (); + void t5 (); + +}; + + +#endif /* _QA_GR_CPM_H */ -namespace gr_tags { -/* - const pmt::pmt_t key_time = pmt::pmt_string_to_symbol("time"); - const pmt::pmt_t key_sample_rate = pmt::pmt_string_to_symbol("sample_rate"); - const pmt::pmt_t key_frequency = pmt::pmt_string_to_symbol("frequency"); - const pmt::pmt_t key_rssi = pmt::pmt_string_to_symbol("rssi"); - const pmt::pmt_t key_rx_gain = pmt::pmt_string_to_symbol("gain"); -*/ -} diff --git a/gnuradio-core/src/lib/general/qa_gri_lfsr.cc b/gnuradio-core/src/lib/general/qa_gri_lfsr.cc index 9f8b62dcf..9625071d8 100644 --- a/gnuradio-core/src/lib/general/qa_gri_lfsr.cc +++ b/gnuradio-core/src/lib/general/qa_gri_lfsr.cc @@ -24,6 +24,7 @@ #include <cppunit/TestAssert.h> #include <stdio.h> #include <string.h> +#include <vector> void qa_gri_lfsr::test_lfsr () @@ -90,12 +91,12 @@ qa_gri_lfsr::test_scrambler() 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, }; int len = sizeof(src); - unsigned char actual[len]; + std::vector<unsigned char> actual(len); for (int i = 0; i < len; i++) actual[i] = scrambler.next_bit_scramble(src[i]); - CPPUNIT_ASSERT(memcmp(expected, actual, len) == 0); + CPPUNIT_ASSERT(memcmp(expected, &actual[0], len) == 0); } void @@ -132,10 +133,10 @@ qa_gri_lfsr::test_descrambler() 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int len = sizeof(src); - unsigned char actual[len]; + std::vector<unsigned char> actual(len); for (int i = 0; i < len; i++) actual[i] = descrambler.next_bit_descramble(src[i]); - CPPUNIT_ASSERT(memcmp(expected, actual, len) == 0); + CPPUNIT_ASSERT(memcmp(expected, &actual[0], len) == 0); } diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt new file mode 100644 index 000000000..e3da278f2 --- /dev/null +++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt @@ -0,0 +1,179 @@ +# Copyright 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +######################################################################## +# generate the python helper script which calls into the build utils +######################################################################## +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re +sys.path.append('${GR_CORE_PYTHONPATH}') +os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') + +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) + +") + +######################################################################## +# 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_includes} + ${generated_gengen_swigs} +) + +######################################################################## +# Create the master gengen swig include files +######################################################################## +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.py " +import os, sys +if __name__ == '__main__': + incs = sys.argv[2:] + h_incs = '\\n'.join(['#include<%s.h>'%(os.path.splitext(os.path.basename(inc))[0]) for inc in incs]) + i_incs = '\\n'.join(['%%include<%s>'%(os.path.basename(inc)) for inc in incs]) + open(sys.argv[1], 'w').write(''' +// +// This file is machine generated. All edits will be overwritten +// + +%%{ +%s +%%} + +%s + +'''%(h_incs, i_incs)) +") + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i + DEPENDS ${generated_gengen_swigs} + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.py + ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i + ${generated_gengen_swigs} +) + +add_custom_target(gengen_generated_index DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i +) + +######################################################################## +# Handle the generated sources + a few non-generated ones +######################################################################## +list(APPEND gnuradio_core_sources + ${generated_gengen_sources} +) + +install(FILES + ${generated_gengen_includes} + ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_noise_type.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sig_source_waveform.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +if(ENABLE_PYTHON) + install(FILES + ${generated_gengen_swigs} + ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.i + ${CMAKE_CURRENT_SOURCE_DIR}/gengen.i + ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" + ) +endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.h.t b/gnuradio-core/src/lib/gengen/gr_add_XX.h.t index 91dd9196a..f0e857abf 100644 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_add_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); /*! * \brief output = sum (input_0, input_1, ...) @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * Add across all input streams. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); @NAME@ (size_t vlen); diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t index 8e9884104..5b46d0f89 100644 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_add_const_XX.h.t @@ -25,20 +25,21 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); /*! * \brief output = input + constant * \ingroup math_blk */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); @O_TYPE@ d_k; // the constant @NAME@ (@O_TYPE@ k); diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t index 574fc686c..9d986e960 100755..100644 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.h.t @@ -25,20 +25,21 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); /*! * \brief output vector = input vector + constant vector * \ingroup math_blk */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); std::vector<@I_TYPE@> d_k; // the constant @NAME@ (const std::vector<@I_TYPE@> &k); diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.h.t b/gnuradio-core/src/lib/gengen/gr_and_XX.h.t index 6152942dd..dbb225907 100644 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_and_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); /*! * \brief output = input_0 & input_1 & , ... & input_N) @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * bitwise boolean and across all input streams. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); @NAME@ (); diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t index 3119611f1..ceffc3066 100644 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_and_const_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); /*! * \brief output_N = input_N & value @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * bitwise boolean and of const to the data stream. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); @O_TYPE@ d_k; // the constant @NAME@ (@O_TYPE@ k); diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t index 2aba94d71..437fa5735 100644 --- a/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t @@ -25,17 +25,18 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); @NAME@ (size_t vlen); size_t d_vlen; diff --git a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.h.t b/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.h.t index a5313d07d..c1393df3f 100644 --- a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_interpolator.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); /*! * \brief Map a stream of symbol indexes (unpacked bytes or shorts) to stream of float or complex onstellation points.in \p D dimensions (\p D = 1 by default) @@ -51,9 +52,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * \sa gr_chunks_to_symbols_sf, gr_chunks_to_symbols_sc. */ -class @NAME@ : public gr_sync_interpolator +class GR_CORE_API @NAME@ : public gr_sync_interpolator { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D); int d_D; std::vector<@O_TYPE@> d_symbol_table; diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t index a59497c8c..ebe5ff5e5 100644 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_divide_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); /*! * \brief output = input_0 / input_1 / input_x ...) @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * Divide across all input streams. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); @NAME@ (size_t vlen); diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t index 01061ff21..c1d81000f 100644 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t @@ -25,13 +25,14 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_decimator.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decim); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decim); /*! * \brief output = sum(input[0]...input[n]) @@ -39,10 +40,10 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * Integrate successive samples in input stream and decimate */ -class @NAME@ : public gr_sync_decimator +class GR_CORE_API @NAME@ : public gr_sync_decimator { private: - friend @SPTR_NAME@ gr_make_@BASE_NAME@(int decim); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@(int decim); @NAME@ (int decim); diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.h.t b/gnuradio-core/src/lib/gengen/gr_max_XX.h.t index 2aba94d71..437fa5735 100644 --- a/gnuradio-core/src/lib/gengen/gr_max_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_max_XX.h.t @@ -25,17 +25,18 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); @NAME@ (size_t vlen); size_t d_vlen; diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t index 2441ca65b..7e228abb6 100644 --- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t @@ -25,13 +25,14 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096); /*! * \brief output is the moving sum of the last N samples, scaled by the scale factor @@ -40,10 +41,10 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * max_iter limits how long we go without flushing the accumulator * This is necessary to avoid numerical instability for float and complex. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { private: - friend @SPTR_NAME@ gr_make_@BASE_NAME@(int length, @O_TYPE@ scale, int max_iter); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@(int length, @O_TYPE@ scale, int max_iter); @NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096); diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t index cb4a0273d..1feb16202 100644 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); /*! * \brief output = prod (input_0, input_1, ...) @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * Multiply across all input streams. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); @NAME@ (size_t vlen); diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t index 0c10185cc..6ff6f74a9 100644 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.h.t @@ -25,20 +25,21 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); /*! * \brief output = input * constant * \ingroup math_blk */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k); @O_TYPE@ d_k; // the constant @NAME@ (@O_TYPE@ k); diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t index 81e781895..f696ab7b1 100755..100644 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.h.t @@ -25,20 +25,21 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); /*! * \brief output vector = input vector * constant vector (element-wise) * \ingroup math_blk */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> &k); std::vector<@I_TYPE@> d_k; // the constant @NAME@ (const std::vector<@I_TYPE@> &k); diff --git a/gnuradio-core/src/lib/gengen/gr_mute_XX.h.t b/gnuradio-core/src/lib/gengen/gr_mute_XX.h.t index 5007787c4..ccf966e53 100644 --- a/gnuradio-core/src/lib/gengen/gr_mute_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_mute_XX.h.t @@ -25,20 +25,21 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (bool mute=false); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (bool mute=false); /*! * \brief output = input or zero if muted. * \ingroup level_blk */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (bool mute); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (bool mute); bool d_mute; @NAME@ (bool mute); diff --git a/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t index a920ce04a..9dd92c8f5 100644 --- a/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t @@ -25,6 +25,7 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_noise_type.h> #include <gr_random.h> @@ -33,15 +34,15 @@ class @NAME@; typedef boost::shared_ptr<@NAME@> @NAME@_sptr; -@NAME@_sptr +GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 3021); /*! * \brief random number source * \ingroup source_blk */ -class @NAME@ : public gr_sync_block { - friend @NAME@_sptr +class GR_CORE_API @NAME@ : public gr_sync_block { + friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed); gr_noise_type_t d_type; diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.h.t b/gnuradio-core/src/lib/gengen/gr_not_XX.h.t index cf8d96ede..b946ffc42 100644 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_not_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); /*! * \brief output = ~input_0 @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * bitwise boolean not across input stream. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); @NAME@ (); diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.h.t b/gnuradio-core/src/lib/gengen/gr_or_XX.h.t index 3e02d9b1a..8d1fea951 100644 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_or_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); /*! * \brief output = input_0 | input_1 | , ... | input_N) @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * bitwise boolean or across all input streams. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); @NAME@ (); diff --git a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.h.t b/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.h.t index 803098c0d..77cd2b470 100644 --- a/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_packed_to_unpacked_XX.h.t @@ -25,13 +25,14 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_block.h> #include <gr_endianness.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); /*! @@ -59,9 +60,9 @@ gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); * \sa gr_chunks_to_symbols_sf, gr_chunks_to_symbols_sc. */ -class @NAME@ : public gr_block +class GR_CORE_API @NAME@ : public gr_block { - friend @SPTR_NAME@ + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); @NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); diff --git a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t index d6a8caf76..d6d1e5e51 100644 --- a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise = 0.25, +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise = 0.25, float threshold_factor_fall = 0.40, int look_ahead = 10, float alpha = 0.001); @@ -57,9 +58,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * This look-ahead range. * \param alpha The gain value of a moving average filter */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise, + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise, float threshold_factor_fall, int look_ahead, float alpha); diff --git a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t index b96487326..328c47106 100644 --- a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); /*! * \brief sample and hold circuit @@ -39,9 +40,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * Samples the data stream (input stream 0) and holds the value * if the control signal is 1 (intput stream 1). */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); @NAME@ (); diff --git a/gnuradio-core/src/lib/gengen/gr_sig_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_sig_source_X.h.t index 9906d16ab..3df723868 100644 --- a/gnuradio-core/src/lib/gengen/gr_sig_source_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_sig_source_X.h.t @@ -25,6 +25,7 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_sig_source_waveform.h> #include <gr_fxpt_nco.h> @@ -37,8 +38,8 @@ typedef boost::shared_ptr<@NAME@> @NAME@_sptr; * \ingroup source_blk */ -class @NAME@ : public gr_sync_block { - friend @NAME@_sptr +class GR_CORE_API @NAME@ : public gr_sync_block { + friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (double sampling_freq, gr_waveform_t waveform, double frequency, double ampl, @TYPE@ offset); @@ -73,7 +74,7 @@ class @NAME@ : public gr_sync_block { void set_offset (@TYPE@ offset); }; -@NAME@_sptr +GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (double sampling_freq, gr_waveform_t waveform, double wave_freq, double ampl, @TYPE@ offset = 0); diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t index a58d1f3b8..4c988945e 100644 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_sub_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen = 1); /*! * \brief output = input_0 - input_1 - ...) @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * Subtract across all input streams. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); @NAME@ (size_t vlen); diff --git a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.h.t b/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.h.t index 42d201093..a7db84c5c 100644 --- a/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_unpacked_to_packed_XX.h.t @@ -25,13 +25,14 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_block.h> #include <gr_endianness.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @NAME@_sptr; -@SPTR_NAME@ +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); /*! @@ -57,9 +58,9 @@ gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc. * \sa gr_chunks_to_symbols_sf, gr_chunks_to_symbols_sc. */ -class @NAME@ : public gr_block +class GR_CORE_API @NAME@ : public gr_block { - friend @SPTR_NAME@ + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); @NAME@ (unsigned int bits_per_chunk, gr_endianness_t endianness); diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t index 7ba5ee9e9..475cc0112 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @NAME@_sptr; -@NAME@_sptr +GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (int vlen = 1); @@ -39,8 +40,8 @@ gr_make_@BASE_NAME@ (int vlen = 1); * \ingroup sink_blk */ -class @NAME@ : public gr_sync_block { - friend @NAME@_sptr gr_make_@BASE_NAME@ (int vlen); +class GR_CORE_API @NAME@ : public gr_sync_block { + friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (int vlen); std::vector<@TYPE@> d_data; int d_vlen; @NAME@ (int vlen); diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t index 63edcb61c..fbab3effb 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t @@ -25,9 +25,10 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> -class @NAME@; +class GR_CORE_API @NAME@; typedef boost::shared_ptr<@NAME@> @NAME@_sptr; /*! @@ -36,7 +37,7 @@ typedef boost::shared_ptr<@NAME@> @NAME@_sptr; */ class @NAME@ : public gr_sync_block { - friend @NAME@_sptr + friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen); std::vector<@TYPE@> d_data; @@ -53,7 +54,7 @@ class @NAME@ : public gr_sync_block { gr_vector_void_star &output_items); }; -@NAME@_sptr +GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1); #endif diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t index 33d729450..b2e1a68c8 100644 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_xor_XX.h.t @@ -25,12 +25,13 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ +#include <gr_core_api.h> #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -@SPTR_NAME@ gr_make_@BASE_NAME@ (); +GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); /*! * \brief output = input_0 ^ input_1 ^ , ... ^ input_N) @@ -38,9 +39,9 @@ typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; * * bitwise boolean xor across all input streams. */ -class @NAME@ : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - friend @SPTR_NAME@ gr_make_@BASE_NAME@ (); + friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (); @NAME@ (); diff --git a/gnuradio-core/src/lib/hier/CMakeLists.txt b/gnuradio-core/src/lib/hier/CMakeLists.txt new file mode 100644 index 000000000..192dd5939 --- /dev/null +++ b/gnuradio-core/src/lib/hier/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.cc +) + +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +if(ENABLE_PYTHON) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/hier.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" + ) +endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/hier/Makefile.am b/gnuradio-core/src/lib/hier/Makefile.am index b525d19b4..369feef75 100644 --- a/gnuradio-core/src/lib/hier/Makefile.am +++ b/gnuradio-core/src/lib/hier/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.h b/gnuradio-core/src/lib/hier/gr_channel_model.h index 116b5dc14..07c0c76b6 100644 --- a/gnuradio-core/src/lib/hier/gr_channel_model.h +++ b/gnuradio-core/src/lib/hier/gr_channel_model.h @@ -19,6 +19,7 @@ * Boston, MA 02110-1301, USA. */ +#include <gr_core_api.h> #include <gr_top_block.h> #include <gr_fractional_interpolator_cc.h> #include <gr_sig_source_c.h> @@ -31,7 +32,7 @@ class gr_channel_model; typedef boost::shared_ptr<gr_channel_model> gr_channel_model_sptr; -gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0, +GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0, double frequency_offset=0.0, double epsilon=1.0, const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1), @@ -41,7 +42,7 @@ gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0, * \brief channel simulator * \ingroup misc_blk */ -class gr_channel_model : public gr_hier_block2 +class GR_CORE_API gr_channel_model : public gr_hier_block2 { private: gr_channel_model(double noise_voltage, @@ -50,7 +51,7 @@ class gr_channel_model : public gr_hier_block2 const std::vector<gr_complex> &taps, double noise_seed); - friend gr_channel_model_sptr gr_make_channel_model(double noise_voltage, + friend GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage, double frequency_offset, double epsilon, const std::vector<gr_complex> &taps, diff --git a/gnuradio-core/src/lib/hier/hier.i b/gnuradio-core/src/lib/hier/hier.i index dbcc8e915..bec3de7ed 100644 --- a/gnuradio-core/src/lib/hier/hier.i +++ b/gnuradio-core/src/lib/hier/hier.i @@ -29,3 +29,4 @@ %} %include "gr_channel_model.i" + diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt new file mode 100644 index 000000000..af9d7583c --- /dev/null +++ b/gnuradio-core/src/lib/io/CMakeLists.txt @@ -0,0 +1,108 @@ +# Copyright 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +######################################################################## +# Append gnuradio-core library sources +######################################################################## +list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.cc + ${CMAKE_CURRENT_SOURCE_DIR}/i2c.cc + ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bitbang.cc + ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio.cc + ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio_pp.cc + ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4702.cc + ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.cc + ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.cc + ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.cc +) + +######################################################################## +# Install runtime headers +######################################################################## +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_trigger_mode.h + ${CMAKE_CURRENT_SOURCE_DIR}/i2c.h + ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bitbang.h + ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio.h + ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio_pp.h + ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4702.h + ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.h + ${CMAKE_CURRENT_SOURCE_DIR}/microtune_eval_board_defs.h + ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.h + ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.h + ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +######################################################################## +# Install swig headers +######################################################################## +if(ENABLE_PYTHON) +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/io.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" +) +endif(ENABLE_PYTHON) + +######################################################################## +# Handle triple-threat files that have cc, h, and i +######################################################################## +set(gr_core_io_triple_threats + gr_file_sink + gr_file_sink_base + gr_file_source + gr_file_descriptor_sink + gr_file_descriptor_source + gr_message_sink + gr_message_source + microtune_xxxx_eval_board + microtune_4702_eval_board + microtune_4937_eval_board + ppio + sdr_1000 + gr_udp_sink + gr_udp_source + gr_wavfile_source + gr_wavfile_sink + gr_tagged_file_sink +) + +foreach(file_tt ${gr_core_io_triple_threats}) + list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") + if(ENABLE_PYTHON) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") + endif(ENABLE_PYTHON) +endforeach(file_tt ${gr_core_io_triple_threats}) diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h index fa8fa3f05..5e4cc6505 100644 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h +++ b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h @@ -23,21 +23,22 @@ #ifndef INCLUDED_GR_FILE_DESCRIPTOR_SINK_H #define INCLUDED_GR_FILE_DESCRIPTOR_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_file_descriptor_sink; typedef boost::shared_ptr<gr_file_descriptor_sink> gr_file_descriptor_sink_sptr; -gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); +GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); /*! * \brief Write stream to file descriptor. * \ingroup sink_blk */ -class gr_file_descriptor_sink : public gr_sync_block +class GR_CORE_API gr_file_descriptor_sink : public gr_sync_block { - friend gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); + friend GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd); private: size_t d_itemsize; diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h b/gnuradio-core/src/lib/io/gr_file_descriptor_source.h index a9f117286..fa513fd25 100644 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h +++ b/gnuradio-core/src/lib/io/gr_file_descriptor_source.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H #define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_file_descriptor_source; typedef boost::shared_ptr<gr_file_descriptor_source> gr_file_descriptor_source_sptr; -gr_file_descriptor_source_sptr +GR_CORE_API gr_file_descriptor_source_sptr gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat = false); /*! @@ -36,9 +37,9 @@ gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat = false); * \ingroup source_blk */ -class gr_file_descriptor_source : public gr_sync_block +class GR_CORE_API gr_file_descriptor_source : public gr_sync_block { - friend gr_file_descriptor_source_sptr + friend GR_CORE_API gr_file_descriptor_source_sptr gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat); private: size_t d_itemsize; diff --git a/gnuradio-core/src/lib/io/gr_file_sink.h b/gnuradio-core/src/lib/io/gr_file_sink.h index b9ad06cd6..180cbef2a 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink.h +++ b/gnuradio-core/src/lib/io/gr_file_sink.h @@ -23,22 +23,23 @@ #ifndef INCLUDED_GR_FILE_SINK_H #define INCLUDED_GR_FILE_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_file_sink_base.h> class gr_file_sink; typedef boost::shared_ptr<gr_file_sink> gr_file_sink_sptr; -gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); +GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); /*! * \brief Write stream to file. * \ingroup sink_blk */ -class gr_file_sink : public gr_sync_block, public gr_file_sink_base +class GR_CORE_API gr_file_sink : public gr_sync_block, public gr_file_sink_base { - friend gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); + friend GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename); private: size_t d_itemsize; diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h index 7b96cdb7f..6765dbad8 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.h +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_FILE_SINK_BASE_H #define INCLUDED_GR_FILE_SINK_BASE_H +#include <gr_core_api.h> #include <boost/thread.hpp> #include <cstdio> /*! * \brief Common base class for file sinks */ -class gr_file_sink_base +class GR_CORE_API gr_file_sink_base { protected: FILE *d_fp; // current FILE pointer diff --git a/gnuradio-core/src/lib/io/gr_file_source.h b/gnuradio-core/src/lib/io/gr_file_source.h index 5f5c2564e..6e8fc4074 100644 --- a/gnuradio-core/src/lib/io/gr_file_source.h +++ b/gnuradio-core/src/lib/io/gr_file_source.h @@ -23,12 +23,13 @@ #ifndef INCLUDED_GR_FILE_SOURCE_H #define INCLUDED_GR_FILE_SOURCE_H +#include <gr_core_api.h> #include <gr_sync_block.h> class gr_file_source; typedef boost::shared_ptr<gr_file_source> gr_file_source_sptr; -gr_file_source_sptr +GR_CORE_API gr_file_source_sptr gr_make_file_source (size_t itemsize, const char *filename, bool repeat = false); /*! @@ -36,9 +37,9 @@ gr_make_file_source (size_t itemsize, const char *filename, bool repeat = false) * \ingroup source_blk */ -class gr_file_source : public gr_sync_block +class GR_CORE_API gr_file_source : public gr_sync_block { - friend gr_file_source_sptr gr_make_file_source (size_t itemsize, + friend GR_CORE_API gr_file_source_sptr gr_make_file_source (size_t itemsize, const char *filename, bool repeat); private: diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.h b/gnuradio-core/src/lib/io/gr_histo_sink_f.h index 8ba45ec55..934066ba2 100644 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.h +++ b/gnuradio-core/src/lib/io/gr_histo_sink_f.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_HISTO_SINK_F_H #define INCLUDED_GR_HISTO_SINK_F_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_msg_queue.h> #include <gruel/thread.h> @@ -30,13 +31,13 @@ class gr_histo_sink_f; typedef boost::shared_ptr<gr_histo_sink_f> gr_histo_sink_f_sptr; -gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); +GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); /*! * \brief Histogram module. * \ingroup sink_blk */ -class gr_histo_sink_f : public gr_sync_block +class GR_CORE_API gr_histo_sink_f : public gr_sync_block { private: gr_msg_queue_sptr d_msgq; @@ -47,7 +48,7 @@ private: float *d_samps; gruel::mutex d_mutex; - friend gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); + friend GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); gr_histo_sink_f (gr_msg_queue_sptr msgq); void send_frame(void); void clear(void); diff --git a/gnuradio-core/src/lib/io/gr_message_sink.h b/gnuradio-core/src/lib/io/gr_message_sink.h index 5f1e5f91f..180055261 100644 --- a/gnuradio-core/src/lib/io/gr_message_sink.h +++ b/gnuradio-core/src/lib/io/gr_message_sink.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_MESSAGE_SINK_H #define INCLUDED_GR_MESSAGE_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_message.h> #include <gr_msg_queue.h> @@ -30,7 +31,7 @@ class gr_message_sink; typedef boost::shared_ptr<gr_message_sink> gr_message_sink_sptr; -gr_message_sink_sptr gr_make_message_sink (size_t itemsize, +GR_CORE_API gr_message_sink_sptr gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); @@ -38,14 +39,14 @@ gr_message_sink_sptr gr_make_message_sink (size_t itemsize, * \brief Gather received items into messages and insert into msgq * \ingroup sink_blk */ -class gr_message_sink : public gr_sync_block +class GR_CORE_API gr_message_sink : public gr_sync_block { private: size_t d_itemsize; gr_msg_queue_sptr d_msgq; bool d_dont_block; - friend gr_message_sink_sptr + friend GR_CORE_API gr_message_sink_sptr gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); protected: diff --git a/gnuradio-core/src/lib/io/gr_message_source.h b/gnuradio-core/src/lib/io/gr_message_source.h index 46a808754..16a0f4474 100644 --- a/gnuradio-core/src/lib/io/gr_message_source.h +++ b/gnuradio-core/src/lib/io/gr_message_source.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_MESSAGE_SOURCE_H #define INCLUDED_GR_MESSAGE_SOURCE_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_message.h> #include <gr_msg_queue.h> @@ -30,14 +31,14 @@ class gr_message_source; typedef boost::shared_ptr<gr_message_source> gr_message_source_sptr; -gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0); -gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq); +GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0); +GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq); /*! * \brief Turn received messages into a stream * \ingroup source_blk */ -class gr_message_source : public gr_sync_block +class GR_CORE_API gr_message_source : public gr_sync_block { private: size_t d_itemsize; @@ -46,9 +47,9 @@ class gr_message_source : public gr_sync_block unsigned d_msg_offset; bool d_eof; - friend gr_message_source_sptr + friend GR_CORE_API gr_message_source_sptr gr_make_message_source(size_t itemsize, int msgq_limit); - friend gr_message_source_sptr + friend GR_CORE_API gr_message_source_sptr gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq); protected: diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.h b/gnuradio-core/src/lib/io/gr_oscope_guts.h index f39db62f6..3223d4e38 100644 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.h +++ b/gnuradio-core/src/lib/io/gr_oscope_guts.h @@ -24,6 +24,7 @@ #ifndef INCLUDED_GR_OSCOPE_GUTS_H #define INCLUDED_GR_OSCOPE_GUTS_H +#include <gr_core_api.h> #include <gr_trigger_mode.h> #include <gr_msg_queue.h> @@ -40,7 +41,7 @@ * consist of 50% pre-trigger data and 50% post-trigger data. */ -class gr_oscope_guts { +class GR_CORE_API gr_oscope_guts { public: static const int MAX_CHANNELS = 8; private: diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h b/gnuradio-core/src/lib/io/gr_oscope_sink_f.h index 1a8022b89..e3d1f65e5 100644 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h +++ b/gnuradio-core/src/lib/io/gr_oscope_sink_f.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_OSCOPE_SINK_F_H #define INCLUDED_GR_OSCOPE_SINK_F_H +#include <gr_core_api.h> #include <gr_oscope_sink_x.h> #include <gr_msg_queue.h> class gr_oscope_sink_f; typedef boost::shared_ptr<gr_oscope_sink_x> gr_oscope_sink_f_sptr; -gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); +GR_CORE_API gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); /*! @@ -38,10 +39,10 @@ gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_ * * Accepts multiple float streams. */ -class gr_oscope_sink_f : public gr_oscope_sink_x +class GR_CORE_API gr_oscope_sink_f : public gr_oscope_sink_x { private: - friend gr_oscope_sink_f_sptr + friend GR_CORE_API gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h b/gnuradio-core/src/lib/io/gr_oscope_sink_x.h index 62cf65100..aaff5870b 100644 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h +++ b/gnuradio-core/src/lib/io/gr_oscope_sink_x.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_OSCOPE_SINK_X_H #define INCLUDED_GR_OSCOPE_SINK_X_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_trigger_mode.h> @@ -34,7 +35,7 @@ class gr_oscope_guts; * * Don't instantiate this. Use gr_oscope_sink_f or gr_oscope_sink_c instead. */ -class gr_oscope_sink_x : public gr_sync_block +class GR_CORE_API gr_oscope_sink_x : public gr_sync_block { protected: double d_sampling_rate; 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 67184b9c5..4ac8c3512 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc +++ b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc @@ -32,7 +32,6 @@ #include <fcntl.h> #include <stdexcept> #include <iostream> -#include <gr_tag_info.h> #ifdef HAVE_IO_H #include <io.h> @@ -85,21 +84,21 @@ gr_tagged_file_sink::work (int noutput_items, pmt::pmt_t bkey = pmt::pmt_string_to_symbol("burst"); //pmt::pmt_t tkey = pmt::pmt_string_to_symbol("time"); // use gr_tags::key_time - std::vector<pmt::pmt_t> all_tags; + std::vector<gr_tag_t> all_tags; get_tags_in_range(all_tags, 0, start_N, end_N); - std::sort(all_tags.begin(), all_tags.end(), gr_tags::nitems_compare); + std::sort(all_tags.begin(), all_tags.end(), gr_tag_t::offset_compare); - std::vector<pmt::pmt_t>::iterator vitr = all_tags.begin(); + std::vector<gr_tag_t>::iterator vitr = all_tags.begin(); int idx = 0, idx_stop = 0; while(idx < noutput_items) { if(d_state == NOT_IN_BURST) { while(vitr != all_tags.end()) { - if((pmt::pmt_eqv(gr_tags::get_key(*vitr), bkey)) && - pmt::pmt_is_true(gr_tags::get_value(*vitr))) { + if((pmt::pmt_eqv((*vitr).key, bkey)) && + pmt::pmt_is_true((*vitr).value)) { - uint64_t N = gr_tags::get_nitems(*vitr); + uint64_t N = (*vitr).offset; idx = (int)(N - start_N); //std::cout << std::endl << "Found start of burst: " @@ -107,17 +106,17 @@ gr_tagged_file_sink::work (int noutput_items, // Find time burst occurred by getting latest time tag and extrapolating // to new time based on sample rate of this block. - std::vector<pmt::pmt_t> time_tags; + std::vector<gr_tag_t> time_tags; //get_tags_in_range(time_tags, 0, d_last_N, N, gr_tags::key_time); get_tags_in_range(time_tags, 0, d_last_N, N, pmt::pmt_string_to_symbol("time")); if(time_tags.size() > 0) { - pmt::pmt_t tag = time_tags[time_tags.size()-1]; + const gr_tag_t tag = time_tags[time_tags.size()-1]; - uint64_t time_nitems = gr_tags::get_nitems(tag); + uint64_t time_nitems = tag.offset; // Get time based on last time tag from USRP - pmt::pmt_t time = gr_tags::get_value(tag); + pmt::pmt_t time = tag.value; int tsecs = pmt::pmt_to_long(pmt::pmt_tuple_ref(time, 0)); double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1)); @@ -175,9 +174,9 @@ gr_tagged_file_sink::work (int noutput_items, } else { // In burst while(vitr != all_tags.end()) { - if((pmt::pmt_eqv(gr_tags::get_key(*vitr), bkey)) && - pmt::pmt_is_false(gr_tags::get_value(*vitr))) { - uint64_t N = gr_tags::get_nitems(*vitr); + if((pmt::pmt_eqv((*vitr).key, bkey)) && + pmt::pmt_is_false((*vitr).value)) { + uint64_t N = (*vitr).offset; idx_stop = (int)N - start_N; //std::cout << "Found end of burst: " diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h b/gnuradio-core/src/lib/io/gr_tagged_file_sink.h index 2e0a5c63a..da12dca78 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h +++ b/gnuradio-core/src/lib/io/gr_tagged_file_sink.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_TAGGED_FILE_SINK_H #define INCLUDED_GR_TAGGED_FILE_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <cstdio> // for FILE class gr_tagged_file_sink; typedef boost::shared_ptr<gr_tagged_file_sink> gr_tagged_file_sink_sptr; -gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, +GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, double samp_rate); /*! @@ -37,9 +38,9 @@ gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, * \ingroup sink_blk */ -class gr_tagged_file_sink : public gr_sync_block +class GR_CORE_API gr_tagged_file_sink : public gr_sync_block { - friend gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, + friend GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize, double samp_rate); private: diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.h b/gnuradio-core/src/lib/io/gr_udp_sink.h index 421d514a4..e9d4f8c73 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.h +++ b/gnuradio-core/src/lib/io/gr_udp_sink.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_UDP_SINK_H #define INCLUDED_GR_UDP_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gruel/thread.h> class gr_udp_sink; typedef boost::shared_ptr<gr_udp_sink> gr_udp_sink_sptr; -gr_udp_sink_sptr +GR_CORE_API gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, const char *host, unsigned short port, int payload_size=1472, bool eof=true); @@ -47,9 +48,9 @@ gr_make_udp_sink (size_t itemsize, * \param eof Send zero-length packet on disconnect */ -class gr_udp_sink : public gr_sync_block +class GR_CORE_API gr_udp_sink : public gr_sync_block { - friend gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, + friend GR_CORE_API gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, const char *host, unsigned short port, int payload_size, bool eof); diff --git a/gnuradio-core/src/lib/io/gr_udp_source.h b/gnuradio-core/src/lib/io/gr_udp_source.h index 5d30fad30..e2898981d 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.h +++ b/gnuradio-core/src/lib/io/gr_udp_source.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_UDP_SOURCE_H #define INCLUDED_GR_UDP_SOURCE_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gruel/thread.h> class gr_udp_source; typedef boost::shared_ptr<gr_udp_source> gr_udp_source_sptr; -gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host, +GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host, unsigned short port, int payload_size=1472, bool eof=true, bool wait=true); @@ -52,9 +53,9 @@ gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host, * */ -class gr_udp_source : public gr_sync_block +class GR_CORE_API gr_udp_source : public gr_sync_block { - friend gr_udp_source_sptr gr_make_udp_source(size_t itemsize, + friend GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host, unsigned short port, int payload_size, diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h b/gnuradio-core/src/lib/io/gr_wavfile_sink.h index a1d6ed527..5fd3eaadc 100644 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h +++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_WAVFILE_SINK_H #define INCLUDED_GR_WAVFILE_SINK_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <gr_file_sink_base.h> #include <boost/thread.hpp> @@ -36,7 +37,7 @@ typedef boost::shared_ptr<gr_wavfile_sink> gr_wavfile_sink_sptr; * \p sample_rate Sample rate [S/s] * \p bits_per_sample 16 or 8 bit, default is 16 */ -gr_wavfile_sink_sptr +GR_CORE_API gr_wavfile_sink_sptr gr_make_wavfile_sink (const char *filename, int n_channels, unsigned int sample_rate, @@ -50,10 +51,10 @@ gr_make_wavfile_sink (const char *filename, * * \ingroup sink_blk */ -class gr_wavfile_sink : public gr_sync_block +class GR_CORE_API gr_wavfile_sink : public gr_sync_block { private: - friend gr_wavfile_sink_sptr gr_make_wavfile_sink (const char *filename, + friend GR_CORE_API gr_wavfile_sink_sptr gr_make_wavfile_sink (const char *filename, int n_channels, unsigned int sample_rate, int bits_per_sample); diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.h b/gnuradio-core/src/lib/io/gr_wavfile_source.h index e434a6b4c..b300f2808 100644 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.h +++ b/gnuradio-core/src/lib/io/gr_wavfile_source.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_GR_WAVFILE_SOURCE_H #define INCLUDED_GR_WAVFILE_SOURCE_H +#include <gr_core_api.h> #include <gr_sync_block.h> #include <cstdio> // for FILE class gr_wavfile_source; typedef boost::shared_ptr<gr_wavfile_source> gr_wavfile_source_sptr; -gr_wavfile_source_sptr +GR_CORE_API gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename, bool repeat = false); /*! @@ -41,10 +42,10 @@ gr_make_wavfile_source (const char *filename, bool repeat = false); * \ingroup source_blk */ -class gr_wavfile_source : public gr_sync_block +class GR_CORE_API gr_wavfile_source : public gr_sync_block { private: - friend gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename, + friend GR_CORE_API gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename, bool repeat); gr_wavfile_source(const char *filename, bool repeat); diff --git a/gnuradio-core/src/lib/io/gri_wavfile.h b/gnuradio-core/src/lib/io/gri_wavfile.h index 2c7c1207c..2268474fb 100644 --- a/gnuradio-core/src/lib/io/gri_wavfile.h +++ b/gnuradio-core/src/lib/io/gri_wavfile.h @@ -23,6 +23,7 @@ // This file stores all the RIFF file type knowledge for the gr_wavfile_* // blocks. +#include <gr_core_api.h> #include <cstdio> /*! diff --git a/gnuradio-core/src/lib/io/i2c.h b/gnuradio-core/src/lib/io/i2c.h index e959f59a8..7d446dfa3 100644 --- a/gnuradio-core/src/lib/io/i2c.h +++ b/gnuradio-core/src/lib/io/i2c.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_I2C_H #define INCLUDED_I2C_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class i2c; @@ -31,7 +32,7 @@ typedef boost::shared_ptr<i2c> i2c_sptr; /*! * \brief abstract class for controlling i2c bus */ -class i2c { +class GR_CORE_API i2c { public: i2c () {} diff --git a/gnuradio-core/src/lib/io/i2c_bbio.h b/gnuradio-core/src/lib/io/i2c_bbio.h index c6b226e39..110a56555 100644 --- a/gnuradio-core/src/lib/io/i2c_bbio.h +++ b/gnuradio-core/src/lib/io/i2c_bbio.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_I2C_BBIO_H #define INCLUDED_I2C_BBIO_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class i2c_bbio; @@ -33,7 +34,7 @@ typedef boost::shared_ptr<i2c_bbio> i2c_bbio_sptr; * \brief abstract class that implements bit banging i/o for i2c bus. * \ingroup base */ -class i2c_bbio { +class GR_CORE_API i2c_bbio { public: i2c_bbio () {} diff --git a/gnuradio-core/src/lib/io/i2c_bbio_pp.h b/gnuradio-core/src/lib/io/i2c_bbio_pp.h index 5a99cdcd1..4a311a2c9 100644 --- a/gnuradio-core/src/lib/io/i2c_bbio_pp.h +++ b/gnuradio-core/src/lib/io/i2c_bbio_pp.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_I2C_BBIO_PP_H #define INCLUDED_I2C_BBIO_PP_H +#include <gr_core_api.h> #include "i2c_bbio.h" #include "ppio.h" @@ -33,8 +34,8 @@ * This class talks to the i2c bus on the microtune eval board using * the parallel port. This works for both the 4937 and 4702 boards. */ -class i2c_bbio_pp : public i2c_bbio { - friend i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); +class GR_CORE_API i2c_bbio_pp : public i2c_bbio { + friend GR_CORE_API i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); i2c_bbio_pp (ppio_sptr pp); public: @@ -50,7 +51,7 @@ class i2c_bbio_pp : public i2c_bbio { ppio_sptr d_pp; }; -i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); +GR_CORE_API i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); #endif /* INCLUDED_I2C_BBIO_PP_H */ diff --git a/gnuradio-core/src/lib/io/i2c_bitbang.h b/gnuradio-core/src/lib/io/i2c_bitbang.h index c9deb38ba..feb23b787 100644 --- a/gnuradio-core/src/lib/io/i2c_bitbang.h +++ b/gnuradio-core/src/lib/io/i2c_bitbang.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_I2C_BITBANG_H #define INCLUDED_I2C_BITBANG_H +#include <gr_core_api.h> #include <i2c.h> #include <i2c_bbio.h> @@ -30,8 +31,8 @@ * \brief class for controlling i2c bus * \ingroup base */ -class i2c_bitbang : public i2c { - friend i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); +class GR_CORE_API i2c_bitbang : public i2c { + friend GR_CORE_API i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); i2c_bitbang (i2c_bbio_sptr io); public: @@ -57,7 +58,7 @@ private: i2c_bbio_sptr d_io; }; -i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); +GR_CORE_API i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); #endif /* INCLUDED_I2C_BITBANG_H */ diff --git a/gnuradio-core/src/lib/io/microtune_4702.h b/gnuradio-core/src/lib/io/microtune_4702.h index 95c64abe7..fd8d89305 100644 --- a/gnuradio-core/src/lib/io/microtune_4702.h +++ b/gnuradio-core/src/lib/io/microtune_4702.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_MICROTUNE_4702_H #define INCLUDED_MICROTUNE_4702_H +#include <gr_core_api.h> #include <microtune_xxxx.h> /*! @@ -30,7 +31,7 @@ * \ingroup hardware */ -class microtune_4702 : public microtune_xxxx { +class GR_CORE_API microtune_4702 : public microtune_xxxx { public: microtune_4702 (i2c_sptr i2c, int i2c_addr); diff --git a/gnuradio-core/src/lib/io/microtune_4702_eval_board.h b/gnuradio-core/src/lib/io/microtune_4702_eval_board.h index 6e9726917..e3c07fdf9 100644 --- a/gnuradio-core/src/lib/io/microtune_4702_eval_board.h +++ b/gnuradio-core/src/lib/io/microtune_4702_eval_board.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_MICROTUNE_4702_EVAL_BOARD_H #define INCLUDED_MICROTUNE_4702_EVAL_BOARD_H +#include <gr_core_api.h> #include "microtune_xxxx_eval_board.h" /*! @@ -30,7 +31,7 @@ * \ingroup hardware */ -class microtune_4702_eval_board : public microtune_xxxx_eval_board { +class GR_CORE_API microtune_4702_eval_board : public microtune_xxxx_eval_board { public: microtune_4702_eval_board (int which_pp = 0); ~microtune_4702_eval_board (); diff --git a/gnuradio-core/src/lib/io/microtune_4937.h b/gnuradio-core/src/lib/io/microtune_4937.h index b263ceb0f..bc8a26c64 100644 --- a/gnuradio-core/src/lib/io/microtune_4937.h +++ b/gnuradio-core/src/lib/io/microtune_4937.h @@ -23,13 +23,14 @@ #ifndef INCLUDED_MICROTUNE_4937_H #define INCLUDED_MICROTUNE_4937_H +#include <gr_core_api.h> #include <microtune_xxxx.h> /*! * \brief class for controlling microtune 4937 tuner module * \ingroup hardware */ -class microtune_4937 : public microtune_xxxx { +class GR_CORE_API microtune_4937 : public microtune_xxxx { public: microtune_4937 (i2c_sptr i2c, int i2c_addr = 0x61); virtual ~microtune_4937 (); diff --git a/gnuradio-core/src/lib/io/microtune_4937_eval_board.h b/gnuradio-core/src/lib/io/microtune_4937_eval_board.h index 154a7281a..09c00d116 100644 --- a/gnuradio-core/src/lib/io/microtune_4937_eval_board.h +++ b/gnuradio-core/src/lib/io/microtune_4937_eval_board.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_MICROTUNE_4937_EVAL_BOARD_H #define INCLUDED_MICROTUNE_4937_EVAL_BOARD_H +#include <gr_core_api.h> #include "microtune_xxxx_eval_board.h" /*! @@ -30,7 +31,7 @@ * \ingroup hardware */ -class microtune_4937_eval_board : public microtune_xxxx_eval_board { +class GR_CORE_API microtune_4937_eval_board : public microtune_xxxx_eval_board { public: microtune_4937_eval_board (int which_pp = 0); ~microtune_4937_eval_board (); diff --git a/gnuradio-core/src/lib/io/microtune_xxxx.h b/gnuradio-core/src/lib/io/microtune_xxxx.h index 4d5074a85..8b6ec25aa 100644 --- a/gnuradio-core/src/lib/io/microtune_xxxx.h +++ b/gnuradio-core/src/lib/io/microtune_xxxx.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_MICROTUNE_XXXX_H #define INCLUDED_MICROTUNE_XXXX_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class i2c; @@ -32,7 +33,7 @@ typedef boost::shared_ptr<i2c> i2c_sptr; * \brief abstract class for controlling microtune {4937,4702} tuner modules * \ingroup base */ -class microtune_xxxx { +class GR_CORE_API microtune_xxxx { public: microtune_xxxx () {} virtual ~microtune_xxxx (); diff --git a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h index 808075e55..08aa438c0 100644 --- a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h +++ b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_MICROTUNE_XXXX_EVAL_BOARD_H #define INCLUDED_MICROTUNE_XXXX_EVAL_BOARD_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class microtune_xxxx; @@ -37,7 +38,7 @@ typedef boost::shared_ptr<i2c> i2c_sptr; * \brief abstract class for controlling microtune xxxx eval board * \ingroup hardware */ -class microtune_xxxx_eval_board { +class GR_CORE_API microtune_xxxx_eval_board { public: microtune_xxxx_eval_board (int which_pp = 0); virtual ~microtune_xxxx_eval_board (); diff --git a/gnuradio-core/src/lib/io/ppio.h b/gnuradio-core/src/lib/io/ppio.h index e1a62e2a3..f7d14d52e 100644 --- a/gnuradio-core/src/lib/io/ppio.h +++ b/gnuradio-core/src/lib/io/ppio.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_PPIO_H #define INCLUDED_PPIO_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class ppio; @@ -34,7 +35,7 @@ typedef boost::shared_ptr<ppio> ppio_sptr; * \ingroup hardware */ -class ppio { +class GR_CORE_API ppio { public: ppio () {} virtual ~ppio (); @@ -55,7 +56,7 @@ class ppio { * Split out from class to make life easier for SWIG */ -ppio_sptr make_ppio (int which_pp); +GR_CORE_API ppio_sptr make_ppio (int which_pp); #endif /* INCLUDED_PPIO_H */ diff --git a/gnuradio-core/src/lib/io/ppio_ppdev.h b/gnuradio-core/src/lib/io/ppio_ppdev.h index b5abe3f0a..5d082d784 100644 --- a/gnuradio-core/src/lib/io/ppio_ppdev.h +++ b/gnuradio-core/src/lib/io/ppio_ppdev.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_PPIO_PPDEV_H #define INCLUDED_PPIO_PPDEV_H +#include <gr_core_api.h> #include <ppio.h> class ppio_ppdev; @@ -33,8 +34,8 @@ typedef boost::shared_ptr<ppio_ppdev> ppio_ppdev_sptr; * \ingroup hardware */ -class ppio_ppdev : public ppio { - friend ppio_ppdev_sptr make_ppio_ppdev (int which = 0); +class GR_CORE_API ppio_ppdev : public ppio { + friend GR_CORE_API ppio_ppdev_sptr make_ppio_ppdev (int which = 0); ppio_ppdev (int which = 0); public: diff --git a/gnuradio-core/src/lib/io/sdr_1000.h b/gnuradio-core/src/lib/io/sdr_1000.h index 113e85deb..6647fbba5 100644 --- a/gnuradio-core/src/lib/io/sdr_1000.h +++ b/gnuradio-core/src/lib/io/sdr_1000.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_SDR_1000_H #define INCLUDED_SDR_1000_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class ppio; @@ -36,7 +37,7 @@ enum { L_EXT = 0, L_BAND = 1, L_DDS0 = 2, L_DDS1 = 3 }; * \sa sdr_1000.py for a higher level interface. * \ingroup hardware */ -class sdr_1000_base { +class GR_CORE_API sdr_1000_base { ppio_sptr d_ppio; int d_shadow[4]; // shadow latches diff --git a/gnuradio-core/src/lib/missing/CMakeLists.txt b/gnuradio-core/src/lib/missing/CMakeLists.txt new file mode 100644 index 000000000..0a376645f --- /dev/null +++ b/gnuradio-core/src/lib/missing/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2010 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/bug_work_around_8.cc +) + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") + list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/posix_memalign.cc + ) +endif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") diff --git a/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt b/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt new file mode 100644 index 000000000..f073249f6 --- /dev/null +++ b/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt @@ -0,0 +1,62 @@ +# Copyright 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## +#MSVC workaround: we cant have dynamically sized arrays. +#So ifdef a max array bounds that is larger than NN and NROOTS +#Its a bit of a hack, but if you look at the code, its so full of ifdefs, +#and lacks optimization where it should be pre-allocating these arrays. +if(MSVC) + set_source_files_properties( + ${CMAKE_CURRENT_SOURCE_DIR}/exercise.c + ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c + PROPERTIES COMPILE_DEFINITIONS "MAX_ARRAY=256;" + ) +endif(MSVC) + +set(gr_core_rs_sources + ${CMAKE_CURRENT_SOURCE_DIR}/encode_rs.c + ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c + ${CMAKE_CURRENT_SOURCE_DIR}/init_rs.c +) + +######################################################################## +# Setup sources and includes +######################################################################## +list(APPEND gnuradio_core_sources ${gr_core_rs_sources}) + +install( + FILES ${CMAKE_CURRENT_SOURCE_DIR}/rs.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +######################################################################## +# Register unit tests +######################################################################## +if(ENABLE_TESTING) +add_executable(gr_core_rstest + ${gr_core_rs_sources} + ${CMAKE_CURRENT_SOURCE_DIR}/rstest.c + ${CMAKE_CURRENT_SOURCE_DIR}/exercise.c +) +add_test(gr-core-reed-solomon-test gr_core_rstest) +endif(ENABLE_TESTING) diff --git a/gnuradio-core/src/lib/reed-solomon/char.h b/gnuradio-core/src/lib/reed-solomon/char.h index 2fbcb504a..8010fb0b9 100644 --- a/gnuradio-core/src/lib/reed-solomon/char.h +++ b/gnuradio-core/src/lib/reed-solomon/char.h @@ -6,6 +6,8 @@ #define DTYPE unsigned char +#include <gr_core_api.h> + /* Reed-Solomon codec control block */ struct rs { unsigned int mm; /* Bits per symbol */ @@ -44,12 +46,11 @@ static inline int modnn(struct rs *rs,int x){ #define INIT_RS init_rs_char #define FREE_RS free_rs_char -void ENCODE_RS(void *p,DTYPE *data,DTYPE *parity); -int DECODE_RS(void *p,DTYPE *data,int *eras_pos,int no_eras); -void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, +GR_CORE_API void ENCODE_RS(void *p,DTYPE *data,DTYPE *parity); +GR_CORE_API int DECODE_RS(void *p,DTYPE *data,int *eras_pos,int no_eras); +GR_CORE_API void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, unsigned int prim,unsigned int nroots); -void FREE_RS(void *p); - +GR_CORE_API void FREE_RS(void *p); diff --git a/gnuradio-core/src/lib/reed-solomon/decode_rs.c b/gnuradio-core/src/lib/reed-solomon/decode_rs.c index 27ddd8532..ba60b89ee 100644 --- a/gnuradio-core/src/lib/reed-solomon/decode_rs.c +++ b/gnuradio-core/src/lib/reed-solomon/decode_rs.c @@ -8,7 +8,6 @@ #endif #include <string.h> -#include <strings.h> #define NULL ((void *)0) #define min(a,b) ((a) < (b) ? (a) : (b)) @@ -32,11 +31,19 @@ DTYPE *data, int *eras_pos, int no_eras){ #endif int deg_lambda, el, deg_omega; int i, j, r,k; +#ifdef MAX_ARRAY + DTYPE u,q,tmp,num1,num2,den,discr_r; + DTYPE lambda[MAX_ARRAY], s[MAX_ARRAY]; /* Err+Eras Locator poly + * and syndrome poly */ + DTYPE b[MAX_ARRAY], t[MAX_ARRAY], omega[MAX_ARRAY]; + DTYPE root[MAX_ARRAY], reg[MAX_ARRAY], loc[MAX_ARRAY]; +#else DTYPE u,q,tmp,num1,num2,den,discr_r; DTYPE lambda[NROOTS+1], s[NROOTS]; /* Err+Eras Locator poly * and syndrome poly */ DTYPE b[NROOTS+1], t[NROOTS+1], omega[NROOTS+1]; DTYPE root[NROOTS], reg[NROOTS+1], loc[NROOTS]; +#endif int syn_error, count; /* form the syndromes; i.e., evaluate data(x) at roots of g(x) */ diff --git a/gnuradio-core/src/lib/reed-solomon/encode_rs.c b/gnuradio-core/src/lib/reed-solomon/encode_rs.c index 147f0a9e3..9d56d0bf1 100644 --- a/gnuradio-core/src/lib/reed-solomon/encode_rs.c +++ b/gnuradio-core/src/lib/reed-solomon/encode_rs.c @@ -3,7 +3,6 @@ * May be used under the terms of the GNU General Public License (GPL) */ #include <string.h> -#include <strings.h> #ifdef FIXED #include "fixed.h" diff --git a/gnuradio-core/src/lib/reed-solomon/exercise.c b/gnuradio-core/src/lib/reed-solomon/exercise.c index 1e04f618d..987fe1aeb 100644 --- a/gnuradio-core/src/lib/reed-solomon/exercise.c +++ b/gnuradio-core/src/lib/reed-solomon/exercise.c @@ -13,7 +13,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <strings.h> #ifdef FIXED #include "fixed.h" @@ -47,11 +46,19 @@ int trials){ #if !defined(CCSDS) && !defined(FIXED) struct rs *rs = (struct rs *)p; #endif +#if MAX_ARRAY + DTYPE block[MAX_ARRAY],tblock[MAX_ARRAY]; + int i; + int errors; + int errlocs[MAX_ARRAY]; + int derrlocs[MAX_ARRAY]; +#else DTYPE block[NN],tblock[NN]; int i; int errors; int errlocs[NN]; int derrlocs[NROOTS]; +#endif int derrors; int errval,errloc; int erasures; diff --git a/gnuradio-core/src/lib/reed-solomon/fixed.h b/gnuradio-core/src/lib/reed-solomon/fixed.h index 9f0ddd9a4..30091e7bf 100644 --- a/gnuradio-core/src/lib/reed-solomon/fixed.h +++ b/gnuradio-core/src/lib/reed-solomon/fixed.h @@ -7,6 +7,8 @@ */ #define DTYPE unsigned char +#include <gr_core_api.h> + static inline int mod255(int x){ while (x >= 255) { x -= 255; @@ -34,5 +36,5 @@ extern unsigned char CCSDS_poly[]; #define ENCODE_RS encode_rs_8 #define DECODE_RS decode_rs_8 -void ENCODE_RS(DTYPE *data,DTYPE *parity); -int DECODE_RS(DTYPE *data, int *eras_pos, int no_eras); +GR_CORE_API void ENCODE_RS(DTYPE *data,DTYPE *parity); +GR_CORE_API int DECODE_RS(DTYPE *data, int *eras_pos, int no_eras);
\ No newline at end of file diff --git a/gnuradio-core/src/lib/reed-solomon/int.h b/gnuradio-core/src/lib/reed-solomon/int.h index 2b0405ae0..79979f827 100644 --- a/gnuradio-core/src/lib/reed-solomon/int.h +++ b/gnuradio-core/src/lib/reed-solomon/int.h @@ -5,8 +5,10 @@ */ #define DTYPE int +#include <gr_core_api.h> + /* Reed-Solomon codec control block */ -struct rs { +struct GR_CORE_API rs { unsigned int mm; /* Bits per symbol */ unsigned int nn; /* Symbols per block (= (1<<mm)-1) */ int *alpha_to; /* log lookup table */ @@ -43,12 +45,11 @@ static inline int modnn(struct rs *rs,int x){ #define INIT_RS init_rs_int #define FREE_RS free_rs_int -void ENCODE_RS(void *p,DTYPE *data,DTYPE *parity); -int DECODE_RS(void *p,DTYPE *data,int *eras_pos,int no_eras); +GR_CORE_API void ENCODE_RS(void *p,DTYPE *data,DTYPE *parity); +GR_CORE_API int DECODE_RS(void *p,DTYPE *data,int *eras_pos,int no_eras); void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, unsigned int prim,unsigned int nroots); -void FREE_RS(void *p); - +GR_CORE_API void FREE_RS(void *p); diff --git a/gnuradio-core/src/lib/reed-solomon/rs.h b/gnuradio-core/src/lib/reed-solomon/rs.h index 9e731d9d9..97e78769e 100644 --- a/gnuradio-core/src/lib/reed-solomon/rs.h +++ b/gnuradio-core/src/lib/reed-solomon/rs.h @@ -1,28 +1,29 @@ +#include <gr_core_api.h> /* User include file for the Reed-Solomon codec * Copyright 2002, Phil Karn KA9Q * May be used under the terms of the GNU General Public License (GPL) */ /* General purpose RS codec, 8-bit symbols */ -void encode_rs_char(void *rs,unsigned char *data,unsigned char *parity); -int decode_rs_char(void *rs,unsigned char *data,int *eras_pos, +GR_CORE_API void encode_rs_char(void *rs,unsigned char *data,unsigned char *parity); +GR_CORE_API int decode_rs_char(void *rs,unsigned char *data,int *eras_pos, int no_eras); -void *init_rs_char(unsigned int symsize,unsigned int gfpoly, +GR_CORE_API void *init_rs_char(unsigned int symsize,unsigned int gfpoly, unsigned int fcr,unsigned int prim,unsigned int nroots); -void free_rs_char(void *rs); +GR_CORE_API void free_rs_char(void *rs); /* General purpose RS codec, integer symbols */ -void encode_rs_int(void *rs,int *data,int *parity); -int decode_rs_int(void *rs,int *data,int *eras_pos,int no_eras); -void *init_rs_int(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, +GR_CORE_API void encode_rs_int(void *rs,int *data,int *parity); +GR_CORE_API int decode_rs_int(void *rs,int *data,int *eras_pos,int no_eras); +GR_CORE_API void *init_rs_int(unsigned int symsize,unsigned int gfpoly,unsigned int fcr, unsigned int prim,unsigned int nroots); -void free_rs_int(void *rs); +GR_CORE_API void free_rs_int(void *rs); /* CCSDS standard (255,223) RS codec with conventional (*not* dual-basis) * symbol representation */ -void encode_rs_8(unsigned char *data,unsigned char *parity); -int decode_rs_8(unsigned char *data,int *eras_pos,int no_eras); +GR_CORE_API void encode_rs_8(unsigned char *data,unsigned char *parity); +GR_CORE_API int decode_rs_8(unsigned char *data,int *eras_pos,int no_eras); /* Tables to map from conventional->dual (Taltab) and * dual->conventional (Tal1tab) bases diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt new file mode 100644 index 000000000..105fc0e06 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -0,0 +1,162 @@ +# Copyright 2010-2010 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +######################################################################## +# Append gnuradio-core library sources +######################################################################## +list(APPEND gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/gr_basic_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_flowgraph.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_flat_flowgraph.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block_detail.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block_executor.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_hier_block2.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_hier_block2_detail.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_buffer.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_dispatcher.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_queue.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_pagesize.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_preferences.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_realtime.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_scheduler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_scheduler_sts.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_scheduler_tpb.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_single_threaded_scheduler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sptr_magic.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sys_paths.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block_impl.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_detail.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_thread_body.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf_mmap_shm_open.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf_mmap_tmpfile.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf_createfilemapping.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf_sysv_shm.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_select_handler.cc +) + +######################################################################## +# Append gnuradio-core test sources +######################################################################## +list(APPEND test_gnuradio_core_sources + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2_derived.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_buffer.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_flowgraph.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_top_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_io_signature.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_vmcircbuf.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_runtime.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc +) + +######################################################################## +# Install runtime headers +######################################################################## +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/gr_basic_block.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_flowgraph.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_flat_flowgraph.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block_detail.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block_executor.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_hier_block2.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_hier_block2_detail.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_buffer.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_complex.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_dispatcher.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_queue.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_pagesize.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_preferences.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_realtime.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_runtime_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_scheduler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_scheduler_sts.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_scheduler_tpb.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_select_handler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_single_threaded_scheduler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sptr_magic.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_block.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block_impl.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_detail.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_thread_body.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_timer.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sys_paths.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_unittests.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tags.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +######################################################################## +# Install swig headers +######################################################################## +if(ENABLE_PYTHON) +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/gr_basic_block.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_block_detail.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_hier_block2.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_buffer.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_dispatcher.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_queue.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_realtime.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_single_threaded_scheduler.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_block.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tags.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.i + ${CMAKE_CURRENT_SOURCE_DIR}/runtime.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" +) +endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/runtime/Makefile.am b/gnuradio-core/src/lib/runtime/Makefile.am index eca92e526..38da3d5fd 100644 --- a/gnuradio-core/src/lib/runtime/Makefile.am +++ b/gnuradio-core/src/lib/runtime/Makefile.am @@ -68,8 +68,7 @@ libruntime_la_SOURCES = \ gr_vmcircbuf_mmap_tmpfile.cc \ gr_vmcircbuf_createfilemapping.cc \ gr_vmcircbuf_sysv_shm.cc \ - gr_select_handler.cc \ - gr_tag_info.cc + gr_select_handler.cc libruntime_qa_la_SOURCES = \ qa_gr_block.cc \ @@ -125,7 +124,7 @@ grinclude_HEADERS = \ gr_types.h \ gr_unittests.h \ gr_vmcircbuf.h \ - gr_tag_info.h + gr_tags.h noinst_HEADERS = \ gr_vmcircbuf_mmap_shm_open.h \ @@ -161,5 +160,6 @@ swiginclude_HEADERS = \ gr_sync_block.i \ gr_sync_decimator.i \ gr_sync_interpolator.i \ + gr_tags.i \ gr_top_block.i \ runtime.i diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index 3b0cd51dd..2adca8ccb 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_BASIC_BLOCK_H #define INCLUDED_GR_BASIC_BLOCK_H +#include <gr_core_api.h> #include <gr_runtime_types.h> #include <gr_sptr_magic.h> #include <boost/enable_shared_from_this.hpp> @@ -41,7 +42,7 @@ * signal processing functions. */ -class gr_basic_block : public gr_msg_accepter, public boost::enable_shared_from_this<gr_basic_block> +class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_shared_from_this<gr_basic_block> { typedef boost::function<void(pmt::pmt_t)> msg_handler_t; @@ -158,7 +159,7 @@ inline bool operator<(gr_basic_block_sptr lhs, gr_basic_block_sptr rhs) typedef std::vector<gr_basic_block_sptr> gr_basic_block_vector_t; typedef std::vector<gr_basic_block_sptr>::iterator gr_basic_block_viter_t; -long gr_basic_block_ncurrently_allocated(); +GR_CORE_API long gr_basic_block_ncurrently_allocated(); inline std::ostream &operator << (std::ostream &os, gr_basic_block_sptr basic_block) { diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 81a55af9d..9463869f5 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -144,16 +144,13 @@ gr_block::nitems_written(unsigned int which_output) void gr_block::add_item_tag(unsigned int which_output, - uint64_t offset, - const pmt::pmt_t &key, - const pmt::pmt_t &value, - const pmt::pmt_t &srcid) + const gr_tag_t &tag) { - d_detail->add_item_tag(which_output, offset, key, value, srcid); + d_detail->add_item_tag(which_output, tag); } void -gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_block::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_output, uint64_t start, uint64_t end) { @@ -161,7 +158,7 @@ gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v, } void -gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_block::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_output, uint64_t start, uint64_t end, const pmt::pmt_t &key) diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index fc22f9ea8..86e0583e9 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -23,7 +23,9 @@ #ifndef INCLUDED_GR_BLOCK_H #define INCLUDED_GR_BLOCK_H +#include <gr_core_api.h> #include <gr_basic_block.h> +#include <gr_tags.h> /*! * \brief The abstract base class for all 'terminal' processing blocks. @@ -53,7 +55,7 @@ * It reads the input items and writes the output items. */ -class gr_block : public gr_basic_block { +class GR_CORE_API gr_block : public gr_basic_block { public: @@ -254,11 +256,27 @@ class gr_block : public gr_basic_block { * \param value any PMT holding any value for the given key * \param srcid optional source ID specifier; defaults to PMT_F */ - void add_item_tag(unsigned int which_output, + inline void add_item_tag(unsigned int which_output, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, - const pmt::pmt_t &srcid=pmt::PMT_F); + const pmt::pmt_t &srcid=pmt::PMT_F) + { + gr_tag_t tag; + tag.offset = abs_offset; + tag.key = key; + tag.value = value; + tag.srcid = srcid; + this->add_item_tag(which_output, tag); + } + + /*! + * \brief Adds a new tag onto the given output buffer. + * + * \param which_output an integer of which output stream to attach the tag + * \param tag the tag object to add + */ + void add_item_tag(unsigned int which_output, const gr_tag_t &tag); /*! * \brief Given a [start,end), returns a vector of all tags in the range. @@ -273,7 +291,7 @@ class gr_block : public gr_basic_block { * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end); @@ -293,14 +311,14 @@ class gr_block : public gr_basic_block { * \param abs_end a uint64 count of the end of the range of interest * \param key a PMT symbol key to filter only tags of this key */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, const pmt::pmt_t &key); // These are really only for internal use, but leaving them public avoids - // having to work up an ever-varying list of friends + // having to work up an ever-varying list of friend GR_CORE_APIs public: gr_block_detail_sptr detail () const { return d_detail; } diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index a360240c0..cbd4239f3 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -150,27 +150,19 @@ gr_block_detail::nitems_written(unsigned int which_output) } void -gr_block_detail::add_item_tag(unsigned int which_output, - uint64_t abs_offset, - const pmt_t &key, - const pmt_t &value, - const pmt_t &srcid) -{ - if(!pmt_is_symbol(key)) { - throw pmt_wrong_type("gr_block_detail::add_item_tag key", key); +gr_block_detail::add_item_tag(unsigned int which_output, const gr_tag_t &tag) +{ + if(!pmt_is_symbol(tag.key)) { + throw pmt_wrong_type("gr_block_detail::add_item_tag key", tag.key); } else { - // build tag tuple - pmt_t nitem = pmt_from_uint64(abs_offset); - pmt_t tuple = pmt_make_tuple(nitem, srcid, key, value); - // Add tag to gr_buffer's deque tags - d_output[which_output]->add_item_tag(tuple); + d_output[which_output]->add_item_tag(tag); } } void -gr_block_detail::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end) @@ -180,13 +172,13 @@ gr_block_detail::get_tags_in_range(std::vector<pmt::pmt_t> &v, } void -gr_block_detail::get_tags_in_range(std::vector<pmt_t> &v, +gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, const pmt_t &key) { - std::vector<pmt_t> found_items; + std::vector<gr_tag_t> found_items; v.resize(0); @@ -195,9 +187,9 @@ gr_block_detail::get_tags_in_range(std::vector<pmt_t> &v, // Filter further by key name pmt_t itemkey; - std::vector<pmt_t>::iterator itr; + std::vector<gr_tag_t>::iterator itr; for(itr = found_items.begin(); itr != found_items.end(); itr++) { - itemkey = pmt_tuple_ref(*itr, 2); + itemkey = (*itr).key; if(pmt_eqv(key, itemkey)) { v.push_back(*itr); } diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index d7ec3b136..89081156a 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -23,9 +23,10 @@ #ifndef INCLUDED_GR_BLOCK_DETAIL_H #define INCLUDED_GR_BLOCK_DETAIL_H +#include <gr_core_api.h> #include <gr_runtime_types.h> #include <gr_tpb_detail.h> -#include <gr_tag_info.h> +#include <gr_tags.h> #include <stdexcept> /*! @@ -36,7 +37,7 @@ * of almost all users of GNU Radio. This decoupling also means that * we can make changes to the guts without having to recompile everything. */ -class gr_block_detail { +class GR_CORE_API gr_block_detail { public: ~gr_block_detail (); @@ -104,17 +105,9 @@ class gr_block_detail { * which appends the tag onto its deque. * * \param which_output an integer of which output stream to attach the tag - * \param abs_offset a uint64 number of the absolute item number - * assicated with the tag. Can get from nitems_written. - * \param key the tag key as a PMT symbol - * \param value any PMT holding any value for the given key - * \param srcid a PMT source ID specifier + * \param tag the tag object to add */ - void add_item_tag(unsigned int which_output, - uint64_t abs_offset, - const pmt::pmt_t &key, - const pmt::pmt_t &value, - const pmt::pmt_t &srcid); + void add_item_tag(unsigned int which_output, const gr_tag_t &tag); /*! * \brief Given a [start,end), returns a vector of all tags in the range. @@ -130,7 +123,7 @@ class gr_block_detail { * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end); @@ -152,7 +145,7 @@ class gr_block_detail { * \param abs_end a uint64 count of the end of the range of interest * \param key a PMT symbol to select only tags of this key */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, @@ -172,16 +165,16 @@ class gr_block_detail { gr_block_detail (unsigned int ninputs, unsigned int noutputs); - friend class gr_tpb_detail; + friend struct gr_tpb_detail; - friend gr_block_detail_sptr + friend GR_CORE_API gr_block_detail_sptr gr_make_block_detail (unsigned int ninputs, unsigned int noutputs); }; -gr_block_detail_sptr +GR_CORE_API gr_block_detail_sptr gr_make_block_detail (unsigned int ninputs, unsigned int noutputs); -long +GR_CORE_API long gr_block_detail_ncurrently_allocated (); #endif /* INCLUDED_GR_BLOCK_DETAIL_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index a8d0bc1c8..737b26f67 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -29,6 +29,7 @@ #include <gr_block_detail.h> #include <gr_buffer.h> #include <boost/thread.hpp> +#include <boost/format.hpp> #include <iostream> #include <limits> #include <assert.h> @@ -90,7 +91,7 @@ min_available_space (gr_block_detail *d, int output_multiple) static bool propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, const std::vector<uint64_t> &start_nitems_read, double rrate, - std::vector<pmt::pmt_t> &rtags) + std::vector<gr_tag_t> &rtags) { // Move tags downstream // if a sink, we don't need to move downstream @@ -108,7 +109,7 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, d->get_tags_in_range(rtags, i, start_nitems_read[i], d->nitems_read(i)); - std::vector<pmt::pmt_t>::iterator t; + std::vector<gr_tag_t>::iterator t; if(rrate == 1.0) { for(t = rtags.begin(); t != rtags.end(); t++) { for(int o = 0; o < d->noutputs(); o++) @@ -117,14 +118,10 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, } else { for(t = rtags.begin(); t != rtags.end(); t++) { - uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0)); - pmt::pmt_t newtup = pmt::mp(pmt::pmt_from_uint64(newcount * rrate), - pmt::pmt_tuple_ref(*t, 1), - pmt::pmt_tuple_ref(*t, 2), - pmt::pmt_tuple_ref(*t, 3)); - + gr_tag_t new_tag = *t; + new_tag.offset *= rrate; for(int o = 0; o < d->noutputs(); o++) - d->output(o)->add_item_tag(newtup); + d->output(o)->add_item_tag(new_tag); } } } @@ -138,14 +135,11 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, d->get_tags_in_range(rtags, i, start_nitems_read[i], d->nitems_read(i)); - std::vector<pmt::pmt_t>::iterator t; + std::vector<gr_tag_t>::iterator t; for(t = rtags.begin(); t != rtags.end(); t++) { - uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0)); - pmt::pmt_t newtup = pmt::mp(pmt::pmt_from_uint64(newcount * rrate), - pmt::pmt_tuple_ref(*t, 1), - pmt::pmt_tuple_ref(*t, 2), - pmt::pmt_tuple_ref(*t, 3)); - d->output(i)->add_item_tag(newtup); + gr_tag_t new_tag = *t; + new_tag.offset *= rrate; + d->output(i)->add_item_tag(new_tag); } } } @@ -165,9 +159,8 @@ gr_block_executor::gr_block_executor (gr_block_sptr block) : d_block(block), d_log(0) { if (ENABLE_LOGGING){ - char name[100]; - snprintf(name, sizeof(name), "sst-%03d.log", which_scheduler++); - d_log = new std::ofstream(name); + std::string name = str(boost::format("sst-%03d.log") % which_scheduler++); + d_log = new std::ofstream(name.c_str()); std::unitbuf(*d_log); // make it unbuffered... *d_log << "gr_block_executor: " << d_block << std::endl; diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.h b/gnuradio-core/src/lib/runtime/gr_block_executor.h index 77ace5522..15279f273 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.h +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.h @@ -23,9 +23,10 @@ #ifndef INCLUDED_GR_BLOCK_EXECUTOR_H #define INCLUDED_GR_BLOCK_EXECUTOR_H +#include <gr_core_api.h> #include <gr_runtime_types.h> #include <fstream> -#include <gruel/pmt.h> +#include <gr_tags.h> //class gr_block_executor; //typedef boost::shared_ptr<gr_block_executor> gr_block_executor_sptr; @@ -36,7 +37,7 @@ * \ingroup internal */ -class gr_block_executor { +class GR_CORE_API gr_block_executor { protected: gr_block_sptr d_block; // The block we're trying to run std::ofstream *d_log; @@ -49,7 +50,7 @@ protected: std::vector<bool> d_input_done; gr_vector_void_star d_output_items; std::vector<uint64_t> d_start_nitems_read; //stores where tag counts are before work - std::vector<pmt::pmt_t> d_returned_tags; + std::vector<gr_tag_t> d_returned_tags; public: gr_block_executor(gr_block_sptr block); diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index fa3722714..8ccc9db32 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc @@ -227,7 +227,7 @@ gr_buffer::drop_reader (gr_buffer_reader *reader) } void -gr_buffer::add_item_tag(const pmt::pmt_t &tag) +gr_buffer::add_item_tag(const gr_tag_t &tag) { gruel::scoped_lock guard(*mutex()); d_item_tags.push_back(tag); @@ -245,7 +245,7 @@ gr_buffer::prune_tags(uint64_t max_time) buffer's mutex al la the scoped_lock line below. */ //gruel::scoped_lock guard(*mutex()); - std::deque<pmt::pmt_t>::iterator itr = d_item_tags.begin(); + std::deque<gr_tag_t>::iterator itr = d_item_tags.begin(); uint64_t item_time; @@ -255,7 +255,7 @@ gr_buffer::prune_tags(uint64_t max_time) // to find more. Mostly, we wil be erasing from the front and // therefore lose little time this way. while(itr != d_item_tags.end()) { - item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); + item_time = (*itr).offset; if(item_time < max_time) { d_item_tags.erase(itr); itr = d_item_tags.begin(); @@ -307,18 +307,18 @@ gr_buffer_reader::update_read_pointer (int nitems) } void -gr_buffer_reader::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_buffer_reader::get_tags_in_range(std::vector<gr_tag_t> &v, uint64_t abs_start, uint64_t abs_end) { gruel::scoped_lock guard(*mutex()); v.resize(0); - std::deque<pmt::pmt_t>::iterator itr = d_buffer->get_tags_begin(); + std::deque<gr_tag_t>::iterator itr = d_buffer->get_tags_begin(); uint64_t item_time; while(itr != d_buffer->get_tags_end()) { - item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); + item_time = (*itr).offset; if((item_time >= abs_start) && (item_time < abs_end)) { v.push_back(*itr); diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h index e5725d386..e8e393756 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.h +++ b/gnuradio-core/src/lib/runtime/gr_buffer.h @@ -23,10 +23,11 @@ #ifndef INCLUDED_GR_BUFFER_H #define INCLUDED_GR_BUFFER_H +#include <gr_core_api.h> #include <gr_runtime_types.h> #include <boost/weak_ptr.hpp> #include <gruel/thread.h> -#include <gruel/pmt.h> +#include <gr_tags.h> #include <deque> class gr_vmcircbuf; @@ -42,14 +43,14 @@ class gr_vmcircbuf; * \param sizeof_item is the size of an item in bytes. * \param link is the block that writes to this buffer. */ -gr_buffer_sptr gr_make_buffer (int nitems, size_t sizeof_item, gr_block_sptr link=gr_block_sptr()); +GR_CORE_API gr_buffer_sptr gr_make_buffer (int nitems, size_t sizeof_item, gr_block_sptr link=gr_block_sptr()); /*! * \brief Single writer, multiple reader fifo. * \ingroup internal */ -class gr_buffer { +class GR_CORE_API gr_buffer { public: virtual ~gr_buffer (); @@ -96,9 +97,9 @@ class gr_buffer { /*! * \brief Adds a new tag to the buffer. * - * \param tag a PMT tuple containing the new tag + * \param tag the new tag */ - void add_item_tag(const pmt::pmt_t &tag); + void add_item_tag(const gr_tag_t &tag); /*! * \brief Removes all tags before \p max_time from buffer @@ -107,16 +108,16 @@ class gr_buffer { */ void prune_tags(uint64_t max_time); - std::deque<pmt::pmt_t>::iterator get_tags_begin() { return d_item_tags.begin(); } - std::deque<pmt::pmt_t>::iterator get_tags_end() { return d_item_tags.end(); } + std::deque<gr_tag_t>::iterator get_tags_begin() { return d_item_tags.begin(); } + std::deque<gr_tag_t>::iterator get_tags_end() { return d_item_tags.end(); } // ------------------------------------------------------------------------- private: friend class gr_buffer_reader; - friend gr_buffer_sptr gr_make_buffer (int nitems, size_t sizeof_item, gr_block_sptr link); - friend gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload, gr_block_sptr link); + friend GR_CORE_API gr_buffer_sptr gr_make_buffer (int nitems, size_t sizeof_item, gr_block_sptr link); + friend GR_CORE_API gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload, gr_block_sptr link); protected: char *d_base; // base address of buffer @@ -135,7 +136,7 @@ class gr_buffer { unsigned int d_write_index; // in items [0,d_bufsize) uint64_t d_abs_write_offset; // num items written since the start bool d_done; - std::deque<pmt::pmt_t> d_item_tags; + std::deque<gr_tag_t> d_item_tags; uint64_t d_last_min_items_read; unsigned @@ -192,11 +193,11 @@ class gr_buffer { * \param nzero_preload -- number of zero items to "preload" into buffer. * \param link is the block that reads from the buffer using this gr_buffer_reader. */ -gr_buffer_reader_sptr +GR_CORE_API gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload, gr_block_sptr link=gr_block_sptr()); //! returns # of gr_buffers currently allocated -long gr_buffer_ncurrently_allocated (); +GR_CORE_API long gr_buffer_ncurrently_allocated (); // --------------------------------------------------------------------------- @@ -206,7 +207,7 @@ long gr_buffer_ncurrently_allocated (); * \ingroup internal */ -class gr_buffer_reader { +class GR_CORE_API gr_buffer_reader { public: ~gr_buffer_reader (); @@ -267,7 +268,7 @@ class gr_buffer_reader { * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, uint64_t abs_start, uint64_t abs_end); @@ -276,7 +277,7 @@ class gr_buffer_reader { private: friend class gr_buffer; - friend gr_buffer_reader_sptr + friend GR_CORE_API gr_buffer_reader_sptr gr_buffer_add_reader (gr_buffer_sptr buf, int nzero_preload, gr_block_sptr link); @@ -290,7 +291,7 @@ class gr_buffer_reader { }; //! returns # of gr_buffer_readers currently allocated -long gr_buffer_reader_ncurrently_allocated (); +GR_CORE_API long gr_buffer_reader_ncurrently_allocated (); #endif /* INCLUDED_GR_BUFFER_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_dispatcher.h b/gnuradio-core/src/lib/runtime/gr_dispatcher.h index 34f825102..735974766 100644 --- a/gnuradio-core/src/lib/runtime/gr_dispatcher.h +++ b/gnuradio-core/src/lib/runtime/gr_dispatcher.h @@ -23,14 +23,15 @@ #ifndef INCLUDED_GR_DISPATCHER_H #define INCLUDED_GR_DISPATCHER_H +#include <gr_core_api.h> #include <gr_select_handler.h> #include <vector> class gr_dispatcher; typedef boost::shared_ptr<gr_dispatcher> gr_dispatcher_sptr; -gr_dispatcher_sptr gr_dispatcher_singleton(); -gr_dispatcher_sptr gr_make_dispatcher(); +GR_CORE_API gr_dispatcher_sptr gr_dispatcher_singleton(); +GR_CORE_API gr_dispatcher_sptr gr_make_dispatcher(); /*! * \brief invoke callbacks based on select. @@ -38,10 +39,10 @@ gr_dispatcher_sptr gr_make_dispatcher(); * * \sa gr_select_handler */ -class gr_dispatcher +class GR_CORE_API gr_dispatcher { gr_dispatcher(); - friend gr_dispatcher_sptr gr_make_dispatcher(); + friend GR_CORE_API gr_dispatcher_sptr gr_make_dispatcher(); std::vector<gr_select_handler_sptr> d_handler; int d_max_index; diff --git a/gnuradio-core/src/lib/runtime/gr_error_handler.h b/gnuradio-core/src/lib/runtime/gr_error_handler.h index aedb6f41f..4c30791f2 100644 --- a/gnuradio-core/src/lib/runtime/gr_error_handler.h +++ b/gnuradio-core/src/lib/runtime/gr_error_handler.h @@ -43,6 +43,7 @@ #ifndef INCLUDED_GR_ERROR_HANDLER_H #define INCLUDED_GR_ERROR_HANDLER_H +#include <gr_core_api.h> #include <stdarg.h> #include <string> #include <cstdio> // for FILE @@ -51,7 +52,7 @@ * \brief abstract error handler * \ingroup base */ -class gr_error_handler { +class GR_CORE_API gr_error_handler { public: enum seriousness { ERR_DEBUG = 0x00000000, @@ -90,7 +91,7 @@ protected: }; -class gr_base_error_handler : public gr_error_handler { +class GR_CORE_API gr_base_error_handler : public gr_error_handler { int d_nwarnings; int d_nerrors; @@ -102,7 +103,7 @@ public: void count_error(seriousness s); }; -class gr_file_error_handler : public gr_base_error_handler { +class GR_CORE_API gr_file_error_handler : public gr_base_error_handler { FILE *d_file; int d_fd; public: diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h index 8e9834337..2cc883686 100644 --- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h +++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h @@ -23,22 +23,23 @@ #ifndef INCLUDED_GR_FLAT_FLOWGRAPH_H #define INCLUDED_GR_FLAT_FLOWGRAPH_H +#include <gr_core_api.h> #include <gr_flowgraph.h> #include <gr_block.h> // Create a shared pointer to a heap allocated gr_flat_flowgraph // (types defined in gr_runtime_types.h) -gr_flat_flowgraph_sptr gr_make_flat_flowgraph(); +GR_CORE_API gr_flat_flowgraph_sptr gr_make_flat_flowgraph(); /*! *\brief Class specializing gr_flat_flowgraph that has all nodes * as gr_blocks, with no hierarchy * \ingroup internal */ -class gr_flat_flowgraph : public gr_flowgraph +class GR_CORE_API gr_flat_flowgraph : public gr_flowgraph { public: - friend gr_flat_flowgraph_sptr gr_make_flat_flowgraph(); + friend GR_CORE_API gr_flat_flowgraph_sptr gr_make_flat_flowgraph(); // Destruct an arbitrary gr_flat_flowgraph ~gr_flat_flowgraph(); diff --git a/gnuradio-core/src/lib/runtime/gr_flowgraph.h b/gnuradio-core/src/lib/runtime/gr_flowgraph.h index 8e988506b..8f9a8ba71 100644 --- a/gnuradio-core/src/lib/runtime/gr_flowgraph.h +++ b/gnuradio-core/src/lib/runtime/gr_flowgraph.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_FLOWGRAPH_H #define INCLUDED_GR_FLOWGRAPH_H +#include <gr_core_api.h> #include <gr_basic_block.h> #include <iostream> @@ -30,7 +31,7 @@ * \brief Class representing a specific input or output graph endpoint * \ingroup internal */ -class gr_endpoint +class GR_CORE_API gr_endpoint { private: gr_basic_block_sptr d_basic_block; @@ -59,7 +60,7 @@ typedef std::vector<gr_endpoint>::iterator gr_endpoint_viter_t; *\brief Class representing a connection between to graph endpoints * */ -class gr_edge +class GR_CORE_API gr_edge { public: gr_edge() : d_src(), d_dst() { }; @@ -81,16 +82,16 @@ typedef std::vector<gr_edge>::iterator gr_edge_viter_t; // Create a shared pointer to a heap allocated flowgraph // (types defined in gr_runtime_types.h) -gr_flowgraph_sptr gr_make_flowgraph(); +GR_CORE_API gr_flowgraph_sptr gr_make_flowgraph(); /*! * \brief Class representing a directed, acyclic graph of basic blocks * \ingroup internal */ -class gr_flowgraph +class GR_CORE_API gr_flowgraph { public: - friend gr_flowgraph_sptr gr_make_flowgraph(); + friend GR_CORE_API gr_flowgraph_sptr gr_make_flowgraph(); // Destruct an arbitrary flowgraph ~gr_flowgraph(); diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2.h b/gnuradio-core/src/lib/runtime/gr_hier_block2.h index 0a40c36b7..8687b7d99 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2.h +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_HIER_BLOCK2_H #define INCLUDED_GR_HIER_BLOCK2_H +#include <gr_core_api.h> #include <gr_basic_block.h> /*! * \brief public constructor for gr_hier_block2 */ -gr_hier_block2_sptr gr_make_hier_block2(const std::string &name, +GR_CORE_API gr_hier_block2_sptr gr_make_hier_block2(const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature); @@ -40,11 +41,11 @@ class gr_hier_block2_detail; * \ingroup base_blk * */ -class gr_hier_block2 : public gr_basic_block +class GR_CORE_API gr_hier_block2 : public gr_basic_block { private: friend class gr_hier_block2_detail; - friend gr_hier_block2_sptr gr_make_hier_block2(const std::string &name, + friend GR_CORE_API gr_hier_block2_sptr gr_make_hier_block2(const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature); diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h index 6f5384e5a..5a77d6a03 100644 --- a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_HIER_BLOCK2_DETAIL_H #define INCLUDED_GR_HIER_BLOCK2_DETAIL_H +#include <gr_core_api.h> #include <gr_hier_block2.h> #include <gr_flat_flowgraph.h> #include <boost/utility.hpp> @@ -29,7 +30,7 @@ /*! * \ingroup internal */ -class gr_hier_block2_detail : boost::noncopyable +class GR_CORE_API gr_hier_block2_detail : boost::noncopyable { public: gr_hier_block2_detail(gr_hier_block2 *owner); diff --git a/gnuradio-core/src/lib/runtime/gr_io_signature.h b/gnuradio-core/src/lib/runtime/gr_io_signature.h index 5d194cf55..11c6b7f13 100644 --- a/gnuradio-core/src/lib/runtime/gr_io_signature.h +++ b/gnuradio-core/src/lib/runtime/gr_io_signature.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_IO_SIGNATURE_H #define INCLUDED_IO_SIGNATURE_H +#include <gr_core_api.h> #include <gr_runtime_types.h> /*! @@ -33,7 +34,7 @@ * \param max_streams specify maximum number of streams (>= min_streams or -1 -> infinite) * \param sizeof_stream_item specify the size of the items in each stream */ -gr_io_signature_sptr +GR_CORE_API gr_io_signature_sptr gr_make_io_signature(int min_streams, int max_streams, int sizeof_stream_item); @@ -45,7 +46,7 @@ gr_make_io_signature(int min_streams, int max_streams, * \param sizeof_stream_item1 specify the size of the items in the first stream * \param sizeof_stream_item2 specify the size of the items in the second and subsequent streams */ -gr_io_signature_sptr +GR_CORE_API gr_io_signature_sptr gr_make_io_signature2(int min_streams, int max_streams, int sizeof_stream_item1, int sizeof_stream_item2 @@ -60,7 +61,7 @@ gr_make_io_signature2(int min_streams, int max_streams, * \param sizeof_stream_item2 specify the size of the items in the second stream * \param sizeof_stream_item3 specify the size of the items in the third and subsequent streams */ -gr_io_signature_sptr +GR_CORE_API gr_io_signature_sptr gr_make_io_signature3(int min_streams, int max_streams, int sizeof_stream_item1, int sizeof_stream_item2, @@ -78,7 +79,7 @@ gr_make_io_signature3(int min_streams, int max_streams, * value of the last entry in sizeof_stream_items is used for the missing values. * sizeof_stream_items must contain at least 1 entry. */ -gr_io_signature_sptr +GR_CORE_API gr_io_signature_sptr gr_make_io_signaturev(int min_streams, int max_streams, const std::vector<int> &sizeof_stream_items); @@ -87,7 +88,7 @@ gr_make_io_signaturev(int min_streams, int max_streams, * \brief i/o signature for input and output ports. * \brief misc */ -class gr_io_signature { +class GR_CORE_API gr_io_signature { int d_min_streams; int d_max_streams; std::vector<int> d_sizeof_stream_item; @@ -95,7 +96,7 @@ class gr_io_signature { gr_io_signature(int min_streams, int max_streams, const std::vector<int> &sizeof_stream_items); - friend gr_io_signature_sptr + friend GR_CORE_API gr_io_signature_sptr gr_make_io_signaturev(int min_streams, int max_streams, const std::vector<int> &sizeof_stream_items); diff --git a/gnuradio-core/src/lib/runtime/gr_local_sighandler.h b/gnuradio-core/src/lib/runtime/gr_local_sighandler.h index 6b60cf09a..9e4eacc47 100644 --- a/gnuradio-core/src/lib/runtime/gr_local_sighandler.h +++ b/gnuradio-core/src/lib/runtime/gr_local_sighandler.h @@ -27,6 +27,7 @@ #include <signal.h> #endif +#include <gr_core_api.h> #include <string> /*! @@ -36,7 +37,7 @@ * Constructor installs new handler, destructor reinstalls * original value. */ -class gr_local_sighandler { +class GR_CORE_API gr_local_sighandler { int d_signum; #ifdef HAVE_SIGACTION struct sigaction d_old_action; @@ -52,7 +53,7 @@ public: /*! * \brief Representation of signal. */ -class gr_signal +class GR_CORE_API gr_signal { int d_signum; public: diff --git a/gnuradio-core/src/lib/runtime/gr_message.h b/gnuradio-core/src/lib/runtime/gr_message.h index 179f7d9bc..ead002616 100644 --- a/gnuradio-core/src/lib/runtime/gr_message.h +++ b/gnuradio-core/src/lib/runtime/gr_message.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_MESSAGE_H #define INCLUDED_GR_MESSAGE_H +#include <gr_core_api.h> #include <gr_types.h> #include <string> @@ -31,10 +32,10 @@ typedef boost::shared_ptr<gr_message> gr_message_sptr; /*! * \brief public constructor for gr_message */ -gr_message_sptr +GR_CORE_API gr_message_sptr gr_make_message(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0); -gr_message_sptr +GR_CORE_API gr_message_sptr gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, double arg2 = 0); /*! @@ -44,7 +45,7 @@ gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, * The ideas and method names for adjustable message length were * lifted from the click modular router "Packet" class. */ -class gr_message { +class GR_CORE_API gr_message { gr_message_sptr d_next; // link field for msg queue long d_type; // type of the message double d_arg1; // optional arg1 @@ -57,10 +58,10 @@ class gr_message { gr_message (long type, double arg1, double arg2, size_t length); - friend gr_message_sptr + friend GR_CORE_API gr_message_sptr gr_make_message (long type, double arg1, double arg2, size_t length); - friend gr_message_sptr + friend GR_CORE_API gr_message_sptr gr_make_message_from_string (const std::string s, long type, double arg1, double arg2); friend class gr_msg_queue; @@ -85,6 +86,6 @@ public: }; -long gr_message_ncurrently_allocated (); +GR_CORE_API long gr_message_ncurrently_allocated (); #endif /* INCLUDED_GR_MESSAGE_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_msg_accepter.h b/gnuradio-core/src/lib/runtime/gr_msg_accepter.h index 79a631f3a..4aec127a9 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_accepter.h +++ b/gnuradio-core/src/lib/runtime/gr_msg_accepter.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_MSG_ACCEPTER_H #define INCLUDED_GR_MSG_ACCEPTER_H +#include <gr_core_api.h> #include <gruel/msg_accepter.h> #include <gruel/pmt.h> @@ -29,7 +30,7 @@ * \brief Accepts messages and inserts them into a message queue, then notifies * subclass gr_basic_block there is a message pending. */ -class gr_msg_accepter : public gruel::msg_accepter +class GR_CORE_API gr_msg_accepter : public gruel::msg_accepter { public: gr_msg_accepter(); diff --git a/gnuradio-core/src/lib/runtime/gr_msg_handler.h b/gnuradio-core/src/lib/runtime/gr_msg_handler.h index 774dce73e..ebe3ffe37 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_handler.h +++ b/gnuradio-core/src/lib/runtime/gr_msg_handler.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_MSG_HANDLER_H #define INCLUDED_GR_MSG_HANDLER_H +#include <gr_core_api.h> #include <gr_message.h> class gr_msg_handler; @@ -31,7 +32,7 @@ typedef boost::shared_ptr<gr_msg_handler> gr_msg_handler_sptr; * \brief abstract class of message handlers * \ingroup base */ -class gr_msg_handler { +class GR_CORE_API gr_msg_handler { public: virtual ~gr_msg_handler (); diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.h b/gnuradio-core/src/lib/runtime/gr_msg_queue.h index 477b1ddf1..bf7b89882 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_queue.h +++ b/gnuradio-core/src/lib/runtime/gr_msg_queue.h @@ -22,19 +22,20 @@ #ifndef INCLUDED_GR_MSG_QUEUE_H #define INCLUDED_GR_MSG_QUEUE_H +#include <gr_core_api.h> #include <gr_msg_handler.h> #include <gruel/thread.h> class gr_msg_queue; typedef boost::shared_ptr<gr_msg_queue> gr_msg_queue_sptr; -gr_msg_queue_sptr gr_make_msg_queue(unsigned int limit=0); +GR_CORE_API gr_msg_queue_sptr gr_make_msg_queue(unsigned int limit=0); /*! * \brief thread-safe message queue * \ingroup misc */ -class gr_msg_queue : public gr_msg_handler { +class GR_CORE_API gr_msg_queue : public gr_msg_handler { gruel::mutex d_mutex; gruel::condition_variable d_not_empty; diff --git a/gnuradio-core/src/lib/runtime/gr_pagesize.h b/gnuradio-core/src/lib/runtime/gr_pagesize.h index 3c1b8eb6b..60dad42c9 100644 --- a/gnuradio-core/src/lib/runtime/gr_pagesize.h +++ b/gnuradio-core/src/lib/runtime/gr_pagesize.h @@ -22,11 +22,13 @@ #ifndef _GR_PAGESIZE_H_ #define _GR_PAGESIZE_H_ +#include <gr_core_api.h> + /*! * \brief return the page size in bytes */ -int gr_pagesize (); +GR_CORE_API int gr_pagesize (); -#endif /* _GR_PAGESIZE_H_ */ +#endif /* _GR_PAGESIZE_H_ */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/runtime/gr_preferences.h b/gnuradio-core/src/lib/runtime/gr_preferences.h index 7f2a25e6b..ab4dc0cb0 100644 --- a/gnuradio-core/src/lib/runtime/gr_preferences.h +++ b/gnuradio-core/src/lib/runtime/gr_preferences.h @@ -23,10 +23,12 @@ #ifndef _GR_PREFERENCES_H_ #define _GR_PREFERENCES_H_ -class gr_preferences { +#include <gr_core_api.h> + +class GR_CORE_API gr_preferences { public: static const char *get (const char *key); static void set (const char *key, const char *value); }; -#endif /* _GR_PREFERENCES_H_ */ +#endif /* _GR_PREFERENCES_H_ */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/runtime/gr_realtime.h b/gnuradio-core/src/lib/runtime/gr_realtime.h index 830c201d7..58db83086 100644 --- a/gnuradio-core/src/lib/runtime/gr_realtime.h +++ b/gnuradio-core/src/lib/runtime/gr_realtime.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_REALTIME_H #define INCLUDED_GR_REALTIME_H +#include <gr_core_api.h> #include <gruel/realtime.h> typedef gruel::rt_status_t gr_rt_status_t; @@ -31,6 +32,6 @@ typedef gruel::rt_status_t gr_rt_status_t; * \brief If possible, enable high-priority "real time" scheduling. * \ingroup misc */ -gr_rt_status_t gr_enable_realtime_scheduling(); +GR_CORE_API gr_rt_status_t gr_enable_realtime_scheduling(); #endif /* INCLUDED_GR_REALTIME_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_runtime_types.h b/gnuradio-core/src/lib/runtime/gr_runtime_types.h index 74d2614a8..98f08b417 100644 --- a/gnuradio-core/src/lib/runtime/gr_runtime_types.h +++ b/gnuradio-core/src/lib/runtime/gr_runtime_types.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_RUNTIME_TYPES_H #define INCLUDED_GR_RUNTIME_TYPES_H +#include <gr_core_api.h> #include <gr_types.h> /* diff --git a/gnuradio-core/src/lib/runtime/gr_scheduler.h b/gnuradio-core/src/lib/runtime/gr_scheduler.h index 13bc1ff14..4e97b5881 100644 --- a/gnuradio-core/src/lib/runtime/gr_scheduler.h +++ b/gnuradio-core/src/lib/runtime/gr_scheduler.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_GR_SCHEDULER_H #define INCLUDED_GR_SCHEDULER_H +#include <gr_core_api.h> #include <boost/utility.hpp> #include <gr_block.h> #include <gr_flat_flowgraph.h> @@ -36,7 +37,7 @@ typedef boost::shared_ptr<gr_scheduler> gr_scheduler_sptr; * * Preconditions: details, buffers and buffer readers have been assigned. */ -class gr_scheduler : boost::noncopyable +class GR_CORE_API gr_scheduler : boost::noncopyable { public: diff --git a/gnuradio-core/src/lib/runtime/gr_scheduler_sts.h b/gnuradio-core/src/lib/runtime/gr_scheduler_sts.h index 4cf835156..9b73b68c1 100644 --- a/gnuradio-core/src/lib/runtime/gr_scheduler_sts.h +++ b/gnuradio-core/src/lib/runtime/gr_scheduler_sts.h @@ -21,13 +21,14 @@ #ifndef INCLUDED_GR_SCHEDULER_STS_H #define INCLUDED_GR_SCHEDULER_STS_H +#include <gr_core_api.h> #include <gr_scheduler.h> #include <gruel/thread_group.h> /*! * \brief Concrete scheduler that uses the single_threaded_scheduler */ -class gr_scheduler_sts : public gr_scheduler +class GR_CORE_API gr_scheduler_sts : public gr_scheduler { gruel::thread_group d_threads; diff --git a/gnuradio-core/src/lib/runtime/gr_scheduler_tpb.h b/gnuradio-core/src/lib/runtime/gr_scheduler_tpb.h index 16a0c0204..f97ab2e7f 100644 --- a/gnuradio-core/src/lib/runtime/gr_scheduler_tpb.h +++ b/gnuradio-core/src/lib/runtime/gr_scheduler_tpb.h @@ -21,13 +21,14 @@ #ifndef INCLUDED_GR_SCHEDULER_TPB_H #define INCLUDED_GR_SCHEDULER_TPB_H +#include <gr_core_api.h> #include <gr_scheduler.h> #include <gruel/thread_group.h> /*! * \brief Concrete scheduler that uses a kernel thread-per-block */ -class gr_scheduler_tpb : public gr_scheduler +class GR_CORE_API gr_scheduler_tpb : public gr_scheduler { gruel::thread_group d_threads; diff --git a/gnuradio-core/src/lib/runtime/gr_select_handler.h b/gnuradio-core/src/lib/runtime/gr_select_handler.h index c3808995b..532707a02 100644 --- a/gnuradio-core/src/lib/runtime/gr_select_handler.h +++ b/gnuradio-core/src/lib/runtime/gr_select_handler.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SELECT_HANDLER_H #define INCLUDED_GR_SELECT_HANDLER_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class gr_select_handler; @@ -35,7 +36,7 @@ typedef boost::shared_ptr<gr_select_handler> gr_select_handler_sptr; * * \sa gr_dispatcher */ -class gr_select_handler +class GR_CORE_API gr_select_handler { int d_fd; diff --git a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc index 7f1b40641..ae04e4a65 100644 --- a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc +++ b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc @@ -29,6 +29,7 @@ #include <gr_block_detail.h> #include <gr_buffer.h> #include <boost/thread.hpp> +#include <boost/format.hpp> #include <iostream> #include <limits> #include <assert.h> @@ -57,9 +58,8 @@ gr_single_threaded_scheduler::gr_single_threaded_scheduler ( : d_blocks (blocks), d_enabled (true), d_log(0) { if (ENABLE_LOGGING){ - char name[100]; - snprintf(name, sizeof(name), "sst-%d.log", which_scheduler++); - d_log = new std::ofstream(name); + std::string name = str(boost::format("sst-%d.log") % which_scheduler++); + d_log = new std::ofstream(name.c_str()); *d_log << "gr_single_threaded_scheduler: " << d_blocks.size () << " blocks\n"; diff --git a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h index 060d3017d..17f4a1c54 100644 --- a/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h +++ b/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SINGLE_THREADED_SCHEDULER_H #define INCLUDED_GR_SINGLE_THREADED_SCHEDULER_H +#include <gr_core_api.h> #include <gr_runtime_types.h> #include <fstream> @@ -35,7 +36,7 @@ typedef boost::shared_ptr<gr_single_threaded_scheduler> gr_single_threaded_sched * \ingroup internal */ -class gr_single_threaded_scheduler { +class GR_CORE_API gr_single_threaded_scheduler { public: ~gr_single_threaded_scheduler (); @@ -51,11 +52,11 @@ class gr_single_threaded_scheduler { void main_loop (); - friend gr_single_threaded_scheduler_sptr + friend GR_CORE_API gr_single_threaded_scheduler_sptr gr_make_single_threaded_scheduler (const std::vector<gr_block_sptr> &blocks); }; -gr_single_threaded_scheduler_sptr +GR_CORE_API gr_single_threaded_scheduler_sptr gr_make_single_threaded_scheduler (const std::vector<gr_block_sptr> &blocks); #endif /* INCLUDED_GR_SINGLE_THREADED_SCHEDULER_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_sptr_magic.h b/gnuradio-core/src/lib/runtime/gr_sptr_magic.h index 872374ab6..4b7f9899d 100644 --- a/gnuradio-core/src/lib/runtime/gr_sptr_magic.h +++ b/gnuradio-core/src/lib/runtime/gr_sptr_magic.h @@ -21,6 +21,7 @@ #ifndef INCLUDED_GR_SPTR_MAGIC_H #define INCLUDED_GR_SPTR_MAGIC_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> class gr_basic_block; @@ -30,7 +31,7 @@ namespace gnuradio { namespace detail { - class sptr_magic { + class GR_CORE_API sptr_magic { public: static boost::shared_ptr<gr_basic_block> fetch_initial_sptr(gr_basic_block *p); static void create_and_stash_initial_sptr(gr_hier_block2 *p); diff --git a/gnuradio-core/src/lib/runtime/gr_sync_block.h b/gnuradio-core/src/lib/runtime/gr_sync_block.h index c5a6a50f1..808c1c18a 100644 --- a/gnuradio-core/src/lib/runtime/gr_sync_block.h +++ b/gnuradio-core/src/lib/runtime/gr_sync_block.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SYNC_BLOCK_H #define INCLUDED_GR_SYNC_BLOCK_H +#include <gr_core_api.h> #include <gr_block.h> /*! @@ -31,7 +32,7 @@ * * Override work to provide the signal processing implementation. */ -class gr_sync_block : public gr_block +class GR_CORE_API gr_sync_block : public gr_block { protected: gr_sync_block (void){} //allows pure virtual interface sub-classes diff --git a/gnuradio-core/src/lib/runtime/gr_sync_decimator.h b/gnuradio-core/src/lib/runtime/gr_sync_decimator.h index 12cd54195..b2ed3c4fe 100644 --- a/gnuradio-core/src/lib/runtime/gr_sync_decimator.h +++ b/gnuradio-core/src/lib/runtime/gr_sync_decimator.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SYNC_DECIMATOR_H #define INCLUDED_GR_SYNC_DECIMATOR_H +#include <gr_core_api.h> #include <gr_sync_block.h> /*! @@ -31,7 +32,7 @@ * * Override work to provide the signal processing implementation. */ -class gr_sync_decimator : public gr_sync_block +class GR_CORE_API gr_sync_decimator : public gr_sync_block { private: unsigned d_decimation; diff --git a/gnuradio-core/src/lib/runtime/gr_sync_interpolator.h b/gnuradio-core/src/lib/runtime/gr_sync_interpolator.h index 0363bc55c..d65b3da1e 100644 --- a/gnuradio-core/src/lib/runtime/gr_sync_interpolator.h +++ b/gnuradio-core/src/lib/runtime/gr_sync_interpolator.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_SYNC_INTERPOLATOR_H #define INCLUDED_GR_SYNC_INTERPOLATOR_H +#include <gr_core_api.h> #include <gr_sync_block.h> /*! @@ -31,7 +32,7 @@ * * Override work to provide the signal processing implementation. */ -class gr_sync_interpolator : public gr_sync_block +class GR_CORE_API gr_sync_interpolator : public gr_sync_block { private: unsigned d_interpolation; diff --git a/gnuradio-core/src/lib/runtime/gr_sys_paths.h b/gnuradio-core/src/lib/runtime/gr_sys_paths.h index aa8249775..1f1759c36 100644 --- a/gnuradio-core/src/lib/runtime/gr_sys_paths.h +++ b/gnuradio-core/src/lib/runtime/gr_sys_paths.h @@ -22,10 +22,12 @@ #ifndef _GR_SYS_PATHS_H_ #define _GR_SYS_PATHS_H_ +#include <gr_core_api.h> + //! directory to create temporary files -const char *gr_tmp_path(); +GR_CORE_API const char *gr_tmp_path(); //! directory to store application data -const char *gr_appdata_path(); +GR_CORE_API const char *gr_appdata_path(); #endif /* _GR_SYS_PATHS_H_ */ diff --git a/gnuradio-core/src/lib/runtime/gr_tag_info.h b/gnuradio-core/src/lib/runtime/gr_tag_info.h deleted file mode 100644 index 5a1e1555a..000000000 --- a/gnuradio-core/src/lib/runtime/gr_tag_info.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_TAG_INFO_H -#define INCLUDED_GR_TAG_INFO_H - -#include <gruel/pmt.h> - -namespace gr_tags { - - enum { - TAG_NITEM_REF = 0, - TAG_SRCID_REF, - TAG_KEY_REF, - TAG_VALUE_REF - }; - - /* - extern const pmt::pmt_t key_time; - extern const pmt::pmt_t key_sample_rate; - extern const pmt::pmt_t key_frequency; - extern const pmt::pmt_t key_rssi; - extern const pmt::pmt_t key_gain; - */ - - /*! - * \brief Returns the item \p tag occurred at (as a uint64_t) - */ - static inline uint64_t - get_nitems(const pmt::pmt_t &tag) { - return pmt::pmt_to_uint64(pmt::pmt_tuple_ref(tag, TAG_NITEM_REF)); - } - - /*! - * \brief Returns the source ID of \p tag (as a PMT) - */ - static inline pmt::pmt_t - get_srcid(const pmt::pmt_t &tag) { - return pmt::pmt_tuple_ref(tag, TAG_SRCID_REF); - } - - /*! - * \brief Returns the key of \p tag (as a PMT symbol) - */ - static inline pmt::pmt_t - get_key(const pmt::pmt_t &tag) { - return pmt::pmt_tuple_ref(tag, TAG_KEY_REF); - } - - /*! - * \brief Returns the value of \p tag (as a PMT) - */ - static inline pmt::pmt_t - get_value(const pmt::pmt_t &tag) { - return pmt::pmt_tuple_ref(tag, TAG_VALUE_REF); - } - - /*! - * \brief Comparison function to test which tag, \p x or \p y, came first in time - */ - static inline bool - nitems_compare(pmt::pmt_t x, pmt::pmt_t y) { - return get_nitems(x) < get_nitems(y); - } - -}; /* namespace tags */ - -#endif /* GR_TAG_INFO */ diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.i b/gnuradio-core/src/lib/runtime/gr_tags.h index 488cab370..5fff6f15b 100644 --- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.i +++ b/gnuradio-core/src/lib/runtime/gr_tags.h @@ -1,6 +1,5 @@ -/* -*- c++ -*- */ /* - * Copyright 2005,2006 Free Software Foundation, Inc. + * Copyright 2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,25 +19,32 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,costas_loop_cc); +#ifndef INCLUDED_GR_TAGS_H +#define INCLUDED_GR_TAGS_H -gr_costas_loop_cc_sptr -gr_make_costas_loop_cc (float alpha, float beta, - float max_freq, float min_freq, - int order - ) throw (std::invalid_argument); +#include <gr_core_api.h> +#include <gruel/pmt.h> +struct GR_CORE_API gr_tag_t{ -class gr_costas_loop_cc : public gr_sync_block -{ - private: - gr_costas_loop_cc (float alpha, float beta, - float max_freq, float min_freq, int order); + //! the item \p tag occurred at (as a uint64_t) + uint64_t offset; - public: - void set_alpha(float alpha); - float alpha(); - void set_beta(float beta); - float beta(); - float freq(); + //! the key of \p tag (as a PMT symbol) + pmt::pmt_t key; + + //! the value of \p tag (as a PMT) + pmt::pmt_t value; + + //! the source ID of \p tag (as a PMT) + pmt::pmt_t srcid; + + //! Comparison function to test which tag, \p x or \p y, came first in time + static inline bool offset_compare( + const gr_tag_t &x, const gr_tag_t &y + ){ + return x.offset < y.offset; + } }; + +#endif /*INCLUDED_GR_TAGS_H*/ diff --git a/gnuradio-core/src/lib/general/gr_crc32.i b/gnuradio-core/src/lib/runtime/gr_tags.i index 7dca5c6a1..828d0147c 100644 --- a/gnuradio-core/src/lib/general/gr_crc32.i +++ b/gnuradio-core/src/lib/runtime/gr_tags.i @@ -1,27 +1,32 @@ -/* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. - * + * Copyright 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. */ -%rename(update_crc32) gr_update_crc32; -%rename(crc32) gr_crc32; +%{ +#include <gr_tags.h> +%} -unsigned int gr_update_crc32(unsigned int crc, const std::string buf); -unsigned int gr_crc32(const std::string buf); +%include <pmt_swig.i> //for pmt support + +%include <gr_tags.h> + +//gives support for a vector of tags (get tags in range) +%include "std_vector.i" +%template(tags_vector_t) std::vector<gr_tag_t>; diff --git a/gnuradio-core/src/lib/runtime/gr_timer.h b/gnuradio-core/src/lib/runtime/gr_timer.h index ff14e315d..fa3c06ece 100644 --- a/gnuradio-core/src/lib/runtime/gr_timer.h +++ b/gnuradio-core/src/lib/runtime/gr_timer.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_GR_TIMER_H #define INCLUDED_GR_TIMER_H +#include <gr_core_api.h> #include <gr_types.h> class gr_timer; typedef boost::shared_ptr<gr_timer> gr_timer_sptr; -typedef void (*gr_timer_hook)(gr_timer *, void *); +GR_CORE_API typedef void (*gr_timer_hook)(gr_timer *, void *); /*! * \brief create a timeout. @@ -36,18 +37,18 @@ typedef void (*gr_timer_hook)(gr_timer *, void *); * \ingroup misc * gr_timer_hook is called when timer fires. */ -gr_timer_sptr gr_make_timer (gr_timer_hook, void *); +GR_CORE_API gr_timer_sptr gr_make_timer (gr_timer_hook, void *); /*! * \brief implement timeouts */ -class gr_timer { +class GR_CORE_API gr_timer { double d_expiry; double d_period; gr_timer_hook d_hook; void *d_hook_arg; - friend gr_timer_sptr gr_make_timer (gr_timer_hook, void *); + friend GR_CORE_API gr_timer_sptr gr_make_timer (gr_timer_hook, void *); gr_timer (...); diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h index ed244cb7c..fca68ae71 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block.h @@ -23,21 +23,22 @@ #ifndef INCLUDED_GR_TOP_BLOCK_H #define INCLUDED_GR_TOP_BLOCK_H +#include <gr_core_api.h> #include <gr_hier_block2.h> class gr_top_block_impl; -gr_top_block_sptr gr_make_top_block(const std::string &name); +GR_CORE_API gr_top_block_sptr gr_make_top_block(const std::string &name); /*! *\brief Top-level hierarchical block representing a flowgraph * \ingroup container_blk * */ -class gr_top_block : public gr_hier_block2 +class GR_CORE_API gr_top_block : public gr_hier_block2 { private: - friend gr_top_block_sptr gr_make_top_block(const std::string &name); + friend GR_CORE_API gr_top_block_sptr gr_make_top_block(const std::string &name); gr_top_block_impl *d_impl; diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h index ef28dd829..904443be5 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_TOP_BLOCK_IMPL_H #define INCLUDED_GR_TOP_BLOCK_IMPL_H +#include <gr_core_api.h> #include <gr_scheduler.h> #include <gruel/thread.h> @@ -34,7 +35,7 @@ * decoupling of changes from dependent classes. * */ -class gr_top_block_impl +class GR_CORE_API gr_top_block_impl { public: gr_top_block_impl(gr_top_block *owner); diff --git a/gnuradio-core/src/lib/runtime/gr_tpb_detail.h b/gnuradio-core/src/lib/runtime/gr_tpb_detail.h index acfa264c7..90908c2f5 100644 --- a/gnuradio-core/src/lib/runtime/gr_tpb_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_tpb_detail.h @@ -21,6 +21,7 @@ #ifndef INCLUDED_GR_TPB_DETAIL_H #define INCLUDED_GR_TPB_DETAIL_H +#include <gr_core_api.h> #include <gruel/thread.h> #include <deque> #include <gruel/pmt.h> @@ -30,7 +31,7 @@ class gr_block_detail; /*! * \brief used by thread-per-block scheduler */ -struct gr_tpb_detail { +struct GR_CORE_API gr_tpb_detail { gruel::mutex mutex; //< protects all vars bool input_changed; diff --git a/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.h b/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.h index a630b1be9..548cfedfb 100644 --- a/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.h +++ b/gnuradio-core/src/lib/runtime/gr_tpb_thread_body.h @@ -21,6 +21,7 @@ #ifndef INCLUDED_GR_TPB_THREAD_BODY_H #define INCLUDED_GR_TPB_THREAD_BODY_H +#include <gr_core_api.h> #include <gr_block_executor.h> #include <gr_block.h> #include <gr_block_detail.h> @@ -33,7 +34,7 @@ * done or is interrupted. */ -class gr_tpb_thread_body { +class GR_CORE_API gr_tpb_thread_body { gr_block_executor d_exec; public: diff --git a/gnuradio-core/src/lib/runtime/gr_types.h b/gnuradio-core/src/lib/runtime/gr_types.h index ad8f145b8..fd5ca7758 100644 --- a/gnuradio-core/src/lib/runtime/gr_types.h +++ b/gnuradio-core/src/lib/runtime/gr_types.h @@ -23,6 +23,7 @@ #ifndef INCLUDED_GR_TYPES_H #define INCLUDED_GR_TYPES_H +#include <gr_core_api.h> #include <boost/shared_ptr.hpp> #include <vector> #include <stddef.h> // size_t diff --git a/gnuradio-core/src/lib/runtime/gr_unittests.h b/gnuradio-core/src/lib/runtime/gr_unittests.h index 59149bb2e..7161b31e7 100644 --- a/gnuradio-core/src/lib/runtime/gr_unittests.h +++ b/gnuradio-core/src/lib/runtime/gr_unittests.h @@ -24,12 +24,14 @@ #include "config.h" #endif +#include <gr_core_api.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> +#include <string> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/path.hpp> diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc b/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc index 3b8a6e617..7138605c9 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc @@ -30,6 +30,8 @@ #include <stdio.h> #include <string.h> #include <gr_local_sighandler.h> +#include <vector> +#include <boost/format.hpp> // all the factories we know about #include <gr_vmcircbuf_createfilemapping.h> @@ -130,7 +132,7 @@ init_buffer (gr_vmcircbuf *c, int counter, int size) } static bool -check_mapping (gr_vmcircbuf *c, int counter, int size, char *msg, bool verbose) +check_mapping (gr_vmcircbuf *c, int counter, int size, const char *msg, bool verbose) { bool ok = true; @@ -163,28 +165,28 @@ check_mapping (gr_vmcircbuf *c, int counter, int size, char *msg, bool verbose) return ok; } -static char * +static const char * memsize (int size) { - static char buf[100]; + static std::string buf; if (size >= (1 << 20)){ - snprintf (buf, sizeof (buf), "%dMB", size / (1 << 20)); + buf = str(boost::format("%dMB") % (size / (1 << 20))); } else if (size >= (1 << 10)){ - snprintf (buf, sizeof (buf), "%dKB", size / (1 << 10)); + buf = str(boost::format("%dKB") % (size / (1 << 10))); } else { - snprintf (buf, sizeof (buf), "%d", size); + buf = str(boost::format("%d") % size); } - return buf; + return buf.c_str(); } static bool test_a_bunch (gr_vmcircbuf_factory *factory, int n, int size, int *start_ptr, bool verbose) { bool ok = true; - int counter[n]; - gr_vmcircbuf *c[n]; + std::vector<int> counter(n); + std::vector<gr_vmcircbuf *> c(n); int cum_size = 0; for (int i = 0; i < n; i++){ @@ -202,9 +204,8 @@ test_a_bunch (gr_vmcircbuf_factory *factory, int n, int size, int *start_ptr, bo } for (int i = 0; i < n; i++){ - char msg[100]; - snprintf (msg, sizeof (msg), "test_a_bunch_%dx%s[%d]", n, memsize (size), i); - ok &= check_mapping (c[i], counter[i], size, msg, verbose); + std::string msg = str(boost::format("test_a_bunch_%dx%s[%d]") % n % memsize (size) % i); + ok &= check_mapping (c[i], counter[i], size, msg.c_str(), verbose); } for (int i = 0; i < n; i++){ diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h b/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h index a73a1559c..0e67d405b 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h @@ -23,13 +23,14 @@ #ifndef _GR_VMCIRCBUF_H_ #define _GR_VMCIRCBUF_H_ +#include <gr_core_api.h> #include <vector> /*! * \brief abstract class to implement doubly mapped virtual memory circular buffers * \ingroup internal */ -class gr_vmcircbuf { +class GR_CORE_API gr_vmcircbuf { protected: int d_size; char *d_base; @@ -48,7 +49,7 @@ class gr_vmcircbuf { /*! * \brief abstract factory for creating circular buffers */ -class gr_vmcircbuf_factory { +class GR_CORE_API gr_vmcircbuf_factory { protected: gr_vmcircbuf_factory () {}; virtual ~gr_vmcircbuf_factory (); @@ -76,7 +77,7 @@ class gr_vmcircbuf_factory { /* * \brief pulls together all implementations of gr_vmcircbuf */ -class gr_vmcircbuf_sysconfig { +class GR_CORE_API gr_vmcircbuf_sysconfig { public: /* diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc index 42c459484..1b4d9700a 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc @@ -37,6 +37,7 @@ #include <stdio.h> #include <gr_pagesize.h> #include <gr_vmcircbuf_createfilemapping.h> +#include <boost/format.hpp> #ifdef HAVE_CREATEFILEMAPPING // Print Windows error (could/should be global?) @@ -72,23 +73,21 @@ gr_vmcircbuf_createfilemapping::gr_vmcircbuf_createfilemapping (int size) throw std::runtime_error ("gr_vmcircbuf_createfilemapping"); } - char seg_name[1024]; - snprintf (seg_name, sizeof (seg_name), "/gnuradio-%d-%d", getpid (), s_seg_counter); + std::string seg_name = str(boost::format("/gnuradio-%d-%d") % getpid () % s_seg_counter); d_handle = CreateFileMapping(INVALID_HANDLE_VALUE, // use paging file NULL, // default security PAGE_READWRITE, // read/write access 0, // max. object size size, // buffer size - seg_name); // name of mapping object + seg_name.c_str()); // name of mapping object s_seg_counter++; if (d_handle == NULL || d_handle == INVALID_HANDLE_VALUE){ - char msg[1024]; - snprintf( msg, sizeof(msg), - "gr_vmcircbuf_mmap_createfilemapping: CreateFileMapping [%s]", + std::string msg = str(boost::format( + "gr_vmcircbuf_mmap_createfilemapping: CreateFileMapping [%s]") % seg_name ); - werror( msg, GetLastError() ); + werror((char *) msg.c_str(), GetLastError() ); throw std::runtime_error ("gr_vmcircbuf_mmap_createfilemapping"); } diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.h b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.h index 9276ae98b..5ef31f5c6 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.h +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.h @@ -23,6 +23,7 @@ #ifndef _GR_VMCIRCBUF_CREATEFILEMAPPING_H_ #define _GR_VMCIRCBUF_CREATEFILEMAPPING_H_ +#include <gr_core_api.h> #include <gr_vmcircbuf.h> #ifdef HAVE_CREATEFILEMAPPING @@ -32,7 +33,7 @@ * \brief concrete class to implement circular buffers with mmap and shm_open * \ingroup internal */ -class gr_vmcircbuf_createfilemapping : public gr_vmcircbuf +class GR_CORE_API gr_vmcircbuf_createfilemapping : public gr_vmcircbuf { public: // CREATORS @@ -49,7 +50,7 @@ class gr_vmcircbuf_createfilemapping : public gr_vmcircbuf /*! * \brief concrete factory for circular buffers built using mmap and shm_open */ -class gr_vmcircbuf_createfilemapping_factory : public gr_vmcircbuf_factory +class GR_CORE_API gr_vmcircbuf_createfilemapping_factory : public gr_vmcircbuf_factory { private: static gr_vmcircbuf_factory *s_the_factory; diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.h b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.h index 238f44414..002f5b434 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.h +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.h @@ -23,13 +23,14 @@ #ifndef _GR_VMCIRCBUF_MMAP_SHM_OPEN_H_ #define _GR_VMCIRCBUF_MMAP_SHM_OPEN_H_ +#include <gr_core_api.h> #include <gr_vmcircbuf.h> /*! * \brief concrete class to implement circular buffers with mmap and shm_open * \ingroup internal */ -class gr_vmcircbuf_mmap_shm_open : public gr_vmcircbuf { +class GR_CORE_API gr_vmcircbuf_mmap_shm_open : public gr_vmcircbuf { public: // CREATORS @@ -41,7 +42,7 @@ class gr_vmcircbuf_mmap_shm_open : public gr_vmcircbuf { /*! * \brief concrete factory for circular buffers built using mmap and shm_open */ -class gr_vmcircbuf_mmap_shm_open_factory : public gr_vmcircbuf_factory { +class GR_CORE_API gr_vmcircbuf_mmap_shm_open_factory : public gr_vmcircbuf_factory { private: static gr_vmcircbuf_factory *s_the_factory; diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.h b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.h index e5be52768..a2ed6b87b 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.h +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.h @@ -23,13 +23,14 @@ #ifndef _GR_VMCIRCBUF_MMAP_TMPFILE_H_ #define _GR_VMCIRCBUF_MMAP_TMPFILE_H_ +#include <gr_core_api.h> #include <gr_vmcircbuf.h> /*! * \brief concrete class to implement circular buffers with mmap and shm_open * \ingroup internal */ -class gr_vmcircbuf_mmap_tmpfile : public gr_vmcircbuf { +class GR_CORE_API gr_vmcircbuf_mmap_tmpfile : public gr_vmcircbuf { public: // CREATORS @@ -41,7 +42,7 @@ class gr_vmcircbuf_mmap_tmpfile : public gr_vmcircbuf { /*! * \brief concrete factory for circular buffers built using mmap and shm_open */ -class gr_vmcircbuf_mmap_tmpfile_factory : public gr_vmcircbuf_factory { +class GR_CORE_API gr_vmcircbuf_mmap_tmpfile_factory : public gr_vmcircbuf_factory { private: static gr_vmcircbuf_factory *s_the_factory; diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_sysv_shm.h b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_sysv_shm.h index cc87f8fe6..c7a008581 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_sysv_shm.h +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_sysv_shm.h @@ -23,13 +23,14 @@ #ifndef _GR_VMCIRCBUF_SYSV_SHM_H_ #define _GR_VMCIRCBUF_SYSV_SHM_H_ +#include <gr_core_api.h> #include <gr_vmcircbuf.h> /*! * \brief concrete class to implement circular buffers with mmap and shm_open * \ingroup internal */ -class gr_vmcircbuf_sysv_shm : public gr_vmcircbuf { +class GR_CORE_API gr_vmcircbuf_sysv_shm : public gr_vmcircbuf { public: // CREATORS @@ -41,7 +42,7 @@ class gr_vmcircbuf_sysv_shm : public gr_vmcircbuf { /*! * \brief concrete factory for circular buffers built using mmap and shm_open */ -class gr_vmcircbuf_sysv_shm_factory : public gr_vmcircbuf_factory { +class GR_CORE_API gr_vmcircbuf_sysv_shm_factory : public gr_vmcircbuf_factory { private: static gr_vmcircbuf_factory *s_the_factory; diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index 07ce5c276..ab5840c6d 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -103,9 +103,9 @@ qa_block_tags::t1 () tb->run(); - std::vector<pmt::pmt_t> tags0 = ann0->data(); - std::vector<pmt::pmt_t> tags3 = ann3->data(); - std::vector<pmt::pmt_t> tags4 = ann4->data(); + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags3 = ann3->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); @@ -187,11 +187,11 @@ qa_block_tags::t2 () tb->run(); - std::vector<pmt::pmt_t> tags0 = ann0->data(); - std::vector<pmt::pmt_t> tags1 = ann1->data(); - std::vector<pmt::pmt_t> tags2 = ann2->data(); - std::vector<pmt::pmt_t> tags3 = ann4->data(); - std::vector<pmt::pmt_t> tags4 = ann4->data(); + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags1 = ann1->data(); + std::vector<gr_tag_t> tags2 = ann2->data(); + std::vector<gr_tag_t> tags3 = ann4->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); @@ -287,9 +287,9 @@ qa_block_tags::t3 () tb->run(); - std::vector<pmt::pmt_t> tags0 = ann0->data(); - std::vector<pmt::pmt_t> tags3 = ann3->data(); - std::vector<pmt::pmt_t> tags4 = ann4->data(); + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags3 = ann3->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); @@ -394,9 +394,9 @@ qa_block_tags::t5 () tb->run(); - std::vector<pmt::pmt_t> tags0 = ann0->data(); - std::vector<pmt::pmt_t> tags1 = ann1->data(); - std::vector<pmt::pmt_t> tags2 = ann2->data(); + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags1 = ann1->data(); + std::vector<gr_tag_t> tags2 = ann2->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); diff --git a/gnuradio-core/src/lib/runtime/qa_runtime.h b/gnuradio-core/src/lib/runtime/qa_runtime.h index c55208c39..e1038aaf6 100644 --- a/gnuradio-core/src/lib/runtime/qa_runtime.h +++ b/gnuradio-core/src/lib/runtime/qa_runtime.h @@ -23,11 +23,12 @@ #ifndef _QA_RUNTIME_H_ #define _QA_RUNTIME_H_ +#include <gruel/attributes.h> #include <cppunit/TestSuite.h> //! collect all the tests for the runtime directory -class qa_runtime { +class __GR_ATTR_EXPORT qa_runtime { public: //! return suite of tests for all of runtime directory static CppUnit::TestSuite *suite (); diff --git a/gnuradio-core/src/lib/runtime/runtime.i b/gnuradio-core/src/lib/runtime/runtime.i index ca89b8fbd..9bf2df31e 100644 --- a/gnuradio-core/src/lib/runtime/runtime.i +++ b/gnuradio-core/src/lib/runtime/runtime.i @@ -20,6 +20,8 @@ * Boston, MA 02110-1301, USA. */ +#define GR_CORE_API + %{ #include <gr_runtime_types.h> #include <gr_io_signature.h> diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt new file mode 100644 index 000000000..b10b7c186 --- /dev/null +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -0,0 +1,93 @@ +# Copyright 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. + +######################################################################## +include(GrPython) +include(GrSwig) + +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +set(GR_SWIG_INCLUDE_DIRS + ${Boost_INCLUDE_DIRS} + ${GSL_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} +) +set(GR_SWIG_LIBRARIES gnuradio-core) + +######################################################################## +# Build and install the swig targets +######################################################################## +# ---------------------------------------------------------------- +# We've split the previously monstrous gnuradio_corethon into 6 +# smaller pieces. This reduces compile time coupling and creates +# smaller pieces for the compiler to digest. prior to this change, on +# X86_64, g++'s resident set size was 650MB! +# ---------------------------------------------------------------- + +set(GR_SWIG_TARGET_DEPS gengen_generated gengen_generated_index filter_generated) + +GR_SWIG_MAKE(gnuradio_core_runtime gnuradio_core_runtime.i) +GR_SWIG_MAKE(gnuradio_core_general gnuradio_core_general.i) +GR_SWIG_MAKE(gnuradio_core_gengen gnuradio_core_gengen.i) +GR_SWIG_MAKE(gnuradio_core_filter gnuradio_core_filter.i) +GR_SWIG_MAKE(gnuradio_core_io gnuradio_core_io.i) +GR_SWIG_MAKE(gnuradio_core_hier gnuradio_core_hier.i) + +GR_SWIG_INSTALL(TARGETS + gnuradio_core_runtime + gnuradio_core_general + gnuradio_core_gengen + gnuradio_core_filter + gnuradio_core_io + gnuradio_core_hier + DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr + COMPONENT "core_python" +) + +######################################################################## +# Install various files +######################################################################## +install(FILES + gnuradio.i + gr_swig_block_magic.i + gr_shared_ptr.i + gnuradio_core_runtime.i + gnuradio_core_general.i + gnuradio_core_gengen.i + gnuradio_core_filter.i + gnuradio_core_io.i + gnuradio_core_hier.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" +) + +GR_PYTHON_INSTALL( + FILES gnuradio_core.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr + COMPONENT "core_python" +) + +install( + FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio_swig_bug_workaround.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_swig" +) diff --git a/gnuradio-core/src/lib/swig/Makefile.am b/gnuradio-core/src/lib/swig/Makefile.am index f8e7640ae..d304a2123 100644 --- a/gnuradio-core/src/lib/swig/Makefile.am +++ b/gnuradio-core/src/lib/swig/Makefile.am @@ -45,7 +45,7 @@ TOP_SWIG_IFILES = \ swiginclude_HEADERS = \ gnuradio.i \ gr_swig_block_magic.i \ - gr_shared_ptr.i + gr_shared_ptr.i # SWIG headers that get installed in ${prefix}/include/gnuradio/swig/... nobase_swiginclude_HEADERS = \ diff --git a/gnuradio-core/src/lib/swig/Makefile.swig.gen b/gnuradio-core/src/lib/swig/Makefile.swig.gen index 0c3247565..cede68817 100644 --- a/gnuradio-core/src/lib/swig/Makefile.swig.gen +++ b/gnuradio-core/src/lib/swig/Makefile.swig.gen @@ -105,7 +105,7 @@ _gnuradio_core_runtime_la_CXXFLAGS = \ $(gnuradio_core_runtime_la_swig_cxxflags) python/gnuradio_core_runtime.cc: gnuradio_core_runtime.py -gnuradio_core_runtime.py: gnuradio_core_runtime.i +gnuradio_core_runtime.py: gnuradio_core_runtime.i # Include the python dependencies for this file -include python/gnuradio_core_runtime.d @@ -250,7 +250,7 @@ _gnuradio_core_general_la_CXXFLAGS = \ $(gnuradio_core_general_la_swig_cxxflags) python/gnuradio_core_general.cc: gnuradio_core_general.py -gnuradio_core_general.py: gnuradio_core_general.i +gnuradio_core_general.py: gnuradio_core_general.i # Include the python dependencies for this file -include python/gnuradio_core_general.d @@ -395,7 +395,7 @@ _gnuradio_core_gengen_la_CXXFLAGS = \ $(gnuradio_core_gengen_la_swig_cxxflags) python/gnuradio_core_gengen.cc: gnuradio_core_gengen.py -gnuradio_core_gengen.py: gnuradio_core_gengen.i +gnuradio_core_gengen.py: gnuradio_core_gengen.i # Include the python dependencies for this file -include python/gnuradio_core_gengen.d @@ -540,7 +540,7 @@ _gnuradio_core_filter_la_CXXFLAGS = \ $(gnuradio_core_filter_la_swig_cxxflags) python/gnuradio_core_filter.cc: gnuradio_core_filter.py -gnuradio_core_filter.py: gnuradio_core_filter.i +gnuradio_core_filter.py: gnuradio_core_filter.i # Include the python dependencies for this file -include python/gnuradio_core_filter.d @@ -685,7 +685,7 @@ _gnuradio_core_io_la_CXXFLAGS = \ $(gnuradio_core_io_la_swig_cxxflags) python/gnuradio_core_io.cc: gnuradio_core_io.py -gnuradio_core_io.py: gnuradio_core_io.i +gnuradio_core_io.py: gnuradio_core_io.i # Include the python dependencies for this file -include python/gnuradio_core_io.d @@ -830,7 +830,7 @@ _gnuradio_core_hier_la_CXXFLAGS = \ $(gnuradio_core_hier_la_swig_cxxflags) python/gnuradio_core_hier.cc: gnuradio_core_hier.py -gnuradio_core_hier.py: gnuradio_core_hier.i +gnuradio_core_hier.py: gnuradio_core_hier.i # Include the python dependencies for this file -include python/gnuradio_core_hier.d diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_general.i b/gnuradio-core/src/lib/swig/gnuradio_core_general.i index adf6b469a..b34d4f936 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_core_general.i +++ b/gnuradio-core/src/lib/swig/gnuradio_core_general.i @@ -19,6 +19,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define GR_CORE_API + #ifndef SWIGIMPORTED %module(directors="1") gnuradio_core_general #endif diff --git a/gnuradio-core/src/lib/viterbi/CMakeLists.txt b/gnuradio-core/src/lib/viterbi/CMakeLists.txt new file mode 100644 index 000000000..add5c77e8 --- /dev/null +++ b/gnuradio-core/src/lib/viterbi/CMakeLists.txt @@ -0,0 +1,63 @@ +# Copyright 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. + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +set(viterbi_sources + ${CMAKE_CURRENT_SOURCE_DIR}/metrics.c + ${CMAKE_CURRENT_SOURCE_DIR}/tab.c + ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.c +) + +######################################################################## +# define missing erf function with C linkage (hack for metrics.c) +######################################################################## +if(MSVC) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/boost_math_erf.cc " +#include <boost/math/special_functions/erf.hpp> +extern \"C\" double erf(double x){ + return boost::math::erf(x); +} +") +list(APPEND viterbi_sources ${CMAKE_CURRENT_BINARY_DIR}/boost_math_erf.cc) +endif(MSVC) + +######################################################################## +# Append gnuradio-core library sources +######################################################################## +list(APPEND gnuradio_core_sources ${viterbi_sources}) + +######################################################################## +# Install runtime headers +######################################################################## +install( + FILES ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_devel" +) + +######################################################################## +# Create some text executables (not registered tests) +# Its not much to build so the sources are just re-listed, +# rather than create a new library just for these two apps. +######################################################################## +#ADD_EXECUTABLE(viterbi_encode ${CMAKE_CURRENT_SOURCE_DIR}/encode.cc ${viterbi_sources}) +#ADD_EXECUTABLE(viterbi_decode ${CMAKE_CURRENT_SOURCE_DIR}/decode.cc ${viterbi_sources}) diff --git a/gnuradio-core/src/lib/viterbi/Makefile.am b/gnuradio-core/src/lib/viterbi/Makefile.am index 8384c52f0..7e65880b3 100644 --- a/gnuradio-core/src/lib/viterbi/Makefile.am +++ b/gnuradio-core/src/lib/viterbi/Makefile.am @@ -21,6 +21,10 @@ include $(top_srcdir)/Makefile.common LIBS = -lm +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(GRUEL_INCLUDES) \ + -I$(top_srcdir)/gnuradio-core/src/lib/general \ + $(WITH_INCLUDES) + noinst_LTLIBRARIES = libviterbi.la libviterbi_la_SOURCES = \ diff --git a/gnuradio-core/src/lib/viterbi/metrics.c b/gnuradio-core/src/lib/viterbi/metrics.c index 9f958cab7..77c6a63c8 100644 --- a/gnuradio-core/src/lib/viterbi/metrics.c +++ b/gnuradio-core/src/lib/viterbi/metrics.c @@ -42,6 +42,9 @@ #include <stdlib.h> #include <math.h> +//declare erf in case it was missing in math.h and provided for by the build system +extern double erf(double x); + /* Normal function integrated from -Inf to x. Range: 0-1 */ #define normal(x) (0.5 + 0.5*erf((x)/M_SQRT2)) diff --git a/gnuradio-core/src/lib/viterbi/viterbi.h b/gnuradio-core/src/lib/viterbi/viterbi.h index 155b0d93a..3a3ea5615 100644 --- a/gnuradio-core/src/lib/viterbi/viterbi.h +++ b/gnuradio-core/src/lib/viterbi/viterbi.h @@ -23,27 +23,31 @@ * than we'd like for K=7, especially since we chain back every 8 bits. * But it fits so nicely into a 32-bit machine word... */ + +#include <gr_core_api.h> + struct viterbi_state { unsigned long path; /* Decoded path to this state */ long metric; /* Cumulative metric to this state */ }; +GR_CORE_API int gen_met(int mettab[2][256], /* Metric table */ int amp, /* Signal amplitude */ double esn0, /* Es/N0 ratio in dB */ double bias, /* Metric bias */ int scale); /* Scale factor */ -unsigned char +GR_CORE_API unsigned char encode(unsigned char *symbols, unsigned char *data, unsigned int nbytes,unsigned char encstate); -void +GR_CORE_API void viterbi_chunks_init(struct viterbi_state* state); -void + GR_CORE_API void viterbi_butterfly2(unsigned char *symbols, int mettab[2][256], struct viterbi_state *state0, struct viterbi_state *state1); -unsigned char +GR_CORE_API unsigned char viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf); diff --git a/gnuradio-core/src/python/build_utils.py b/gnuradio-core/src/python/build_utils.py index c7acf6bd0..90c7978f2 100644 --- a/gnuradio-core/src/python/build_utils.py +++ b/gnuradio-core/src/python/build_utils.py @@ -93,7 +93,7 @@ def output_makefile_fragment (): return # overwrite the source, which must be writable; this should have been # checked for beforehand in the top-level Makefile.gen.gen . - f = open_src ('Makefile.gen', 'w') + f = open (os.path.join (os.environ.get('gendir', os.environ.get('srcdir', '.')), 'Makefile.gen'), 'w') f.write ('#\n# This file is machine generated. All edits will be overwritten\n#\n') output_subfrag (f, 'h') output_subfrag (f, 'i') diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/crc.py b/gnuradio-core/src/python/gnuradio/CMakeLists.txt index d31aca0ea..8d04b183d 100644 --- a/gnuradio-core/src/python/gnuradio/gruimpl/crc.py +++ b/gnuradio-core/src/python/gnuradio/CMakeLists.txt @@ -1,38 +1,39 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. # -# Copyright 2005,2007 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 -from hexint import * -import struct +include(GrPython) -def gen_and_append_crc32(s): - crc = gr.crc32(s) - return s + struct.pack(">I", hexint(crc) & 0xFFFFFFFF) +add_subdirectory(gr) +add_subdirectory(gru) +add_subdirectory(gruimpl) +add_subdirectory(blks2) +add_subdirectory(blks2impl) -def check_crc32(s): - if len(s) < 4: - return (False, '') - msg = s[:-4] - #print "msg = '%s'" % (msg,) - actual = gr.crc32(msg) - (expected,) = struct.unpack(">I", s[-4:]) - # print "actual =", hex(actual), "expected =", hex(expected) - return (actual == expected, msg) +GR_PYTHON_INSTALL(FILES + __init__.py + eng_notation.py + eng_option.py + gr_unittest.py + gr_xmlrunner.py + optfir.py + usrp_options.py + window.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio + COMPONENT "core_python" +) diff --git a/gnuradio-core/src/python/gnuradio/Makefile.am b/gnuradio-core/src/python/gnuradio/Makefile.am index eff35e95c..ffc171b2d 100644 --- a/gnuradio-core/src/python/gnuradio/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/Makefile.am @@ -22,19 +22,14 @@ include $(top_srcdir)/Makefile.common if PYTHON -SUBDIRS = gr gru gruimpl blks2 blks2impl vocoder +SUBDIRS = gr gru gruimpl blks2 blks2impl grpython_PYTHON = \ __init__.py \ eng_notation.py \ eng_option.py \ - modulation_utils.py \ - modulation_utils2.py \ - ofdm_packet_utils.py \ - packet_utils.py \ gr_unittest.py \ gr_xmlrunner.py \ optfir.py \ - usrp_options.py \ window.py endif diff --git a/gnuradio-core/src/lib/g72x/Makefile.am b/gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt index d2700376f..83d11dd83 100644 --- a/gnuradio-core/src/lib/g72x/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/blks2/CMakeLists.txt @@ -1,27 +1,26 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. # -# Copyright 2001 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. -# - -include $(top_srcdir)/Makefile.common -noinst_LTLIBRARIES = libccitt.la -libccitt_la_SOURCES = g711.c g72x.c g721.c g723_24.c g723_40.c g72x.h +include(GrPython) -EXTRA_DIST += encode.c decode.c +GR_PYTHON_INSTALL( + FILES __init__.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/blks2 + COMPONENT "core_python" +) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt new file mode 100644 index 000000000..dd0c201a3 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt @@ -0,0 +1,46 @@ +# Copyright 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. + +include(GrPython) + +GR_PYTHON_INSTALL(FILES + __init__.py + am_demod.py + channel_model.py + filterbank.py + fm_demod.py + fm_emph.py + generic_usrp.py + logpwrfft.py + nbfm_rx.py + nbfm_tx.py + pfb_arb_resampler.py + pfb_channelizer.py + pfb_decimator.py + pfb_interpolator.py + rational_resampler.py + standard_squelch.py + stream_to_vector_decimator.py + wfm_rcv.py + wfm_rcv_fmdet.py + wfm_rcv_pll.py + wfm_tx.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/blks2impl + COMPONENT "core_python" +) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am index 7b24fb69d..eb031cd20 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am @@ -30,37 +30,16 @@ grblkspython_PYTHON = \ __init__.py \ am_demod.py \ channel_model.py \ - dbpsk.py \ - dbpsk2.py \ - dqpsk.py \ - dqpsk2.py \ - d8psk.py \ filterbank.py \ fm_demod.py \ fm_emph.py \ - generic_usrp.py \ - gmsk.py \ - cpm.py \ logpwrfft.py \ nbfm_rx.py \ nbfm_tx.py \ - ofdm.py \ - ofdm_receiver.py \ - ofdm_sync_fixed.py \ - ofdm_sync_pn.py \ - ofdm_sync_pnac.py \ - ofdm_sync_ml.py \ pfb_arb_resampler.py \ pfb_channelizer.py \ pfb_decimator.py \ pfb_interpolator.py \ - pkt.py \ - psk.py \ - qam.py \ - qam8.py \ - qam16.py \ - qam64.py \ - qam256.py \ rational_resampler.py \ standard_squelch.py \ stream_to_vector_decimator.py \ diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/cpm.py b/gnuradio-core/src/python/gnuradio/blks2impl/cpm.py deleted file mode 100644 index 8f593cd51..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/cpm.py +++ /dev/null @@ -1,249 +0,0 @@ -# -# CPM modulation and demodulation. -# -# -# Copyright 2005,2006,2007 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. -# - -# See gnuradio-examples/python/digital for examples - -from gnuradio import gr -from gnuradio import modulation_utils -from math import pi -import numpy -from pprint import pprint -import inspect - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_bits_per_symbol = 1 -_def_h_numerator = 1 -_def_h_denominator = 2 -_def_cpm_type = 0 # 0=CPFSK, 1=GMSK, 2=RC, 3=GENERAL -_def_bt = 0.35 -_def_symbols_per_pulse = 1 -_def_generic_taps = numpy.empty(1) -_def_verbose = False -_def_log = False - - -# ///////////////////////////////////////////////////////////////////////////// -# CPM modulator -# ///////////////////////////////////////////////////////////////////////////// - -class cpm_mod(gr.hier_block2): - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - bits_per_symbol=_def_bits_per_symbol, - h_numerator=_def_h_numerator, - h_denominator=_def_h_denominator, - cpm_type=_def_cpm_type, - bt=_def_bt, - symbols_per_pulse=_def_symbols_per_pulse, - generic_taps=_def_generic_taps, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for Continuous Phase - modulation. - - The input is a byte stream (unsigned char) - representing packed bits and the - output is the complex modulated signal at baseband. - - See Proakis for definition of generic CPM signals: - s(t)=exp(j phi(t)) - phi(t)= 2 pi h int_0^t f(t') dt' - f(t)=sum_k a_k g(t-kT) - (normalizing assumption: int_0^infty g(t) dt = 1/2) - - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param bits_per_symbol: bits per symbol - @type bits_per_symbol: integer - @param h_numerator: numerator of modulation index - @type h_numerator: integer - @param h_denominator: denominator of modulation index (numerator and denominator must be relative primes) - @type h_denominator: integer - @param cpm_type: supported types are: 0=CPFSK, 1=GMSK, 2=RC, 3=GENERAL - @type cpm_type: integer - @param bt: bandwidth symbol time product for GMSK - @type bt: float - @param symbols_per_pulse: shaping pulse duration in symbols - @type symbols_per_pulse: integer - @param generic_taps: define a generic CPM pulse shape (sum = samples_per_symbol/2) - @type generic_taps: array of floats - - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modulation data to files? - @type debug: bool - """ - - gr.hier_block2.__init__("cpm_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._bits_per_symbol = bits_per_symbol - self._h_numerator = h_numerator - self._h_denominator = h_denominator - self._cpm_type = cpm_type - self._bt=bt - if cpm_type == 0 or cpm_type == 2 or cpm_type == 3: # CPFSK, RC, Generic - self._symbols_per_pulse = symbols_per_pulse - elif cpm_type == 1: # GMSK - self._symbols_per_pulse = 4 - else: - raise TypeError, ("cpm_type must be an integer in {0,1,2,3}, is %r" % (cpm_type,)) - - self._generic_taps=numpy.array(generic_taps) - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,)) - - self.nsymbols = 2**bits_per_symbol - self.sym_alphabet=numpy.arange(-(self.nsymbols-1),self.nsymbols,2) - - - self.ntaps = self._symbols_per_pulse * samples_per_symbol - sensitivity = 2 * pi * h_numerator / h_denominator / samples_per_symbol - - # Unpack Bytes into bits_per_symbol groups - self.B2s = gr.packed_to_unpacked_bb(bits_per_symbol,gr.GR_MSB_FIRST) - - - # Turn it into symmetric PAM data. - self.pam = gr.chunks_to_symbols_bf(self.sym_alphabet,1) - - # Generate pulse (sum of taps = samples_per_symbol/2) - if cpm_type == 0: # CPFSK - self.taps= (1.0/self._symbols_per_pulse/2,) * self.ntaps - elif cpm_type == 1: # GMSK - gaussian_taps = gr.firdes.gaussian( - 1.0/2, # gain - samples_per_symbol, # symbol_rate - bt, # bandwidth * symbol time - self.ntaps # number of taps - ) - sqwave = (1,) * samples_per_symbol # rectangular window - self.taps = numpy.convolve(numpy.array(gaussian_taps),numpy.array(sqwave)) - elif cpm_type == 2: # Raised Cosine - # generalize it for arbitrary roll-off factor - self.taps = (1-numpy.cos(2*pi*numpy.arange(0,self.ntaps)/samples_per_symbol/self._symbols_per_pulse))/(2*self._symbols_per_pulse) - elif cpm_type == 3: # Generic CPM - self.taps = generic_taps - else: - raise TypeError, ("cpm_type must be an integer in {0,1,2,3}, is %r" % (cpm_type,)) - - self.filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps) - - # FM modulation - self.fmmod = gr.frequency_modulator_fc(sensitivity) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.B2s, self.pam, self.filter, self.fmmod, self) - - #def samples_per_symbol(self): - #return self._samples_per_symbol - - #def bits_per_symbol(self): - #return self._bits_per_symbol - - #def h_numerator(self): - #return self._h_numerator - - #def h_denominator(self): - #return self._h_denominator - - #def cpm_type(self): - #return self._cpm_type - - #def bt(self): - #return self._bt - - #def symbols_per_pulse(self): - #return self._symbols_per_pulse - - - def _print_verbage(self): - print "Samples per symbol = %d" % self._samples_per_symbol - print "Bits per symbol = %d" % self._bits_per_symbol - print "h = " , self._h_numerator , " / " , self._h_denominator - print "Symbol alphabet = " , self.sym_alphabet - print "Symbols per pulse = %d" % self._symbols_per_pulse - print "taps = " , self.taps - - print "CPM type = %d" % self._cpm_type - if self._cpm_type == 1: - print "Gaussian filter BT = %.2f" % self._bt - - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.B2s, - gr.file_sink(gr.sizeof_float, "symbols.dat")) - self.connect(self.pam, - gr.file_sink(gr.sizeof_float, "pam.dat")) - self.connect(self.filter, - gr.file_sink(gr.sizeof_float, "filter.dat")) - self.connect(self.fmmod, - gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) - - - def add_options(parser): - """ - Adds CPM modulation-specific options to the standard parser - """ - parser.add_option("", "--bt", type="float", default=_def_bt, - help="set bandwidth-time product [default=%default] (GMSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(cpm_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - - -# ///////////////////////////////////////////////////////////////////////////// -# CPM demodulator -# ///////////////////////////////////////////////////////////////////////////// -# -# Not yet implemented -# - - - -# -# Add these to the mod/demod registry -# -modulation_utils.add_type_1_mod('cpm', cpm_mod) -#modulation_utils.add_type_1_demod('cpm', cpm_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/d8psk.py b/gnuradio-core/src/python/gnuradio/blks2impl/d8psk.py deleted file mode 100644 index 67cf9f569..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/d8psk.py +++ /dev/null @@ -1,363 +0,0 @@ -# -# Copyright 2005,2006,2007 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -differential 8PSK modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils -from math import pi, sqrt -import psk -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 3 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_costas_alpha = 0.175 -_def_gain_mu = 0.175 -_def_mu = 0.5 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# D8PSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class d8psk_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "d8psk_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol) - - ntaps = 11 * samples_per_symbol - - arity = pow(2,self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - rot = 1 - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const) - - # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( - self._samples_per_symbol, # gain (sps since we're interpolating by sps) - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - - self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect & Initialize base class - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 3 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "Gray code = %s" % self._gray_code - print "RS roll-off factor = %f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) - - def add_options(parser): - """ - Adds 8PSK modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(d8psk_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# D8PSK demodulator -# -# Differentially coherent detection of differentially encoded 8psk -# ///////////////////////////////////////////////////////////////////////////// - -class d8psk_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - costas_alpha=_def_costas_alpha, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered DQPSK demodulation - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (LSB) - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: float - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param costas_alpha: loop filter gain - @type costas_alphas: float - @param gain_mu: for M&M block - @type gain_mu: float - @param mu: for M&M block - @type mu: float - @param omega_relative_limit: for M&M block - @type omega_relative_limit: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "d8psk_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._costas_alpha = costas_alpha - self._mm_gain_mu = gain_mu - self._mm_mu = mu - self._mm_omega_relative_limit = omega_relative_limit - self._gray_code = gray_code - - if samples_per_symbol < 2: - raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol - - arity = pow(2,self.bits_per_symbol()) - - # Automatic gain control - scale = (1.0/16384.0) - self.pre_scaler = gr.multiply_const_cc(scale) # scale the signal from full-range to +-1 - #self.agc = gr.agc_cc(1e-2, 1, 1, 100) - self.agc = gr.agc2_cc(1e-1, 1e-2, 1, 1, 100) - #self.agc = gr.feedforward_agc_cc(16, 1.0) - - # RRC data filter - ntaps = 11 * samples_per_symbol - self.rrc_taps = gr.firdes.root_raised_cosine( - 1.0, # gain - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps) - - # symbol clock recovery - self._mm_omega = self._samples_per_symbol - self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu - self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha - fmin = -0.025 - fmax = 0.025 - - self.receiver=gr.mpsk_receiver_cc(arity, 0, - self._costas_alpha, self._costas_beta, - fmin, fmax, - self._mm_mu, self._mm_gain_mu, - self._mm_omega, self._mm_gain_omega, - self._mm_omega_relative_limit) - - # Perform Differential decoding on the constellation - self.diffdec = gr.diff_phasor_cc() - - # find closest constellation point - rot = 1 - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) - - - # unpack the k bit vector into a stream of bits - self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver, - self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 3 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "\nDemodulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRC roll-off factor: %.2f" % self._excess_bw - print "Costas Loop alpha: %.2e" % self._costas_alpha - print "Costas Loop beta: %.2e" % self._costas_beta - print "M&M mu: %.2f" % self._mm_mu - print "M&M mu gain: %.2e" % self._mm_gain_mu - print "M&M omega: %.2f" % self._mm_omega - print "M&M omega gain: %.2e" % self._mm_gain_omega - print "M&M omega limit: %.2f" % self._mm_omega_relative_limit - - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.pre_scaler, - gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat")) - self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat")) - self.connect(self.receiver, - gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat")) - self.connect(self.diffdec, - gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) - self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "rx_slicer.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat")) - self.connect(self.unpack, - gr.file_sink(gr.sizeof_char, "rx_unpack.dat")) - - def add_options(parser): - """ - Adds modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - parser.add_option("", "--costas-alpha", type="float", default=_def_costas_alpha, - help="set Costas loop alpha value [default=%default] (PSK)") - parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu, - help="set M&M symbol sync loop gain mu value [default=%default] (PSK)") - parser.add_option("", "--mu", type="float", default=_def_mu, - help="set M&M symbol sync loop mu value [default=%default] (PSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options( - d8psk_demod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# -# Add these to the mod/demod registry -# -# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK -modulation_utils.add_type_1_mod('d8psk', d8psk_mod) -modulation_utils.add_type_1_demod('d8psk', d8psk_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py deleted file mode 100644 index 55e4890f3..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py +++ /dev/null @@ -1,363 +0,0 @@ -# -# Copyright 2005,2006,2007,2009 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -differential BPSK modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils -from math import pi, sqrt -import psk -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_costas_alpha = 0.1 -_def_gain_mu = None -_def_mu = 0.5 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# DBPSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class dbpsk_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered differential BPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Log modulation data to files? - @type log: bool - """ - - gr.hier_block2.__init__(self, "dbpsk_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if not isinstance(self._samples_per_symbol, int) or self._samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % self._samples_per_symbol) - - ntaps = 11 * self._samples_per_symbol - - arity = pow(2,self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity]) - - # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( - self._samples_per_symbol, # gain (samples_per_symbol since we're - # interpolating by samples_per_symbol) - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, - self.rrc_taps) - - # Connect - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # static method that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def add_options(parser): - """ - Adds DBPSK modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default]") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=True, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(dbpsk_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - - def _print_verbage(self): - print "\nModulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRC roll-off factor: %.2f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) - - -# ///////////////////////////////////////////////////////////////////////////// -# DBPSK demodulator -# -# Differentially coherent detection of differentially encoded BPSK -# ///////////////////////////////////////////////////////////////////////////// - -class dbpsk_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - costas_alpha=_def_costas_alpha, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered differential BPSK demodulation - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (LSB) - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: float - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param costas_alpha: loop filter gain - @type costas_alphas: float - @param gain_mu: for M&M block - @type gain_mu: float - @param mu: for M&M block - @type mu: float - @param omega_relative_limit: for M&M block - @type omega_relative_limit: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "dbpsk_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._costas_alpha = costas_alpha - self._mm_gain_mu = gain_mu - self._mm_mu = mu - self._mm_omega_relative_limit = omega_relative_limit - self._gray_code = gray_code - - if samples_per_symbol < 2: - raise TypeError, "samples_per_symbol must be >= 2, is %r" % (samples_per_symbol,) - - arity = pow(2,self.bits_per_symbol()) - - # Automatic gain control - #scale = (1.0/16384.0) - #self.pre_scaler = gr.multiply_const_cc(scale) # scale the signal from full-range to +-1 - self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) - #self.agc = gr.feedforward_agc_cc(16, 2.0) - - # RRC data filter - ntaps = 11 * samples_per_symbol - self.rrc_taps = gr.firdes.root_raised_cosine( - 1.0, # gain - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps) - - # symbol clock recovery - if not self._mm_gain_mu: - self._mm_gain_mu = 0.1 - - self._mm_omega = self._samples_per_symbol - self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu - self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha - fmin = -0.25 - fmax = 0.25 - - self.receiver=gr.mpsk_receiver_cc(arity, 0, - self._costas_alpha, self._costas_beta, - fmin, fmax, - self._mm_mu, self._mm_gain_mu, - self._mm_omega, self._mm_gain_omega, - self._mm_omega_relative_limit) - - # Do differential decoding based on phase change of symbols - self.diffdec = gr.diff_phasor_cc() - - # find closest constellation point - rot = 1 - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) - - # unpack the k bit vector into a stream of bits - self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect and Initialize base class - self.connect(self, self.agc, self.rrc_filter, self.receiver, - self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "\nDemodulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRC roll-off factor: %.2f" % self._excess_bw - print "Costas Loop alpha: %.2e" % self._costas_alpha - print "Costas Loop beta: %.2e" % self._costas_beta - print "M&M mu: %.2f" % self._mm_mu - print "M&M mu gain: %.2e" % self._mm_gain_mu - print "M&M omega: %.2f" % self._mm_omega - print "M&M omega gain: %.2e" % self._mm_gain_omega - print "M&M omega limit: %.2f" % self._mm_omega_relative_limit - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.pre_scaler, - gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat")) - self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat")) - self.connect(self.receiver, - gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat")) - self.connect(self.diffdec, - gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) - self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "rx_slicer.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "rx_symbol_mapper.dat")) - self.connect(self.unpack, - gr.file_sink(gr.sizeof_char, "rx_unpack.dat")) - - def add_options(parser): - """ - Adds DBPSK demodulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - parser.add_option("", "--costas-alpha", type="float", default=None, - help="set Costas loop alpha value [default=%default] (PSK)") - parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu, - help="set M&M symbol sync loop gain mu value [default=%default] (GMSK/PSK)") - parser.add_option("", "--mu", type="float", default=_def_mu, - help="set M&M symbol sync loop mu value [default=%default] (GMSK/PSK)") - parser.add_option("", "--omega-relative-limit", type="float", default=_def_omega_relative_limit, - help="M&M clock recovery omega relative limit [default=%default] (GMSK/PSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options( - dbpsk_demod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) -# -# Add these to the mod/demod registry -# -modulation_utils.add_type_1_mod('dbpsk', dbpsk_mod) -modulation_utils.add_type_1_demod('dbpsk', dbpsk_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py deleted file mode 100644 index d7bcf5390..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py +++ /dev/null @@ -1,369 +0,0 @@ -# -# Copyright 2009,2010 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -differential BPSK modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils2 -from math import pi, sqrt, ceil -import psk -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_freq_alpha = 0.010 -_def_phase_alpha = 0.1 -_def_timing_alpha = 0.100 -_def_timing_beta = 0.010 -_def_timing_max_dev = 1.5 - - -# ///////////////////////////////////////////////////////////////////////////// -# DBPSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class dbpsk2_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered differential BPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Log modulation data to files? - @type log: bool - """ - - gr.hier_block2.__init__(self, "dbpsk_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if self._samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % self._samples_per_symbol) - - arity = pow(2,self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity]) - - # pulse shaping filter - nfilts = 32 - ntaps = nfilts * 11 * int(self._samples_per_symbol) # make nfilts filters of ntaps each - self.rrc_taps = gr.firdes.root_raised_cosine( - nfilts, # gain - nfilts, # sampling rate based on 32 filters in resampler - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - self.rrc_filter = gr.pfb_arb_resampler_ccf(self._samples_per_symbol, self.rrc_taps) - - # Connect - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # static method that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def add_options(parser): - """ - Adds DBPSK modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default]") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=True, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils2.extract_kwargs_from_options(dbpsk2_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - - def _print_verbage(self): - print "\nModulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRC roll-off factor: %.2f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) - - -# ///////////////////////////////////////////////////////////////////////////// -# DBPSK demodulator -# -# Differentially coherent detection of differentially encoded BPSK -# ///////////////////////////////////////////////////////////////////////////// - -class dbpsk2_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - freq_alpha=_def_freq_alpha, - phase_alpha=_def_phase_alpha, - timing_alpha=_def_timing_alpha, - timing_max_dev=_def_timing_max_dev, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log, - sync_out=False): - """ - Hierarchical block for RRC-filtered differential BPSK demodulation - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (LSB) - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: float - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param freq_alpha: loop filter gain for frequency recovery - @type freq_alpha: float - @param phase_alpha: loop filter gain for phase/fine frequency recovery - @type phase_alpha: float - @param timing_alpha: loop alpha gain for timing recovery - @type timing_alpha: float - @param timing_max: timing loop maximum rate deviations - @type timing_max: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Print modualtion data to files? - @type log: bool - @param sync_out: Output a sync signal on :1? - @type sync_out: bool - """ - if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex)) - else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char) - - gr.hier_block2.__init__(self, "dqpsk2_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - io_sig_out) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._freq_alpha = freq_alpha - self._freq_beta = 0.10*self._freq_alpha - self._phase_alpha = phase_alpha - self._timing_alpha = timing_alpha - self._timing_beta = _def_timing_beta - self._timing_max_dev=timing_max_dev - self._gray_code = gray_code - - if samples_per_symbol < 2: - raise TypeError, "samples_per_symbol must be >= 2, is %r" % (samples_per_symbol,) - - arity = pow(2,self.bits_per_symbol()) - - # Automatic gain control - self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) - #self.agc = gr.feedforward_agc_cc(16, 1.0) - - # Frequency correction - self.freq_recov = gr.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, - 11*int(self._samples_per_symbol), - self._freq_alpha, self._freq_beta) - - # symbol timing recovery with RRC data filter - nfilts = 32 - ntaps = 11 * int(self._samples_per_symbol*nfilts) - taps = gr.firdes.root_raised_cosine(nfilts, nfilts, - 1.0/float(self._samples_per_symbol), - self._excess_bw, ntaps) - self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol, - self._timing_alpha, - taps, nfilts, nfilts/2, self._timing_max_dev) - self.time_recov.set_beta(self._timing_beta) - - # Perform phase / fine frequency correction - self._phase_beta = 0.25 * self._phase_alpha * self._phase_alpha - # Allow a frequency swing of +/- half of the sample rate - fmin = -0.5 - fmax = 0.5 - - self.phase_recov = gr.costas_loop_cc(self._phase_alpha, - self._phase_beta, - fmax, fmin, arity) - - # Do differential decoding based on phase change of symbols - self.diffdec = gr.diff_phasor_cc() - - # find closest constellation point - rot = 1 - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) - - # unpack the k bit vector into a stream of bits - self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.agc, - self.freq_recov, self.time_recov, self.phase_recov, - self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) - if sync_out: self.connect(self.time_recov, (self, 1)) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "\nDemodulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRC roll-off factor: %.2f" % self._excess_bw - print "FLL gain: %.2e" % self._freq_alpha - print "Timing alpha gain: %.2e" % self._timing_alpha - print "Timing beta gain: %.2e" % self._timing_beta - print "Timing max dev: %.2f" % self._timing_max_dev - print "Phase track alpha: %.2e" % self._phase_alpha - print "Phase track beta: %.2e" % self._phase_beta - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) - self.connect(self.freq_recov, - gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.dat")) - self.connect(self.time_recov, - gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.dat")) - self.connect(self.phase_recov, - gr.file_sink(gr.sizeof_gr_complex, "rx_phase_recov.dat")) - self.connect(self.diffdec, - gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) - self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "rx_slicer.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "rx_symbol_mapper.dat")) - self.connect(self.unpack, - gr.file_sink(gr.sizeof_char, "rx_unpack.dat")) - - def add_options(parser): - """ - Adds DBPSK demodulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - parser.add_option("", "--freq-alpha", type="float", default=_def_freq_alpha, - help="set frequency lock loop alpha gain value [default=%default] (PSK)") - parser.add_option("", "--phase-alpha", type="float", default=_def_phase_alpha, - help="set phase tracking loop alpha value [default=%default] (PSK)") - parser.add_option("", "--timing-alpha", type="float", default=_def_timing_alpha, - help="set timing symbol sync loop gain alpha value [default=%default] (GMSK/PSK)") - parser.add_option("", "--timing-beta", type="float", default=_def_timing_beta, - help="set timing symbol sync loop gain beta value [default=%default] (GMSK/PSK)") - parser.add_option("", "--timing-max-dev", type="float", default=_def_timing_max_dev, - help="set timing symbol sync loop maximum deviation [default=%default] (GMSK/PSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils2.extract_kwargs_from_options( - dbpsk2_demod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) -# -# Add these to the mod/demod registry -# -modulation_utils2.add_type_1_mod('dbpsk2', dbpsk2_mod) -modulation_utils2.add_type_1_demod('dbpsk2', dbpsk2_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py deleted file mode 100644 index 42d534168..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py +++ /dev/null @@ -1,363 +0,0 @@ -# -# Copyright 2005,2006,2007,2009 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -differential QPSK modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils -from math import pi, sqrt -import psk -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_costas_alpha = 0.15 -_def_gain_mu = None -_def_mu = 0.5 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# DQPSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class dqpsk_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "dqpsk_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol) - - ntaps = 11 * samples_per_symbol - - arity = pow(2,self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - rot = .707 + .707j - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const) - - # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( - self._samples_per_symbol, # gain (sps since we're interpolating by sps) - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - - self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect & Initialize base class - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 2 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "\nModulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRS roll-off factor: %f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) - - def add_options(parser): - """ - Adds QPSK modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(dqpsk_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# DQPSK demodulator -# -# Differentially coherent detection of differentially encoded qpsk -# ///////////////////////////////////////////////////////////////////////////// - -class dqpsk_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - costas_alpha=_def_costas_alpha, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered DQPSK demodulation - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (LSB) - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: float - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param costas_alpha: loop filter gain - @type costas_alphas: float - @param gain_mu: for M&M block - @type gain_mu: float - @param mu: for M&M block - @type mu: float - @param omega_relative_limit: for M&M block - @type omega_relative_limit: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "dqpsk_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._costas_alpha = costas_alpha - self._mm_gain_mu = gain_mu - self._mm_mu = mu - self._mm_omega_relative_limit = omega_relative_limit - self._gray_code = gray_code - - if samples_per_symbol < 2: - raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol - - arity = pow(2,self.bits_per_symbol()) - - # Automatic gain control - scale = (1.0/16384.0) - self.pre_scaler = gr.multiply_const_cc(scale) # scale the signal from full-range to +-1 - #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) - self.agc = gr.feedforward_agc_cc(16, 2.0) - - # RRC data filter - ntaps = 11 * samples_per_symbol - self.rrc_taps = gr.firdes.root_raised_cosine( - 1.0, # gain - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps) - - if not self._mm_gain_mu: - sbs_to_mm = {2: 0.050, 3: 0.075, 4: 0.11, 5: 0.125, 6: 0.15, 7: 0.15} - self._mm_gain_mu = sbs_to_mm[samples_per_symbol] - - self._mm_omega = self._samples_per_symbol - self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu - self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha - fmin = -0.25 - fmax = 0.25 - - self.receiver=gr.mpsk_receiver_cc(arity, pi/4.0, - self._costas_alpha, self._costas_beta, - fmin, fmax, - self._mm_mu, self._mm_gain_mu, - self._mm_omega, self._mm_gain_omega, - self._mm_omega_relative_limit) - - # Perform Differential decoding on the constellation - self.diffdec = gr.diff_phasor_cc() - - # find closest constellation point - rot = 1 - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) - - # unpack the k bit vector into a stream of bits - self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect & Initialize base class - self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver, - self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 2 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "\nDemodulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRC roll-off factor: %.2f" % self._excess_bw - print "Costas Loop alpha: %.2e" % self._costas_alpha - print "Costas Loop beta: %.2e" % self._costas_beta - print "M&M mu: %.2f" % self._mm_mu - print "M&M mu gain: %.2e" % self._mm_gain_mu - print "M&M omega: %.2f" % self._mm_omega - print "M&M omega gain: %.2e" % self._mm_gain_omega - print "M&M omega limit: %.2f" % self._mm_omega_relative_limit - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.pre_scaler, - gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat")) - self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat")) - self.connect(self.receiver, - gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat")) - self.connect(self.diffdec, - gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) - self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "rx_slicer.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat")) - self.connect(self.unpack, - gr.file_sink(gr.sizeof_char, "rx_unpack.dat")) - - def add_options(parser): - """ - Adds modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - parser.add_option("", "--costas-alpha", type="float", default=_def_costas_alpha, - help="set Costas loop alpha value [default=%default] (PSK)") - parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu, - help="set M&M symbol sync loop gain mu value [default=%default] (PSK)") - parser.add_option("", "--mu", type="float", default=_def_mu, - help="set M&M symbol sync loop mu value [default=%default] (PSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options( - dqpsk_demod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# -# Add these to the mod/demod registry -# -modulation_utils.add_type_1_mod('dqpsk', dqpsk_mod) -modulation_utils.add_type_1_demod('dqpsk', dqpsk_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py deleted file mode 100644 index e1e627707..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py +++ /dev/null @@ -1,377 +0,0 @@ -# -# Copyright 2009,2010 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -differential QPSK modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils2 -from math import pi, sqrt -import psk -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_freq_alpha = 0.010 -_def_phase_alpha = 0.01 -_def_timing_alpha = 0.100 -_def_timing_beta = 0.010 -_def_timing_max_dev = 1.5 - - -# ///////////////////////////////////////////////////////////////////////////// -# DQPSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class dqpsk2_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "dqpsk2_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if samples_per_symbol < 2: - raise TypeError, ("sbp must be >= 2, is %f" % samples_per_symbol) - - ntaps = 11 * samples_per_symbol - - arity = pow(2,self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - rot = .707 + .707j - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const) - - # pulse shaping filter - nfilts = 32 - ntaps = 11 * int(nfilts * self._samples_per_symbol) # make nfilts filters of ntaps each - self.rrc_taps = gr.firdes.root_raised_cosine( - nfilts, # gain - nfilts, # sampling rate based on 32 filters in resampler - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - self.rrc_filter = gr.pfb_arb_resampler_ccf(self._samples_per_symbol, self.rrc_taps) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect & Initialize base class - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 2 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "\nModulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRS roll-off factor: %f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) - - def add_options(parser): - """ - Adds QPSK modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils2.extract_kwargs_from_options(dqpsk2_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# DQPSK demodulator -# -# Differentially coherent detection of differentially encoded qpsk -# ///////////////////////////////////////////////////////////////////////////// - -class dqpsk2_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - freq_alpha=_def_freq_alpha, - phase_alpha=_def_phase_alpha, - timing_alpha=_def_timing_alpha, - timing_max_dev=_def_timing_max_dev, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log, - sync_out=False): - """ - Hierarchical block for RRC-filtered DQPSK demodulation - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (LSB) - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: float - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param freq_alpha: loop filter gain for frequency recovery - @type freq_alpha: float - @param phase_alpha: loop filter gain - @type phase_alphas: float - @param timing_alpha: timing loop alpha gain - @type timing_alpha: float - @param timing_max: timing loop maximum rate deviations - @type timing_max: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Print modualtion data to files? - @type log: bool - @param sync_out: Output a sync signal on :1? - @type sync_out: bool - """ - if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex)) - else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char) - - gr.hier_block2.__init__(self, "dqpsk2_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - io_sig_out) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._freq_alpha = freq_alpha - self._freq_beta = 0.25*self._freq_alpha**2 - self._phase_alpha = phase_alpha - self._timing_alpha = timing_alpha - self._timing_beta = _def_timing_beta - self._timing_max_dev=timing_max_dev - self._gray_code = gray_code - - if samples_per_symbol < 2: - raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol - - arity = pow(2,self.bits_per_symbol()) - - # Automatic gain control - self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) - #self.agc = gr.feedforward_agc_cc(16, 2.0) - - # Frequency correction - self.freq_recov = gr.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, - 11*int(self._samples_per_symbol), - self._freq_alpha, self._freq_beta) - - - # symbol timing recovery with RRC data filter - nfilts = 32 - ntaps = 11 * int(samples_per_symbol*nfilts) - taps = gr.firdes.root_raised_cosine(nfilts, nfilts, - 1.0/float(self._samples_per_symbol), - self._excess_bw, ntaps) - self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol, - self._timing_alpha, - taps, nfilts, nfilts/2, self._timing_max_dev) - self.time_recov.set_beta(self._timing_beta) - - - # Perform phase / fine frequency correction - self._phase_beta = 0.25 * self._phase_alpha * self._phase_alpha - # Allow a frequency swing of +/- half of the sample rate - fmin = -0.5 - fmax = 0.5 - - self.phase_recov = gr.costas_loop_cc(self._phase_alpha, - self._phase_beta, - fmax, fmin, arity) - - - # Perform Differential decoding on the constellation - self.diffdec = gr.diff_phasor_cc() - - # find closest constellation point - rot = 1 - rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) - self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) - else: - self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) - - # unpack the k bit vector into a stream of bits - self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.agc, - self.freq_recov, self.time_recov, self.phase_recov, - self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) - if sync_out: self.connect(self.time_recov, (self, 1)) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 2 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "\nDemodulator:" - print "bits per symbol: %d" % self.bits_per_symbol() - print "Gray code: %s" % self._gray_code - print "RRC roll-off factor: %.2f" % self._excess_bw - print "FLL gain: %.2f" % self._freq_alpha - print "Timing alpha gain: %.2f" % self._timing_alpha - print "Timing beta gain: %.2f" % self._timing_beta - print "Timing max dev: %.2f" % self._timing_max_dev - print "Phase track alpha: %.2e" % self._phase_alpha - print "Phase track beta: %.2e" % self._phase_beta - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) - self.connect(self.freq_recov, - gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.dat")) - self.connect(self.time_recov, - gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.dat")) - self.connect(self.phase_recov, - gr.file_sink(gr.sizeof_gr_complex, "rx_phase_recov.dat")) - self.connect(self.diffdec, - gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) - self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "rx_slicer.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat")) - self.connect(self.unpack, - gr.file_sink(gr.sizeof_char, "rx_unpack.dat")) - - def add_options(parser): - """ - Adds DQPSK demodulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - parser.add_option("", "--freq-alpha", type="float", default=_def_freq_alpha, - help="set frequency lock loop alpha gain value [default=%default] (PSK)") - parser.add_option("", "--phase-alpha", type="float", default=_def_phase_alpha, - help="set phase tracking loop alpha value [default=%default] (PSK)") - parser.add_option("", "--timing-alpha", type="float", default=_def_timing_alpha, - help="set timing symbol sync loop gain alpha value [default=%default] (GMSK/PSK)") - parser.add_option("", "--timing-beta", type="float", default=_def_timing_beta, - help="set timing symbol sync loop gain beta value [default=%default] (GMSK/PSK)") - parser.add_option("", "--timing-max-dev", type="float", default=_def_timing_max_dev, - help="set timing symbol sync loop maximum deviation [default=%default] (GMSK/PSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils2.extract_kwargs_from_options( - dqpsk2_demod.__init__, ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# -# Add these to the mod/demod registry -# -modulation_utils2.add_type_1_mod('dqpsk2', dqpsk2_mod) -modulation_utils2.add_type_1_demod('dqpsk2', dqpsk2_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py b/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py index 1910b5011..55870513a 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py @@ -88,7 +88,7 @@ class demod_20k0f3e_cf(fm_demod_cf): fm_demod_cf.__init__(self, channel_rate, audio_decim, 5000, # Deviation 3000, # Audio passband frequency - 4000) # Audio stopband frequency + 4500) # Audio stopband frequency class demod_200kf3e_cf(fm_demod_cf): """ diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/gmsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/gmsk.py deleted file mode 100644 index 3b6c016a0..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/gmsk.py +++ /dev/null @@ -1,292 +0,0 @@ -# -# GMSK modulation and demodulation. -# -# -# Copyright 2005,2006,2007 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. -# - -# See gnuradio-examples/python/digital for examples - -from gnuradio import gr -from gnuradio import modulation_utils -from math import pi -import numpy -from pprint import pprint -import inspect - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_bt = 0.35 -_def_verbose = False -_def_log = False - -_def_gain_mu = None -_def_mu = 0.5 -_def_freq_error = 0.0 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# GMSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class gmsk_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - bt=_def_bt, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for Gaussian Minimum Shift Key (GMSK) - modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param bt: Gaussian filter bandwidth * symbol time - @type bt: float - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "gmsk_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._bt = bt - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,)) - - ntaps = 4 * samples_per_symbol # up to 3 bits in filter at once - sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 - - # Turn it into NRZ data. - self.nrz = gr.bytes_to_syms() - - # Form Gaussian filter - # Generate Gaussian response (Needs to be convolved with window below). - self.gaussian_taps = gr.firdes.gaussian( - 1, # gain - samples_per_symbol, # symbol_rate - bt, # bandwidth * symbol time - ntaps # number of taps - ) - - self.sqwave = (1,) * samples_per_symbol # rectangular window - self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave)) - self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps) - - # FM modulation - self.fmmod = gr.frequency_modulator_fc(sensitivity) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect & Initialize base class - self.connect(self, self.nrz, self.gaussian_filter, self.fmmod, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "Gaussian filter bt = %.2f" % self._bt - - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.nrz, - gr.file_sink(gr.sizeof_float, "nrz.dat")) - self.connect(self.gaussian_filter, - gr.file_sink(gr.sizeof_float, "gaussian_filter.dat")) - self.connect(self.fmmod, - gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) - - - def add_options(parser): - """ - Adds GMSK modulation-specific options to the standard parser - """ - parser.add_option("", "--bt", type="float", default=_def_bt, - help="set bandwidth-time product [default=%default] (GMSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(gmsk_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - - -# ///////////////////////////////////////////////////////////////////////////// -# GMSK demodulator -# ///////////////////////////////////////////////////////////////////////////// - -class gmsk_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - freq_error=_def_freq_error, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for Gaussian Minimum Shift Key (GMSK) - demodulation. - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (the LSB) - - @param samples_per_symbol: samples per baud - @type samples_per_symbol: integer - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Print modualtion data to files? - @type log: bool - - Clock recovery parameters. These all have reasonble defaults. - - @param gain_mu: controls rate of mu adjustment - @type gain_mu: float - @param mu: fractional delay [0.0, 1.0] - @type mu: float - @param omega_relative_limit: sets max variation in omega - @type omega_relative_limit: float, typically 0.000200 (200 ppm) - @param freq_error: bit rate error as a fraction - @param float - """ - - gr.hier_block2.__init__(self, "gmsk_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._gain_mu = gain_mu - self._mu = mu - self._omega_relative_limit = omega_relative_limit - self._freq_error = freq_error - - if samples_per_symbol < 2: - raise TypeError, "samples_per_symbol >= 2, is %f" % samples_per_symbol - - self._omega = samples_per_symbol*(1+self._freq_error) - - if not self._gain_mu: - self._gain_mu = 0.175 - - self._gain_omega = .25 * self._gain_mu * self._gain_mu # critically damped - - # Demodulate FM - sensitivity = (pi / 2) / samples_per_symbol - self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity) - - # the clock recovery block tracks the symbol clock and resamples as needed. - # the output of the block is a stream of soft symbols (float) - self.clock_recovery = gr.clock_recovery_mm_ff(self._omega, self._gain_omega, - self._mu, self._gain_mu, - self._omega_relative_limit) - - # slice the floats at 0, outputting 1 bit (the LSB of the output byte) per sample - self.slicer = gr.binary_slicer_fb() - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect & Initialize base class - self.connect(self, self.fmdemod, self.clock_recovery, self.slicer, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "M&M clock recovery omega = %f" % self._omega - print "M&M clock recovery gain mu = %f" % self._gain_mu - print "M&M clock recovery mu = %f" % self._mu - print "M&M clock recovery omega rel. limit = %f" % self._omega_relative_limit - print "frequency error = %f" % self._freq_error - - - def _setup_logging(self): - print "Demodulation logging turned on." - self.connect(self.fmdemod, - gr.file_sink(gr.sizeof_float, "fmdemod.dat")) - self.connect(self.clock_recovery, - gr.file_sink(gr.sizeof_float, "clock_recovery.dat")) - self.connect(self.slicer, - gr.file_sink(gr.sizeof_char, "slicer.dat")) - - def add_options(parser): - """ - Adds GMSK demodulation-specific options to the standard parser - """ - parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu, - help="M&M clock recovery gain mu [default=%default] (GMSK/PSK)") - parser.add_option("", "--mu", type="float", default=_def_mu, - help="M&M clock recovery mu [default=%default] (GMSK/PSK)") - parser.add_option("", "--omega-relative-limit", type="float", default=_def_omega_relative_limit, - help="M&M clock recovery omega relative limit [default=%default] (GMSK/PSK)") - parser.add_option("", "--freq-error", type="float", default=_def_freq_error, - help="M&M clock recovery frequency error [default=%default] (GMSK)") - add_options=staticmethod(add_options) - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(gmsk_demod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# -# Add these to the mod/demod registry -# -modulation_utils.add_type_1_mod('gmsk', gmsk_mod) -modulation_utils.add_type_1_demod('gmsk', gmsk_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py deleted file mode 100644 index 2663f7cf8..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2008 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. -# - -import math -from gnuradio import gr, ofdm_packet_utils -import gnuradio.gr.gr_threading as _threading -import psk, qam - -from gnuradio.blks2impl.ofdm_receiver import ofdm_receiver - - -# ///////////////////////////////////////////////////////////////////////////// -# mod/demod with packets as i/o -# ///////////////////////////////////////////////////////////////////////////// - -class ofdm_mod(gr.hier_block2): - """ - Modulates an OFDM stream. Based on the options fft_length, occupied_tones, and - cp_length, this block creates OFDM symbols using a specified modulation option. - - Send packets by calling send_pkt - """ - def __init__(self, options, msgq_limit=2, pad_for_usrp=True): - """ - Hierarchical block for sending packets - - Packets to be sent are enqueued by calling send_pkt. - The output is the complex modulated signal at baseband. - - @param options: pass modulation options from higher layers (fft length, occupied tones, etc.) - @param msgq_limit: maximum number of messages in message queue - @type msgq_limit: int - @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples - """ - - gr.hier_block2.__init__(self, "ofdm_mod", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._pad_for_usrp = pad_for_usrp - self._modulation = options.modulation - self._fft_length = options.fft_length - self._occupied_tones = options.occupied_tones - self._cp_length = options.cp_length - - win = [] #[1 for i in range(self._fft_length)] - - # Use freq domain to get doubled-up known symbol for correlation in time domain - zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) - ksfreq = known_symbols_4512_3[0:self._occupied_tones] - for i in range(len(ksfreq)): - if((zeros_on_left + i) & 1): - ksfreq[i] = 0 - - # hard-coded known symbols - preambles = (ksfreq,) - - padded_preambles = list() - for pre in preambles: - padded = self._fft_length*[0,] - padded[zeros_on_left : zeros_on_left + self._occupied_tones] = pre - padded_preambles.append(padded) - - symbol_length = options.fft_length + options.cp_length - - mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} - arity = mods[self._modulation] - - rot = 1 - if self._modulation == "qpsk": - rot = (0.707+0.707j) - - if(self._modulation.find("psk") >= 0): - rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity]) - elif(self._modulation.find("qam") >= 0): - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - #print rotated_const - self._pkt_input = gr.ofdm_mapper_bcv(rotated_const, msgq_limit, - options.occupied_tones, options.fft_length) - - self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles) - self.ifft = gr.fft_vcc(self._fft_length, False, win, True) - self.cp_adder = gr.ofdm_cyclic_prefixer(self._fft_length, symbol_length) - self.scale = gr.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) - - self.connect((self._pkt_input, 0), (self.preambles, 0)) - self.connect((self._pkt_input, 1), (self.preambles, 1)) - self.connect(self.preambles, self.ifft, self.cp_adder, self.scale, self) - - if options.verbose: - self._print_verbage() - - if options.log: - self.connect(self._pkt_input, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, - "ofdm_mapper_c.dat")) - self.connect(self.preambles, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, - "ofdm_preambles.dat")) - self.connect(self.ifft, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, - "ofdm_ifft_c.dat")) - self.connect(self.cp_adder, gr.file_sink(gr.sizeof_gr_complex, - "ofdm_cp_adder_c.dat")) - - def send_pkt(self, payload='', eof=False): - """ - Send the payload. - - @param payload: data to send - @type payload: string - """ - if eof: - msg = gr.message(1) # tell self._pkt_input we're not sending any more packets - else: - # print "original_payload =", string_to_hex_list(payload) - pkt = ofdm_packet_utils.make_packet(payload, 1, 1, self._pad_for_usrp, whitening=True) - - #print "pkt =", string_to_hex_list(pkt) - msg = gr.message_from_string(pkt) - self._pkt_input.msgq().insert_tail(msg) - - def add_options(normal, expert): - """ - Adds OFDM-specific options to the Options Parser - """ - normal.add_option("-m", "--modulation", type="string", default="bpsk", - help="set modulation type (bpsk, qpsk, 8psk, qam{16,64}) [default=%default]") - expert.add_option("", "--fft-length", type="intx", default=512, - help="set the number of FFT bins [default=%default]") - expert.add_option("", "--occupied-tones", type="intx", default=200, - help="set the number of occupied FFT bins [default=%default]") - expert.add_option("", "--cp-length", type="intx", default=128, - help="set the number of bits in the cyclic prefix [default=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): - """ - Prints information about the OFDM modulator - """ - print "\nOFDM Modulator:" - print "Modulation Type: %s" % (self._modulation) - print "FFT length: %3d" % (self._fft_length) - print "Occupied Tones: %3d" % (self._occupied_tones) - print "CP length: %3d" % (self._cp_length) - - -class ofdm_demod(gr.hier_block2): - """ - Demodulates a received OFDM stream. Based on the options fft_length, occupied_tones, and - cp_length, this block performs synchronization, FFT, and demodulation of incoming OFDM - symbols and passes packets up the a higher layer. - - The input is complex baseband. When packets are demodulated, they are passed to the - app via the callback. - """ - - def __init__(self, options, callback=None): - """ - Hierarchical block for demodulating and deframing packets. - - The input is the complex modulated signal at baseband. - Demodulated packets are sent to the handler. - - @param options: pass modulation options from higher layers (fft length, occupied tones, etc.) - @param callback: function of two args: ok, payload - @type callback: ok: bool; payload: string - """ - gr.hier_block2.__init__(self, "ofdm_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - - self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY - - self._modulation = options.modulation - self._fft_length = options.fft_length - self._occupied_tones = options.occupied_tones - self._cp_length = options.cp_length - self._snr = options.snr - - # Use freq domain to get doubled-up known symbol for correlation in time domain - zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) - ksfreq = known_symbols_4512_3[0:self._occupied_tones] - for i in range(len(ksfreq)): - if((zeros_on_left + i) & 1): - ksfreq[i] = 0 - - # hard-coded known symbols - preambles = (ksfreq,) - - symbol_length = self._fft_length + self._cp_length - self.ofdm_recv = ofdm_receiver(self._fft_length, self._cp_length, - self._occupied_tones, self._snr, preambles, - options.log) - - mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} - arity = mods[self._modulation] - - rot = 1 - if self._modulation == "qpsk": - rot = (0.707+0.707j) - - if(self._modulation.find("psk") >= 0): - rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity]) - elif(self._modulation.find("qam") >= 0): - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - #print rotated_const - - phgain = 0.25 - frgain = phgain*phgain / 4.0 - self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity), - self._rcvd_pktq, - self._occupied_tones, - phgain, frgain) - - self.connect(self, self.ofdm_recv) - self.connect((self.ofdm_recv, 0), (self.ofdm_demod, 0)) - self.connect((self.ofdm_recv, 1), (self.ofdm_demod, 1)) - - # added output signature to work around bug, though it might not be a bad - # thing to export, anyway - self.connect(self.ofdm_recv.chan_filt, self) - - if options.log: - self.connect(self.ofdm_demod, gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, "ofdm_frame_sink_c.dat")) - else: - self.connect(self.ofdm_demod, gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) - - if options.verbose: - self._print_verbage() - - self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) - - def add_options(normal, expert): - """ - Adds OFDM-specific options to the Options Parser - """ - normal.add_option("-m", "--modulation", type="string", default="bpsk", - help="set modulation type (bpsk or qpsk) [default=%default]") - expert.add_option("", "--fft-length", type="intx", default=512, - help="set the number of FFT bins [default=%default]") - expert.add_option("", "--occupied-tones", type="intx", default=200, - help="set the number of occupied FFT bins [default=%default]") - expert.add_option("", "--cp-length", type="intx", default=128, - help="set the number of bits in the cyclic prefix [default=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): - """ - Prints information about the OFDM demodulator - """ - print "\nOFDM Demodulator:" - print "Modulation Type: %s" % (self._modulation) - print "FFT length: %3d" % (self._fft_length) - print "Occupied Tones: %3d" % (self._occupied_tones) - print "CP length: %3d" % (self._cp_length) - - - -class _queue_watcher_thread(_threading.Thread): - def __init__(self, rcvd_pktq, callback): - _threading.Thread.__init__(self) - self.setDaemon(1) - self.rcvd_pktq = rcvd_pktq - self.callback = callback - self.keep_running = True - self.start() - - - def run(self): - while self.keep_running: - msg = self.rcvd_pktq.delete_head() - ok, payload = ofdm_packet_utils.unmake_packet(msg.to_string()) - if self.callback: - self.callback(ok, payload) - -# Generating known symbols with: -# i = [2*random.randint(0,1)-1 for i in range(4512)] - -known_symbols_4512_3 = [-1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1] diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py deleted file mode 100644 index 56ae0c0f0..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006, 2007, 2008 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. -# - -import math -from numpy import fft -from gnuradio import gr -from gnuradio.blks2impl.ofdm_sync_ml import ofdm_sync_ml -from gnuradio.blks2impl.ofdm_sync_pn import ofdm_sync_pn -from gnuradio.blks2impl.ofdm_sync_pnac import ofdm_sync_pnac -from gnuradio.blks2impl.ofdm_sync_fixed import ofdm_sync_fixed - -class ofdm_receiver(gr.hier_block2): - """ - Performs receiver synchronization on OFDM symbols. - - The receiver performs channel filtering as well as symbol, frequency, and phase synchronization. - The synchronization routines are available in three flavors: preamble correlator (Schmidl and Cox), - modifid preamble correlator with autocorrelation (not yet working), and cyclic prefix correlator - (Van de Beeks). - """ - - def __init__(self, fft_length, cp_length, occupied_tones, snr, ks, logging=False): - """ - Hierarchical block for receiving OFDM symbols. - - The input is the complex modulated signal at baseband. - Synchronized packets are sent back to the demodulator. - - @param fft_length: total number of subcarriers - @type fft_length: int - @param cp_length: length of cyclic prefix as specified in subcarriers (<= fft_length) - @type cp_length: int - @param occupied_tones: number of subcarriers used for data - @type occupied_tones: int - @param snr: estimated signal to noise ratio used to guide cyclic prefix synchronizer - @type snr: float - @param ks: known symbols used as preambles to each packet - @type ks: list of lists - @param logging: turn file logging on or off - @type logging: bool - """ - - gr.hier_block2.__init__(self, "ofdm_receiver", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature2(2, 2, gr.sizeof_gr_complex*occupied_tones, gr.sizeof_char)) # Output signature - - bw = (float(occupied_tones) / float(fft_length)) / 2.0 - tb = bw*0.08 - chan_coeffs = gr.firdes.low_pass (1.0, # gain - 1.0, # sampling rate - bw+tb, # midpoint of trans. band - tb, # width of trans. band - gr.firdes.WIN_HAMMING) # filter type - self.chan_filt = gr.fft_filter_ccc(1, chan_coeffs) - - win = [1 for i in range(fft_length)] - - zeros_on_left = int(math.ceil((fft_length - occupied_tones)/2.0)) - ks0 = fft_length*[0,] - ks0[zeros_on_left : zeros_on_left + occupied_tones] = ks[0] - - ks0 = fft.ifftshift(ks0) - ks0time = fft.ifft(ks0) - # ADD SCALING FACTOR - ks0time = ks0time.tolist() - - SYNC = "pn" - if SYNC == "ml": - nco_sensitivity = -1.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_ml(fft_length, cp_length, snr, ks0time, logging) - elif SYNC == "pn": - nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_pn(fft_length, cp_length, logging) - elif SYNC == "pnac": - nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_pnac(fft_length, cp_length, ks0time, logging) - elif SYNC == "fixed": # for testing only; do not user over the air - self.chan_filt = gr.multiply_const_cc(1.0) # remove filter and filter delay for this - nsymbols = 18 # enter the number of symbols per packet - freq_offset = 0.0 # if you use a frequency offset, enter it here - nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_fixed(fft_length, cp_length, nsymbols, freq_offset, logging) - - # Set up blocks - - self.nco = gr.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block - self.sigmix = gr.multiply_cc() - self.sampler = gr.ofdm_sampler(fft_length, fft_length+cp_length) - self.fft_demod = gr.fft_vcc(fft_length, True, win, True) - self.ofdm_frame_acq = gr.ofdm_frame_acquisition(occupied_tones, fft_length, - cp_length, ks[0]) - - self.connect(self, self.chan_filt) # filter the input channel - self.connect(self.chan_filt, self.ofdm_sync) # into the synchronization alg. - self.connect((self.ofdm_sync,0), self.nco, (self.sigmix,1)) # use sync freq. offset output to derotate input signal - self.connect(self.chan_filt, (self.sigmix,0)) # signal to be derotated - self.connect(self.sigmix, (self.sampler,0)) # sample off timing signal detected in sync alg - self.connect((self.ofdm_sync,1), (self.sampler,1)) # timing signal to sample at - - self.connect((self.sampler,0), self.fft_demod) # send derotated sampled signal to FFT - self.connect(self.fft_demod, (self.ofdm_frame_acq,0)) # find frame start and equalize signal - self.connect((self.sampler,1), (self.ofdm_frame_acq,1)) # send timing signal to signal frame start - self.connect((self.ofdm_frame_acq,0), (self,0)) # finished with fine/coarse freq correction, - self.connect((self.ofdm_frame_acq,1), (self,1)) # frame and symbol timing, and equalization - - if logging: - self.connect(self.chan_filt, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-chan_filt_c.dat")) - self.connect(self.fft_demod, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-fft_out_c.dat")) - self.connect(self.ofdm_frame_acq, - gr.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_receiver-frame_acq_c.dat")) - self.connect((self.ofdm_frame_acq,1), gr.file_sink(1, "ofdm_receiver-found_corr_b.dat")) - self.connect(self.sampler, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-sampler_c.dat")) - self.connect(self.sigmix, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-sigmix_c.dat")) - self.connect(self.nco, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-nco_c.dat")) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_fixed.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_fixed.py deleted file mode 100644 index 9bac789bf..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_fixed.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -import math -from gnuradio import gr - -class ofdm_sync_fixed(gr.hier_block2): - def __init__(self, fft_length, cp_length, nsymbols, freq_offset, logging=False): - - gr.hier_block2.__init__(self, "ofdm_sync_fixed", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature - - # Use a fixed trigger point instead of sync block - symbol_length = fft_length + cp_length - pkt_length = nsymbols*symbol_length - data = (pkt_length)*[0,] - data[(symbol_length)-1] = 1 - self.peak_trigger = gr.vector_source_b(data, True) - - # Use a pre-defined frequency offset - foffset = (pkt_length)*[math.pi*freq_offset,] - self.frequency_offset = gr.vector_source_f(foffset, True) - - self.connect(self, gr.null_sink(gr.sizeof_gr_complex)) - self.connect(self.frequency_offset, (self,0)) - self.connect(self.peak_trigger, (self,1)) - - if logging: - self.connect(self.peak_trigger, gr.file_sink(gr.sizeof_char, "ofdm_sync_fixed-peaks_b.dat")) - diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_ml.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_ml.py deleted file mode 100644 index 7c75d7f1d..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_ml.py +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2008 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. -# - -import math -from gnuradio import gr - -class ofdm_sync_ml(gr.hier_block2): - def __init__(self, fft_length, cp_length, snr, kstime, logging): - ''' Maximum Likelihood OFDM synchronizer: - J. van de Beek, M. Sandell, and P. O. Borjesson, "ML Estimation - of Time and Frequency Offset in OFDM Systems," IEEE Trans. - Signal Processing, vol. 45, no. 7, pp. 1800-1805, 1997. - ''' - - gr.hier_block2.__init__(self, "ofdm_sync_ml", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature - - self.input = gr.add_const_cc(0) - - SNR = 10.0**(snr/10.0) - rho = SNR / (SNR + 1.0) - symbol_length = fft_length + cp_length - - # ML Sync - - # Energy Detection from ML Sync - - self.connect(self, self.input) - - # Create a delay line - self.delay = gr.delay(gr.sizeof_gr_complex, fft_length) - self.connect(self.input, self.delay) - - # magnitude squared blocks - self.magsqrd1 = gr.complex_to_mag_squared() - self.magsqrd2 = gr.complex_to_mag_squared() - self.adder = gr.add_ff() - - moving_sum_taps = [rho/2 for i in range(cp_length)] - self.moving_sum_filter = gr.fir_filter_fff(1,moving_sum_taps) - - self.connect(self.input,self.magsqrd1) - self.connect(self.delay,self.magsqrd2) - self.connect(self.magsqrd1,(self.adder,0)) - self.connect(self.magsqrd2,(self.adder,1)) - self.connect(self.adder,self.moving_sum_filter) - - - # Correlation from ML Sync - self.conjg = gr.conjugate_cc(); - self.mixer = gr.multiply_cc(); - - movingsum2_taps = [1.0 for i in range(cp_length)] - self.movingsum2 = gr.fir_filter_ccf(1,movingsum2_taps) - - # Correlator data handler - self.c2mag = gr.complex_to_mag() - self.angle = gr.complex_to_arg() - self.connect(self.input,(self.mixer,1)) - self.connect(self.delay,self.conjg,(self.mixer,0)) - self.connect(self.mixer,self.movingsum2,self.c2mag) - self.connect(self.movingsum2,self.angle) - - # ML Sync output arg, need to find maximum point of this - self.diff = gr.sub_ff() - self.connect(self.c2mag,(self.diff,0)) - self.connect(self.moving_sum_filter,(self.diff,1)) - - #ML measurements input to sampler block and detect - self.f2c = gr.float_to_complex() - self.pk_detect = gr.peak_detector_fb(0.2, 0.25, 30, 0.0005) - self.sample_and_hold = gr.sample_and_hold_ff() - - # use the sync loop values to set the sampler and the NCO - # self.diff = theta - # self.angle = epsilon - - self.connect(self.diff, self.pk_detect) - - # The DPLL corrects for timing differences between CP correlations - use_dpll = 0 - if use_dpll: - self.dpll = gr.dpll_bb(float(symbol_length),0.01) - self.connect(self.pk_detect, self.dpll) - self.connect(self.dpll, (self.sample_and_hold,1)) - else: - self.connect(self.pk_detect, (self.sample_and_hold,1)) - - self.connect(self.angle, (self.sample_and_hold,0)) - - ################################ - # correlate against known symbol - # This gives us the same timing signal as the PN sync block only on the preamble - # we don't use the signal generated from the CP correlation because we don't want - # to readjust the timing in the middle of the packet or we ruin the equalizer settings. - kstime = [k.conjugate() for k in kstime] - kstime.reverse() - self.kscorr = gr.fir_filter_ccc(1, kstime) - self.corrmag = gr.complex_to_mag_squared() - self.div = gr.divide_ff() - - # The output signature of the correlation has a few spikes because the rest of the - # system uses the repeated preamble symbol. It needs to work that generically if - # anyone wants to use this against a WiMAX-like signal since it, too, repeats. - # The output theta of the correlator above is multiplied with this correlation to - # identify the proper peak and remove other products in this cross-correlation - self.threshold_factor = 0.1 - self.slice = gr.threshold_ff(self.threshold_factor, self.threshold_factor, 0) - self.f2b = gr.float_to_char() - self.b2f = gr.char_to_float() - self.mul = gr.multiply_ff() - - # Normalize the power of the corr output by the energy. This is not really needed - # and could be removed for performance, but it makes for a cleaner signal. - # if this is removed, the threshold value needs adjustment. - self.connect(self.input, self.kscorr, self.corrmag, (self.div,0)) - self.connect(self.moving_sum_filter, (self.div,1)) - - self.connect(self.div, (self.mul,0)) - self.connect(self.pk_detect, self.b2f, (self.mul,1)) - self.connect(self.mul, self.slice) - - # Set output signals - # Output 0: fine frequency correction value - # Output 1: timing signal - self.connect(self.sample_and_hold, (self,0)) - self.connect(self.slice, self.f2b, (self,1)) - - - if logging: - self.connect(self.moving_sum_filter, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat")) - self.connect(self.diff, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat")) - self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-epsilon_f.dat")) - self.connect(self.corrmag, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-corrmag_f.dat")) - self.connect(self.kscorr, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-kscorr_c.dat")) - self.connect(self.div, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat")) - self.connect(self.mul, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat")) - self.connect(self.slice, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat")) - self.connect(self.pk_detect, gr.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat")) - if use_dpll: - self.connect(self.dpll, gr.file_sink(gr.sizeof_char, "ofdm_sync_ml-dpll_b.dat")) - - self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_ml-sample_and_hold_f.dat")) - self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-input_c.dat")) - diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py deleted file mode 100644 index 05b1de2e1..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2008 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. -# - -import math -from numpy import fft -from gnuradio import gr - -class ofdm_sync_pn(gr.hier_block2): - def __init__(self, fft_length, cp_length, logging=False): - """ - OFDM synchronization using PN Correlation: - T. M. Schmidl and D. C. Cox, "Robust Frequency and Timing - Synchonization for OFDM," IEEE Trans. Communications, vol. 45, - no. 12, 1997. - """ - - gr.hier_block2.__init__(self, "ofdm_sync_pn", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature - - self.input = gr.add_const_cc(0) - - # PN Sync - - # Create a delay line - self.delay = gr.delay(gr.sizeof_gr_complex, fft_length/2) - - # Correlation from ML Sync - self.conjg = gr.conjugate_cc(); - self.corr = gr.multiply_cc(); - - # Create a moving sum filter for the corr output - if 1: - moving_sum_taps = [1.0 for i in range(fft_length//2)] - self.moving_sum_filter = gr.fir_filter_ccf(1,moving_sum_taps) - else: - moving_sum_taps = [complex(1.0,0.0) for i in range(fft_length//2)] - self.moving_sum_filter = gr.fft_filter_ccc(1,moving_sum_taps) - - # Create a moving sum filter for the input - self.inputmag2 = gr.complex_to_mag_squared() - movingsum2_taps = [1.0 for i in range(fft_length//2)] - - if 1: - self.inputmovingsum = gr.fir_filter_fff(1,movingsum2_taps) - else: - self.inputmovingsum = gr.fft_filter_fff(1,movingsum2_taps) - - self.square = gr.multiply_ff() - self.normalize = gr.divide_ff() - - # Get magnitude (peaks) and angle (phase/freq error) - self.c2mag = gr.complex_to_mag_squared() - self.angle = gr.complex_to_arg() - - self.sample_and_hold = gr.sample_and_hold_ff() - - #ML measurements input to sampler block and detect - self.sub1 = gr.add_const_ff(-1) - self.pk_detect = gr.peak_detector_fb(0.20, 0.20, 30, 0.001) - #self.pk_detect = gr.peak_detector2_fb(9) - - self.connect(self, self.input) - - # Calculate the frequency offset from the correlation of the preamble - self.connect(self.input, self.delay) - self.connect(self.input, (self.corr,0)) - self.connect(self.delay, self.conjg) - self.connect(self.conjg, (self.corr,1)) - self.connect(self.corr, self.moving_sum_filter) - self.connect(self.moving_sum_filter, self.c2mag) - self.connect(self.moving_sum_filter, self.angle) - self.connect(self.angle, (self.sample_and_hold,0)) - - # Get the power of the input signal to normalize the output of the correlation - self.connect(self.input, self.inputmag2, self.inputmovingsum) - self.connect(self.inputmovingsum, (self.square,0)) - self.connect(self.inputmovingsum, (self.square,1)) - self.connect(self.square, (self.normalize,1)) - self.connect(self.c2mag, (self.normalize,0)) - - # Create a moving sum filter for the corr output - matched_filter_taps = [1.0/cp_length for i in range(cp_length)] - self.matched_filter = gr.fir_filter_fff(1,matched_filter_taps) - self.connect(self.normalize, self.matched_filter) - - self.connect(self.matched_filter, self.sub1, self.pk_detect) - #self.connect(self.matched_filter, self.pk_detect) - self.connect(self.pk_detect, (self.sample_and_hold,1)) - - # Set output signals - # Output 0: fine frequency correction value - # Output 1: timing signal - self.connect(self.sample_and_hold, (self,0)) - self.connect(self.pk_detect, (self,1)) - - if logging: - self.connect(self.matched_filter, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat")) - self.connect(self.normalize, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat")) - self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-epsilon_f.dat")) - self.connect(self.pk_detect, gr.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat")) - self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-sample_and_hold_f.dat")) - self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-input_c.dat")) - diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pnac.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pnac.py deleted file mode 100644 index 10a125964..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pnac.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 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. -# - -import math -from numpy import fft -from gnuradio import gr - -class ofdm_sync_pnac(gr.hier_block2): - def __init__(self, fft_length, cp_length, kstime, logging=False): - """ - OFDM synchronization using PN Correlation and initial cross-correlation: - F. Tufvesson, O. Edfors, and M. Faulkner, "Time and Frequency Synchronization for OFDM using - PN-Sequency Preambles," IEEE Proc. VTC, 1999, pp. 2203-2207. - - This implementation is meant to be a more robust version of the Schmidl and Cox receiver design. - By correlating against the preamble and using that as the input to the time-delayed correlation, - this circuit produces a very clean timing signal at the end of the preamble. The timing is - more accurate and does not have the problem associated with determining the timing from the - plateau structure in the Schmidl and Cox. - - This implementation appears to require that the signal is received with a normalized power or signal - scalling factor to reduce ambiguities intorduced from partial correlation of the cyclic prefix and - the peak detection. A better peak detection block might fix this. - - Also, the cross-correlation falls apart as the frequency offset gets larger and completely fails - when an integer offset is introduced. Another thing to look at. - """ - - gr.hier_block2.__init__(self, "ofdm_sync_pnac", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature - - - self.input = gr.add_const_cc(0) - - symbol_length = fft_length + cp_length - - # PN Sync with cross-correlation input - - # cross-correlate with the known symbol - kstime = [k.conjugate() for k in kstime[0:fft_length//2]] - kstime.reverse() - self.crosscorr_filter = gr.fir_filter_ccc(1, kstime) - - # Create a delay line - self.delay = gr.delay(gr.sizeof_gr_complex, fft_length/2) - - # Correlation from ML Sync - self.conjg = gr.conjugate_cc(); - self.corr = gr.multiply_cc(); - - # Create a moving sum filter for the input - self.mag = gr.complex_to_mag_squared() - movingsum_taps = (fft_length//1)*[1.0,] - self.power = gr.fir_filter_fff(1,movingsum_taps) - - # Get magnitude (peaks) and angle (phase/freq error) - self.c2mag = gr.complex_to_mag_squared() - self.angle = gr.complex_to_arg() - self.compare = gr.sub_ff() - - self.sample_and_hold = gr.sample_and_hold_ff() - - #ML measurements input to sampler block and detect - self.threshold = gr.threshold_ff(0,0,0) # threshold detection might need to be tweaked - self.peaks = gr.float_to_char() - - self.connect(self, self.input) - - # Cross-correlate input signal with known preamble - self.connect(self.input, self.crosscorr_filter) - - # use the output of the cross-correlation as input time-shifted correlation - self.connect(self.crosscorr_filter, self.delay) - self.connect(self.crosscorr_filter, (self.corr,0)) - self.connect(self.delay, self.conjg) - self.connect(self.conjg, (self.corr,1)) - self.connect(self.corr, self.c2mag) - self.connect(self.corr, self.angle) - self.connect(self.angle, (self.sample_and_hold,0)) - - # Get the power of the input signal to compare against the correlation - self.connect(self.crosscorr_filter, self.mag, self.power) - - # Compare the power to the correlator output to determine timing peak - # When the peak occurs, it peaks above zero, so the thresholder detects this - self.connect(self.c2mag, (self.compare,0)) - self.connect(self.power, (self.compare,1)) - self.connect(self.compare, self.threshold) - self.connect(self.threshold, self.peaks, (self.sample_and_hold,1)) - - # Set output signals - # Output 0: fine frequency correction value - # Output 1: timing signal - self.connect(self.sample_and_hold, (self,0)) - self.connect(self.peaks, (self,1)) - - if logging: - self.connect(self.compare, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-compare_f.dat")) - self.connect(self.c2mag, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-theta_f.dat")) - self.connect(self.power, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-inputpower_f.dat")) - self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-epsilon_f.dat")) - self.connect(self.threshold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-threshold_f.dat")) - self.connect(self.peaks, gr.file_sink(gr.sizeof_char, "ofdm_sync_pnac-peaks_b.dat")) - self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pnac-sample_and_hold_f.dat")) - self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pnac-input_c.dat")) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py index 62f40582e..3aadf700b 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py @@ -73,3 +73,56 @@ class pfb_arb_resampler_ccf(gr.hier_block2): def set_rate(self, rate): self.pfb.set_rate(rate) + + +class pfb_arb_resampler_fff(gr.hier_block2): + ''' + Convenience wrapper for the polyphase filterbank arbitrary resampler. + + The block takes a single float stream in and outputs a single float + stream out. As such, it requires no extra glue to handle the input/output + streams. This block is provided to be consistent with the interface to the + other PFB block. + ''' + def __init__(self, rate, taps=None, flt_size=32, atten=100): + gr.hier_block2.__init__(self, "pfb_arb_resampler_fff", + gr.io_signature(1, 1, gr.sizeof_float), # Input signature + gr.io_signature(1, 1, gr.sizeof_float)) # Output signature + + self._rate = rate + self._size = flt_size + + if taps is not None: + self._taps = taps + else: + # Create a filter that covers the full bandwidth of the input signal + bw = 0.4 + tb = 0.2 + ripple = 0.1 + #self._taps = gr.firdes.low_pass_2(self._size, self._size, bw, tb, atten) + made = False + while not made: + try: + self._taps = optfir.low_pass(self._size, self._size, bw, bw+tb, ripple, atten) + made = True + except RuntimeError: + ripple += 0.01 + made = False + print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) + + # Build in an exit strategy; if we've come this far, it ain't working. + if(ripple >= 1.0): + raise RuntimeError("optfir could not generate an appropriate filter.") + + self.pfb = gr.pfb_arb_resampler_fff(self._rate, self._taps, self._size) + #print "PFB has %d taps\n" % (len(self._taps),) + + self.connect(self, self.pfb) + self.connect(self.pfb, self) + + # Note -- set_taps not implemented in base class yet + def set_taps(self, taps): + self.pfb.set_taps(taps) + + def set_rate(self, rate): + self.pfb.set_rate(rate) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pkt.py b/gnuradio-core/src/python/gnuradio/blks2impl/pkt.py deleted file mode 100644 index 908437ef2..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pkt.py +++ /dev/null @@ -1,164 +0,0 @@ -# -# Copyright 2005, 2006, 2007 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 math import pi -from gnuradio import gr, packet_utils -import gnuradio.gr.gr_threading as _threading - - -# ///////////////////////////////////////////////////////////////////////////// -# mod/demod with packets as i/o -# ///////////////////////////////////////////////////////////////////////////// - -class mod_pkts(gr.hier_block2): - """ - Wrap an arbitrary digital modulator in our packet handling framework. - - Send packets by calling send_pkt - """ - def __init__(self, modulator, access_code=None, msgq_limit=2, pad_for_usrp=True, use_whitener_offset=False): - """ - Hierarchical block for sending packets - - Packets to be sent are enqueued by calling send_pkt. - The output is the complex modulated signal at baseband. - - @param modulator: instance of modulator class (gr_block or hier_block2) - @type modulator: complex baseband out - @param access_code: AKA sync vector - @type access_code: string of 1's and 0's between 1 and 64 long - @param msgq_limit: maximum number of messages in message queue - @type msgq_limit: int - @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples - @param use_whitener_offset: If true, start of whitener XOR string is incremented each packet - - See gmsk_mod for remaining parameters - """ - - gr.hier_block2.__init__(self, "mod_pkts", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._modulator = modulator - self._pad_for_usrp = pad_for_usrp - self._use_whitener_offset = use_whitener_offset - self._whitener_offset = 0 - - if access_code is None: - access_code = packet_utils.default_access_code - if not packet_utils.is_1_0_string(access_code): - raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) - self._access_code = access_code - - # accepts messages from the outside world - self._pkt_input = gr.message_source(gr.sizeof_char, msgq_limit) - self.connect(self._pkt_input, self._modulator, self) - - def send_pkt(self, payload='', eof=False): - """ - Send the payload. - - @param payload: data to send - @type payload: string - """ - if eof: - msg = gr.message(1) # tell self._pkt_input we're not sending any more packets - else: - # print "original_payload =", string_to_hex_list(payload) - pkt = packet_utils.make_packet(payload, - self._modulator.samples_per_symbol(), - self._modulator.bits_per_symbol(), - self._access_code, - self._pad_for_usrp, - self._whitener_offset) - #print "pkt =", string_to_hex_list(pkt) - msg = gr.message_from_string(pkt) - if self._use_whitener_offset is True: - self._whitener_offset = (self._whitener_offset + 1) % 16 - - self._pkt_input.msgq().insert_tail(msg) - - - -class demod_pkts(gr.hier_block2): - """ - Wrap an arbitrary digital demodulator in our packet handling framework. - - The input is complex baseband. When packets are demodulated, they are passed to the - app via the callback. - """ - - def __init__(self, demodulator, access_code=None, callback=None, threshold=-1): - """ - Hierarchical block for demodulating and deframing packets. - - The input is the complex modulated signal at baseband. - Demodulated packets are sent to the handler. - - @param demodulator: instance of demodulator class (gr_block or hier_block2) - @type demodulator: complex baseband in - @param access_code: AKA sync vector - @type access_code: string of 1's and 0's - @param callback: function of two args: ok, payload - @type callback: ok: bool; payload: string - @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default) - @type threshold: int - """ - - gr.hier_block2.__init__(self, "demod_pkts", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(0, 0, 0)) # Output signature - - self._demodulator = demodulator - if access_code is None: - access_code = packet_utils.default_access_code - if not packet_utils.is_1_0_string(access_code): - raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) - self._access_code = access_code - - if threshold == -1: - threshold = 12 # FIXME raise exception - - self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY - self.correlator = gr.correlate_access_code_bb(access_code, threshold) - - self.framer_sink = gr.framer_sink_1(self._rcvd_pktq) - self.connect(self, self._demodulator, self.correlator, self.framer_sink) - - self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) - - -class _queue_watcher_thread(_threading.Thread): - def __init__(self, rcvd_pktq, callback): - _threading.Thread.__init__(self) - self.setDaemon(1) - self.rcvd_pktq = rcvd_pktq - self.callback = callback - self.keep_running = True - self.start() - - - def run(self): - while self.keep_running: - msg = self.rcvd_pktq.delete_head() - ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1())) - if self.callback: - self.callback(ok, payload) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/psk.py b/gnuradio-core/src/python/gnuradio/blks2impl/psk.py deleted file mode 100644 index acedf3b69..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/psk.py +++ /dev/null @@ -1,94 +0,0 @@ -# -# Copyright 2005,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. -# - -from math import pi, sqrt, log10 -import math, cmath - -# The following algorithm generates Gray coded constellations for M-PSK for M=[2,4,8] -def make_gray_constellation(m): - # number of bits/symbol (log2(M)) - k = int(log10(m) / log10(2.0)) - - coeff = 1 - const_map = [] - bits = [0]*3 - for i in range(m): - # get a vector of the k bits to use in this mapping - bits[3-k:3] = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(k)] - - theta = -(2*bits[0]-1)*(2*pi/m)*(bits[0]+abs(bits[1]-bits[2])+2*bits[1]) - re = math.cos(theta) - im = math.sin(theta) - const_map.append(complex(re, im)) # plug it into the constellation - - # return the constellation; by default, it is normalized - return const_map - -# This makes a constellation that increments around the unit circle -def make_constellation(m): - return [cmath.exp(i * 2 * pi / m * 1j) for i in range(m)] - -# Common definition of constellations for Tx and Rx -constellation = { - 2 : make_constellation(2), # BPSK - 4 : make_constellation(4), # QPSK - 8 : make_constellation(8) # 8PSK - } - -gray_constellation = { - 2 : make_gray_constellation(2), # BPSK - 4 : make_gray_constellation(4), # QPSK - 8 : make_gray_constellation(8) # 8PSK - } - -# ----------------------- -# Do Gray code -# ----------------------- -# binary to gray coding -- constellation does Gray coding -binary_to_gray = { - 2 : range(2), - 4 : [0,1,3,2], - 8 : [0, 1, 3, 2, 7, 6, 4, 5] - } - -# gray to binary -gray_to_binary = { - 2 : range(2), - 4 : [0,1,3,2], - 8 : [0, 1, 3, 2, 6, 7, 5, 4] - } - -# ----------------------- -# Don't Gray code -# ----------------------- -# identity mapping -binary_to_ungray = { - 2 : range(2), - 4 : range(4), - 8 : range(8) - } - -# identity mapping -ungray_to_binary = { - 2 : range(2), - 4 : range(4), - 8 : range(8) - } diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam.py deleted file mode 100644 index 22b1e1dab..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/qam.py +++ /dev/null @@ -1,113 +0,0 @@ -# -# Copyright 2005,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. -# - -from math import pi, sqrt -import math - -# These constellations are generated for Gray coding when symbos [1, ..., m] are used -# Mapping to Gray coding is therefore unnecessary - -def make_constellation(m): - # number of bits/symbol (log2(M)) - k = int(math.log10(m) / math.log10(2.0)) - - coeff = 1 - const_map = [] - for i in range(m): - a = (i&(0x01 << k-1)) >> k-1 - b = (i&(0x01 << k-2)) >> k-2 - bits_i = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(2, k, 2)] - bits_q = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(3, k, 2)] - - ss = 0 - ll = len(bits_i) - for ii in range(ll): - rr = 0 - for jj in range(ll-ii): - rr = abs(bits_i[jj] - rr) - ss += rr*pow(2.0, ii+1) - re = (2*a-1)*(ss+1) - - ss = 0 - ll = len(bits_q) - for ii in range(ll): - rr = 0 - for jj in range(ll-ii): - rr = abs(bits_q[jj] - rr) - ss += rr*pow(2.0, ii+1) - im = (2*b-1)*(ss+1) - - a = max(re, im) - if a > coeff: - coeff = a - const_map.append(complex(re, im)) - - norm_map = [complex(i.real/coeff, i.imag/coeff) for i in const_map] - return norm_map - -# Common definition of constellations for Tx and Rx -constellation = { - 4 : make_constellation(4), # QAM4 (QPSK) - 8 : make_constellation(8), # QAM8 - 16: make_constellation(16), # QAM16 - 64: make_constellation(64), # QAM64 - 256: make_constellation(256) # QAM256 - } - -# ----------------------- -# Do Gray code -# ----------------------- -# binary to gray coding -binary_to_gray = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64), - 256: range(256) - } - -# gray to binary -gray_to_binary = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64), - 256: range(256) - } - -# ----------------------- -# Don't Gray code -# ----------------------- -# identity mapping -binary_to_ungray = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64) - } - -# identity mapping -ungray_to_binary = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64) - } diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam16.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam16.py deleted file mode 100644 index 0bdb9c6fb..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/qam16.py +++ /dev/null @@ -1,208 +0,0 @@ -# -# Copyright 2005,2006,2007 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -QAM16 modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils -from math import pi, sqrt -import qam -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_costas_alpha = None -_def_gain_mu = 0.03 -_def_mu = 0.05 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM16 modulator -# ///////////////////////////////////////////////////////////////////////////// - -class qam16_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "qam16_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol) - - ntaps = 11 * samples_per_symbol - - arity = pow(2, self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - rot = 1.0 - print "constellation with %d arity" % arity - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const) - - # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( - self._samples_per_symbol, # gain (sps since we're interpolating by sps) - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - - self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 4 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "Gray code = %s" % self._gray_code - print "RRS roll-off factor = %f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat")) - - def add_options(parser): - """ - Adds QAM modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(qam16_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM16 demodulator -# -# ///////////////////////////////////////////////////////////////////////////// - -class qam16_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - costas_alpha=_def_costas_alpha, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - gr.hier_block2.__init__(self, "qam16_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - # do this - pass - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 4 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - -# -# Add these to the mod/demod registry -# -# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK -#modulation_utils.add_type_1_mod('qam16', qam16_mod) -#modulation_utils.add_type_1_demod('qam16', qam16_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam256.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam256.py deleted file mode 100644 index fc455f17c..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/qam256.py +++ /dev/null @@ -1,209 +0,0 @@ -# -# Copyright 2005,2006,2007 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -QAM256 modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils -from math import pi, sqrt -import qam -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_costas_alpha = None -_def_gain_mu = 0.03 -_def_mu = 0.05 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM256 modulator -# ///////////////////////////////////////////////////////////////////////////// - -class qam256_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "qam256_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol) - - ntaps = 11 * samples_per_symbol - - arity = pow(2, self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - rot = 1.0 - print "constellation with %d arity" % arity - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const) - - # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( - self._samples_per_symbol, # gain (sps since we're interpolating by sps) - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - - self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 8 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "Gray code = %s" % self._gray_code - print "RRS roll-off factor = %f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat")) - - def add_options(parser): - """ - Adds QAM modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(qam256_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM256 demodulator -# -# ///////////////////////////////////////////////////////////////////////////// - -class qam256_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - costas_alpha=_def_costas_alpha, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - gr.hier_block2.__init__(self, "qam256_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - - # do this - pass - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 8 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - -# -# Add these to the mod/demod registry -# -# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK -#modulation_utils.add_type_1_mod('qam256', qam256_mod) -#modulation_utils.add_type_1_demod('qam256', qam256_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam64.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam64.py deleted file mode 100644 index 5509f3745..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/qam64.py +++ /dev/null @@ -1,208 +0,0 @@ -# -# Copyright 2005,2006,2007 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -differential QPSK modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils -from math import pi, sqrt -import qam -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_costas_alpha = None -_def_gain_mu = 0.03 -_def_mu = 0.05 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM64 modulator -# ///////////////////////////////////////////////////////////////////////////// - -class qam64_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "qam64_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol) - - ntaps = 11 * samples_per_symbol - - arity = pow(2, self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - rot = 1.0 - print "constellation with %d arity" % arity - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const) - - # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( - self._samples_per_symbol, # gain (sps since we're interpolating by sps) - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - - self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 6 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "Gray code = %s" % self._gray_code - print "RRS roll-off factor = %f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat")) - - def add_options(parser): - """ - Adds QAM modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(qam64_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM16 demodulator -# -# ///////////////////////////////////////////////////////////////////////////// - -class qam64_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - costas_alpha=_def_costas_alpha, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - gr.hier_block2.__init__(self, "qam64_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - - # do this - pass - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 6 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - -# -# Add these to the mod/demod registry -# -# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK -#modulation_utils.add_type_1_mod('qam64', qam64_mod) -#modulation_utils.add_type_1_demod('qam16', qam16_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam8.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam8.py deleted file mode 100644 index 6a7b35597..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/qam8.py +++ /dev/null @@ -1,209 +0,0 @@ -# -# Copyright 2005,2006,2007 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. -# - -# See gnuradio-examples/python/digital for examples - -""" -QAM8 modulation and demodulation. -""" - -from gnuradio import gr, gru, modulation_utils -from math import pi, sqrt -import qam -import cmath -from pprint import pprint - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_gray_code = True -_def_verbose = False -_def_log = False - -_def_costas_alpha = None -_def_gain_mu = 0.03 -_def_mu = 0.05 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM8 modulator -# ///////////////////////////////////////////////////////////////////////////// - -class qam8_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: integer - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param gray_code: Tell modulator to Gray code the bits - @type gray_code: bool - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - - gr.hier_block2.__init__(self, "qam8_mod", - gr.io_signature(1, 1, gr.sizeof_char), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._excess_bw = excess_bw - self._gray_code = gray_code - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol) - - ntaps = 11 * samples_per_symbol - - arity = pow(2, self.bits_per_symbol()) - - # turn bytes into k-bit vectors - self.bytes2chunks = \ - gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST) - - if self._gray_code: - self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity]) - else: - self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity]) - - self.diffenc = gr.diff_encoder_bb(arity) - - rot = 1.0 - print "constellation with %d arity" % arity - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const) - - # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( - self._samples_per_symbol, # gain (sps since we're interpolating by sps) - self._samples_per_symbol, # sampling rate - 1.0, # symbol rate - self._excess_bw, # excess bandwidth (roll-off factor) - ntaps) - - self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) - - if verbose: - self._print_verbage() - - if log: - self._setup_logging() - - # Connect - self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc, - self.chunks2symbols, self.rrc_filter, self) - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 3 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "Gray code = %s" % self._gray_code - print "RRS roll-off factor = %f" % self._excess_bw - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "bytes2chunks.dat")) - self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "graycoder.dat")) - self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "diffenc.dat")) - self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat")) - self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat")) - - def add_options(parser): - """ - Adds QAM modulation-specific options to the standard parser - """ - parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw, - help="set RRC excess bandwith factor [default=%default] (PSK)") - parser.add_option("", "--no-gray-code", dest="gray_code", - action="store_false", default=_def_gray_code, - help="disable gray coding on modulated bits (PSK)") - add_options=staticmethod(add_options) - - - def extract_kwargs_from_options(options): - """ - Given command line options, create dictionary suitable for passing to __init__ - """ - return modulation_utils.extract_kwargs_from_options(qam8_mod.__init__, - ('self',), options) - extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# QAM8 demodulator -# -# ///////////////////////////////////////////////////////////////////////////// - -class qam8_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - costas_alpha=_def_costas_alpha, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - gray_code=_def_gray_code, - verbose=_def_verbose, - log=_def_log): - - gr.hier_block2.__init__(self, "qam8_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - - # do this - pass - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 3 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM - -# -# Add these to the mod/demod registry -# -# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK -modulation_utils.add_type_1_mod('qam8', qam8_mod) -#modulation_utils.add_type_1_demod('qam8', qam8_demod) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py index 858b9cde6..14eaa1606 100755 --- a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py @@ -28,8 +28,9 @@ class wfm_rcv_fmdet(gr.hier_block2): """ Hierarchical block for demodulating a broadcast FM signal. - The input is the downconverted complex baseband signal (gr_complex). - The output is two streams of the demodulated audio (float) 0=Left, 1=Right. + The input is the downconverted complex baseband signal + (gr_complex). The output is two streams of the demodulated + audio (float) 0=Left, 1=Right. @param demod_rate: input sample rate of complex baseband input. @type demod_rate: float @@ -39,16 +40,15 @@ class wfm_rcv_fmdet(gr.hier_block2): gr.hier_block2.__init__(self, "wfm_rcv_fmdet", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(2, 2, gr.sizeof_float)) # Output signature - lowfreq = -125e3 - highfreq = 125e3 + lowfreq = -125e3/demod_rate + highfreq = 125e3/demod_rate audio_rate = demod_rate / audio_decimation - - # We assign to self so that outsiders can grab the demodulator + # We assign to self so that outsiders can grab the demodulator # if they need to. E.g., to plot its output. # # input: complex; output: float - + self.fm_demod = gr.fmdet_cf (demod_rate, lowfreq, highfreq, 0.05) # input: float; output: float @@ -62,25 +62,31 @@ class wfm_rcv_fmdet(gr.hier_block2): 15000 , width_of_transition_band, gr.firdes.WIN_HAMMING) + # input: float; output: float self.audio_filter = gr.fir_filter_fff (audio_decimation, audio_coeffs) if 1: - # Pick off the stereo carrier/2 with this filter. It attenuated 10 dB so apply 10 dB gain - # We pick off the negative frequency half because we want to base band by it! - ## NOTE THIS WAS HACKED TO OFFSET INSERTION LOSS DUE TO DEEMPHASIS + # Pick off the stereo carrier/2 with this filter. It + # attenuated 10 dB so apply 10 dB gain We pick off the + # negative frequency half because we want to base band by + # it! + ## NOTE THIS WAS HACKED TO OFFSET INSERTION LOSS DUE TO + ## DEEMPHASIS stereo_carrier_filter_coeffs = gr.firdes.complex_band_pass(10.0, - demod_rate, - -19020, - -18980, - width_of_transition_band, - gr.firdes.WIN_HAMMING) + demod_rate, + -19020, + -18980, + width_of_transition_band, + gr.firdes.WIN_HAMMING) #print "len stereo carrier filter = ",len(stereo_carrier_filter_coeffs) #print "stereo carrier filter ", stereo_carrier_filter_coeffs #print "width of transition band = ",width_of_transition_band, " audio rate = ", audio_rate - # Pick off the double side band suppressed carrier Left-Right audio. It is attenuated 10 dB so apply 10 dB gain + # Pick off the double side band suppressed carrier + # Left-Right audio. It is attenuated 10 dB so apply 10 dB + # gain stereo_dsbsc_filter_coeffs = gr.firdes.complex_band_pass(20.0, demod_rate, @@ -90,101 +96,120 @@ class wfm_rcv_fmdet(gr.hier_block2): gr.firdes.WIN_HAMMING) #print "len stereo dsbsc filter = ",len(stereo_dsbsc_filter_coeffs) #print "stereo dsbsc filter ", stereo_dsbsc_filter_coeffs - # construct overlap add filter system from coefficients for stereo carrier - self.stereo_carrier_filter = gr.fir_filter_fcc(audio_decimation, stereo_carrier_filter_coeffs) - - # carrier is twice the picked off carrier so arrange to do a commplex multiply + # construct overlap add filter system from coefficients + # for stereo carrier + self.stereo_carrier_filter = gr.fir_filter_fcc(audio_decimation, + stereo_carrier_filter_coeffs) + # carrier is twice the picked off carrier so arrange to do + # a commplex multiply self.stereo_carrier_generator = gr.multiply_cc(); # Pick off the rds signal - stereo_rds_filter_coeffs = gr.firdes.complex_band_pass(30.0, - demod_rate, - 57000 - 1500, - 57000 + 1500, - width_of_transition_band, - gr.firdes.WIN_HAMMING) + demod_rate, + 57000 - 1500, + 57000 + 1500, + width_of_transition_band, + gr.firdes.WIN_HAMMING) #print "len stereo dsbsc filter = ",len(stereo_dsbsc_filter_coeffs) #print "stereo dsbsc filter ", stereo_dsbsc_filter_coeffs # construct overlap add filter system from coefficients for stereo carrier - self.rds_signal_filter = gr.fir_filter_fcc(audio_decimation, stereo_rds_filter_coeffs) - - - - - - + self.rds_signal_filter = gr.fir_filter_fcc(audio_decimation, + stereo_rds_filter_coeffs) self.rds_carrier_generator = gr.multiply_cc(); self.rds_signal_generator = gr.multiply_cc(); self_rds_signal_processor = gr.null_sink(gr.sizeof_gr_complex); - - - alpha = 5 * 0.25 * math.pi / (audio_rate) - beta = alpha * alpha / 4.0 + loop_bw = 2*math.pi/100.0 max_freq = -2.0*math.pi*18990/audio_rate; - min_freq = -2.0*math.pi*19010/audio_rate; + min_freq = -2.0*math.pi*19010/audio_rate; + self.stereo_carrier_pll_recovery = gr.pll_refout_cc(loop_bw, + max_freq, + min_freq); + + #self.stereo_carrier_pll_recovery.squelch_enable(False) + ##pll_refout does not have squelch yet, so disabled for + #now - self.stereo_carrier_pll_recovery = gr.pll_refout_cc(alpha,beta,max_freq,min_freq); - #self.stereo_carrier_pll_recovery.squelch_enable(False) #pll_refout does not have squelch yet, so disabled for now - - - # set up mixer (multiplier) to get the L-R signal at baseband + # set up mixer (multiplier) to get the L-R signal at + # baseband self.stereo_basebander = gr.multiply_cc(); - # pick off the real component of the basebanded L-R signal. The imaginary SHOULD be zero + # pick off the real component of the basebanded L-R + # signal. The imaginary SHOULD be zero self.LmR_real = gr.complex_to_real(); self.Make_Left = gr.add_ff(); self.Make_Right = gr.sub_ff(); - self.stereo_dsbsc_filter = gr.fir_filter_fcc(audio_decimation, stereo_dsbsc_filter_coeffs) + self.stereo_dsbsc_filter = gr.fir_filter_fcc(audio_decimation, + stereo_dsbsc_filter_coeffs) if 1: - # send the real signal to complex filter to pick off the carrier and then to one side of a multiplier - self.connect (self, self.fm_demod,self.stereo_carrier_filter,self.stereo_carrier_pll_recovery, (self.stereo_carrier_generator,0)) + # send the real signal to complex filter to pick off the + # carrier and then to one side of a multiplier + self.connect (self, self.fm_demod, self.stereo_carrier_filter, + self.stereo_carrier_pll_recovery, + (self.stereo_carrier_generator,0)) + # send the already filtered carrier to the otherside of the carrier + # the resulting signal from this multiplier is the carrier + # with correct phase but at -38000 Hz. self.connect (self.stereo_carrier_pll_recovery, (self.stereo_carrier_generator,1)) - # the resulting signal from this multiplier is the carrier with correct phase but at -38000 Hz. # send the new carrier to one side of the mixer (multiplier) self.connect (self.stereo_carrier_generator, (self.stereo_basebander,0)) + # send the demphasized audio to the DSBSC pick off filter, the complex # DSBSC signal at +38000 Hz is sent to the other side of the mixer/multiplier - self.connect (self.fm_demod,self.stereo_dsbsc_filter, (self.stereo_basebander,1)) # the result is BASEBANDED DSBSC with phase zero! + self.connect (self.fm_demod,self.stereo_dsbsc_filter, (self.stereo_basebander,1)) - # Pick off the real part since the imaginary is theoretically zero and then to one side of a summer + # Pick off the real part since the imaginary is + # theoretically zero and then to one side of a summer self.connect (self.stereo_basebander, self.LmR_real, (self.Make_Left,0)) - #take the same real part of the DSBSC baseband signal and send it to negative side of a subtracter + + #take the same real part of the DSBSC baseband signal and + #send it to negative side of a subtracter self.connect (self.LmR_real,(self.Make_Right,1)) - # Make rds carrier by taking the squared pilot tone and multiplying by pilot tone + # Make rds carrier by taking the squared pilot tone and + # multiplying by pilot tone self.connect (self.stereo_basebander,(self.rds_carrier_generator,0)) self.connect (self.stereo_carrier_pll_recovery,(self.rds_carrier_generator,1)) - # take signal, filter off rds, send into mixer 0 channel + + # take signal, filter off rds, send into mixer 0 channel self.connect (self.fm_demod,self.rds_signal_filter,(self.rds_signal_generator,0)) - # take rds_carrier_generator output and send into mixer 1 channel + + # take rds_carrier_generator output and send into mixer 1 + # channel self.connect (self.rds_carrier_generator,(self.rds_signal_generator,1)) - # send basebanded rds signal and send into "processor" which for now is a null sink + + # send basebanded rds signal and send into "processor" + # which for now is a null sink self.connect (self.rds_signal_generator,self_rds_signal_processor) if 1: - # pick off the audio, L+R that is what we used to have and send it to the summer + # pick off the audio, L+R that is what we used to have and + # send it to the summer self.connect(self.fm_demod, self.audio_filter, (self.Make_Left, 1)) - # take the picked off L+R audio and send it to the PLUS side of the subtractor + + # take the picked off L+R audio and send it to the PLUS + # side of the subtractor self.connect(self.audio_filter,(self.Make_Right, 0)) + # The result of Make_Left gets (L+R) + (L-R) and results in 2*L # The result of Make_Right gets (L+R) - (L-R) and results in 2*R self.connect(self.Make_Left , self.deemph_Left, (self, 0)) self.connect(self.Make_Right, self.deemph_Right, (self, 1)) + # NOTE: mono support will require variable number of outputs in hier_block2s # See ticket:174 in Trac database #else: diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py index dd0fae6e7..a2c1b3651 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py @@ -47,11 +47,9 @@ class wfm_rcv_pll(gr.hier_block2): # if they need to. E.g., to plot its output. # # input: complex; output: float - alpha = 0.25*bandwidth * math.pi / demod_rate - beta = alpha * alpha / 4.0 + loop_bw = 2*math.pi/100.0 max_freq = 2.0*math.pi*90e3/demod_rate - - self.fm_demod = gr.pll_freqdet_cf (alpha,beta,max_freq,-max_freq) + self.fm_demod = gr.pll_freqdet_cf (loop_bw, max_freq,-max_freq) # input: float; output: float self.deemph_Left = fm_deemph (audio_rate) @@ -125,12 +123,11 @@ class wfm_rcv_pll(gr.hier_block2): - alpha = 5 * 0.25 * math.pi / (audio_rate) - beta = alpha * alpha / 4.0 + loop_bw = 2*math.pi/100.0 max_freq = -2.0*math.pi*18990/audio_rate; min_freq = -2.0*math.pi*19010/audio_rate; - self.stereo_carrier_pll_recovery = gr.pll_refout_cc(alpha,beta,max_freq,min_freq); + self.stereo_carrier_pll_recovery = gr.pll_refout_cc(loop_bw, max_freq, min_freq); #self.stereo_carrier_pll_recovery.squelch_enable(False) #pll_refout does not have squelch yet, so disabled for now diff --git a/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt new file mode 100644 index 000000000..7b62a2f1e --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/CMakeLists.txt @@ -0,0 +1,52 @@ +# Copyright 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. + +######################################################################## +include(GrPython) + +GR_PYTHON_INSTALL(FILES + __init__.py + exceptions.py + gr_threading.py + gr_threading_23.py + gr_threading_24.py + hier_block2.py + prefs.py + top_block.py + pubsub.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr + COMPONENT "core_python" +) + +######################################################################## +# Handle the unit tests +######################################################################## +if(ENABLE_TESTING) +include(GrTest) +file(GLOB py_qa_test_files "qa_*.py") +foreach(py_qa_test_file ${py_qa_test_files}) + get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) + set(GR_TEST_PYTHON_DIRS + ${CMAKE_BINARY_DIR}/gnuradio-core/src/python + ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig + ) + set(GR_TEST_TARGET_DEPS gruel gnuradio-core) + GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${py_qa_test_file}) +endforeach(py_qa_test_file) +endif(ENABLE_TESTING) diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am index 45c970227..0960323dc 100644 --- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am @@ -49,11 +49,8 @@ noinst_PYTHON = \ qa_argmax.py \ qa_bin_statistics.py \ qa_classify.py \ - qa_cma_equalizer.py \ qa_complex_to_xxx.py \ - qa_constellation_decoder_cb.py \ qa_copy.py \ - qa_correlate_access_code.py \ qa_delay.py \ qa_dc_blocker.py \ qa_diff_encoder.py \ @@ -82,7 +79,6 @@ noinst_PYTHON = \ qa_mute.py \ qa_nlog10.py \ qa_noise.py \ - qa_ofdm_insert_preamble.py \ qa_packed_to_unpacked.py \ qa_pipe_fittings.py \ qa_pll_carriertracking.py \ diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py b/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py deleted file mode 100755 index 79e9cd092..000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2010 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 - -class test_cma_equalizer_fir(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def transform(self, src_data): - SRC = gr.vector_source_c(src_data, False) - EQU = gr.cma_equalizer_cc(4, 1.0, .001) - DST = gr.vector_sink_c() - self.tb.connect(SRC, EQU, DST) - self.tb.run() - return DST.data() - - def test_001_identity(self): - # Constant modulus signal so no adjustments - src_data = (1+0j, 0+1j, -1+0j, 0-1j)*1000 - expected_data = src_data - result = self.transform(src_data) - self.assertComplexTuplesAlmostEqual(expected_data, result) - -if __name__ == "__main__": - gr_unittest.run(test_cma_equalizer_fir, "test_cma_equalizer_fir.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_constellation_decoder_cb.py b/gnuradio-core/src/python/gnuradio/gr/qa_constellation_decoder_cb.py deleted file mode 100755 index 27e1802e0..000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_constellation_decoder_cb.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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 -import math - -class test_constellation_decoder (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_constellation_decoder_cb (self): - symbol_positions = [1 + 0j, 0 + 1j , -1 + 0j, 0 - 1j] - symbol_values_out = [0, 1, 2, 3] - expected_result = ( 0, 3, 2, 1, 0, 0, 3) - src_data = (0.5 + 0j, 0.1 - 1.2j, -0.8 - 0.1j, -0.45 + 0.8j, 0.8 - 0j, 0.5 + 0j, 0.1 - 1.2j) - src = gr.vector_source_c (src_data) - op = gr.constellation_decoder_cb (symbol_positions, symbol_values_out) - dst = gr.vector_sink_b () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () # run the graph and wait for it to finish - actual_result = dst.data () # fetch the contents of the sink - #print "actual result", actual_result - #print "expected result", expected_result - self.assertFloatTuplesAlmostEqual (expected_result, actual_result) - - -if __name__ == '__main__': - gr_unittest.run(test_constellation_decoder, "test_constellation_decoder.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py b/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py deleted file mode 100755 index b3575f4e6..000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2010 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 -import math - -default_access_code = '\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC' - -def string_to_1_0_list(s): - r = [] - for ch in s: - x = ord(ch) - for i in range(8): - t = (x >> i) & 0x1 - r.append(t) - - return r - -def to_1_0_string(L): - return ''.join(map(lambda x: chr(x + ord('0')), L)) - -class test_correlate_access_code(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_001(self): - pad = (0,) * 64 - # 0 0 0 1 0 0 0 1 - src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7 - expected_result = pad + (1, 0, 1, 1, 3, 1, 0, 1, 1, 2) + (0,) * 6 - src = gr.vector_source_b (src_data) - op = gr.correlate_access_code_bb("1011", 0) - dst = gr.vector_sink_b () - self.tb.connect (src, op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - - - def test_002(self): - code = tuple(string_to_1_0_list(default_access_code)) - access_code = to_1_0_string(code) - pad = (0,) * 64 - #print code - #print access_code - src_data = code + (1, 0, 1, 1) + pad - expected_result = pad + code + (3, 0, 1, 1) - src = gr.vector_source_b (src_data) - op = gr.correlate_access_code_bb(access_code, 0) - dst = gr.vector_sink_b () - self.tb.connect (src, op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - - - -if __name__ == '__main__': - gr_unittest.run(test_correlate_access_code, "test_correlate_access_code.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py b/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py deleted file mode 100755 index d69f5ca5b..000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 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 pprint import pprint - -class test_ofdm_insert_preamble (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def helper(self, v0, v1, fft_length, preamble): - tb = self.tb - src0 = gr.vector_source_c(v0) - src1 = gr.vector_source_b(v1) - - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_length) - - # print "len(v) = %d" % (len(v)) - - op = gr.ofdm_insert_preamble(fft_length, preamble) - - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_length) - dst0 = gr.vector_sink_c() - dst1 = gr.vector_sink_b() - - tb.connect(src0, s2v, (op, 0)) - tb.connect(src1, (op, 1)) - tb.connect((op, 0), v2s, dst0) - tb.connect((op, 1), dst1) - - tb.run() - r0 = dst0.data() - r0v = [] - for i in range(len(r0)//fft_length): - r0v.append(r0[i*fft_length:(i+1)*fft_length]) - - r1 = dst1.data() - self.assertEqual(len(r0v), len(r1)) - return (r1, r0v) - - def check_match(self, actual, expected_list): - lst = [] - map(lambda x: lst.append(x), expected_list) - self.assertEqual(actual, lst) - - - # ---------------------------------------------------------------- - - def test_000(self): - # no preamble, 1 symbol payloads - - preamble = () - fft_length = 8 - npayloads = 8 - v = [] - p = [] - for i in range(npayloads): - t = fft_length*[(i + i*1j)] - p.append(tuple(t)) - v += t - - p = tuple(p) - - r = self.helper(v, npayloads*[1], fft_length, preamble) - # pprint(r) - - self.assertEqual(r[0], tuple(npayloads*[1])) - self.check_match(r[1], (p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7])) - - - def test_001(self): - # 1 symbol preamble, 1 symbol payloads - preamble = ((100, 101, 102, 103, 104, 105, 106, 107),) - p0 = preamble[0] - fft_length = 8 - npayloads = 8 - v = [] - p = [] - for i in range(npayloads): - t = fft_length*[(i + i*1j)] - p.append(tuple(t)) - v += t - - - r = self.helper(v, npayloads*[1], fft_length, preamble) - - self.assertEqual(r[0], tuple(npayloads*[1, 0])) - self.check_match(r[1], (p0, p[0], - p0, p[1], - p0, p[2], - p0, p[3], - p0, p[4], - p0, p[5], - p0, p[6], - p0, p[7])) - - def test_002(self): - # 2 symbol preamble, 1 symbol payloads - preamble = ((100, 101, 102, 103, 104, 105, 106, 107), - (200, 201, 202, 203, 204, 205, 206, 207)) - p0 = preamble[0] - p1 = preamble[1] - - fft_length = 8 - npayloads = 8 - v = [] - p = [] - for i in range(npayloads): - t = fft_length*[(i + i*1j)] - p.append(tuple(t)) - v += t - - r = self.helper(v, npayloads*[1], fft_length, preamble) - - self.assertEqual(r[0], tuple(npayloads*[1, 0, 0])) - self.check_match(r[1], (p0, p1, p[0], - p0, p1, p[1], - p0, p1, p[2], - p0, p1, p[3], - p0, p1, p[4], - p0, p1, p[5], - p0, p1, p[6], - p0, p1, p[7])) - - - def xtest_003_preamble(self): - # 2 symbol preamble, 2 symbol payloads - preamble = ((100, 101, 102, 103, 104, 105, 106, 107), - (200, 201, 202, 203, 204, 205, 206, 207)) - p0 = preamble[0] - p1 = preamble[1] - - fft_length = 8 - npayloads = 8 - v = [] - p = [] - for i in range(npayloads * 2): - t = fft_length*[(i + i*1j)] - p.append(tuple(t)) - v += t - - r = self.helper(v, npayloads*[1, 0], fft_length, preamble) - - self.assertEqual(r[0], tuple(npayloads*[1, 0, 0, 0])) - self.check_match(r[1], (p0, p1, p[0], p[1], - p0, p1, p[2], p[3], - p0, p1, p[4], p[5], - p0, p1, p[6], p[7], - p0, p1, p[8], p[9], - p0, p1, p[10], p[11], - p0, p1, p[12], p[13], - p0, p1, p[14], p[15])) - - -if __name__ == '__main__': - gr_unittest.run(test_ofdm_insert_preamble, "test_ofdm_insert_preamble.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py b/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py index 47f0ecb22..5977c1b52 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -34,115 +34,114 @@ class test_pll_carriertracking (gr_unittest.TestCase): def test_pll_carriertracking (self): expected_result = ((1.00000238419+7.21919457547e-09j), (0.998025715351+0.062790453434j), - (0.992878139019+0.119114711881j), - (0.985585451126+0.16916936636j), - (0.976963579655+0.21341380477j), - (0.967643141747+0.252319812775j), - (0.958120942116+0.286356031895j), - (0.948766887188+0.315971136093j), - (0.939851403236+0.341586351395j), - (0.931558966637+0.363589793444j), - (0.924019515514+0.382339715958j), - (0.917312920094+0.398162424564j), - (0.9114767313+0.411352336407j), - (0.906515955925+0.422172755003j), - (0.902329206467+0.431043088436j), - (0.8989828825+0.437978446484j), - (0.896438419819+0.443168222904j), - (0.894643902779+0.446782171726j), - (0.893543541431+0.448972672224j), - (0.893085837364+0.449881345034j), - (0.893211960793+0.449634194374j), - (0.893862366676+0.448344886303j), - (0.894974172115+0.446114838123j), - (0.89649784565+0.443042784929j), - (0.898379862309+0.439216792583j), - (0.900570392609+0.434715718031j), - (0.902926802635+0.429791986942j), - (0.905423760414+0.424503326416j), - (0.908115327358+0.418716549873j), - (0.910964310169+0.412489384413j), - (0.913929581642+0.405871063471j), - (0.916985273361+0.398915469646j), - (0.920104384422+0.391668856144j), - (0.923261523247+0.384174525738j), - (0.926428377628+0.376470327377j), - (0.929587602615+0.3685952425j), - (0.932724237442+0.360585510731j), - (0.935822367668+0.352472603321j), - (0.938865244389+0.344285786152j), - (0.941773712635+0.336241692305j), - (0.944620370865+0.328158795834j), - (0.94739818573+0.32005661726j), - (0.950098872185+0.311952739954j), - (0.952714562416+0.303861320019j), - (0.955247402191+0.295800030231j), - (0.957694888115+0.287783116102j), - (0.960053324699+0.279822826385j), - (0.962315440178+0.271930038929j), - (0.96448802948+0.264117747545j), - (0.966570436954+0.256397068501j), - (0.968563258648+0.248777091503j), - (0.970409572124+0.241460204124j), - (0.972127914429+0.234440952539j), - (0.97377294302+0.227515518665j), - (0.975345790386+0.220690101385j), - (0.976839780807+0.213968709111j), - (0.978262722492+0.207358703017j), - (0.979616940022+0.200864806771j), - (0.980905056+0.194491744041j), - (0.982122182846+0.188243359327j), - (0.983273088932+0.18212479353j), - (0.984363257885+0.176140069962j), - (0.985394001007+0.170292437077j), - (0.986363172531+0.16458517313j), - (0.98724168539+0.159217983484j), - (0.988072276115+0.153976023197j), - (0.988858819008+0.148855358362j), - (0.989599764347+0.143855035305j), - (0.990294575691+0.138971716166j), - (0.990951240063+0.134203910828j), - (0.991572141647+0.129550367594j), - (0.992157161236+0.125009477139j), - (0.992702245712+0.120578929782j), - (0.993216574192+0.116259463131j), - (0.993701457977+0.112050771713j), - (0.994158565998+0.107951454818j), - (0.994559407234+0.104160495102j), - (0.9949182868+0.100662395358j), - (0.995259582996+0.0972395762801j), - (0.995584189892+0.0938917249441j), - (0.995885193348+0.0906178206205j), - (0.99616932869+0.0874189138412j), - (0.996438741684+0.0842954516411j), - (0.996694862843+0.0812477469444j), - (0.996931552887+0.0782764554024j), - (0.997152447701+0.0753828883171j), - (0.997361660004+0.0725681483746j), - (0.997559130192+0.0698337852955j), - (0.997741162777+0.067180365324j), - (0.99789583683+0.0648084580898j), - (0.998042702675+0.0624987781048j), - (0.998183488846+0.0602464973927j), - (0.998314678669+0.0580499768257j), - (0.998434245586+0.0559054017067j), - (0.998548746109+0.053810685873j), - (0.998658537865+0.0517641305923j), - (0.998762428761+0.0497645735741j), - (0.998855054379+0.0478102117777j), - (0.998943626881+0.0459015443921j), - (0.999028742313+0.0440383702517j)) + (0.992777824402+0.119947694242j), + (0.985192835331+0.171441286802j), + (0.976061582565+0.217501848936j), + (0.966034710407+0.258409559727j), + (0.95565611124+0.294477283955j), + (0.945357382298+0.326030552387j), + (0.935475051403+0.353395611048j), + (0.926258146763+0.376889169216j), + (0.917895197868+0.39681750536j), + (0.910515546799+0.413470208645j), + (0.904196679592+0.427117019892j), + (0.898972511292+0.438006043434j), + (0.894769787788+0.446523308754j), + (0.891652584076+0.452715367079j), + (0.8895829916+0.456773489714j), + (0.888502895832+0.458873122931j), + (0.888343691826+0.459175437689j), + (0.889035582542+0.457833081484j), + (0.890497922897+0.454985737801j), + (0.892645597458+0.450762689114j), + (0.895388305187+0.445282936096j), + (0.898648142815+0.438664674759j), + (0.902342617512+0.431016951799j), + (0.906392872334+0.422441422939j), + (0.910642921925+0.413191765547j), + (0.915039420128+0.403358519077j), + (0.919594764709+0.392864197493j), + (0.92425006628+0.381792247295j), + (0.928944349289+0.370217680931j), + (0.933634519577+0.358220815659j), + (0.938279032707+0.345874190331j), + (0.942840516567+0.333247303963j), + (0.947280526161+0.32040438056j), + (0.951574921608+0.307409763336j), + (0.955703914165+0.294323593378j), + (0.959648966789+0.281201630831j), + (0.963392794132+0.268095195293j), + (0.966880619526+0.255221515894j), + (0.970162451267+0.242447137833j), + (0.973235487938+0.229809194803j), + (0.97609680891+0.217341512442j), + (0.978744983673+0.20507311821j), + (0.981189727783+0.193033605814j), + (0.983436584473+0.181248426437j), + (0.985490739346+0.169738590717j), + (0.987353682518+0.158523857594j), + (0.989041447639+0.147622272372j), + (0.990563035011+0.137049794197j), + (0.991928339005+0.126818582416j), + (0.993117690086+0.117111675441j), + (0.994156062603+0.107930034399j), + (0.995076179504+0.0990980416536j), + (0.995887458324+0.0906178802252j), + (0.996591091156+0.0824909061193j), + (0.997202515602+0.0747182965279j), + (0.997730851173+0.0672992765903j), + (0.998185396194+0.0602316558361j), + (0.99856698513+0.0535135567188j), + (0.998885989189+0.0471420884132j), + (0.99915266037+0.0411129891872j), + (0.999372899532+0.0354214012623j), + (0.999548316002+0.0300626158714j), + (0.999680638313+0.0252036750317j), + (0.999784469604+0.020652115345j), + (0.999865531921+0.0163950324059j), + (0.999923825264+0.0124222636223j), + (0.999960243702+0.00872156023979j), + (0.999983668327+0.00528120994568j), + (0.999997138977+0.00209015607834j), + (1.00000119209-0.00086285173893j), + (0.999992132187-0.00358882546425j), + (0.999979138374-0.00609711557627j), + (0.999963641167-0.00839691981673j), + (0.999947249889-0.0104993218556j), + (0.999924004078-0.0122378543019j), + (0.999904811382-0.0136305987835j), + (0.999888062477-0.0148707330227j), + (0.9998742342-0.0159679055214j), + (0.999856114388-0.0169314742088j), + (0.999839782715-0.0177700817585j), + (0.999826967716-0.0184917747974j), + (0.999818325043-0.0191045701504j), + (0.999807476997-0.0196143388748j), + (0.999797284603-0.0200265944004j), + (0.999791204929-0.0203481912613j), + (0.99978852272-0.0205836892128j), + (0.99978530407-0.0207380950451j), + (0.999785065651-0.0206423997879j), + (0.999787807465-0.0204866230488j), + (0.999794304371-0.0202808082104j), + (0.999800384045-0.0200312435627j), + (0.999803245068-0.0197458267212j), + (0.9998087883-0.0194311738014j), + (0.999816894531-0.0190933048725j), + (0.999825954437-0.0187371373177j), + (0.999829888344-0.0183679759502j), + (0.999835848808-0.017987690866j), + (0.999844014645-0.0176006518304j)) sampling_freq = 10e3 freq = sampling_freq / 100 - alpha = 0.1 - beta = alpha * alpha / 4.0 + loop_bw = math.pi/100.0 maxf = 1 minf = -1 src = gr.sig_source_c (sampling_freq, gr.GR_COS_WAVE, freq, 1.0) - pll = gr.pll_carriertracking_cc(alpha, beta, maxf, minf) + pll = gr.pll_carriertracking_cc(loop_bw, maxf, minf) head = gr.head (gr.sizeof_gr_complex, int (freq)) dst = gr.vector_sink_c () diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py b/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py index a044ca4e3..152026c35 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -31,118 +31,117 @@ class test_pll_freqdet (gr_unittest.TestCase): def tearDown (self): self.tb = None - def test_pll_refout (self): + def test_pll_freqdet (self): expected_result = (0.0, - 1.1489677586e-07, - 0.972820967928, - 2.74556447638, - 5.14063115504, - 8.00965893424, - 11.2291407849, - 14.6967083575, - 18.3279143967, - 22.0534772463, - 25.8170063427, - 29.5729048372, - 33.28476877, - 36.923851464, - 40.4367920663, - 43.8452165447, - 47.1363805488, - 50.3011890178, - 53.3336388558, - 56.2301430274, - 58.9891659262, - 61.6107668417, - 64.0962975824, - 66.4481415997, - 68.6694590418, - 70.7640385293, - 72.7048794706, - 74.5033240115, - 76.2012544926, - 77.8019140677, - 79.3088126954, - 80.7255967005, - 82.0560428456, - 83.3039575383, - 84.473129399, - 85.5673470484, - 86.5902864563, - 87.5456176636, - 88.4368624865, - 89.2363977903, - 89.9861118444, - 90.6888920639, - 91.3474657813, - 91.9644713943, - 92.5423101413, - 93.0832765389, - 93.5894931633, - 94.0629225081, - 94.5054203452, - 94.9186882929, - 95.3043331057, - 95.6326268597, - 95.9117515522, - 96.1801447842, - 96.437391527, - 96.6831953314, - 96.9173605408, - 97.1397982206, - 97.3504727968, - 97.5493842694, - 97.7366275022, - 97.9123032879, - 98.0766013539, - 98.2297054988, - 98.3408027946, - 98.4487102971, - 98.5534280064, - 98.6549025616, - 98.7531576788, - 98.848110352, - 98.9397131494, - 99.0278712074, - 99.1124718752, - 99.193408431, - 99.2705445084, - 99.3437733855, - 99.3817366678, - 99.391110391, - 99.4089151289, - 99.4333959024, - 99.4630289627, - 99.4964565726, - 99.5325047932, - 99.5701419814, - 99.6084313579, - 99.6465902967, - 99.6838954618, - 99.7197776709, - 99.7537270313, - 99.7542606398, - 99.7595848672, - 99.7691305308, - 99.7823047325, - 99.7986450115, - 99.8176059012, - 99.838724941, - 99.8615040962, - 99.8854690481, - 99.910157336, - 99.9351302152) + 4.33888922882e-08, + 0.367369994515, + 1.08135249597, + 2.10983253908, + 3.42221529438, + 4.98940390402, + 6.78379190842, + 8.77923286024, + 10.9510106794, + 13.2758363182, + 15.7317829127, + 18.2982902299, + 20.9561068599, + 23.6755271122, + 26.452952094, + 29.2731265301, + 32.1219053479, + 34.9862418188, + 37.8540971414, + 40.7144315483, + 43.5571390869, + 46.3730179743, + 49.1537231663, + 51.8917218889, + 54.58026103, + 57.2015358514, + 59.7513664199, + 62.2380533124, + 64.657612252, + 67.006640002, + 69.2822432184, + 71.4820384499, + 73.6041047056, + 75.6469478817, + 77.6094829742, + 79.4909866472, + 81.2911031615, + 83.0097850853, + 84.6355598352, + 86.1820937186, + 87.6504420946, + 89.0418441206, + 90.3577286819, + 91.5996432431, + 92.7692775646, + 93.8684162704, + 94.8989269904, + 95.8627662892, + 96.7619381633, + 97.598505899, + 98.362769679, + 99.0579904444, + 99.6992633875, + 100.288805948, + 100.828805921, + 101.321421457, + 101.76878699, + 102.17300138, + 102.536116055, + 102.860158727, + 103.147085962, + 103.398830608, + 103.617254366, + 103.792467691, + 103.939387906, + 104.060030865, + 104.15631756, + 104.230085975, + 104.283067372, + 104.316933727, + 104.333238432, + 104.333440018, + 104.318914008, + 104.290941063, + 104.250742554, + 104.187634452, + 104.103822339, + 104.013227468, + 103.916810336, + 103.815448432, + 103.709936239, + 103.600997093, + 103.489283183, + 103.375351833, + 103.259712936, + 103.142828952, + 103.025091195, + 102.90686726, + 102.776726069, + 102.648078982, + 102.521459607, + 102.397294831, + 102.275999684, + 102.157882471, + 102.043215927, + 101.93218978, + 101.824958181, + 101.72159228, + 101.622151366) sampling_freq = 10e3 freq = sampling_freq / 100 - alpha = 0.2 - beta = alpha * alpha / 4.0 + loop_bw = math.pi/100.0 maxf = 1 minf = -1 src = gr.sig_source_c (sampling_freq, gr.GR_COS_WAVE, freq, 1.0) - pll = gr.pll_freqdet_cf(alpha, beta, maxf, minf) + pll = gr.pll_freqdet_cf(loop_bw, maxf, minf) head = gr.head (gr.sizeof_float, int (freq)) dst = gr.vector_sink_f () @@ -154,7 +153,7 @@ class test_pll_freqdet (gr_unittest.TestCase): # convert it from normalized frequency to absolute frequency (Hz) dst_data = [i*(sampling_freq/(2*math.pi)) for i in dst_data] - + self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 3) if __name__ == '__main__': diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py b/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py index c719d901d..4d82ed692 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py @@ -33,116 +33,115 @@ class test_pll_refout (gr_unittest.TestCase): def test_pll_refout (self): expected_result = ((1+0j), - (1+7.39965699825e-10j), - (0.999980390072+0.00626518437639j), - (0.999828696251+0.0185074303299j), - (0.999342679977+0.0362518914044j), - (0.998255133629+0.0590478256345j), - (0.996255218983+0.0864609181881j), - (0.993005692959+0.118066303432j), - (0.988157629967+0.153442293406j), - (0.981362581253+0.192165210843j), - (0.972283244133+0.233806177974j), - (0.960601866245+0.277928203344j), - (0.946027696133+0.324085712433j), - (0.928303182125+0.371824204922j), - (0.907292485237+0.420500129461j), - (0.882742881775+0.469856321812j), - (0.854515135288+0.519426465034j), - (0.822515428066+0.568742752075j), - (0.786696374416+0.617340147495j), - (0.747057676315+0.664759278297j), - (0.703645706177+0.710551023483j), - (0.656552672386+0.754280149937j), - (0.605915188789+0.795529305935j), - (0.551911652088+0.833902597427j), - (0.494760125875+0.869029581547j), - (0.43471467495+0.900568246841j), - (0.37224906683+0.928132891655j), - (0.307677358389+0.95149075985j), - (0.241136670113+0.970491170883j), - (0.17298206687+0.984924972057j), - (0.103586681187+0.99462044239j), - (0.0333374515176+0.999444127083j), - (-0.0373689383268+0.999301552773j), - (-0.108129791915+0.994136810303j), - (-0.178540587425+0.983932554722j), - (-0.248198464513+0.968709230423j), - (-0.316705435514+0.948523938656j), - (-0.383672863245+0.92346906662j), - (-0.448723107576+0.893670797348j), - (-0.511321544647+0.859389483929j), - (-0.571328163147+0.820721685886j), - (-0.628419756889+0.777874410152j), - (-0.682292759418+0.731079041958j), - (-0.73266518116+0.680589199066j), - (-0.779277086258+0.626679480076j), - (-0.821892678738+0.569642364979j), - (-0.860300958157+0.509786486626j), - (-0.894316911697+0.447434008121j), - (-0.923782110214+0.382918506861j), - (-0.948564827442+0.316582858562j), - (-0.968560934067+0.248776495457j), - (-0.983657181263+0.180051460862j), - (-0.993847966194+0.110752984881j), - (-0.999158382416+0.0410190448165j), - (-0.999585151672-0.0288016609848j), - (-0.995150506496-0.0983637422323j), - (-0.985901653767-0.167325690389j), - (-0.971909880638-0.235353350639j), - (-0.953269898891-0.302119880915j), - (-0.930099308491-0.367308050394j), - (-0.902536988258-0.430612236261j), - (-0.870742440224-0.491739332676j), - (-0.834894299507-0.550410330296j), - (-0.795189321041-0.606361210346j), - (-0.751972556114-0.659194409847j), - (-0.705345034599-0.708864152431j), - (-0.65554022789-0.755160212517j), - (-0.602804005146-0.79788929224j), - (-0.547393083572-0.836875617504j), - (-0.489574193954-0.871961593628j), - (-0.429622590542-0.903008520603j), - (-0.367820799351-0.929896712303j), - (-0.30445766449-0.952525854111j), - (-0.239826664329-0.970815718174j), - (-0.174224823713-0.984705924988j), - (-0.107951194048-0.994156181812j), - (-0.0415062084794-0.999138236046j), - (0.0248276274651-0.999691724777j), - (0.0909758731723-0.995853126049j), - (0.156649366021-0.987654268742j), - (0.221562758088-0.975146114826j), - (0.285434871912-0.958398103714j), - (0.34799093008-0.937497913837j), - (0.408963024616-0.912550985813j), - (0.468091547489-0.883679986j), - (0.525126516819-0.851024150848j), - (0.579828321934-0.814738690853j), - (0.631969094276-0.774993598461j), - (0.68133354187-0.731973052025j), - (0.727582633495-0.68602001667j), - (0.770699501038-0.637198805809j), - (0.810512304306-0.585721611977j), - (0.846863090992-0.531810939312j), - (0.879608631134-0.475698083639j), - (0.908620357513-0.417623102665j), - (0.933785498142-0.357833325863j), - (0.955007135868-0.29658266902j), - (0.972205162048-0.23413066566j), - (0.985315918922-0.170741200447j), - (0.994293212891-0.106681533158j)) + (1+6.4087357643e-10j), + (0.999985277653+0.00542619498447j), + (0.999868750572+0.0162021834403j), + (0.99948567152+0.0320679470897j), + (0.99860727787+0.0527590736747j), + (0.996953129768+0.0780025869608j), + (0.994203746319+0.107512556016j), + (0.990011692047+0.140985429287j), + (0.984013140202+0.178095817566j), + (0.975838363171+0.218493551016j), + (0.965121984482+0.261800557375j), + (0.95151245594+0.307610183954j), + (0.934681296349+0.355486690998j), + (0.914401650429+0.404808044434j), + (0.890356600285+0.455263823271j), + (0.862329125404+0.506348133087j), + (0.830152392387+0.557536482811j), + (0.793714106083+0.608290970325j), + (0.752960026264+0.658066213131j), + (0.707896590233+0.706316053867j), + (0.658591926098+0.752500295639j), + (0.605175673962+0.796091973782j), + (0.547837555408+0.836584687233j), + (0.48682525754+0.873499393463j), + (0.42244040966+0.906390726566j), + (0.355197101831+0.934791445732j), + (0.285494059324+0.958380460739j), + (0.213591173291+0.976923108101j), + (0.139945343137+0.990159213543j), + (0.065038472414+0.997882783413j), + (-0.0106285437942+0.999943494797j), + (-0.0865436866879+0.996248066425j), + (-0.162189796567+0.986759603024j), + (-0.23705175519+0.971496999264j), + (-0.310622543097+0.950533330441j), + (-0.38240903616+0.923993110657j), + (-0.451937526464+0.89204955101j), + (-0.518758952618+0.854920566082j), + (-0.582311093807+0.812966048717j), + (-0.642372369766+0.76639264822j), + (-0.698591887951+0.715520322323j), + (-0.750654160976+0.660695314407j), + (-0.798280358315+0.602286040783j), + (-0.841228663921+0.540679454803j), + (-0.87929558754+0.476276367903j), + (-0.912315964699+0.409486919641j), + (-0.940161883831+0.340728074312j), + (-0.962742805481+0.270418733358j), + (-0.980004072189+0.198977485299j), + (-0.991925954819+0.126818284392j), + (-0.99851256609+0.0545223206282j), + (-0.999846458435-0.0175215266645j), + (-0.996021270752-0.0891158208251j), + (-0.987133920193-0.159895718098j), + (-0.973306238651-0.2295101583j), + (-0.954683184624-0.297624111176j), + (-0.931430280209-0.363919824362j), + (-0.903732538223-0.428097635508j), + (-0.871792256832-0.489875763655j), + (-0.835827112198-0.548992812634j), + (-0.796068251133-0.605206847191j), + (-0.752758979797-0.658296227455j), + (-0.706152498722-0.70805978775j), + (-0.656641483307-0.754202902317j), + (-0.604367733002-0.79670548439j), + (-0.549597978592-0.835429251194j), + (-0.492602348328-0.870254516602j), + (-0.433654457331-0.901079237461j), + (-0.373029649258-0.927819430828j), + (-0.31100410223-0.950408577919j), + (-0.247853919864-0.968797445297j), + (-0.183855071664-0.982953369617j), + (-0.119282215834-0.992860376835j), + (-0.0544078871608-0.998518764973j), + (0.0104992967099-0.999944865704j), + (0.0749994292855-0.997183561325j), + (0.138844624162-0.990314185619j), + (0.201967850327-0.979392170906j), + (0.264124274254-0.964488625526j), + (0.325075358152-0.945688128471j), + (0.3845885396-0.92308807373j), + (0.442438393831-0.89679890871j), + (0.498407125473-0.866943061352j), + (0.552284479141-0.833655714989j), + (0.603869199753-0.797083437443j), + (0.652970373631-0.757383465767j), + (0.69940674305-0.714723825455j), + (0.743007957935-0.66928255558j), + (0.78350687027-0.62138313055j), + (0.820889055729-0.571087777615j), + (0.855021059513-0.51859331131j), + (0.885780930519-0.46410369873j), + (0.913058102131-0.407829582691j), + (0.936754107475-0.349988251925j), + (0.956783294678-0.290801793337j), + (0.973072886467-0.230497643352j), + (0.985563337803-0.169307261705j), + (0.9942086339-0.1074674353j), + (0.9989772439-0.0452152714133j)) sampling_freq = 10e3 freq = sampling_freq / 100 - alpha = 0.1 - beta = alpha * alpha / 4.0 + loop_bw = math.pi/100.0 maxf = 1 minf = -1 src = gr.sig_source_c (sampling_freq, gr.GR_COS_WAVE, freq, 1.0) - pll = gr.pll_refout_cc(alpha, beta, maxf, minf) + pll = gr.pll_refout_cc(loop_bw, maxf, minf) head = gr.head (gr.sizeof_gr_complex, int (freq)) dst = gr.vector_sink_c () @@ -151,8 +150,7 @@ class test_pll_refout (gr_unittest.TestCase): self.tb.run () dst_data = dst.data () - - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 4) if __name__ == '__main__': gr_unittest.run(test_pll_refout, "test_pll_refout.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py b/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py index ded77f5f3..c3dc5cf13 100644 --- a/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py +++ b/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py @@ -6,8 +6,6 @@ XML Test Runner for PyUnit # the Public Domain. With contributions by Paolo Borelli and others. # Added to GNU Radio Oct. 3, 2010 -from __future__ import with_statement - __version__ = "0.1" import os.path @@ -185,7 +183,9 @@ class XMLTestRunner(object): result = _XMLTestResult(classname) start_time = time.time() - with _fake_std_streams(): + fss = _fake_std_streams() + fss.__enter__() + try: test(result) try: out_s = sys.stdout.getvalue() @@ -195,6 +195,8 @@ class XMLTestRunner(object): err_s = sys.stderr.getvalue() except AttributeError: err_s = "" + finally: + fss.__exit__(None, None, None) time_taken = time.time() - start_time result.print_report(stream, time_taken, out_s, err_s) @@ -218,8 +220,8 @@ class _fake_std_streams(object): def __enter__(self): self._orig_stdout = sys.stdout self._orig_stderr = sys.stderr - sys.stdout = StringIO() - sys.stderr = StringIO() + #sys.stdout = StringIO() + #sys.stderr = StringIO() def __exit__(self, exc_type, exc_val, exc_tb): sys.stdout = self._orig_stdout diff --git a/gnuradio-core/src/python/gnuradio/vocoder/Makefile.am b/gnuradio-core/src/python/gnuradio/gru/CMakeLists.txt index 69c140c10..1c50989d9 100644 --- a/gnuradio-core/src/python/gnuradio/vocoder/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gru/CMakeLists.txt @@ -1,26 +1,26 @@ +# Copyright 2010-2011 Free Software Foundation, Inc. # -# Copyright 2004,2007 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. -# -include $(top_srcdir)/Makefile.common +include(GrPython) -grvocoderpythondir = $(grpythondir)/vocoder -grvocoderpython_PYTHON = \ - __init__.py +GR_PYTHON_INSTALL( + FILES __init__.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/gru + COMPONENT "core_python" +) diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt new file mode 100644 index 000000000..7d48f3512 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright 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. + +include(GrPython) + +GR_PYTHON_INSTALL(FILES + __init__.py + freqz.py + gnuplot_freqz.py + hexint.py + listmisc.py + mathmisc.py + lmx2306.py + msgq_runner.py + os_read_exactly.py + sdr_1000.py + seq_with_cursor.py + socket_stuff.py + daemon.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/gruimpl + COMPONENT "core_python" +) diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/Makefile.am b/gnuradio-core/src/python/gnuradio/gruimpl/Makefile.am index ffae4b809..903bc2695 100644 --- a/gnuradio-core/src/python/gnuradio/gruimpl/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gruimpl/Makefile.am @@ -25,7 +25,6 @@ grupythondir = $(grpythondir)/gruimpl grupython_PYTHON = \ __init__.py \ - crc.py \ freqz.py \ gnuplot_freqz.py \ hexint.py \ diff --git a/gnuradio-core/src/python/gnuradio/modulation_utils.py b/gnuradio-core/src/python/gnuradio/modulation_utils.py deleted file mode 100644 index 71ba77389..000000000 --- a/gnuradio-core/src/python/gnuradio/modulation_utils.py +++ /dev/null @@ -1,81 +0,0 @@ -# -# 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 this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -""" -Miscellaneous utilities for managing mods and demods, as well as other items -useful in dealing with generalized handling of different modulations and demods. -""" - -import inspect - - -# Type 1 modulators accept a stream of bytes on their input and produce complex baseband output -_type_1_modulators = {} - -def type_1_mods(): - return _type_1_modulators - -def add_type_1_mod(name, mod_class): - _type_1_modulators[name] = mod_class - - -# Type 1 demodulators accept complex baseband input and produce a stream of bits, packed -# 1 bit / byte as their output. Their output is completely unambiguous. There is no need -# to resolve phase or polarity ambiguities. -_type_1_demodulators = {} - -def type_1_demods(): - return _type_1_demodulators - -def add_type_1_demod(name, demod_class): - _type_1_demodulators[name] = demod_class - - -def extract_kwargs_from_options(function, excluded_args, options): - """ - Given a function, a list of excluded arguments and the result of - parsing command line options, create a dictionary of key word - arguments suitable for passing to the function. The dictionary - will be populated with key/value pairs where the keys are those - that are common to the function's argument list (minus the - excluded_args) and the attributes in options. The values are the - corresponding values from options unless that value is None. - In that case, the corresponding dictionary entry is not populated. - - (This allows different modulations that have the same parameter - names, but different default values to coexist. The downside is - that --help in the option parser will list the default as None, - but in that case the default provided in the __init__ argument - list will be used since there is no kwargs entry.) - - @param function: the function whose parameter list will be examined - @param excluded_args: function arguments that are NOT to be added to the dictionary - @type excluded_args: sequence of strings - @param options: result of command argument parsing - @type options: optparse.Values - """ - # Try this in C++ ;) - args, varargs, varkw, defaults = inspect.getargspec(function) - d = {} - for kw in [a for a in args if a not in excluded_args]: - if hasattr(options, kw): - if getattr(options, kw) is not None: - d[kw] = getattr(options, kw) - return d diff --git a/gnuradio-core/src/python/gnuradio/modulation_utils2.py b/gnuradio-core/src/python/gnuradio/modulation_utils2.py deleted file mode 100644 index c5dba3e79..000000000 --- a/gnuradio-core/src/python/gnuradio/modulation_utils2.py +++ /dev/null @@ -1,81 +0,0 @@ -# -# Copyright 2010 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 this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -""" -Miscellaneous utilities for managing mods and demods, as well as other items -useful in dealing with generalized handling of different modulations and demods. -""" - -import inspect - - -# Type 1 modulators accept a stream of bytes on their input and produce complex baseband output -_type_1_modulators = {} - -def type_1_mods(): - return _type_1_modulators - -def add_type_1_mod(name, mod_class): - _type_1_modulators[name] = mod_class - - -# Type 1 demodulators accept complex baseband input and produce a stream of bits, packed -# 1 bit / byte as their output. Their output is completely unambiguous. There is no need -# to resolve phase or polarity ambiguities. -_type_1_demodulators = {} - -def type_1_demods(): - return _type_1_demodulators - -def add_type_1_demod(name, demod_class): - _type_1_demodulators[name] = demod_class - - -def extract_kwargs_from_options(function, excluded_args, options): - """ - Given a function, a list of excluded arguments and the result of - parsing command line options, create a dictionary of key word - arguments suitable for passing to the function. The dictionary - will be populated with key/value pairs where the keys are those - that are common to the function's argument list (minus the - excluded_args) and the attributes in options. The values are the - corresponding values from options unless that value is None. - In that case, the corresponding dictionary entry is not populated. - - (This allows different modulations that have the same parameter - names, but different default values to coexist. The downside is - that --help in the option parser will list the default as None, - but in that case the default provided in the __init__ argument - list will be used since there is no kwargs entry.) - - @param function: the function whose parameter list will be examined - @param excluded_args: function arguments that are NOT to be added to the dictionary - @type excluded_args: sequence of strings - @param options: result of command argument parsing - @type options: optparse.Values - """ - # Try this in C++ ;) - args, varargs, varkw, defaults = inspect.getargspec(function) - d = {} - for kw in [a for a in args if a not in excluded_args]: - if hasattr(options, kw): - if getattr(options, kw) is not None: - d[kw] = getattr(options, kw) - return d diff --git a/gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py b/gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py deleted file mode 100644 index f151ffe74..000000000 --- a/gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py +++ /dev/null @@ -1,453 +0,0 @@ -# -# Copyright 2007 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. -# - -import struct -import numpy -from gnuradio import gru - -def conv_packed_binary_string_to_1_0_string(s): - """ - '\xAF' --> '10101111' - """ - r = [] - for ch in s: - x = ord(ch) - for i in range(7,-1,-1): - t = (x >> i) & 0x1 - r.append(t) - - return ''.join(map(lambda x: chr(x + ord('0')), r)) - -def conv_1_0_string_to_packed_binary_string(s): - """ - '10101111' -> ('\xAF', False) - - Basically the inverse of conv_packed_binary_string_to_1_0_string, - but also returns a flag indicating if we had to pad with leading zeros - to get to a multiple of 8. - """ - if not is_1_0_string(s): - raise ValueError, "Input must be a string containing only 0's and 1's" - - # pad to multiple of 8 - padded = False - rem = len(s) % 8 - if rem != 0: - npad = 8 - rem - s = '0' * npad + s - padded = True - - assert len(s) % 8 == 0 - - r = [] - i = 0 - while i < len(s): - t = 0 - for j in range(8): - t = (t << 1) | (ord(s[i + j]) - ord('0')) - r.append(chr(t)) - i += 8 - return (''.join(r), padded) - - -def is_1_0_string(s): - if not isinstance(s, str): - return False - for ch in s: - if not ch in ('0', '1'): - return False - return True - -def string_to_hex_list(s): - return map(lambda x: hex(ord(x)), s) - - -def whiten(s, o): - sa = numpy.fromstring(s, numpy.uint8) - z = sa ^ random_mask_vec8[o:len(sa)+o] - return z.tostring() - -def dewhiten(s, o): - return whiten(s, o) # self inverse - - -def make_header(payload_len, whitener_offset=0): - # Upper nibble is offset, lower 12 bits is len - val = ((whitener_offset & 0xf) << 12) | (payload_len & 0x0fff) - #print "offset =", whitener_offset, " len =", payload_len, " val=", val - return struct.pack('!HH', val, val) - -def make_packet(payload, samples_per_symbol, bits_per_symbol, - pad_for_usrp=True, whitener_offset=0, whitening=True): - """ - Build a packet, given access code, payload, and whitener offset - - @param payload: packet payload, len [0, 4096] - @param samples_per_symbol: samples per symbol (needed for padding calculation) - @type samples_per_symbol: int - @param bits_per_symbol: (needed for padding calculation) - @type bits_per_symbol: int - @param whitener_offset offset into whitener string to use [0-16) - @param whitening: Turn whitener on or off - @type whitening: bool - - Packet will have access code at the beginning, followed by length, payload - and finally CRC-32. - """ - - if not whitener_offset >=0 and whitener_offset < 16: - raise ValueError, "whitener_offset must be between 0 and 15, inclusive (%i)" % (whitener_offset,) - - payload_with_crc = gru.gen_and_append_crc32(payload) - #print "outbound crc =", string_to_hex_list(payload_with_crc[-4:]) - - L = len(payload_with_crc) - MAXLEN = len(random_mask_tuple) - if L > MAXLEN: - raise ValueError, "len(payload) must be in [0, %d]" % (MAXLEN,) - - pkt_hd = make_header(L, whitener_offset) - pkt_dt = ''.join((payload_with_crc, '\x55')) - packet_length = len(pkt_hd) + len(pkt_dt) - - if pad_for_usrp: - usrp_packing = _npadding_bytes(packet_length, samples_per_symbol, bits_per_symbol) * '\x55' - pkt_dt = pkt_dt + usrp_packing - - if(whitening): - pkt = pkt_hd + whiten(pkt_dt, whitener_offset) - else: - pkt = pkt_hd + pkt_dt - - #print "make_packet: len(pkt) =", len(pkt) - - return pkt - -def _npadding_bytes(pkt_byte_len, samples_per_symbol, bits_per_symbol): - """ - Generate sufficient padding such that each packet ultimately ends - up being a multiple of 512 bytes when sent across the USB. We - send 4-byte samples across the USB (16-bit I and 16-bit Q), thus - we want to pad so that after modulation the resulting packet - is a multiple of 128 samples. - - @param ptk_byte_len: len in bytes of packet, not including padding. - @param samples_per_symbol: samples per bit (1 bit / symbolwidth GMSK) - @type samples_per_symbol: int - @param bits_per_symbol: bits per symbol (log2(modulation order)) - @type bits_per_symbol: int - - @returns number of bytes of padding to append. - """ - modulus = 128 - byte_modulus = gru.lcm(modulus/8, samples_per_symbol) * bits_per_symbol / samples_per_symbol - r = pkt_byte_len % byte_modulus - if r == 0: - return 0 - return byte_modulus - r - - -def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1): - """ - Return (ok, payload) - - @param whitened_payload_with_crc: string - @param whitener_offset offset into whitener string to use [0-16) - @param dewhitening: Turn whitener on or off - @type dewhitening: bool - """ - - if dewhitening: - payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) - else: - payload_with_crc = whitened_payload_with_crc - - ok, payload = gru.check_crc32(payload_with_crc) - - if 0: - print "payload_with_crc =", string_to_hex_list(payload_with_crc) - print "ok = %r, len(payload) = %d" % (ok, len(payload)) - print "payload =", string_to_hex_list(payload) - - return ok, payload - - -# FYI, this PN code is the output of a 15-bit LFSR -random_mask_tuple = ( - 255, 63, 0, 16, 0, 12, 0, 5, 192, 3, 16, 1, 204, 0, 85, 192, - 63, 16, 16, 12, 12, 5, 197, 195, 19, 17, 205, 204, 85, 149, 255, 47, - 0, 28, 0, 9, 192, 6, 208, 2, 220, 1, 153, 192, 106, 208, 47, 28, - 28, 9, 201, 198, 214, 210, 222, 221, 152, 89, 170, 186, 255, 51, 0, 21, - 192, 15, 16, 4, 12, 3, 69, 193, 243, 16, 69, 204, 51, 21, 213, 207, - 31, 20, 8, 15, 70, 132, 50, 227, 85, 137, 255, 38, 192, 26, 208, 11, - 28, 7, 73, 194, 182, 209, 182, 220, 118, 217, 230, 218, 202, 219, 23, 27, - 78, 139, 116, 103, 103, 106, 170, 175, 63, 60, 16, 17, 204, 12, 85, 197, - 255, 19, 0, 13, 192, 5, 144, 3, 44, 1, 221, 192, 89, 144, 58, 236, - 19, 13, 205, 197, 149, 147, 47, 45, 220, 29, 153, 201, 170, 214, 255, 30, - 192, 8, 80, 6, 188, 2, 241, 193, 132, 80, 99, 124, 41, 225, 222, 200, - 88, 86, 186, 190, 243, 48, 69, 212, 51, 31, 85, 200, 63, 22, 144, 14, - 236, 4, 77, 195, 117, 145, 231, 44, 74, 157, 247, 41, 134, 158, 226, 232, - 73, 142, 182, 228, 118, 203, 102, 215, 106, 222, 175, 24, 124, 10, 161, 199, - 56, 82, 146, 189, 173, 177, 189, 180, 113, 183, 100, 118, 171, 102, 255, 106, - 192, 47, 16, 28, 12, 9, 197, 198, 211, 18, 221, 205, 153, 149, 170, 239, - 63, 12, 16, 5, 204, 3, 21, 193, 207, 16, 84, 12, 63, 69, 208, 51, - 28, 21, 201, 207, 22, 212, 14, 223, 68, 88, 51, 122, 149, 227, 47, 9, - 220, 6, 217, 194, 218, 209, 155, 28, 107, 73, 239, 118, 204, 38, 213, 218, - 223, 27, 24, 11, 74, 135, 119, 34, 166, 153, 186, 234, 243, 15, 5, 196, - 3, 19, 65, 205, 240, 85, 132, 63, 35, 80, 25, 252, 10, 193, 199, 16, - 82, 140, 61, 165, 209, 187, 28, 115, 73, 229, 246, 203, 6, 215, 66, 222, - 177, 152, 116, 106, 167, 111, 58, 172, 19, 61, 205, 209, 149, 156, 111, 41, - 236, 30, 205, 200, 85, 150, 191, 46, 240, 28, 68, 9, 243, 70, 197, 242, - 211, 5, 157, 195, 41, 145, 222, 236, 88, 77, 250, 181, 131, 55, 33, 214, - 152, 94, 234, 184, 79, 50, 180, 21, 183, 79, 54, 180, 22, 247, 78, 198, - 180, 82, 247, 125, 134, 161, 162, 248, 121, 130, 162, 225, 185, 136, 114, 230, - 165, 138, 251, 39, 3, 90, 129, 251, 32, 67, 88, 49, 250, 148, 67, 47, - 113, 220, 36, 89, 219, 122, 219, 99, 27, 105, 203, 110, 215, 108, 94, 173, - 248, 125, 130, 161, 161, 184, 120, 114, 162, 165, 185, 187, 50, 243, 85, 133, - 255, 35, 0, 25, 192, 10, 208, 7, 28, 2, 137, 193, 166, 208, 122, 220, - 35, 25, 217, 202, 218, 215, 27, 30, 139, 72, 103, 118, 170, 166, 255, 58, - 192, 19, 16, 13, 204, 5, 149, 195, 47, 17, 220, 12, 89, 197, 250, 211, - 3, 29, 193, 201, 144, 86, 236, 62, 205, 208, 85, 156, 63, 41, 208, 30, - 220, 8, 89, 198, 186, 210, 243, 29, 133, 201, 163, 22, 249, 206, 194, 212, - 81, 159, 124, 104, 33, 238, 152, 76, 106, 181, 239, 55, 12, 22, 133, 206, - 227, 20, 73, 207, 118, 212, 38, 223, 90, 216, 59, 26, 147, 75, 45, 247, - 93, 134, 185, 162, 242, 249, 133, 130, 227, 33, 137, 216, 102, 218, 170, 219, - 63, 27, 80, 11, 124, 7, 97, 194, 168, 81, 190, 188, 112, 113, 228, 36, - 75, 91, 119, 123, 102, 163, 106, 249, 239, 2, 204, 1, 149, 192, 111, 16, - 44, 12, 29, 197, 201, 147, 22, 237, 206, 205, 148, 85, 175, 127, 60, 32, - 17, 216, 12, 90, 133, 251, 35, 3, 89, 193, 250, 208, 67, 28, 49, 201, - 212, 86, 223, 126, 216, 32, 90, 152, 59, 42, 147, 95, 45, 248, 29, 130, - 137, 161, 166, 248, 122, 194, 163, 17, 185, 204, 114, 213, 229, 159, 11, 40, - 7, 94, 130, 184, 97, 178, 168, 117, 190, 167, 48, 122, 148, 35, 47, 89, - 220, 58, 217, 211, 26, 221, 203, 25, 151, 74, 238, 183, 12, 118, 133, 230, - 227, 10, 201, 199, 22, 210, 142, 221, 164, 89, 187, 122, 243, 99, 5, 233, - 195, 14, 209, 196, 92, 83, 121, 253, 226, 193, 137, 144, 102, 236, 42, 205, - 223, 21, 152, 15, 42, 132, 31, 35, 72, 25, 246, 138, 198, 231, 18, 202, - 141, 151, 37, 174, 155, 60, 107, 81, 239, 124, 76, 33, 245, 216, 71, 26, - 178, 139, 53, 167, 87, 58, 190, 147, 48, 109, 212, 45, 159, 93, 168, 57, - 190, 146, 240, 109, 132, 45, 163, 93, 185, 249, 178, 194, 245, 145, 135, 44, - 98, 157, 233, 169, 142, 254, 228, 64, 75, 112, 55, 100, 22, 171, 78, 255, - 116, 64, 39, 112, 26, 164, 11, 59, 71, 83, 114, 189, 229, 177, 139, 52, - 103, 87, 106, 190, 175, 48, 124, 20, 33, 207, 88, 84, 58, 191, 83, 48, - 61, 212, 17, 159, 76, 104, 53, 238, 151, 12, 110, 133, 236, 99, 13, 233, - 197, 142, 211, 36, 93, 219, 121, 155, 98, 235, 105, 143, 110, 228, 44, 75, - 93, 247, 121, 134, 162, 226, 249, 137, 130, 230, 225, 138, 200, 103, 22, 170, - 142, 255, 36, 64, 27, 112, 11, 100, 7, 107, 66, 175, 113, 188, 36, 113, - 219, 100, 91, 107, 123, 111, 99, 108, 41, 237, 222, 205, 152, 85, 170, 191, - 63, 48, 16, 20, 12, 15, 69, 196, 51, 19, 85, 205, 255, 21, 128, 15, - 32, 4, 24, 3, 74, 129, 247, 32, 70, 152, 50, 234, 149, 143, 47, 36, - 28, 27, 73, 203, 118, 215, 102, 222, 170, 216, 127, 26, 160, 11, 56, 7, - 82, 130, 189, 161, 177, 184, 116, 114, 167, 101, 186, 171, 51, 63, 85, 208, - 63, 28, 16, 9, 204, 6, 213, 194, 223, 17, 152, 12, 106, 133, 239, 35, - 12, 25, 197, 202, 211, 23, 29, 206, 137, 148, 102, 239, 106, 204, 47, 21, - 220, 15, 25, 196, 10, 211, 71, 29, 242, 137, 133, 166, 227, 58, 201, 211, - 22, 221, 206, 217, 148, 90, 239, 123, 12, 35, 69, 217, 243, 26, 197, 203, - 19, 23, 77, 206, 181, 148, 119, 47, 102, 156, 42, 233, 223, 14, 216, 4, - 90, 131, 123, 33, 227, 88, 73, 250, 182, 195, 54, 209, 214, 220, 94, 217, - 248, 90, 194, 187, 17, 179, 76, 117, 245, 231, 7, 10, 130, 135, 33, 162, - 152, 121, 170, 162, 255, 57, 128, 18, 224, 13, 136, 5, 166, 131, 58, 225, - 211, 8, 93, 198, 185, 146, 242, 237, 133, 141, 163, 37, 185, 219, 50, 219, - 85, 155, 127, 43, 96, 31, 104, 8, 46, 134, 156, 98, 233, 233, 142, 206, - 228, 84, 75, 127, 119, 96, 38, 168, 26, 254, 139, 0, 103, 64, 42, 176, - 31, 52, 8, 23, 70, 142, 178, 228, 117, 139, 103, 39, 106, 154, 175, 43, - 60, 31, 81, 200, 60, 86, 145, 254, 236, 64, 77, 240, 53, 132, 23, 35, - 78, 153, 244, 106, 199, 111, 18, 172, 13, 189, 197, 177, 147, 52, 109, 215, - 109, 158, 173, 168, 125, 190, 161, 176, 120, 116, 34, 167, 89, 186, 186, 243, - 51, 5, 213, 195, 31, 17, 200, 12, 86, 133, 254, 227, 0, 73, 192, 54, - 208, 22, 220, 14, 217, 196, 90, 211, 123, 29, 227, 73, 137, 246, 230, 198, - 202, 210, 215, 29, 158, 137, 168, 102, 254, 170, 192, 127, 16, 32, 12, 24, - 5, 202, 131, 23, 33, 206, 152, 84, 106, 191, 111, 48, 44, 20, 29, 207, - 73, 148, 54, 239, 86, 204, 62, 213, 208, 95, 28, 56, 9, 210, 134, 221, - 162, 217, 185, 154, 242, 235, 5, 143, 67, 36, 49, 219, 84, 91, 127, 123, - 96, 35, 104, 25, 238, 138, 204, 103, 21, 234, 143, 15, 36, 4, 27, 67, - 75, 113, 247, 100, 70, 171, 114, 255, 101, 128, 43, 32, 31, 88, 8, 58, - 134, 147, 34, 237, 217, 141, 154, 229, 171, 11, 63, 71, 80, 50, 188, 21, - 177, 207, 52, 84, 23, 127, 78, 160, 52, 120, 23, 98, 142, 169, 164, 126, - 251, 96, 67, 104, 49, 238, 148, 76, 111, 117, 236, 39, 13, 218, 133, 155, - 35, 43, 89, 223, 122, 216, 35, 26, 153, 203, 42, 215, 95, 30, 184, 8, - 114, 134, 165, 162, 251, 57, 131, 82, 225, 253, 136, 65, 166, 176, 122, 244, - 35, 7, 89, 194, 186, 209, 179, 28, 117, 201, 231, 22, 202, 142, 215, 36, - 94, 155, 120, 107, 98, 175, 105, 188, 46, 241, 220, 68, 89, 243, 122, 197, - 227, 19, 9, 205, 198, 213, 146, 223, 45, 152, 29, 170, 137, 191, 38, 240, - 26, 196, 11, 19, 71, 77, 242, 181, 133, 183, 35, 54, 153, 214, 234, 222, - 207, 24, 84, 10, 191, 71, 48, 50, 148, 21, 175, 79, 60, 52, 17, 215, - 76, 94, 181, 248, 119, 2, 166, 129, 186, 224, 115, 8, 37, 198, 155, 18, - 235, 77, 143, 117, 164, 39, 59, 90, 147, 123, 45, 227, 93, 137, 249, 166, - 194, 250, 209, 131, 28, 97, 201, 232, 86, 206, 190, 212, 112, 95, 100, 56, - 43, 82, 159, 125, 168, 33, 190, 152, 112, 106, 164, 47, 59, 92, 19, 121, - 205, 226, 213, 137, 159, 38, 232, 26, 206, 139, 20, 103, 79, 106, 180, 47, - 55, 92, 22, 185, 206, 242, 212, 69, 159, 115, 40, 37, 222, 155, 24, 107, - 74, 175, 119, 60, 38, 145, 218, 236, 91, 13, 251, 69, 131, 115, 33, 229, - 216, 75, 26, 183, 75, 54, 183, 86, 246, 190, 198, 240, 82, 196, 61, 147, - 81, 173, 252, 125, 129, 225, 160, 72, 120, 54, 162, 150, 249, 174, 194, 252, - 81, 129, 252, 96, 65, 232, 48, 78, 148, 52, 111, 87, 108, 62, 173, 208, - 125, 156, 33, 169, 216, 126, 218, 160, 91, 56, 59, 82, 147, 125, 173, 225, - 189, 136, 113, 166, 164, 122, 251, 99, 3, 105, 193, 238, 208, 76, 92, 53, - 249, 215, 2, 222, 129, 152, 96, 106, 168, 47, 62, 156, 16, 105, 204, 46, - 213, 220, 95, 25, 248, 10, 194, 135, 17, 162, 140, 121, 165, 226, 251, 9, - 131, 70, 225, 242, 200, 69, 150, 179, 46, 245, 220, 71, 25, 242, 138, 197, - 167, 19, 58, 141, 211, 37, 157, 219, 41, 155, 94, 235, 120, 79, 98, 180, - 41, 183, 94, 246, 184, 70, 242, 178, 197, 181, 147, 55, 45, 214, 157, 158, - 233, 168, 78, 254, 180, 64, 119, 112, 38, 164, 26, 251, 75, 3, 119, 65, - 230, 176, 74, 244, 55, 7, 86, 130, 190, 225, 176, 72, 116, 54, 167, 86, - 250, 190, 195, 48, 81, 212, 60, 95, 81, 248, 60, 66, 145, 241, 172, 68, - 125, 243, 97, 133, 232, 99, 14, 169, 196, 126, 211, 96, 93, 232, 57, 142, - 146, 228, 109, 139, 109, 167, 109, 186, 173, 179, 61, 181, 209, 183, 28, 118, - 137, 230, 230, 202, 202, 215, 23, 30, 142, 136, 100, 102, 171, 106, 255, 111, - 0, 44, 0, 29, 192, 9, 144, 6, 236, 2, 205, 193, 149, 144, 111, 44, - 44, 29, 221, 201, 153, 150, 234, 238, 207, 12, 84, 5, 255, 67, 0, 49, - 192, 20, 80, 15, 124, 4, 33, 195, 88, 81, 250, 188, 67, 49, 241, 212, - 68, 95, 115, 120, 37, 226, 155, 9, 171, 70, 255, 114, 192, 37, 144, 27, - 44, 11, 93, 199, 121, 146, 162, 237, 185, 141, 178, 229, 181, 139, 55, 39, - 86, 154, 190, 235, 48, 79, 84, 52, 63, 87, 80, 62, 188, 16, 113, 204, - 36, 85, 219, 127, 27, 96, 11, 104, 7, 110, 130, 172, 97, 189, 232, 113, - 142, 164, 100, 123, 107, 99, 111, 105, 236, 46, 205, 220, 85, 153, 255, 42, - 192, 31, 16, 8, 12, 6, 133, 194, 227, 17, 137, 204, 102, 213, 234, 223, - 15, 24, 4, 10, 131, 71, 33, 242, 152, 69, 170, 179, 63, 53, 208, 23, - 28, 14, 137, 196, 102, 211, 106, 221, 239, 25, 140, 10, 229, 199, 11, 18, - 135, 77, 162, 181, 185, 183, 50, 246, 149, 134, 239, 34, 204, 25, 149, 202, - 239, 23, 12, 14, 133, 196, 99, 19, 105, 205, 238, 213, 140, 95, 37, 248, - 27, 2, 139, 65, 167, 112, 122, 164, 35, 59, 89, 211, 122, 221, 227, 25, - 137, 202, 230, 215, 10, 222, 135, 24, 98, 138, 169, 167, 62, 250, 144, 67, - 44, 49, 221, 212, 89, 159, 122, 232, 35, 14, 153, 196, 106, 211, 111, 29, - 236, 9, 141, 198, 229, 146, 203, 45, 151, 93, 174, 185, 188, 114, 241, 229, - 132, 75, 35, 119, 89, 230, 186, 202, 243, 23, 5, 206, 131, 20, 97, 207, - 104, 84, 46, 191, 92, 112, 57, 228, 18, 203, 77, 151, 117, 174, 167, 60, - 122, 145, 227, 44, 73, 221, 246, 217, 134, 218, 226, 219, 9, 155, 70, 235, - 114, 207, 101, 148, 43, 47, 95, 92, 56, 57, 210, 146, 221, 173, 153, 189, - 170, 241, 191, 4, 112, 3, 100, 1, 235, 64, 79, 112, 52, 36, 23, 91, - 78, 187, 116, 115, 103, 101, 234, 171, 15, 63, 68, 16, 51, 76, 21, 245, - 207, 7, 20, 2, 143, 65, 164, 48, 123, 84, 35, 127, 89, 224, 58, 200, - 19, 22, 141, 206, 229, 148, 75, 47, 119, 92, 38, 185, 218, 242, 219, 5, - 155, 67, 43, 113, 223, 100, 88, 43, 122, 159, 99, 40, 41, 222, 158, 216, - 104, 90, 174, 187, 60, 115, 81, 229, 252, 75, 1, 247, 64, 70, 176, 50, - 244, 21, 135, 79, 34, 180, 25, 183, 74, 246, 183, 6, 246, 130, 198, 225, - 146, 200, 109, 150, 173, 174, 253, 188, 65, 177, 240, 116, 68, 39, 115, 90, - 165, 251, 59, 3, 83, 65, 253, 240, 65, 132, 48, 99, 84, 41, 255, 94, - 192, 56, 80, 18, 188, 13, 177, 197, 180, 83, 55, 125, 214, 161, 158, 248, - 104, 66, 174, 177, 188, 116, 113, 231, 100, 74, 171, 119, 63, 102, 144, 42, - 236, 31, 13, 200, 5, 150, 131, 46, 225, 220, 72, 89, 246, 186, 198, 243, - 18, 197, 205, 147, 21, 173, 207, 61, 148, 17, 175, 76, 124, 53, 225, 215, - 8, 94, 134, 184, 98, 242, 169, 133, 190, 227, 48, 73, 212, 54, 223, 86, - 216, 62, 218, 144, 91, 44, 59, 93, 211, 121, 157, 226, 233, 137, 142, 230, - 228, 74, 203, 119, 23, 102, 142, 170, 228, 127, 11, 96, 7, 104, 2, 174, - 129, 188, 96, 113, 232, 36, 78, 155, 116, 107, 103, 111, 106, 172, 47, 61, - 220, 17, 153, 204, 106, 213, 239, 31, 12, 8, 5, 198, 131, 18, 225, 205, - 136, 85, 166, 191, 58, 240, 19, 4, 13, 195, 69, 145, 243, 44, 69, 221, - 243, 25, 133, 202, 227, 23, 9, 206, 134, 212, 98, 223, 105, 152, 46, 234, - 156, 79, 41, 244, 30, 199, 72, 82, 182, 189, 182, 241, 182, 196, 118, 211, - 102, 221, 234, 217, 143, 26, 228, 11, 11, 71, 71, 114, 178, 165, 181, 187, - 55, 51, 86, 149, 254, 239, 0, 76, 0, 53, 192, 23, 16, 14, 140, 4, - 101, 195, 107, 17, 239, 76, 76, 53, 245, 215, 7, 30, 130, 136, 97, 166, - 168, 122, 254, 163, 0, 121, 192, 34, 208, 25, 156, 10, 233, 199, 14, 210, - 132, 93, 163, 121, 185, 226, 242, 201, 133, 150, 227, 46, 201, 220, 86, 217, - 254, 218, 192, 91, 16, 59, 76, 19, 117, 205, 231, 21, 138, 143, 39, 36, - 26, 155, 75, 43, 119, 95, 102, 184, 42, 242, 159, 5, 168, 3, 62, 129, - 208, 96, 92, 40, 57, 222, 146, 216, 109, 154, 173, 171, 61, 191, 81, 176, - 60, 116, 17, 231, 76, 74, 181, 247, 55, 6, 150, 130, 238, 225, 140, 72, - 101, 246, 171, 6, 255, 66, 192, 49, 144, 20, 108, 15, 109, 196, 45, 147, - 93, 173, 249, 189, 130, 241, 161, 132, 120, 99, 98, 169, 233, 190, 206, 240, - 84, 68, 63, 115, 80, 37, 252, 27, 1, 203, 64, 87, 112, 62, 164, 16, - 123, 76, 35, 117, 217, 231, 26, 202, 139, 23, 39, 78, 154, 180, 107, 55, - 111, 86, 172, 62, 253, 208, 65, 156, 48, 105, 212, 46, 223, 92, 88, 57, - 250, 146, 195, 45, 145, 221, 172, 89, 189, 250, 241, 131, 4, 97, 195, 104, - 81, 238, 188, 76, 113, 245, 228, 71, 11, 114, 135, 101, 162, 171, 57, 191, - 82, 240, 61, 132, 17, 163, 76, 121, 245, 226, 199, 9, 146, 134, 237, 162, - 205, 185, 149, 178, 239, 53, 140, 23, 37, 206, 155, 20, 107, 79, 111, 116, - 44, 39, 93, 218, 185, 155, 50, 235, 85, 143, 127, 36, 32, 27, 88, 11, - 122, 135, 99, 34, 169, 217, 190, 218, 240, 91, 4, 59, 67, 83, 113, 253, - 228, 65, 139, 112, 103, 100, 42, 171, 95, 63, 120, 16, 34, 140, 25, 165, - 202, 251, 23, 3, 78, 129, 244, 96, 71, 104, 50, 174, 149, 188, 111, 49, - 236, 20, 77, 207, 117, 148, 39, 47, 90, 156, 59, 41, 211, 94, 221, 248, - 89, 130, 186, 225, 179, 8, 117, 198, 167, 18, 250, 141, 131, 37, 161, 219, - 56, 91, 82, 187, 125, 179, 97, 181, 232, 119, 14, 166, 132, 122, 227, 99, - 9, 233, 198, 206, 210, 212, 93, 159, 121, 168, 34, 254, 153, 128, 106, 224, - 47, 8, 28, 6, 137, 194, 230, 209, 138, 220, 103, 25, 234, 138, 207, 39, - 20, 26, 143, 75, 36, 55, 91, 86, 187, 126, 243, 96, 69, 232, 51, 14, - 149, 196, 111, 19, 108, 13, 237, 197, 141, 147, 37, 173, 219, 61, 155, 81, - 171, 124, 127, 97, 224, 40, 72, 30, 182, 136, 118, 230, 166, 202, 250, 215, - 3, 30, 129, 200, 96, 86, 168, 62, 254, 144, 64, 108, 48, 45, 212, 29, - 159, 73, 168, 54, 254, 150, 192, 110, 208, 44, 92, 29, 249, 201, 130, 214, - 225, 158, 200, 104, 86, 174, 190, 252, 112, 65, 228, 48, 75, 84, 55, 127, - 86, 160, 62, 248, 16, 66, 140, 49, 165, 212, 123, 31, 99, 72, 41, 246, - 158, 198, 232, 82, 206, 189, 148, 113, 175, 100, 124, 43, 97, 223, 104, 88, - 46, 186, 156, 115, 41, 229, 222, 203, 24, 87, 74, 190, 183, 48, 118, 148, - 38, 239, 90, 204, 59, 21, 211, 79, 29, 244, 9, 135, 70, 226, 178, 201, - 181, 150, 247, 46, 198, 156, 82, 233, 253, 142, 193, 164, 80, 123, 124, 35, - 97, 217, 232, 90, 206, 187, 20, 115, 79, 101, 244, 43, 7, 95, 66, 184, - 49, 178, 148, 117, 175, 103, 60, 42, 145, 223, 44, 88, 29, 250, 137, 131, - 38, 225, 218, 200, 91, 22, 187, 78, 243, 116, 69, 231, 115, 10, 165, 199, - 59, 18, 147, 77, 173, 245, 189, 135, 49, 162, 148, 121, 175, 98, 252, 41, - 129, 222, 224, 88, 72, 58, 182, 147, 54, 237, 214, 205, 158, 213, 168, 95, - 62, 184, 16, 114, 140, 37, 165, 219, 59, 27, 83, 75, 125, 247, 97, 134, - 168, 98, 254, 169, 128, 126, 224, 32, 72, 24, 54, 138, 150, 231, 46, 202, - 156, 87, 41, 254, 158, 192, 104, 80, 46, 188, 28, 113, 201, 228, 86, 203, - 126, 215, 96, 94, 168, 56, 126, 146, 160, 109, 184, 45, 178, 157, 181, 169, - 183, 62, 246, 144, 70, 236, 50, 205, 213, 149, 159, 47, 40, 28, 30, 137, - 200, 102, 214, 170, 222, 255, 24, 64, 10, 176, 7, 52, 2, 151, 65, 174, - 176, 124, 116, 33, 231, 88, 74, 186, 183, 51, 54, 149, 214, 239, 30, 204, - 8, 85, 198, 191, 18, 240, 13, 132, 5, 163, 67, 57, 241, 210, 196, 93, - 147, 121, 173, 226, 253, 137, 129, 166, 224, 122, 200, 35, 22, 153, 206, 234, - 212, 79, 31, 116, 8, 39, 70, 154, 178, 235, 53, 143, 87, 36, 62, 155, - 80, 107, 124, 47, 97, 220, 40, 89, 222, 186, 216, 115, 26, 165, 203, 59, - 23, 83, 78, 189, 244, 113, 135, 100, 98, 171, 105, 191, 110, 240, 44, 68, - 29, 243, 73, 133, 246, 227, 6, 201, 194, 214, 209, 158, 220, 104, 89, 238, - 186, 204, 115, 21, 229, 207, 11, 20, 7, 79, 66, 180, 49, 183, 84, 118, - 191, 102, 240, 42, 196, 31, 19, 72, 13, 246, 133, 134, 227, 34, 201, 217, - 150, 218, 238, 219, 12, 91, 69, 251, 115, 3, 101, 193, 235, 16, 79, 76, - 52, 53, 215, 87, 30, 190, 136, 112, 102, 164, 42, 251, 95, 3, 120, 1, - 226, 128, 73, 160, 54, 248, 22, 194, 142, 209, 164, 92, 123, 121, 227, 98, - 201, 233, 150, 206, 238, 212, 76, 95, 117, 248, 39, 2, 154, 129, 171, 32, - 127, 88, 32, 58, 152, 19, 42, 141, 223, 37, 152, 27, 42, 139, 95, 39, - 120, 26, 162, 139, 57, 167, 82, 250, 189, 131, 49, 161, 212, 120, 95, 98, - 184, 41, 178, 158, 245, 168, 71, 62, 178, 144, 117, 172, 39, 61, 218, 145, - 155, 44, 107, 93, 239, 121, 140, 34, 229, 217, 139, 26, 231, 75, 10, 183, - 71, 54, 178, 150, 245, 174, 199, 60, 82, 145, 253, 172, 65, 189, 240, 113, - 132, 36, 99, 91, 105, 251, 110, 195, 108, 81, 237, 252, 77, 129, 245, 160, - 71, 56, 50, 146, 149, 173, 175, 61, 188, 17, 177, 204, 116, 85, 231, 127, - 10, 160, 7, 56, 2, 146, 129, 173, 160, 125, 184, 33, 178, 152, 117, 170, - 167, 63, 58, 144, 19, 44, 13, 221, 197, 153, 147, 42, 237, 223, 13, 152, - 5, 170, 131, 63, 33, 208, 24, 92, 10, 185, 199, 50, 210, 149, 157, 175, - 41, 188, 30, 241, 200, 68, 86, 179, 126, 245, 224, 71, 8, 50, 134, 149, - 162, 239, 57, 140, 18, 229, 205, 139, 21, 167, 79, 58, 180, 19, 55, 77, - 214, 181, 158, 247, 40, 70, 158, 178, 232, 117, 142, 167, 36, 122, 155, 99, - 43, 105, 223, 110, 216, 44, 90, 157, 251, 41, 131, 94, 225, 248, 72, 66, - 182, 177, 182, 244, 118, 199, 102, 210, 170, 221, 191, 25, 176, 10, 244, 7, - 7, 66, 130, 177, 161, 180, 120, 119, 98, 166, 169, 186, 254, 243, 0, 69, - 192, 51, 16, 21, 204, 15, 21, 196, 15, 19, 68, 13, 243, 69, 133, 243, - 35, 5, 217, 195, 26, 209, 203, 28, 87, 73, 254, 182, 192, 118, 208, 38, - 220, 26, 217, 203, 26, 215, 75, 30, 183, 72, 118, 182, 166, 246, 250, 198, - 195, 18, 209, 205, 156, 85, 169, 255, 62, 192, 16, 80, 12, 60, 5, 209, - 195, 28, 81, 201, 252, 86, 193, 254, 208, 64, 92, 48, 57, 212, 18, 223, - 77, 152, 53, 170, 151, 63, 46, 144, 28, 108, 9, 237, 198, 205, 146, 213, - 173, 159, 61, 168, 17, 190, 140, 112, 101, 228, 43, 11, 95, 71, 120, 50, - 162, 149, 185, 175, 50, 252, 21, 129, 207, 32, 84, 24, 63, 74, 144, 55, - 44, 22, 157, 206, 233, 148, 78, 239, 116, 76, 39, 117, 218, 167, 27, 58, - 139, 83, 39, 125, 218, 161, 155, 56, 107, 82, 175, 125, 188, 33, 177, 216, - 116, 90, 167, 123, 58, 163, 83, 57, 253, 210, 193, 157, 144, 105, 172, 46, - 253, 220, 65, 153, 240, 106, 196, 47, 19, 92, 13, 249, 197, 130, 211, 33, - 157, 216, 105, 154, 174, 235, 60, 79, 81, 244, 60, 71, 81, 242, 188, 69, - 177, 243, 52, 69, 215, 115, 30, 165, 200, 123, 22, 163, 78, 249, 244, 66, - 199, 113, 146, 164, 109, 187, 109, 179, 109, 181, 237, 183, 13, 182, 133, 182, - 227, 54, 201, 214, 214, 222, 222, 216, 88, 90, 186, 187, 51, 51, 255, 63 ) - -random_mask_vec8 = numpy.array(random_mask_tuple, numpy.uint8) - diff --git a/gnuradio-core/src/python/gnuradio/packet_utils.py b/gnuradio-core/src/python/gnuradio/packet_utils.py deleted file mode 100644 index e36b05413..000000000 --- a/gnuradio-core/src/python/gnuradio/packet_utils.py +++ /dev/null @@ -1,457 +0,0 @@ -# -# Copyright 2005,2006,2007 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. -# - -import struct -import numpy -from gnuradio import gru - - -def conv_packed_binary_string_to_1_0_string(s): - """ - '\xAF' --> '10101111' - """ - r = [] - for ch in s: - x = ord(ch) - for i in range(7,-1,-1): - t = (x >> i) & 0x1 - r.append(t) - - return ''.join(map(lambda x: chr(x + ord('0')), r)) - -def conv_1_0_string_to_packed_binary_string(s): - """ - '10101111' -> ('\xAF', False) - - Basically the inverse of conv_packed_binary_string_to_1_0_string, - but also returns a flag indicating if we had to pad with leading zeros - to get to a multiple of 8. - """ - if not is_1_0_string(s): - raise ValueError, "Input must be a string containing only 0's and 1's" - - # pad to multiple of 8 - padded = False - rem = len(s) % 8 - if rem != 0: - npad = 8 - rem - s = '0' * npad + s - padded = True - - assert len(s) % 8 == 0 - - r = [] - i = 0 - while i < len(s): - t = 0 - for j in range(8): - t = (t << 1) | (ord(s[i + j]) - ord('0')) - r.append(chr(t)) - i += 8 - return (''.join(r), padded) - - -default_access_code = \ - conv_packed_binary_string_to_1_0_string('\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC') -preamble = \ - conv_packed_binary_string_to_1_0_string('\xA4\xF2') - -def is_1_0_string(s): - if not isinstance(s, str): - return False - for ch in s: - if not ch in ('0', '1'): - return False - return True - -def string_to_hex_list(s): - return map(lambda x: hex(ord(x)), s) - - -def whiten(s, o): - sa = numpy.fromstring(s, numpy.uint8) - z = sa ^ random_mask_vec8[o:len(sa)+o] - return z.tostring() - -def dewhiten(s, o): - return whiten(s, o) # self inverse - - -def make_header(payload_len, whitener_offset=0): - # Upper nibble is offset, lower 12 bits is len - val = ((whitener_offset & 0xf) << 12) | (payload_len & 0x0fff) - #print "offset =", whitener_offset, " len =", payload_len, " val=", val - return struct.pack('!HH', val, val) - -def make_packet(payload, samples_per_symbol, bits_per_symbol, - access_code=default_access_code, pad_for_usrp=True, - whitener_offset=0, whitening=True): - """ - Build a packet, given access code, payload, and whitener offset - - @param payload: packet payload, len [0, 4096] - @param samples_per_symbol: samples per symbol (needed for padding calculation) - @type samples_per_symbol: int - @param bits_per_symbol: (needed for padding calculation) - @type bits_per_symbol: int - @param access_code: string of ascii 0's and 1's - @param whitener_offset offset into whitener string to use [0-16) - - Packet will have access code at the beginning, followed by length, payload - and finally CRC-32. - """ - if not is_1_0_string(access_code): - raise ValueError, "access_code must be a string containing only 0's and 1's (%r)" % (access_code,) - - if not whitener_offset >=0 and whitener_offset < 16: - raise ValueError, "whitener_offset must be between 0 and 15, inclusive (%i)" % (whitener_offset,) - - (packed_access_code, padded) = conv_1_0_string_to_packed_binary_string(access_code) - (packed_preamble, ignore) = conv_1_0_string_to_packed_binary_string(preamble) - - payload_with_crc = gru.gen_and_append_crc32(payload) - #print "outbound crc =", string_to_hex_list(payload_with_crc[-4:]) - - L = len(payload_with_crc) - MAXLEN = len(random_mask_tuple) - if L > MAXLEN: - raise ValueError, "len(payload) must be in [0, %d]" % (MAXLEN,) - - if whitening: - pkt = ''.join((packed_preamble, packed_access_code, make_header(L, whitener_offset), - whiten(payload_with_crc, whitener_offset), '\x55')) - else: - pkt = ''.join((packed_preamble, packed_access_code, make_header(L, whitener_offset), - (payload_with_crc), '\x55')) - - if pad_for_usrp: - pkt = pkt + (_npadding_bytes(len(pkt), int(samples_per_symbol), bits_per_symbol) * '\x55') - - #print "make_packet: len(pkt) =", len(pkt) - return pkt - -def _npadding_bytes(pkt_byte_len, samples_per_symbol, bits_per_symbol): - """ - Generate sufficient padding such that each packet ultimately ends - up being a multiple of 512 bytes when sent across the USB. We - send 4-byte samples across the USB (16-bit I and 16-bit Q), thus - we want to pad so that after modulation the resulting packet - is a multiple of 128 samples. - - @param ptk_byte_len: len in bytes of packet, not including padding. - @param samples_per_symbol: samples per bit (1 bit / symbolwidth GMSK) - @type samples_per_symbol: int - @param bits_per_symbol: bits per symbol (log2(modulation order)) - @type bits_per_symbol: int - - @returns number of bytes of padding to append. - """ - modulus = 128 - byte_modulus = gru.lcm(modulus/8, samples_per_symbol) * bits_per_symbol / samples_per_symbol - r = pkt_byte_len % byte_modulus - if r == 0: - return 0 - return byte_modulus - r - - -def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True): - """ - Return (ok, payload) - - @param whitened_payload_with_crc: string - """ - - if dewhitening: - payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) - else: - payload_with_crc = (whitened_payload_with_crc) - - ok, payload = gru.check_crc32(payload_with_crc) - - if 0: - print "payload_with_crc =", string_to_hex_list(payload_with_crc) - print "ok = %r, len(payload) = %d" % (ok, len(payload)) - print "payload =", string_to_hex_list(payload) - - return ok, payload - - -# FYI, this PN code is the output of a 15-bit LFSR -random_mask_tuple = ( - 255, 63, 0, 16, 0, 12, 0, 5, 192, 3, 16, 1, 204, 0, 85, 192, - 63, 16, 16, 12, 12, 5, 197, 195, 19, 17, 205, 204, 85, 149, 255, 47, - 0, 28, 0, 9, 192, 6, 208, 2, 220, 1, 153, 192, 106, 208, 47, 28, - 28, 9, 201, 198, 214, 210, 222, 221, 152, 89, 170, 186, 255, 51, 0, 21, - 192, 15, 16, 4, 12, 3, 69, 193, 243, 16, 69, 204, 51, 21, 213, 207, - 31, 20, 8, 15, 70, 132, 50, 227, 85, 137, 255, 38, 192, 26, 208, 11, - 28, 7, 73, 194, 182, 209, 182, 220, 118, 217, 230, 218, 202, 219, 23, 27, - 78, 139, 116, 103, 103, 106, 170, 175, 63, 60, 16, 17, 204, 12, 85, 197, - 255, 19, 0, 13, 192, 5, 144, 3, 44, 1, 221, 192, 89, 144, 58, 236, - 19, 13, 205, 197, 149, 147, 47, 45, 220, 29, 153, 201, 170, 214, 255, 30, - 192, 8, 80, 6, 188, 2, 241, 193, 132, 80, 99, 124, 41, 225, 222, 200, - 88, 86, 186, 190, 243, 48, 69, 212, 51, 31, 85, 200, 63, 22, 144, 14, - 236, 4, 77, 195, 117, 145, 231, 44, 74, 157, 247, 41, 134, 158, 226, 232, - 73, 142, 182, 228, 118, 203, 102, 215, 106, 222, 175, 24, 124, 10, 161, 199, - 56, 82, 146, 189, 173, 177, 189, 180, 113, 183, 100, 118, 171, 102, 255, 106, - 192, 47, 16, 28, 12, 9, 197, 198, 211, 18, 221, 205, 153, 149, 170, 239, - 63, 12, 16, 5, 204, 3, 21, 193, 207, 16, 84, 12, 63, 69, 208, 51, - 28, 21, 201, 207, 22, 212, 14, 223, 68, 88, 51, 122, 149, 227, 47, 9, - 220, 6, 217, 194, 218, 209, 155, 28, 107, 73, 239, 118, 204, 38, 213, 218, - 223, 27, 24, 11, 74, 135, 119, 34, 166, 153, 186, 234, 243, 15, 5, 196, - 3, 19, 65, 205, 240, 85, 132, 63, 35, 80, 25, 252, 10, 193, 199, 16, - 82, 140, 61, 165, 209, 187, 28, 115, 73, 229, 246, 203, 6, 215, 66, 222, - 177, 152, 116, 106, 167, 111, 58, 172, 19, 61, 205, 209, 149, 156, 111, 41, - 236, 30, 205, 200, 85, 150, 191, 46, 240, 28, 68, 9, 243, 70, 197, 242, - 211, 5, 157, 195, 41, 145, 222, 236, 88, 77, 250, 181, 131, 55, 33, 214, - 152, 94, 234, 184, 79, 50, 180, 21, 183, 79, 54, 180, 22, 247, 78, 198, - 180, 82, 247, 125, 134, 161, 162, 248, 121, 130, 162, 225, 185, 136, 114, 230, - 165, 138, 251, 39, 3, 90, 129, 251, 32, 67, 88, 49, 250, 148, 67, 47, - 113, 220, 36, 89, 219, 122, 219, 99, 27, 105, 203, 110, 215, 108, 94, 173, - 248, 125, 130, 161, 161, 184, 120, 114, 162, 165, 185, 187, 50, 243, 85, 133, - 255, 35, 0, 25, 192, 10, 208, 7, 28, 2, 137, 193, 166, 208, 122, 220, - 35, 25, 217, 202, 218, 215, 27, 30, 139, 72, 103, 118, 170, 166, 255, 58, - 192, 19, 16, 13, 204, 5, 149, 195, 47, 17, 220, 12, 89, 197, 250, 211, - 3, 29, 193, 201, 144, 86, 236, 62, 205, 208, 85, 156, 63, 41, 208, 30, - 220, 8, 89, 198, 186, 210, 243, 29, 133, 201, 163, 22, 249, 206, 194, 212, - 81, 159, 124, 104, 33, 238, 152, 76, 106, 181, 239, 55, 12, 22, 133, 206, - 227, 20, 73, 207, 118, 212, 38, 223, 90, 216, 59, 26, 147, 75, 45, 247, - 93, 134, 185, 162, 242, 249, 133, 130, 227, 33, 137, 216, 102, 218, 170, 219, - 63, 27, 80, 11, 124, 7, 97, 194, 168, 81, 190, 188, 112, 113, 228, 36, - 75, 91, 119, 123, 102, 163, 106, 249, 239, 2, 204, 1, 149, 192, 111, 16, - 44, 12, 29, 197, 201, 147, 22, 237, 206, 205, 148, 85, 175, 127, 60, 32, - 17, 216, 12, 90, 133, 251, 35, 3, 89, 193, 250, 208, 67, 28, 49, 201, - 212, 86, 223, 126, 216, 32, 90, 152, 59, 42, 147, 95, 45, 248, 29, 130, - 137, 161, 166, 248, 122, 194, 163, 17, 185, 204, 114, 213, 229, 159, 11, 40, - 7, 94, 130, 184, 97, 178, 168, 117, 190, 167, 48, 122, 148, 35, 47, 89, - 220, 58, 217, 211, 26, 221, 203, 25, 151, 74, 238, 183, 12, 118, 133, 230, - 227, 10, 201, 199, 22, 210, 142, 221, 164, 89, 187, 122, 243, 99, 5, 233, - 195, 14, 209, 196, 92, 83, 121, 253, 226, 193, 137, 144, 102, 236, 42, 205, - 223, 21, 152, 15, 42, 132, 31, 35, 72, 25, 246, 138, 198, 231, 18, 202, - 141, 151, 37, 174, 155, 60, 107, 81, 239, 124, 76, 33, 245, 216, 71, 26, - 178, 139, 53, 167, 87, 58, 190, 147, 48, 109, 212, 45, 159, 93, 168, 57, - 190, 146, 240, 109, 132, 45, 163, 93, 185, 249, 178, 194, 245, 145, 135, 44, - 98, 157, 233, 169, 142, 254, 228, 64, 75, 112, 55, 100, 22, 171, 78, 255, - 116, 64, 39, 112, 26, 164, 11, 59, 71, 83, 114, 189, 229, 177, 139, 52, - 103, 87, 106, 190, 175, 48, 124, 20, 33, 207, 88, 84, 58, 191, 83, 48, - 61, 212, 17, 159, 76, 104, 53, 238, 151, 12, 110, 133, 236, 99, 13, 233, - 197, 142, 211, 36, 93, 219, 121, 155, 98, 235, 105, 143, 110, 228, 44, 75, - 93, 247, 121, 134, 162, 226, 249, 137, 130, 230, 225, 138, 200, 103, 22, 170, - 142, 255, 36, 64, 27, 112, 11, 100, 7, 107, 66, 175, 113, 188, 36, 113, - 219, 100, 91, 107, 123, 111, 99, 108, 41, 237, 222, 205, 152, 85, 170, 191, - 63, 48, 16, 20, 12, 15, 69, 196, 51, 19, 85, 205, 255, 21, 128, 15, - 32, 4, 24, 3, 74, 129, 247, 32, 70, 152, 50, 234, 149, 143, 47, 36, - 28, 27, 73, 203, 118, 215, 102, 222, 170, 216, 127, 26, 160, 11, 56, 7, - 82, 130, 189, 161, 177, 184, 116, 114, 167, 101, 186, 171, 51, 63, 85, 208, - 63, 28, 16, 9, 204, 6, 213, 194, 223, 17, 152, 12, 106, 133, 239, 35, - 12, 25, 197, 202, 211, 23, 29, 206, 137, 148, 102, 239, 106, 204, 47, 21, - 220, 15, 25, 196, 10, 211, 71, 29, 242, 137, 133, 166, 227, 58, 201, 211, - 22, 221, 206, 217, 148, 90, 239, 123, 12, 35, 69, 217, 243, 26, 197, 203, - 19, 23, 77, 206, 181, 148, 119, 47, 102, 156, 42, 233, 223, 14, 216, 4, - 90, 131, 123, 33, 227, 88, 73, 250, 182, 195, 54, 209, 214, 220, 94, 217, - 248, 90, 194, 187, 17, 179, 76, 117, 245, 231, 7, 10, 130, 135, 33, 162, - 152, 121, 170, 162, 255, 57, 128, 18, 224, 13, 136, 5, 166, 131, 58, 225, - 211, 8, 93, 198, 185, 146, 242, 237, 133, 141, 163, 37, 185, 219, 50, 219, - 85, 155, 127, 43, 96, 31, 104, 8, 46, 134, 156, 98, 233, 233, 142, 206, - 228, 84, 75, 127, 119, 96, 38, 168, 26, 254, 139, 0, 103, 64, 42, 176, - 31, 52, 8, 23, 70, 142, 178, 228, 117, 139, 103, 39, 106, 154, 175, 43, - 60, 31, 81, 200, 60, 86, 145, 254, 236, 64, 77, 240, 53, 132, 23, 35, - 78, 153, 244, 106, 199, 111, 18, 172, 13, 189, 197, 177, 147, 52, 109, 215, - 109, 158, 173, 168, 125, 190, 161, 176, 120, 116, 34, 167, 89, 186, 186, 243, - 51, 5, 213, 195, 31, 17, 200, 12, 86, 133, 254, 227, 0, 73, 192, 54, - 208, 22, 220, 14, 217, 196, 90, 211, 123, 29, 227, 73, 137, 246, 230, 198, - 202, 210, 215, 29, 158, 137, 168, 102, 254, 170, 192, 127, 16, 32, 12, 24, - 5, 202, 131, 23, 33, 206, 152, 84, 106, 191, 111, 48, 44, 20, 29, 207, - 73, 148, 54, 239, 86, 204, 62, 213, 208, 95, 28, 56, 9, 210, 134, 221, - 162, 217, 185, 154, 242, 235, 5, 143, 67, 36, 49, 219, 84, 91, 127, 123, - 96, 35, 104, 25, 238, 138, 204, 103, 21, 234, 143, 15, 36, 4, 27, 67, - 75, 113, 247, 100, 70, 171, 114, 255, 101, 128, 43, 32, 31, 88, 8, 58, - 134, 147, 34, 237, 217, 141, 154, 229, 171, 11, 63, 71, 80, 50, 188, 21, - 177, 207, 52, 84, 23, 127, 78, 160, 52, 120, 23, 98, 142, 169, 164, 126, - 251, 96, 67, 104, 49, 238, 148, 76, 111, 117, 236, 39, 13, 218, 133, 155, - 35, 43, 89, 223, 122, 216, 35, 26, 153, 203, 42, 215, 95, 30, 184, 8, - 114, 134, 165, 162, 251, 57, 131, 82, 225, 253, 136, 65, 166, 176, 122, 244, - 35, 7, 89, 194, 186, 209, 179, 28, 117, 201, 231, 22, 202, 142, 215, 36, - 94, 155, 120, 107, 98, 175, 105, 188, 46, 241, 220, 68, 89, 243, 122, 197, - 227, 19, 9, 205, 198, 213, 146, 223, 45, 152, 29, 170, 137, 191, 38, 240, - 26, 196, 11, 19, 71, 77, 242, 181, 133, 183, 35, 54, 153, 214, 234, 222, - 207, 24, 84, 10, 191, 71, 48, 50, 148, 21, 175, 79, 60, 52, 17, 215, - 76, 94, 181, 248, 119, 2, 166, 129, 186, 224, 115, 8, 37, 198, 155, 18, - 235, 77, 143, 117, 164, 39, 59, 90, 147, 123, 45, 227, 93, 137, 249, 166, - 194, 250, 209, 131, 28, 97, 201, 232, 86, 206, 190, 212, 112, 95, 100, 56, - 43, 82, 159, 125, 168, 33, 190, 152, 112, 106, 164, 47, 59, 92, 19, 121, - 205, 226, 213, 137, 159, 38, 232, 26, 206, 139, 20, 103, 79, 106, 180, 47, - 55, 92, 22, 185, 206, 242, 212, 69, 159, 115, 40, 37, 222, 155, 24, 107, - 74, 175, 119, 60, 38, 145, 218, 236, 91, 13, 251, 69, 131, 115, 33, 229, - 216, 75, 26, 183, 75, 54, 183, 86, 246, 190, 198, 240, 82, 196, 61, 147, - 81, 173, 252, 125, 129, 225, 160, 72, 120, 54, 162, 150, 249, 174, 194, 252, - 81, 129, 252, 96, 65, 232, 48, 78, 148, 52, 111, 87, 108, 62, 173, 208, - 125, 156, 33, 169, 216, 126, 218, 160, 91, 56, 59, 82, 147, 125, 173, 225, - 189, 136, 113, 166, 164, 122, 251, 99, 3, 105, 193, 238, 208, 76, 92, 53, - 249, 215, 2, 222, 129, 152, 96, 106, 168, 47, 62, 156, 16, 105, 204, 46, - 213, 220, 95, 25, 248, 10, 194, 135, 17, 162, 140, 121, 165, 226, 251, 9, - 131, 70, 225, 242, 200, 69, 150, 179, 46, 245, 220, 71, 25, 242, 138, 197, - 167, 19, 58, 141, 211, 37, 157, 219, 41, 155, 94, 235, 120, 79, 98, 180, - 41, 183, 94, 246, 184, 70, 242, 178, 197, 181, 147, 55, 45, 214, 157, 158, - 233, 168, 78, 254, 180, 64, 119, 112, 38, 164, 26, 251, 75, 3, 119, 65, - 230, 176, 74, 244, 55, 7, 86, 130, 190, 225, 176, 72, 116, 54, 167, 86, - 250, 190, 195, 48, 81, 212, 60, 95, 81, 248, 60, 66, 145, 241, 172, 68, - 125, 243, 97, 133, 232, 99, 14, 169, 196, 126, 211, 96, 93, 232, 57, 142, - 146, 228, 109, 139, 109, 167, 109, 186, 173, 179, 61, 181, 209, 183, 28, 118, - 137, 230, 230, 202, 202, 215, 23, 30, 142, 136, 100, 102, 171, 106, 255, 111, - 0, 44, 0, 29, 192, 9, 144, 6, 236, 2, 205, 193, 149, 144, 111, 44, - 44, 29, 221, 201, 153, 150, 234, 238, 207, 12, 84, 5, 255, 67, 0, 49, - 192, 20, 80, 15, 124, 4, 33, 195, 88, 81, 250, 188, 67, 49, 241, 212, - 68, 95, 115, 120, 37, 226, 155, 9, 171, 70, 255, 114, 192, 37, 144, 27, - 44, 11, 93, 199, 121, 146, 162, 237, 185, 141, 178, 229, 181, 139, 55, 39, - 86, 154, 190, 235, 48, 79, 84, 52, 63, 87, 80, 62, 188, 16, 113, 204, - 36, 85, 219, 127, 27, 96, 11, 104, 7, 110, 130, 172, 97, 189, 232, 113, - 142, 164, 100, 123, 107, 99, 111, 105, 236, 46, 205, 220, 85, 153, 255, 42, - 192, 31, 16, 8, 12, 6, 133, 194, 227, 17, 137, 204, 102, 213, 234, 223, - 15, 24, 4, 10, 131, 71, 33, 242, 152, 69, 170, 179, 63, 53, 208, 23, - 28, 14, 137, 196, 102, 211, 106, 221, 239, 25, 140, 10, 229, 199, 11, 18, - 135, 77, 162, 181, 185, 183, 50, 246, 149, 134, 239, 34, 204, 25, 149, 202, - 239, 23, 12, 14, 133, 196, 99, 19, 105, 205, 238, 213, 140, 95, 37, 248, - 27, 2, 139, 65, 167, 112, 122, 164, 35, 59, 89, 211, 122, 221, 227, 25, - 137, 202, 230, 215, 10, 222, 135, 24, 98, 138, 169, 167, 62, 250, 144, 67, - 44, 49, 221, 212, 89, 159, 122, 232, 35, 14, 153, 196, 106, 211, 111, 29, - 236, 9, 141, 198, 229, 146, 203, 45, 151, 93, 174, 185, 188, 114, 241, 229, - 132, 75, 35, 119, 89, 230, 186, 202, 243, 23, 5, 206, 131, 20, 97, 207, - 104, 84, 46, 191, 92, 112, 57, 228, 18, 203, 77, 151, 117, 174, 167, 60, - 122, 145, 227, 44, 73, 221, 246, 217, 134, 218, 226, 219, 9, 155, 70, 235, - 114, 207, 101, 148, 43, 47, 95, 92, 56, 57, 210, 146, 221, 173, 153, 189, - 170, 241, 191, 4, 112, 3, 100, 1, 235, 64, 79, 112, 52, 36, 23, 91, - 78, 187, 116, 115, 103, 101, 234, 171, 15, 63, 68, 16, 51, 76, 21, 245, - 207, 7, 20, 2, 143, 65, 164, 48, 123, 84, 35, 127, 89, 224, 58, 200, - 19, 22, 141, 206, 229, 148, 75, 47, 119, 92, 38, 185, 218, 242, 219, 5, - 155, 67, 43, 113, 223, 100, 88, 43, 122, 159, 99, 40, 41, 222, 158, 216, - 104, 90, 174, 187, 60, 115, 81, 229, 252, 75, 1, 247, 64, 70, 176, 50, - 244, 21, 135, 79, 34, 180, 25, 183, 74, 246, 183, 6, 246, 130, 198, 225, - 146, 200, 109, 150, 173, 174, 253, 188, 65, 177, 240, 116, 68, 39, 115, 90, - 165, 251, 59, 3, 83, 65, 253, 240, 65, 132, 48, 99, 84, 41, 255, 94, - 192, 56, 80, 18, 188, 13, 177, 197, 180, 83, 55, 125, 214, 161, 158, 248, - 104, 66, 174, 177, 188, 116, 113, 231, 100, 74, 171, 119, 63, 102, 144, 42, - 236, 31, 13, 200, 5, 150, 131, 46, 225, 220, 72, 89, 246, 186, 198, 243, - 18, 197, 205, 147, 21, 173, 207, 61, 148, 17, 175, 76, 124, 53, 225, 215, - 8, 94, 134, 184, 98, 242, 169, 133, 190, 227, 48, 73, 212, 54, 223, 86, - 216, 62, 218, 144, 91, 44, 59, 93, 211, 121, 157, 226, 233, 137, 142, 230, - 228, 74, 203, 119, 23, 102, 142, 170, 228, 127, 11, 96, 7, 104, 2, 174, - 129, 188, 96, 113, 232, 36, 78, 155, 116, 107, 103, 111, 106, 172, 47, 61, - 220, 17, 153, 204, 106, 213, 239, 31, 12, 8, 5, 198, 131, 18, 225, 205, - 136, 85, 166, 191, 58, 240, 19, 4, 13, 195, 69, 145, 243, 44, 69, 221, - 243, 25, 133, 202, 227, 23, 9, 206, 134, 212, 98, 223, 105, 152, 46, 234, - 156, 79, 41, 244, 30, 199, 72, 82, 182, 189, 182, 241, 182, 196, 118, 211, - 102, 221, 234, 217, 143, 26, 228, 11, 11, 71, 71, 114, 178, 165, 181, 187, - 55, 51, 86, 149, 254, 239, 0, 76, 0, 53, 192, 23, 16, 14, 140, 4, - 101, 195, 107, 17, 239, 76, 76, 53, 245, 215, 7, 30, 130, 136, 97, 166, - 168, 122, 254, 163, 0, 121, 192, 34, 208, 25, 156, 10, 233, 199, 14, 210, - 132, 93, 163, 121, 185, 226, 242, 201, 133, 150, 227, 46, 201, 220, 86, 217, - 254, 218, 192, 91, 16, 59, 76, 19, 117, 205, 231, 21, 138, 143, 39, 36, - 26, 155, 75, 43, 119, 95, 102, 184, 42, 242, 159, 5, 168, 3, 62, 129, - 208, 96, 92, 40, 57, 222, 146, 216, 109, 154, 173, 171, 61, 191, 81, 176, - 60, 116, 17, 231, 76, 74, 181, 247, 55, 6, 150, 130, 238, 225, 140, 72, - 101, 246, 171, 6, 255, 66, 192, 49, 144, 20, 108, 15, 109, 196, 45, 147, - 93, 173, 249, 189, 130, 241, 161, 132, 120, 99, 98, 169, 233, 190, 206, 240, - 84, 68, 63, 115, 80, 37, 252, 27, 1, 203, 64, 87, 112, 62, 164, 16, - 123, 76, 35, 117, 217, 231, 26, 202, 139, 23, 39, 78, 154, 180, 107, 55, - 111, 86, 172, 62, 253, 208, 65, 156, 48, 105, 212, 46, 223, 92, 88, 57, - 250, 146, 195, 45, 145, 221, 172, 89, 189, 250, 241, 131, 4, 97, 195, 104, - 81, 238, 188, 76, 113, 245, 228, 71, 11, 114, 135, 101, 162, 171, 57, 191, - 82, 240, 61, 132, 17, 163, 76, 121, 245, 226, 199, 9, 146, 134, 237, 162, - 205, 185, 149, 178, 239, 53, 140, 23, 37, 206, 155, 20, 107, 79, 111, 116, - 44, 39, 93, 218, 185, 155, 50, 235, 85, 143, 127, 36, 32, 27, 88, 11, - 122, 135, 99, 34, 169, 217, 190, 218, 240, 91, 4, 59, 67, 83, 113, 253, - 228, 65, 139, 112, 103, 100, 42, 171, 95, 63, 120, 16, 34, 140, 25, 165, - 202, 251, 23, 3, 78, 129, 244, 96, 71, 104, 50, 174, 149, 188, 111, 49, - 236, 20, 77, 207, 117, 148, 39, 47, 90, 156, 59, 41, 211, 94, 221, 248, - 89, 130, 186, 225, 179, 8, 117, 198, 167, 18, 250, 141, 131, 37, 161, 219, - 56, 91, 82, 187, 125, 179, 97, 181, 232, 119, 14, 166, 132, 122, 227, 99, - 9, 233, 198, 206, 210, 212, 93, 159, 121, 168, 34, 254, 153, 128, 106, 224, - 47, 8, 28, 6, 137, 194, 230, 209, 138, 220, 103, 25, 234, 138, 207, 39, - 20, 26, 143, 75, 36, 55, 91, 86, 187, 126, 243, 96, 69, 232, 51, 14, - 149, 196, 111, 19, 108, 13, 237, 197, 141, 147, 37, 173, 219, 61, 155, 81, - 171, 124, 127, 97, 224, 40, 72, 30, 182, 136, 118, 230, 166, 202, 250, 215, - 3, 30, 129, 200, 96, 86, 168, 62, 254, 144, 64, 108, 48, 45, 212, 29, - 159, 73, 168, 54, 254, 150, 192, 110, 208, 44, 92, 29, 249, 201, 130, 214, - 225, 158, 200, 104, 86, 174, 190, 252, 112, 65, 228, 48, 75, 84, 55, 127, - 86, 160, 62, 248, 16, 66, 140, 49, 165, 212, 123, 31, 99, 72, 41, 246, - 158, 198, 232, 82, 206, 189, 148, 113, 175, 100, 124, 43, 97, 223, 104, 88, - 46, 186, 156, 115, 41, 229, 222, 203, 24, 87, 74, 190, 183, 48, 118, 148, - 38, 239, 90, 204, 59, 21, 211, 79, 29, 244, 9, 135, 70, 226, 178, 201, - 181, 150, 247, 46, 198, 156, 82, 233, 253, 142, 193, 164, 80, 123, 124, 35, - 97, 217, 232, 90, 206, 187, 20, 115, 79, 101, 244, 43, 7, 95, 66, 184, - 49, 178, 148, 117, 175, 103, 60, 42, 145, 223, 44, 88, 29, 250, 137, 131, - 38, 225, 218, 200, 91, 22, 187, 78, 243, 116, 69, 231, 115, 10, 165, 199, - 59, 18, 147, 77, 173, 245, 189, 135, 49, 162, 148, 121, 175, 98, 252, 41, - 129, 222, 224, 88, 72, 58, 182, 147, 54, 237, 214, 205, 158, 213, 168, 95, - 62, 184, 16, 114, 140, 37, 165, 219, 59, 27, 83, 75, 125, 247, 97, 134, - 168, 98, 254, 169, 128, 126, 224, 32, 72, 24, 54, 138, 150, 231, 46, 202, - 156, 87, 41, 254, 158, 192, 104, 80, 46, 188, 28, 113, 201, 228, 86, 203, - 126, 215, 96, 94, 168, 56, 126, 146, 160, 109, 184, 45, 178, 157, 181, 169, - 183, 62, 246, 144, 70, 236, 50, 205, 213, 149, 159, 47, 40, 28, 30, 137, - 200, 102, 214, 170, 222, 255, 24, 64, 10, 176, 7, 52, 2, 151, 65, 174, - 176, 124, 116, 33, 231, 88, 74, 186, 183, 51, 54, 149, 214, 239, 30, 204, - 8, 85, 198, 191, 18, 240, 13, 132, 5, 163, 67, 57, 241, 210, 196, 93, - 147, 121, 173, 226, 253, 137, 129, 166, 224, 122, 200, 35, 22, 153, 206, 234, - 212, 79, 31, 116, 8, 39, 70, 154, 178, 235, 53, 143, 87, 36, 62, 155, - 80, 107, 124, 47, 97, 220, 40, 89, 222, 186, 216, 115, 26, 165, 203, 59, - 23, 83, 78, 189, 244, 113, 135, 100, 98, 171, 105, 191, 110, 240, 44, 68, - 29, 243, 73, 133, 246, 227, 6, 201, 194, 214, 209, 158, 220, 104, 89, 238, - 186, 204, 115, 21, 229, 207, 11, 20, 7, 79, 66, 180, 49, 183, 84, 118, - 191, 102, 240, 42, 196, 31, 19, 72, 13, 246, 133, 134, 227, 34, 201, 217, - 150, 218, 238, 219, 12, 91, 69, 251, 115, 3, 101, 193, 235, 16, 79, 76, - 52, 53, 215, 87, 30, 190, 136, 112, 102, 164, 42, 251, 95, 3, 120, 1, - 226, 128, 73, 160, 54, 248, 22, 194, 142, 209, 164, 92, 123, 121, 227, 98, - 201, 233, 150, 206, 238, 212, 76, 95, 117, 248, 39, 2, 154, 129, 171, 32, - 127, 88, 32, 58, 152, 19, 42, 141, 223, 37, 152, 27, 42, 139, 95, 39, - 120, 26, 162, 139, 57, 167, 82, 250, 189, 131, 49, 161, 212, 120, 95, 98, - 184, 41, 178, 158, 245, 168, 71, 62, 178, 144, 117, 172, 39, 61, 218, 145, - 155, 44, 107, 93, 239, 121, 140, 34, 229, 217, 139, 26, 231, 75, 10, 183, - 71, 54, 178, 150, 245, 174, 199, 60, 82, 145, 253, 172, 65, 189, 240, 113, - 132, 36, 99, 91, 105, 251, 110, 195, 108, 81, 237, 252, 77, 129, 245, 160, - 71, 56, 50, 146, 149, 173, 175, 61, 188, 17, 177, 204, 116, 85, 231, 127, - 10, 160, 7, 56, 2, 146, 129, 173, 160, 125, 184, 33, 178, 152, 117, 170, - 167, 63, 58, 144, 19, 44, 13, 221, 197, 153, 147, 42, 237, 223, 13, 152, - 5, 170, 131, 63, 33, 208, 24, 92, 10, 185, 199, 50, 210, 149, 157, 175, - 41, 188, 30, 241, 200, 68, 86, 179, 126, 245, 224, 71, 8, 50, 134, 149, - 162, 239, 57, 140, 18, 229, 205, 139, 21, 167, 79, 58, 180, 19, 55, 77, - 214, 181, 158, 247, 40, 70, 158, 178, 232, 117, 142, 167, 36, 122, 155, 99, - 43, 105, 223, 110, 216, 44, 90, 157, 251, 41, 131, 94, 225, 248, 72, 66, - 182, 177, 182, 244, 118, 199, 102, 210, 170, 221, 191, 25, 176, 10, 244, 7, - 7, 66, 130, 177, 161, 180, 120, 119, 98, 166, 169, 186, 254, 243, 0, 69, - 192, 51, 16, 21, 204, 15, 21, 196, 15, 19, 68, 13, 243, 69, 133, 243, - 35, 5, 217, 195, 26, 209, 203, 28, 87, 73, 254, 182, 192, 118, 208, 38, - 220, 26, 217, 203, 26, 215, 75, 30, 183, 72, 118, 182, 166, 246, 250, 198, - 195, 18, 209, 205, 156, 85, 169, 255, 62, 192, 16, 80, 12, 60, 5, 209, - 195, 28, 81, 201, 252, 86, 193, 254, 208, 64, 92, 48, 57, 212, 18, 223, - 77, 152, 53, 170, 151, 63, 46, 144, 28, 108, 9, 237, 198, 205, 146, 213, - 173, 159, 61, 168, 17, 190, 140, 112, 101, 228, 43, 11, 95, 71, 120, 50, - 162, 149, 185, 175, 50, 252, 21, 129, 207, 32, 84, 24, 63, 74, 144, 55, - 44, 22, 157, 206, 233, 148, 78, 239, 116, 76, 39, 117, 218, 167, 27, 58, - 139, 83, 39, 125, 218, 161, 155, 56, 107, 82, 175, 125, 188, 33, 177, 216, - 116, 90, 167, 123, 58, 163, 83, 57, 253, 210, 193, 157, 144, 105, 172, 46, - 253, 220, 65, 153, 240, 106, 196, 47, 19, 92, 13, 249, 197, 130, 211, 33, - 157, 216, 105, 154, 174, 235, 60, 79, 81, 244, 60, 71, 81, 242, 188, 69, - 177, 243, 52, 69, 215, 115, 30, 165, 200, 123, 22, 163, 78, 249, 244, 66, - 199, 113, 146, 164, 109, 187, 109, 179, 109, 181, 237, 183, 13, 182, 133, 182, - 227, 54, 201, 214, 214, 222, 222, 216, 88, 90, 186, 187, 51, 51, 255, 63 ) - -random_mask_vec8 = numpy.array(random_mask_tuple, numpy.uint8) - diff --git a/gnuradio-core/src/python/gnuradio/vocoder/__init__.py b/gnuradio-core/src/python/gnuradio/vocoder/__init__.py deleted file mode 100644 index a4917cf64..000000000 --- a/gnuradio-core/src/python/gnuradio/vocoder/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# make this a package diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt new file mode 100644 index 000000000..6de259116 --- /dev/null +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -0,0 +1,69 @@ +# Copyright 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. + +######################################################################## +include(GrMiscUtils) #check n def +GR_CHECK_HDR_N_DEF(sys/resource.h HAVE_SYS_RESOURCE_H) + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories(${GRUEL_INCLUDE_DIRS}) +include_directories(${GNURADIO_CORE_INCLUDE_DIRS}) + +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +include_directories(${CPPUNIT_INCLUDE_DIRS}) +link_directories(${CPPUNIT_LIBRARY_DIRS}) + +######################################################################## +# Build benchmarks and non-registered tests +######################################################################## +set(tests_not_run #single source per test + benchmark_dotprod_fff.cc + benchmark_dotprod_fsf.cc + benchmark_dotprod_ccf.cc + benchmark_dotprod_fcc.cc + benchmark_dotprod_scc.cc + benchmark_dotprod_ccc.cc + benchmark_nco.cc + benchmark_vco.cc + test_runtime.cc + test_general.cc + test_filter.cc + #test_atsc.cc + test_vmcircbuf.cc +) + +foreach(test_not_run_src ${tests_not_run}) + get_filename_component(name ${test_not_run_src} NAME_WE) + add_executable(${name} ${test_not_run_src}) + target_link_libraries(${name} test-gnuradio-core) +endforeach(test_not_run_src) + +######################################################################## +# Build the test-all test to end all tests +# Set the test environment so the build libs will be found under MSVC. +######################################################################## +include(GrTest) +set(GR_TEST_TARGET_DEPS gruel gnuradio-core test-gnuradio-core) +add_executable(gr_core_test_all test_all.cc) +target_link_libraries(gr_core_test_all test-gnuradio-core) +GR_ADD_TEST(gr-core-test-all gr_core_test_all) |