summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorjcorgan2007-04-26 22:51:48 +0000
committerjcorgan2007-04-26 22:51:48 +0000
commit43819f0f33498239970b4479684f12aa080859e6 (patch)
treecb48bd98bde120d4b9c9d098414f7a25cf9b41fd /gnuradio-core/src/lib
parentc6baf9d41d452965fe6af642b61b2bb823dcf9ea (diff)
downloadgnuradio-43819f0f33498239970b4479684f12aa080859e6.tar.gz
gnuradio-43819f0f33498239970b4479684f12aa080859e6.tar.bz2
gnuradio-43819f0f33498239970b4479684f12aa080859e6.zip
Merged r4518:5130 from developer branch n4hy/ofdm into trunk, passes distcheck.
Adds incomplete OFDM implementation, further work to be completed in the features/ofdm branch. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@5131 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am30
-rw-r--r--gnuradio-core/src/lib/general/general.i18
-rw-r--r--gnuradio-core/src/lib/general/gr_delay.cc63
-rw-r--r--gnuradio-core/src/lib/general/gr_delay.h54
-rw-r--r--gnuradio-core/src/lib/general/gr_delay.i35
-rw-r--r--gnuradio-core/src/lib/general/gr_dpll_ff.cc86
-rw-r--r--gnuradio-core/src/lib/general/gr_dpll_ff.h59
-rw-r--r--gnuradio-core/src/lib/general/gr_dpll_ff.i33
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc.cc61
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc.h10
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc.i6
-rw-r--r--gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc97
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h68
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i40
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc159
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h78
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i48
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_correlator.cc191
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_correlator.h115
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_correlator.i49
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc68
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h58
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i34
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc41
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h55
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i36
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc41
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i36
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_sampler.cc94
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_sampler.h59
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_sampler.i31
-rw-r--r--gnuradio-core/src/lib/general/gr_stream_mux.cc192
-rw-r--r--gnuradio-core/src/lib/general/gr_stream_mux.h90
-rw-r--r--gnuradio-core/src/lib/general/gr_stream_mux.i42
-rw-r--r--gnuradio-core/src/lib/gengen/Makefile.am5
-rw-r--r--gnuradio-core/src/lib/gengen/Makefile.gen21
-rwxr-xr-xgnuradio-core/src/lib/gengen/generate_common.py8
-rw-r--r--gnuradio-core/src/lib/gengen/gengen_generated.i14
-rw-r--r--gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t110
-rw-r--r--gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t125
-rw-r--r--gnuradio-core/src/lib/gengen/gr_peak_detector_XX.i.t49
-rw-r--r--gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t62
-rw-r--r--gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t57
-rw-r--r--gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.i.t33
-rw-r--r--gnuradio-core/src/lib/io/Makefile.am6
-rw-r--r--gnuradio-core/src/lib/io/gr_frame.h41
-rw-r--r--gnuradio-core/src/lib/io/gr_message_vector_source.cc97
-rw-r--r--gnuradio-core/src/lib/io/gr_message_vector_source.h63
-rw-r--r--gnuradio-core/src/lib/io/gr_message_vector_source.i36
-rw-r--r--gnuradio-core/src/lib/io/io.i6
52 files changed, 2937 insertions, 31 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index d72a5a10d..87e695a60 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -59,9 +59,11 @@ libgeneral_la_SOURCES = \
gr_ctcss_squelch_ff.cc \
gr_dd_mpsk_sync_cc.cc \
gr_deinterleave.cc \
+ gr_delay.cc \
gr_diff_decoder_bb.cc \
gr_diff_encoder_bb.cc \
gr_diff_phasor_cc.cc \
+ gr_dpll_ff.cc \
gr_fake_channel_coder_pp.cc \
gr_fast_atan2f.cc \
gr_feedforward_agc_cc.cc \
@@ -94,6 +96,13 @@ libgeneral_la_SOURCES = \
gr_nop.cc \
gr_null_sink.cc \
gr_null_source.cc \
+ gr_ofdm_correlator.cc \
+ gr_ofdm_cyclic_prefixer.cc \
+ gr_ofdm_demapper_vcb.cc \
+ gr_ofdm_mapper_bcv.cc \
+ gr_ofdm_bpsk_demapper.cc \
+ gr_ofdm_bpsk_mapper.cc \
+ gr_ofdm_sampler.cc \
gr_pa_2x2_phase_combiner.cc \
gr_packet_sink.cc \
gr_phase_modulator_fc.cc \
@@ -121,6 +130,7 @@ libgeneral_la_SOURCES = \
gr_skiphead.cc \
gr_squelch_base_cc.cc \
gr_squelch_base_ff.cc \
+ gr_stream_mux.cc \
gr_stream_to_streams.cc \
gr_stream_to_vector.cc \
gr_streams_to_stream.cc \
@@ -184,7 +194,9 @@ grinclude_HEADERS = \
gr_diff_decoder_bb.h \
gr_diff_encoder_bb.h \
gr_deinterleave.h \
+ gr_delay.h \
gr_diff_phasor_cc.h \
+ gr_dpll_ff.h \
gr_expj.h \
gr_fake_channel_coder_pp.h \
gr_feedforward_agc_cc.h \
@@ -221,6 +233,13 @@ grinclude_HEADERS = \
gr_nop.h \
gr_null_sink.h \
gr_null_source.h \
+ gr_ofdm_correlator.h \
+ gr_ofdm_cyclic_prefixer.h \
+ gr_ofdm_demapper_vcb.h \
+ gr_ofdm_mapper_bcv.h \
+ gr_ofdm_bpsk_mapper.h \
+ gr_ofdm_bpsk_demapper.h \
+ gr_ofdm_sampler.h \
gr_pa_2x2_phase_combiner.h \
gr_packet_sink.h \
gr_phase_modulator_fc.h \
@@ -249,6 +268,7 @@ grinclude_HEADERS = \
gr_skiphead.h \
gr_squelch_base_cc.h \
gr_squelch_base_ff.h \
+ gr_stream_mux.h \
gr_stream_to_streams.h \
gr_stream_to_vector.h \
gr_streams_to_stream.h \
@@ -320,7 +340,9 @@ swiginclude_HEADERS = \
gr_diff_decoder_bb.i \
gr_diff_encoder_bb.i \
gr_diff_phasor_cc.i \
+ gr_dpll_ff.i \
gr_deinterleave.i \
+ gr_delay.i \
gr_fake_channel_coder_pp.i \
gr_feedforward_agc_cc.i \
gr_feval.i \
@@ -349,6 +371,13 @@ swiginclude_HEADERS = \
gr_nop.i \
gr_null_sink.i \
gr_null_source.i \
+ gr_ofdm_correlator.i \
+ gr_ofdm_cyclic_prefixer.i \
+ gr_ofdm_demapper_vcb.i \
+ gr_ofdm_mapper_bcv.i \
+ gr_ofdm_bpsk_demapper.i \
+ gr_ofdm_bpsk_mapper.i \
+ gr_ofdm_sampler.i \
gr_pa_2x2_phase_combiner.i \
gr_packet_sink.i \
gr_phase_modulator_fc.i \
@@ -374,6 +403,7 @@ swiginclude_HEADERS = \
gr_skiphead.i \
gr_squelch_base_cc.i \
gr_squelch_base_ff.i \
+ gr_stream_mux.i \
gr_stream_to_streams.i \
gr_stream_to_vector.i \
gr_streams_to_stream.i \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 2c915b602..c49a01222 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 Free Software Foundation, Inc.
+ * Copyright 2004,2005,2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -57,6 +57,7 @@
#include <gr_firdes.h>
#include <gr_interleave.h>
#include <gr_deinterleave.h>
+#include <gr_delay.h>
#include <gr_simple_squelch_cc.h>
#include <gr_agc_ff.h>
#include <gr_agc_cc.h>
@@ -68,6 +69,7 @@
#include <gr_fake_channel_coder_pp.h>
#include <gr_throttle.h>
#include <gr_mpsk_receiver_cc.h>
+#include <gr_stream_mux.h>
#include <gr_stream_to_streams.h>
#include <gr_streams_to_stream.h>
#include <gr_streams_to_vector.h>
@@ -82,6 +84,7 @@
#include <gr_packet_sink.h>
#include <gr_lms_dfe_cc.h>
#include <gr_lms_dfe_ff.h>
+#include <gr_dpll_ff.h>
#include <gr_pll_freqdet_cf.h>
#include <gr_pll_refout_cc.h>
#include <gr_pll_carriertracking_cc.h>
@@ -89,6 +92,11 @@
#include <gr_probe_avg_mag_sqrd_c.h>
#include <gr_probe_avg_mag_sqrd_f.h>
#include <gr_probe_signal_f.h>
+#include <gr_ofdm_correlator.h>
+#include <gr_ofdm_cyclic_prefixer.h>
+#include <gr_ofdm_bpsk_demapper.h>
+#include <gr_ofdm_bpsk_mapper.h>
+#include <gr_ofdm_sampler.h>
#include <gr_costas_loop_cc.h>
#include <gr_pa_2x2_phase_combiner.h>
#include <gr_kludge_copy.h>
@@ -150,6 +158,7 @@
%include "gr_firdes.i"
%include "gr_interleave.i"
%include "gr_deinterleave.i"
+%include "gr_delay.i"
%include "gr_simple_squelch_cc.i"
%include "gr_agc_ff.i"
%include "gr_agc_cc.i"
@@ -161,6 +170,7 @@
%include "gr_fake_channel_coder_pp.i"
%include "gr_throttle.i"
%include "gr_mpsk_receiver_cc.i"
+%include "gr_stream_mux.i"
%include "gr_stream_to_streams.i"
%include "gr_streams_to_stream.i"
%include "gr_streams_to_vector.i"
@@ -175,6 +185,7 @@
%include "gr_packet_sink.i"
%include "gr_lms_dfe_cc.i"
%include "gr_lms_dfe_ff.i"
+%include "gr_dpll_ff.i"
%include "gr_pll_freqdet_cf.i"
%include "gr_pll_refout_cc.i"
%include "gr_pll_carriertracking_cc.i"
@@ -182,6 +193,11 @@
%include "gr_probe_avg_mag_sqrd_c.i"
%include "gr_probe_avg_mag_sqrd_f.i"
%include "gr_probe_signal_f.i"
+%include "gr_ofdm_correlator.i"
+%include "gr_ofdm_cyclic_prefixer.i"
+%include "gr_ofdm_bpsk_demapper.i"
+%include "gr_ofdm_bpsk_mapper.i"
+%include "gr_ofdm_sampler.i"
%include "gr_costas_loop_cc.i"
%include "gr_pa_2x2_phase_combiner.i"
%include "gr_kludge_copy.i"
diff --git a/gnuradio-core/src/lib/general/gr_delay.cc b/gnuradio-core/src/lib/general/gr_delay.cc
new file mode 100644
index 000000000..12c50e4b6
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_delay.cc
@@ -0,0 +1,63 @@
+/* -*- 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 2, 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_delay.h>
+#include <gr_io_signature.h>
+
+gr_delay_sptr
+gr_make_delay (size_t itemsize, int delay)
+{
+ return gr_delay_sptr (new gr_delay (itemsize, delay));
+}
+
+gr_delay::gr_delay (size_t itemsize, int delay)
+ : gr_sync_block ("delay",
+ gr_make_io_signature (1, -1, itemsize),
+ gr_make_io_signature (1, -1, itemsize)),
+ d_itemsize(itemsize)
+{
+ set_delay(delay);
+}
+
+int
+gr_delay::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ assert(input_items.size() == output_items.size());
+
+ const char *iptr;
+ char *optr;
+
+ for(int i = 0; i < input_items.size(); i++) {
+ iptr = (const char *) input_items[i];
+ optr = (char *) output_items[i];
+
+ memcpy(optr, iptr + delay()*d_itemsize, noutput_items*d_itemsize);
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_delay.h b/gnuradio-core/src/lib/general/gr_delay.h
new file mode 100644
index 000000000..fb4fe55a1
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_delay.h
@@ -0,0 +1,54 @@
+/* -*- 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 2, 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_DELAY_H
+#define INCLUDED_GR_DELAY_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);
+
+/*!
+ * \brief delay the input by a certain number of samples
+ * \ingroup block
+ */
+class gr_delay : public gr_sync_block
+{
+ friend gr_delay_sptr gr_make_delay (size_t itemsize, int delay);
+
+ gr_delay (size_t itemsize, int delay);
+
+ size_t d_itemsize;
+
+ public:
+ int delay () const { return history()-1; }
+ void set_delay (int delay) { set_history(delay+1); }
+
+ 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_delay.i b/gnuradio-core/src/lib/general/gr_delay.i
new file mode 100644
index 000000000..776c9657c
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_delay.i
@@ -0,0 +1,35 @@
+/* -*- 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 2, 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,delay)
+
+ gr_delay_sptr gr_make_delay (size_t itemsize, int delay);
+
+class gr_delay : public gr_sync_block
+{
+ private:
+ gr_delay (size_t itemsize, int delay);
+
+ public:
+ int delay() const { return history()-1; }
+ void set_delay (int delay) { set_history(delay+1); }
+};
diff --git a/gnuradio-core/src/lib/general/gr_dpll_ff.cc b/gnuradio-core/src/lib/general/gr_dpll_ff.cc
new file mode 100644
index 000000000..ae868fce5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_dpll_ff.cc
@@ -0,0 +1,86 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// WARNING: this file is machine generated. Edits will be over written
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_dpll_ff.h>
+#include <gr_io_signature.h>
+
+gr_dpll_ff_sptr
+gr_make_dpll_ff (float period, float gain)
+{
+ return gr_dpll_ff_sptr (new gr_dpll_ff (period, gain));
+}
+
+gr_dpll_ff::gr_dpll_ff (float period, float gain)
+ : gr_sync_block ("dpll_ff",
+ gr_make_io_signature (1, 1, sizeof (float)),
+ gr_make_io_signature (1, 1, sizeof (float))),
+ d_restart(0),d_pulse_phase(0)
+{
+ d_pulse_frequency = 1.0/period;
+ d_gain = gain;
+ d_decision_threshold = 1.0 - 0.5*d_pulse_frequency;
+#if 1
+ fprintf(stderr,"frequency = %f period = %f gain = %f threshold = %f\n",
+ d_pulse_frequency,
+ period,
+ d_gain,
+ d_decision_threshold);
+#endif
+ set_history(1); // so we can look behind us
+}
+
+int
+gr_dpll_ff::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ float *iptr = (float *) input_items[0];
+ float *optr = (float *) output_items[0];
+
+ for (int i = 0; i < noutput_items; i++){
+ optr[i]= (float)0;
+ if(iptr[i] ==(float)1) {
+ if (d_restart == 0) {
+ d_pulse_phase = 1;
+ } else {
+ if (d_pulse_phase > 0.5) d_pulse_phase += d_gain*(1.0-d_pulse_phase);
+ else d_pulse_phase -= d_gain*d_pulse_phase;
+ }
+ d_restart = 3;
+ }
+ if (d_pulse_phase > d_decision_threshold) {
+ d_pulse_phase -= 1.0;
+ if (d_restart > 0) {
+ d_restart -= 1;
+ optr[i] = (float)1;
+ }
+ }
+ d_pulse_phase += d_pulse_frequency;
+ }
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_dpll_ff.h b/gnuradio-core/src/lib/general/gr_dpll_ff.h
new file mode 100644
index 000000000..1de1efa85
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_dpll_ff.h
@@ -0,0 +1,59 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// WARNING: this file is machine generated. Edits will be over written
+
+#ifndef INCLUDED_GR_DPLL_FF_H
+#define INCLUDED_GR_DPLL_FF_H
+
+#include <gr_sync_block.h>
+
+class gr_dpll_ff;
+typedef boost::shared_ptr<gr_dpll_ff> gr_dpll_ff_sptr;
+
+gr_dpll_ff_sptr gr_make_dpll_ff (float period, float gain);
+
+/*!
+ * \brief Detect the peak of a signal
+ * \ingroup block
+ *
+ * If a peak is detected, this block outputs a 1,
+ * or it outputs 0's.
+ */
+class gr_dpll_ff : public gr_sync_block
+{
+ friend gr_dpll_ff_sptr gr_make_dpll_ff (float period, float gain);
+
+ gr_dpll_ff (float period, float gain);
+
+ private:
+ unsigned char d_restart;
+ float d_pulse_phase, d_pulse_frequency,d_gain,d_decision_threshold;
+
+ 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_dpll_ff.i b/gnuradio-core/src/lib/general/gr_dpll_ff.i
new file mode 100644
index 000000000..9606fba52
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_dpll_ff.i
@@ -0,0 +1,33 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// WARNING: this file is machine generated. Edits will be over written
+
+GR_SWIG_BLOCK_MAGIC(gr,dpll_ff)
+
+ gr_dpll_ff_sptr gr_make_dpll_ff (float period, float gain);
+
+class gr_dpll_ff : public gr_sync_block
+{
+ private:
+ gr_dpll_ff (float period, float gain);
+};
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.cc b/gnuradio-core/src/lib/general/gr_fft_vcc.cc
index 9ee9f7458..d6961486e 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc.cc
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -30,16 +30,16 @@
#include <math.h>
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> window)
+gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> window, bool shift)
{
- return gr_fft_vcc_sptr (new gr_fft_vcc (fft_size, forward, window));
+ return gr_fft_vcc_sptr (new gr_fft_vcc (fft_size, forward, window, shift));
}
-gr_fft_vcc::gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window)
+gr_fft_vcc::gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift)
: gr_sync_block ("fft_vcc",
gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex)),
gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))),
- d_fft_size(fft_size)
+ d_fft_size(fft_size), d_forward(forward), d_shift(shift)
{
d_fft = new gri_fft_complex (d_fft_size, forward);
@@ -66,27 +66,43 @@ gr_fft_vcc::work (int noutput_items,
int count = 0;
while (count++ < noutput_items){
-
+
// copy input into optimally aligned buffer
-
+
if (d_window.size()){
gr_complex *dst = d_fft->get_inbuf();
for (unsigned int i = 0; i < d_fft_size; i++) // apply window
dst[i] = in[i] * d_window[i];
}
- else
- memcpy (d_fft->get_inbuf(), in, input_data_size);
-
+ else {
+ if(!d_forward && d_shift) { // apply an ifft shift on the data
+ gr_complex *dst = d_fft->get_inbuf();
+ unsigned int len = (unsigned int)(floor(d_fft_size/2.0)); // half length of complex array
+ memcpy(&dst[0], &in[len], sizeof(gr_complex)*(d_fft_size - len));
+ memcpy(&dst[d_fft_size - len], &in[0], sizeof(gr_complex)*len);
+ }
+ else {
+ memcpy (d_fft->get_inbuf(), in, input_data_size);
+ }
+ }
+
// compute the fft
d_fft->execute ();
-
- // cpoy result to our output
- memcpy (out, d_fft->get_outbuf (), output_data_size);
-
+
+ // copy result to our output
+ if(d_forward && d_shift) { // apply a fft shift on the data
+ unsigned int len = (unsigned int)(ceil(d_fft_size/2.0));
+ memcpy(&out[0], &d_fft->get_outbuf()[len], sizeof(gr_complex)*(d_fft_size - len));
+ memcpy(&out[d_fft_size - len], &d_fft->get_outbuf()[0], sizeof(gr_complex)*len);
+ }
+ else {
+ memcpy (out, d_fft->get_outbuf (), output_data_size);
+ }
+
in += d_fft_size;
out += d_fft_size;
}
-
+
return noutput_items;
}
@@ -100,3 +116,18 @@ gr_fft_vcc::set_window(const std::vector<float> window)
else
return false;
}
+
+/*
+fftshift
+
+ for(i=0; i < ceil(d_occupied_carriers/2.0); i++) {
+ unsigned int k=ceil(d_occupied_carriers/2.0);
+ out[i] = gr_complex(-1+2*in[i+k],0);
+ }
+ for(; i < d_vlen - ceil(d_occupied_carriers/2.0); i++) {
+ out[i]=gr_complex(0,0);
+ }
+ for(unsigned int j=0;i<d_vlen;i++,j++) {
+ out[i]= gr_complex((-1+2*in[j]),0);
+ }
+*/
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.h b/gnuradio-core/src/lib/general/gr_fft_vcc.h
index a7ce548a3..2fa025850 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc.h
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -31,7 +31,7 @@ class gr_fft_vcc;
typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr;
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false);
/*!
* \brief Compute forward or reverse FFT. complex vector in / complex vector out.
@@ -41,13 +41,15 @@ gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
class gr_fft_vcc : public gr_sync_block
{
friend gr_fft_vcc_sptr
- gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+ gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift);
unsigned int d_fft_size;
std::vector<float> d_window;
gri_fft_complex *d_fft;
+ bool d_forward;
+ bool d_shift;
- gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+ gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift);
public:
~gr_fft_vcc ();
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.i b/gnuradio-core/src/lib/general/gr_fft_vcc.i
index 039f09a3d..8295af65b 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc.i
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,12 +23,12 @@
GR_SWIG_BLOCK_MAGIC(gr, fft_vcc)
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false);
class gr_fft_vcc : public gr_sync_block
{
protected:
- gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+ gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift);
public:
bool set_window(const std::vector<float> window);
diff --git a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc
index 87b2f541a..6b8cc320a 100644
--- a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc
@@ -319,7 +319,7 @@ gr_mpsk_receiver_cc::general_work (int noutput_items,
int i=0, o=0;
//while(i < ninput_items[0]) {
- while(o < noutput_items) {
+ 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++;
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
new file mode 100644
index 000000000..53484b96a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
@@ -0,0 +1,97 @@
+/* -*- 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 2, 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_bpsk_demapper.h>
+#include <gr_io_signature.h>
+
+gr_ofdm_bpsk_demapper_sptr
+gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers)
+{
+ return gr_ofdm_bpsk_demapper_sptr (new gr_ofdm_bpsk_demapper (occupied_carriers));
+}
+
+gr_ofdm_bpsk_demapper::gr_ofdm_bpsk_demapper (unsigned occupied_carriers)
+ : gr_block ("ofdm_bpsk_demapper",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers),
+ gr_make_io_signature (1, 1, sizeof(unsigned char))),
+ d_occupied_carriers(occupied_carriers),
+ d_byte_offset(0), d_partial_byte(0)
+{
+}
+
+gr_ofdm_bpsk_demapper::~gr_ofdm_bpsk_demapper(void)
+{
+}
+
+unsigned char gr_ofdm_bpsk_demapper::slicer(gr_complex x)
+{
+ return (unsigned char)(x.real() > 0 ? 1 : 0);
+}
+
+void
+gr_ofdm_bpsk_demapper::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;
+}
+
+int
+gr_ofdm_bpsk_demapper::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];
+ unsigned char *out = (unsigned char *) output_items[0];
+
+ unsigned int i=0, bytes_produced=0;
+
+ while(i < d_occupied_carriers) {
+
+ while((d_byte_offset < 8) && (i < d_occupied_carriers)) {
+ //fprintf(stderr, "%f+j%f\n", in[i].real(), in[i].imag());
+ d_partial_byte |= slicer(in[i++]) << (d_byte_offset++);
+ }
+
+ if(d_byte_offset == 8) {
+ out[bytes_produced++] = d_partial_byte;
+ d_byte_offset = 0;
+ d_partial_byte = 0;
+ }
+ }
+
+#if 0
+printf("demod out: ");
+ for(i = 0; i < bytes_produced; i++) {
+ printf("%4x", out[i]);
+ }
+ printf(" \tlen: %d\n", i);
+#endif
+
+ consume_each(1);
+ return bytes_produced;
+}
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
new file mode 100644
index 000000000..c361c62fa
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
@@ -0,0 +1,68 @@
+/* -*- 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 2, 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_BPSK_DEMAPPER_H
+#define INCLUDED_GR_OFDM_BPSK_DEMAPPER_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_make_ofdm_bpsk_demapper (unsigned int occupied_carriers);
+
+
+/*!
+ * \brief take a vector of complex constellation points in from an FFT
+ * and demodulate to a stream of bits. Simple BPSK version.
+ */
+
+class gr_ofdm_bpsk_demapper : public gr_block
+{
+ friend gr_ofdm_bpsk_demapper_sptr
+ gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers);
+
+ protected:
+ gr_ofdm_bpsk_demapper (unsigned int occupied_carriers);
+
+ private:
+ unsigned char slicer(gr_complex x);
+
+ unsigned int d_occupied_carriers;
+ unsigned int d_byte_offset;
+ unsigned char d_partial_byte;
+
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ public:
+ ~gr_ofdm_bpsk_demapper(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_bpsk_demapper.i b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
new file mode 100644
index 000000000..1af4430de
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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_bpsk_demapper)
+
+gr_ofdm_bpsk_demapper_sptr
+gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers);
+
+class gr_ofdm_bpsk_demapper : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_bpsk_demapper (unsigned int occupied_carriers);
+
+ public:
+ 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_bpsk_mapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
new file mode 100644
index 000000000..df4632398
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
@@ -0,0 +1,159 @@
+/* -*- 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 2, 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_bpsk_mapper.h>
+#include <gr_io_signature.h>
+#include <vector>
+
+gr_ofdm_bpsk_mapper_sptr
+gr_make_ofdm_bpsk_mapper (unsigned int mtu, unsigned int occupied_carriers, unsigned int vlen,
+ std::vector<gr_complex> known_symbol1, std::vector<gr_complex> known_symbol2)
+{
+ return gr_ofdm_bpsk_mapper_sptr (new gr_ofdm_bpsk_mapper (mtu, occupied_carriers, vlen,
+ known_symbol1, known_symbol2));
+}
+
+gr_ofdm_bpsk_mapper::gr_ofdm_bpsk_mapper (unsigned int mtu, unsigned int occupied_carriers, unsigned int vlen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2)
+ : gr_block ("ofdm_bpsk_mapper",
+ gr_make_io_signature (1, 1, 2*sizeof(int) + sizeof(unsigned char)*mtu),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen)),
+ d_mtu(mtu),
+ d_occupied_carriers(occupied_carriers),
+ d_vlen(vlen),
+ d_packet_offset(0),
+ d_bit_offset(0),
+ d_header_sent(0),
+ d_known_symbol1(known_symbol1),
+ d_known_symbol2(known_symbol2)
+
+{
+ assert(d_occupied_carriers < d_vlen);
+ assert(d_occupied_carriers == d_known_symbol1.size());
+ assert(d_occupied_carriers == d_known_symbol2.size());
+}
+
+gr_ofdm_bpsk_mapper::~gr_ofdm_bpsk_mapper(void)
+{
+}
+
+void
+gr_ofdm_bpsk_mapper::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;
+}
+
+int
+gr_ofdm_bpsk_mapper::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_frame *in = (const gr_frame *) input_items[0];
+ gr_complex *out = (gr_complex *)output_items[0];
+
+ unsigned int i=0;
+ unsigned int num_symbols = 0, pkt_length;
+
+ //printf("OFDM BPSK Mapper: ninput_items: %d noutput_items: %d\n", ninput_items[0], noutput_items);
+
+ pkt_length = in[0].length;
+
+ std::vector<gr_complex>::iterator ks_itr;
+ if(d_header_sent == 0) {
+ ks_itr = d_known_symbol1.begin();
+ }
+ else if(d_header_sent == 1) {
+ ks_itr = d_known_symbol2.begin();
+ }
+
+ if(d_header_sent < 2) {
+ // Add training symbols here
+ for(i=0; i < (ceil((d_vlen - d_occupied_carriers)/2.0)); i++) {
+ out[i] = gr_complex(0,0);
+ }
+ for(;i<d_vlen - ceil((d_vlen-d_occupied_carriers)/2.0);i++) {
+ //out[i] = gr_complex(1,0);
+ out[i] = *(ks_itr++);
+ }
+ for(; i < d_vlen; i++) {
+ out[i] = gr_complex(0,0);
+ }
+
+ num_symbols = 1;
+ out += d_vlen;
+ d_header_sent++;
+ }
+
+ unsigned int unoccupied_carriers = d_vlen - d_occupied_carriers;
+ unsigned int zeros_on_left = (unsigned)ceil(unoccupied_carriers/2.0);
+ unsigned int zeros_on_right = unoccupied_carriers - zeros_on_left;
+
+ while(num_symbols < (unsigned)noutput_items) {
+
+ // stick in unused carriers
+ for(i = d_vlen-zeros_on_right; i < d_vlen; i++) {
+ out[i] = gr_complex(0,0);
+ }
+
+ for(i=0; i < zeros_on_left; i++) {
+ out[i] = gr_complex(0,0);
+ }
+
+ while((d_packet_offset < pkt_length) && (i < d_vlen-zeros_on_right)) {
+ unsigned char bit = (in[0].data[d_packet_offset] >> (d_bit_offset++)) & 0x01;
+ out[i++] = gr_complex(-1+2*(bit));
+ if(d_bit_offset == 8) {
+ d_bit_offset = 0;
+ d_packet_offset++;
+ }
+ }
+
+ // Ran out of data to put in symbols
+ if(d_packet_offset == pkt_length) {
+ while(i < d_vlen-zeros_on_right) {
+ out[i++] = gr_complex(0,0);
+ }
+
+ d_packet_offset = 0;
+ assert(d_bit_offset == 0);
+ num_symbols++;
+ d_header_sent = 0;
+ consume_each(1);
+ return num_symbols;
+ }
+
+ // Ran out of space in symbol
+ out += d_vlen;
+ num_symbols++;
+ }
+ consume_each(0);
+ return num_symbols;
+}
+
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
new file mode 100644
index 000000000..1ae6c75d8
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
@@ -0,0 +1,78 @@
+/* -*- 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 2, 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_BPSK_MAPPER_H
+#define INCLUDED_GR_OFDM_BPSK_MAPPER_H
+
+
+#include <gr_block.h>
+#include <gr_frame.h>
+#include <vector>
+
+class gr_ofdm_bpsk_mapper;
+typedef boost::shared_ptr<gr_ofdm_bpsk_mapper> gr_ofdm_bpsk_mapper_sptr;
+
+gr_ofdm_bpsk_mapper_sptr
+gr_make_ofdm_bpsk_mapper (unsigned mtu, unsigned occupied_carriers, unsigned int vlen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+/*!
+ * \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. Simple BPSK version.
+ */
+
+class gr_ofdm_bpsk_mapper : public gr_block
+{
+ friend gr_ofdm_bpsk_mapper_sptr
+ gr_make_ofdm_bpsk_mapper (unsigned mtu, unsigned occupied_carriers, unsigned int vlen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+ protected:
+ gr_ofdm_bpsk_mapper (unsigned mtu, unsigned occupied_carriers, unsigned int vlen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+ private:
+ unsigned int d_mtu;
+ unsigned int d_occupied_carriers;
+ unsigned int d_vlen;
+ unsigned int d_packet_offset;
+ unsigned int d_bit_offset;
+ unsigned int d_header_sent;
+ std::vector<gr_complex> d_known_symbol1, d_known_symbol2;
+
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ public:
+ ~gr_ofdm_bpsk_mapper(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_bpsk_mapper.i b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
new file mode 100644
index 000000000..12b86dc33
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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_bpsk_mapper)
+
+gr_ofdm_bpsk_mapper_sptr
+gr_make_ofdm_bpsk_mapper (unsigned int mtu,
+ unsigned int bits_per_symbol,
+ unsigned int vlen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+class gr_ofdm_bpsk_mapper : public gr_block
+{
+ protected:
+ gr_ofdm_bpsk_mapper (unsigned int mtu,
+ unsigned int bits_per_symbol,
+ unsigned int vlen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+ public:
+ 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_correlator.cc b/gnuradio-core/src/lib/general/gr_ofdm_correlator.cc
new file mode 100644
index 000000000..21fbc6b3e
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_correlator.cc
@@ -0,0 +1,191 @@
+/* -*- 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 2, 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_correlator.h>
+#include <gr_io_signature.h>
+
+#define VERBOSE 0
+#define M_TWOPI (2*M_PI)
+
+gr_ofdm_correlator_sptr
+gr_make_ofdm_correlator (unsigned int occupied_carriers, unsigned int vlen,
+ unsigned int cplen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2)
+{
+ return gr_ofdm_correlator_sptr (new gr_ofdm_correlator (occupied_carriers, vlen, cplen,
+ known_symbol1, known_symbol2));
+}
+
+gr_ofdm_correlator::gr_ofdm_correlator (unsigned occupied_carriers, unsigned int vlen,
+ unsigned int cplen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2)
+ : gr_block ("ofdm_correlator",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers)),
+ d_occupied_carriers(occupied_carriers),
+ d_vlen(vlen),
+ d_cplen(cplen),
+ d_freq_shift_len(5),
+ d_known_symbol1(known_symbol1),
+ d_known_symbol2(known_symbol2),
+ d_coarse_freq(0),
+ d_phase_count(0)
+{
+ d_diff_corr_factor.resize(d_occupied_carriers);
+ d_hestimate.resize(d_occupied_carriers);
+
+ std::vector<gr_complex>::iterator i1, i2;
+
+ int i = 0;
+ gr_complex one(1.0, 0.0);
+ for(i1 = d_known_symbol1.begin(), i2 = d_known_symbol2.begin(); i1 != d_known_symbol1.end(); i1++, i2++) {
+ d_diff_corr_factor[i] = one / ((*i1) * conj(*i2));
+ i++;
+ }
+}
+
+gr_ofdm_correlator::~gr_ofdm_correlator(void)
+{
+}
+
+void
+gr_ofdm_correlator::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] = 2;
+}
+
+gr_complex
+gr_ofdm_correlator::coarse_freq_comp(int freq_delta, int symbol_count)
+{
+ return gr_complex(cos(-M_TWOPI*freq_delta*d_cplen/d_vlen*symbol_count),
+ sin(-M_TWOPI*freq_delta*d_cplen/d_vlen*symbol_count));
+}
+
+bool
+gr_ofdm_correlator::correlate(const gr_complex *previous, const gr_complex *current,
+ int zeros_on_left)
+{
+ unsigned int i = 0;
+ int search_delta = 0;
+ bool found = false;
+
+ gr_complex h_sqrd = gr_complex(0.0,0.0);
+ float power = 0.0F;
+
+ while(!found && (abs(search_delta) < d_freq_shift_len)) {
+ h_sqrd = gr_complex(0.0,0.0);
+ power = 0.0F;
+
+ for(i = 0; i < d_occupied_carriers; i++) {
+ h_sqrd = h_sqrd + previous[i+zeros_on_left+search_delta] *
+ conj(coarse_freq_comp(search_delta,1)*current[i+zeros_on_left+search_delta]) *
+ d_diff_corr_factor[i];
+ power = power + norm(current[i+zeros_on_left+search_delta]); // No need to do coarse freq here
+ }
+
+#if VERBOSE
+ printf("bin %d\th_sqrd = ( %f, %f )\t power = %f\t real(h)/p = %f\t angle = %f\n",
+ search_delta, h_sqrd.real(), h_sqrd.imag(), power, h_sqrd.real()/power, arg(h_sqrd));
+#endif
+
+ if(h_sqrd.real() > 0.75*power) {
+ found = true;
+ d_coarse_freq = search_delta;
+ d_phase_count = 1;
+ d_snr_est = 10*log10(power/(power-h_sqrd.real()));
+
+ printf("CORR: Found, bin %d\tSNR Est %f dB\tcorr power fraction %f\n",
+ search_delta, d_snr_est, h_sqrd.real()/power);
+ // search_delta,10*log10(h_sqrd.real()/fabs(h_sqrd.imag())),h_sqrd.real()/power);
+ break;
+ }
+ else {
+ if(search_delta <= 0)
+ search_delta = (-search_delta) + 1;
+ else
+ search_delta = -search_delta;
+ }
+ }
+ return found;
+}
+
+void
+gr_ofdm_correlator::calculate_equalizer(const gr_complex *previous, const gr_complex *current,
+ int zeros_on_left)
+{
+ unsigned int i=0;
+
+ for(i = 0; i < d_occupied_carriers; i++) {
+ // FIXME possibly add small epsilon in divisor to protect from div 0
+ //d_hestimate[i] = 0.5F * (d_known_symbol1[i] / previous[i+zeros_on_left] +
+ // d_known_symbol2[i] / (coarse_freq_comp(d_coarse_freq,1)*
+ // current[i+zeros_on_left+d_coarse_freq]));
+ d_hestimate[i] = 0.5F * (d_known_symbol1[i] / previous[i+zeros_on_left+d_coarse_freq] +
+ d_known_symbol2[i] / (coarse_freq_comp(d_coarse_freq,1)*
+ current[i+zeros_on_left+d_coarse_freq]));
+
+#if VERBOSE
+ fprintf(stderr, "%f %f ", d_hestimate[i].real(), d_hestimate[i].imag());
+#endif
+ }
+#if VERBOSE
+ fprintf(stderr, "\n");
+#endif
+}
+
+int
+gr_ofdm_correlator::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];
+ const gr_complex *previous = &in[0];
+ const gr_complex *current = &in[d_vlen];
+
+ gr_complex *out = (gr_complex *) output_items[0];
+
+ unsigned int i=0;
+
+ int unoccupied_carriers = d_vlen - d_occupied_carriers;
+ int zeros_on_left = (int)ceil(unoccupied_carriers/2.0);
+
+ bool corr = correlate(previous, current, zeros_on_left);
+ if(corr) {
+ calculate_equalizer(previous, current, zeros_on_left);
+ }
+
+ for(i = 0; i < d_occupied_carriers; i++) {
+ out[i] = d_hestimate[i]*coarse_freq_comp(d_coarse_freq,d_phase_count)*current[i+zeros_on_left+d_coarse_freq];
+ }
+ d_phase_count++;
+ consume_each(1);
+ return 1;
+}
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_correlator.h b/gnuradio-core/src/lib/general/gr_ofdm_correlator.h
new file mode 100644
index 000000000..4c44cca32
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_correlator.h
@@ -0,0 +1,115 @@
+/* -*- 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 2, 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_CORRELATOR_H
+#define INCLUDED_GR_OFDM_CORRELATOR_H
+
+
+#include <gr_block.h>
+#include <vector>
+
+class gr_ofdm_correlator;
+typedef boost::shared_ptr<gr_ofdm_correlator> gr_ofdm_correlator_sptr;
+
+gr_ofdm_correlator_sptr
+gr_make_ofdm_correlator (unsigned int occupied_carriers, unsigned int vlen,
+ unsigned int cplen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+/*!
+ * \brief take a vector of complex constellation points in from an FFT
+ * and performs a correlation and equalization.
+ * \inblock blocks
+ *
+ * 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
+ * symbosl to estimate the channel response overa 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_correlator : public gr_block
+{
+ /*!
+ * \brief Build an OFDM correlator and equalizer.
+ * \param occupied_carriers The number of subcarriers with data in the received symbol
+ * \param vlen The size of the FFT vector (occupied_carriers + unused carriers)
+ * \param known_symbol1 A vector of complex numbers representing a known symbol at the
+ * start of a frame (usually a BPSK PN sequence)
+ * \param known_symbol2 A vector of complex numbers representing a known symbol at the
+ * start of a frame after known_symbol1 (usually a BPSK PN sequence).
+ * Both of these start symbols are differentially correlated to compensate
+ * for phase changes between symbols.
+ */
+ friend gr_ofdm_correlator_sptr
+ gr_make_ofdm_correlator (unsigned int occupied_carriers, unsigned int vlen,
+ unsigned int cplen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+ protected:
+ gr_ofdm_correlator (unsigned int occupied_carriers, unsigned int vlen,
+ unsigned int cplen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+ private:
+ unsigned char slicer(gr_complex x);
+ bool correlate(const gr_complex *previous, const gr_complex *current, int zeros_on_left);
+ void calculate_equalizer(const gr_complex *previous,
+ const gr_complex *current, 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_vlen; // !< \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_symbol1, d_known_symbol2; // !< \brief known symbols at start of frame
+ std::vector<gr_complex> d_diff_corr_factor; // !< \brief factor used in correlation
+ std::vector<gr_complex> d_hestimate; // !< channel estimate
+ signed 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
+
+ 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_correlator(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_correlator.i b/gnuradio-core/src/lib/general/gr_ofdm_correlator.i
new file mode 100644
index 000000000..fbbf6a8af
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_correlator.i
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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_correlator)
+
+gr_ofdm_correlator_sptr
+gr_make_ofdm_correlator (unsigned int occupied_carriers,
+ unsigned int vlen,
+ unsigned int cplen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+class gr_ofdm_correlator : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_correlator (unsigned int occupied_carriers,
+ unsigned int vlen,
+ unsigned int cplen,
+ std::vector<gr_complex> known_symbol1,
+ std::vector<gr_complex> known_symbol2);
+
+ 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_cyclic_prefixer.cc b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
new file mode 100644
index 000000000..fa9cfac49
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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 gr_ofdm_cyclic_prefixer_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
new file mode 100644
index 000000000..e4992f87a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
@@ -0,0 +1,58 @@
+/* -*- 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 2, 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 block
+ */
+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_cyclic_prefixer.i b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
new file mode 100644
index 000000000..52a7e6c4d
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
@@ -0,0 +1,34 @@
+/* -*- 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 2, 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_cyclic_prefixer)
+
+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_decimator
+{
+ protected:
+ gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+ public:
+};
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
new file mode 100644
index 000000000..c355e28ca
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
@@ -0,0 +1,41 @@
+/* -*- 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 2, 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
new file mode 100644
index 000000000..e0b01c721
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
@@ -0,0 +1,55 @@
+/* -*- 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 2, 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.
+ *
+ */
+
+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_demapper_vcb.i b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
new file mode 100644
index 000000000..8ba0670c3
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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 (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+class gr_ofdm_mapper_bcv : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_mapper_bcv (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+ public:
+};
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
new file mode 100644
index 000000000..a7b46e00d
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
@@ -0,0 +1,41 @@
+/* -*- 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 2, 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>
+
+gr_ofdm_mapper_bcv::~gr_ofdm_mapper_bcv(void)
+{
+}
+
+gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (unsigned bits_per_symbol,unsigned int vlen)
+ : gr_sync_decimator ("ofdm_mapper_bcv",
+ gr_make_io_signature (1, 1, sizeof(unsigned char)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen),
+ bits_per_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
new file mode 100644
index 000000000..b1a74fc02
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
@@ -0,0 +1,56 @@
+/* -*- 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 2, 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_decimator.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 (unsigned int bits_per_symbol, unsigned int vlen);
+
+
+/*!
+ * \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.
+ *
+ */
+
+class gr_ofdm_mapper_bcv : public gr_sync_decimator
+{
+ friend gr_ofdm_mapper_bcv_sptr
+ gr_make_ofdm_mapper_bcv (unsigned int bits_per_symbol, unsigned int vlen);
+
+protected:
+ gr_ofdm_mapper_bcv (unsigned int bits_per_symbol, unsigned int vlen);
+
+public:
+ ~gr_ofdm_mapper_bcv(void);
+};
+
+
+
+#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
new file mode 100644
index 000000000..8ba0670c3
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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 (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+class gr_ofdm_mapper_bcv : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_mapper_bcv (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+ public:
+};
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc b/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
new file mode 100644
index 000000000..9ac5abdcd
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
@@ -0,0 +1,94 @@
+/* -*- 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 2, 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>
+
+gr_ofdm_sampler_sptr
+gr_make_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length)
+{
+ return gr_ofdm_sampler_sptr (new gr_ofdm_sampler (fft_length, symbol_length));
+}
+
+gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length)
+ : gr_block ("ofdm_sampler",
+ gr_make_io_signature (2, 2, sizeof (gr_complex)),
+ gr_make_io_signature (1, 1, sizeof (gr_complex)*fft_length)),
+ d_fft_length(fft_length), d_symbol_length(symbol_length)
+{
+}
+
+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;
+ 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)
+{
+ gr_complex *iptr = (gr_complex *) input_items[0];
+ gr_complex *trigger = (gr_complex *) input_items[1];
+
+ gr_complex *optr = (gr_complex *) output_items[0];
+
+ int found=0;
+
+ unsigned int i=d_fft_length-1;
+
+ while(!found && i<std::min(ninput_items[0],ninput_items[1]) )
+ if(trigger[i].real() > 0.5)
+ found = 1;
+ else
+ i++;
+
+ if(found) {
+ assert(i-d_fft_length+1 >= 0);
+ for(unsigned int j=i-d_fft_length+1;j<=i;j++)
+ *optr++ = iptr[j];
+ consume_each(i-d_fft_length+2);
+ //printf("OFDM Sampler found: ninput_items: %d/%d noutput_items: %d consumed: %d found: %d\n",
+ // ninput_items[0], ninput_items[1], noutput_items, (i-d_fft_length+2), found);
+ }
+ else {
+ consume_each(i-d_fft_length+1);
+ //printf("OFDM Sampler not found: ninput_items: %d/%d noutput_items: %d consumed: %d found: %d\n",
+ // ninput_items[0], ninput_items[1], noutput_items, (i-d_fft_length+1), found);
+ }
+
+
+ return found;
+}
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.h b/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
new file mode 100644
index 000000000..0c3fd75f2
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
@@ -0,0 +1,59 @@
+/* -*- 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 2, 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);
+
+/*!
+ * \brief does the rest of the OFDM stuff (fixme)
+ */
+
+class gr_ofdm_sampler : public gr_block
+{
+ friend gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length);
+
+ gr_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length);
+
+ private:
+ 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
new file mode 100644
index 000000000..510636e89
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
@@ -0,0 +1,31 @@
+/* -*- 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 2, 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);
+
+class gr_ofdm_sampler : public gr_sync_block
+{
+ private:
+ gr_ofdm_sampler (unsigned int fft_length, unsigned int symbol_length);
+};
diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.cc b/gnuradio-core/src/lib/general/gr_stream_mux.cc
new file mode 100644
index 000000000..1eaad29a2
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_stream_mux.cc
@@ -0,0 +1,192 @@
+/* -*- 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 2, 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_stream_mux.h>
+#include <gr_io_signature.h>
+
+#define VERBOSE 0
+
+gr_stream_mux_sptr
+gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths)
+{
+ return gr_stream_mux_sptr (new gr_stream_mux (itemsize, lengths));
+}
+
+gr_stream_mux::gr_stream_mux (size_t itemsize, const std::vector<int> &lengths)
+ : gr_block ("stream_mux",
+ gr_make_io_signature (1, -1, itemsize),
+ gr_make_io_signature (1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_stream(0),
+ d_residual(0),
+ d_lengths(lengths)
+{
+}
+
+gr_stream_mux::~gr_stream_mux(void)
+{
+}
+
+void
+gr_stream_mux::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] = 0;
+}
+
+
+int
+gr_stream_mux::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+
+ char *out = (char *) output_items[0];
+ const char *in;
+
+ int acc = 0;
+ int N=0;
+ int M=0;
+ std::vector<int> consume_vector(d_lengths.size(), 0);
+
+ #if VERBOSE
+ printf("mux: nouput_items: %d d_stream: %d\n", noutput_items, d_stream);
+ for(int i = 0; i < d_lengths.size(); i++)
+ printf("\tninput_items[%d]: %d\n", i, ninput_items[i]);
+ #endif
+
+ in = (const char *) input_items[d_stream];
+
+ if(d_residual) {
+ #if VERBOSE
+ printf("Cleaning up residual bytes (%d) from stream %d\n", d_residual, d_stream);
+ #endif
+
+ // get the number of items available in input stream up to the
+ // num items required
+ N=std::min(d_residual, ninput_items[d_stream]);
+
+ // get the number of items we can put into the output buffer
+ M=std::min(N, noutput_items);
+
+ // copy the items to the output buff
+ memcpy(out, in, M*d_itemsize);
+
+ // increment the output accumulator
+ acc += M;
+
+ // keep track of items consumed
+ consume_vector[d_stream]=M;
+
+ // keep track if there are residual items left from the input stream
+ d_residual -= M;
+
+ #if VERBOSE
+ printf("Stream: %d (%x) Wrote: %d bytes Output has: %d bytes residual: %d bytes\n",
+ d_stream, in, M, acc, d_residual);
+ #endif
+
+ // if no residual items, we're done with this input stream for
+ // this round
+ if (!d_residual) {
+ if(d_stream == d_lengths.size() - 1) {
+ d_stream=0; // wrap stream pointer
+ }
+ else {
+ d_stream++; // or increment the stream pointer
+ }
+ #if VERBOSE
+ printf("Going to next stream: %d\n", d_stream);
+ #endif
+ in = ((const char *) (input_items[d_stream])) + d_itemsize*consume_vector[d_stream];
+ }
+ }
+
+ if(!d_residual) {
+ while (acc<noutput_items){
+ // get the number of items available in input stream up to the
+ // num items required
+ N=std::min(d_lengths[d_stream], ninput_items[d_stream]);
+
+ // get the number of items we can put into the output buffer
+ M=std::min(N, noutput_items-acc);
+
+ // copy the items to the output buff
+ memcpy(out+acc*d_itemsize,in,M*d_itemsize);
+
+ // increment the output accumulator
+ acc += M;
+
+ // keep track of items consumed
+ consume_vector[d_stream]+=M;
+
+ // keep track if there are residual items left from the input stream
+ d_residual=d_lengths[d_stream] - M;
+
+ #if VERBOSE
+ printf("Stream: %d (%x) Wrote: %d bytes Output has: %d bytes residual: %d bytes\n",
+ d_stream, in, M, acc, d_residual);
+ #endif
+
+ // if no residual items, we're done with this input stream for
+ // this round
+ if (!d_residual) {
+ if(d_stream == d_lengths.size() - 1) {
+ d_stream=0; // wrap stream pointer
+ }
+ else {
+ d_stream++; // or increment the stream pointer
+ }
+ #if VERBOSE
+ printf("Going to next stream: %d\n", d_stream);
+ #endif
+
+ // get next stream pointer
+ in = ((const char *) (input_items[d_stream])) + d_itemsize*consume_vector[d_stream];
+ }
+ else{
+ break;
+ }
+ }
+ }
+
+ for (unsigned int j=0;j<d_lengths.size();j++){
+ consume(j,consume_vector[j]);
+
+ #if VERBOSE
+ printf("consuming: %d on stream: %d\n", consume_vector[j], j);
+ #endif
+ }
+
+ #if VERBOSE
+ printf("mux: returning: %d\n\n", acc);
+ #endif
+
+ return acc;
+
+}
diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.h b/gnuradio-core/src/lib/general/gr_stream_mux.h
new file mode 100644
index 000000000..492940001
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_stream_mux.h
@@ -0,0 +1,90 @@
+/* -*- 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 2, 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_STREAM_MUX_H
+#define INCLUDED_GR_STREAM_MUX_H
+
+
+#include <gr_block.h>
+#include <gr_frame.h>
+#include <vector>
+
+class gr_stream_mux;
+typedef boost::shared_ptr<gr_stream_mux> gr_stream_mux_sptr;
+
+/*!
+ * \brief Creates a stream muxing block to multiplex many streams into
+ * one with a specified format.
+ *
+ * \param itemsize the item size of the stream
+ * \param length a vector (list/tuple) specifying the number of
+ * items from each stream the mux together.
+ * Warning: this requires that at least as many items
+ * per stream are available or the system will wait
+ * indefinitely for the items.
+ *
+ */
+
+gr_stream_mux_sptr
+gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths);
+
+
+/*!
+ * \brief Stream muxing block to multiplex many streams into
+ * one with a specified format.
+ *
+ * Muxes N streams together producing an output stream that
+ * contains N0 items from the first stream, N1 items from the second,
+ * etc. and repeats:
+ *
+ * [N0, N1, N2, ..., Nm, N0, N1, ...]
+ */
+
+class gr_stream_mux : public gr_block
+{
+ friend gr_stream_mux_sptr
+ gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths);
+
+ protected:
+ gr_stream_mux (size_t itemsize, const std::vector<int> &lengths);
+ private:
+ size_t d_itemsize;
+ unsigned int d_stream;
+ int d_residual;
+ int d_times;
+ int d_unconsume;
+ //gr_vector_int d_unconsume;
+ gr_vector_int d_lengths;
+ public:
+ ~gr_stream_mux(void);
+
+ 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_stream_mux.i b/gnuradio-core/src/lib/general/gr_stream_mux.i
new file mode 100644
index 000000000..022135150
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_stream_mux.i
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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 2, 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,stream_mux)
+
+gr_stream_mux_sptr
+gr_make_stream_mux (size_t itemsize,
+ const std::vector<int> &lengths);
+
+class gr_stream_mux : public gr_block
+{
+ protected:
+ gr_make_stream_mux (size_t itemsize,
+ const std::vector<int> &lengths);
+
+ public:
+ 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/gengen/Makefile.am b/gnuradio-core/src/lib/gengen/Makefile.am
index d3fa84cf4..c566570e2 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.am
+++ b/gnuradio-core/src/lib/gengen/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2001,2002,2004,2006 Free Software Foundation, Inc.
+# Copyright 2001,2002,2004,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -71,6 +71,9 @@ CODE_GENERATOR = \
gr_packed_to_unpacked_XX.cc.t \
gr_packed_to_unpacked_XX.h.t \
gr_packed_to_unpacked_XX.i.t \
+ gr_peak_detector_XX.cc.t \
+ gr_peak_detector_XX.h.t \
+ gr_peak_detector_XX.i.t \
gr_sig_source_X.cc.t \
gr_sig_source_X.h.t \
gr_sig_source_X.i.t \
diff --git a/gnuradio-core/src/lib/gengen/Makefile.gen b/gnuradio-core/src/lib/gengen/Makefile.gen
index f0c477e3d..adbceba10 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.gen
+++ b/gnuradio-core/src/lib/gengen/Makefile.gen
@@ -56,6 +56,13 @@ GENERATED_H = \
gr_packed_to_unpacked_bb.h \
gr_packed_to_unpacked_ii.h \
gr_packed_to_unpacked_ss.h \
+ gr_peak_detector_ff.h \
+ gr_peak_detector_ii.h \
+ gr_peak_detector_ss.h \
+ gr_sample_and_hold_bb.h \
+ gr_sample_and_hold_ff.h \
+ gr_sample_and_hold_ii.h \
+ gr_sample_and_hold_ss.h \
gr_sig_source_c.h \
gr_sig_source_f.h \
gr_sig_source_i.h \
@@ -133,6 +140,13 @@ GENERATED_I = \
gr_packed_to_unpacked_bb.i \
gr_packed_to_unpacked_ii.i \
gr_packed_to_unpacked_ss.i \
+ gr_peak_detector_ff.i \
+ gr_peak_detector_ii.i \
+ gr_peak_detector_ss.i \
+ gr_sample_and_hold_bb.i \
+ gr_sample_and_hold_ff.i \
+ gr_sample_and_hold_ii.i \
+ gr_sample_and_hold_ss.i \
gr_sig_source_c.i \
gr_sig_source_f.i \
gr_sig_source_i.i \
@@ -210,6 +224,13 @@ GENERATED_CC = \
gr_packed_to_unpacked_bb.cc \
gr_packed_to_unpacked_ii.cc \
gr_packed_to_unpacked_ss.cc \
+ gr_peak_detector_ff.cc \
+ gr_peak_detector_ii.cc \
+ gr_peak_detector_ss.cc \
+ gr_sample_and_hold_bb.cc \
+ gr_sample_and_hold_ff.cc \
+ gr_sample_and_hold_ii.cc \
+ gr_sample_and_hold_ss.cc \
gr_sig_source_c.cc \
gr_sig_source_f.cc \
gr_sig_source_i.cc \
diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py
index 5abb15cea..2ab0586df 100755
--- a/gnuradio-core/src/lib/gengen/generate_common.py
+++ b/gnuradio-core/src/lib/gengen/generate_common.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2006 Free Software Foundation, Inc.
+# Copyright 2004,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -50,14 +50,16 @@ reg_roots = [
'gr_add_vXX',
'gr_multiply_vXX',
'gr_add_const_vXX',
- 'gr_multiply_const_vXX'
+ 'gr_multiply_const_vXX',
]
# other blocks
others = (
('gr_chunks_to_symbols_XX', ('bf', 'bc', 'sf', 'sc', 'if', 'ic')),
('gr_unpacked_to_packed_XX', ('bb','ss','ii')),
- ('gr_packed_to_unpacked_XX', ('bb','ss','ii'))
+ ('gr_packed_to_unpacked_XX', ('bb','ss','ii')),
+ ('gr_sample_and_hold_XX', ('bb','ss','ii','ff')),
+ ('gr_peak_detector_XX', ('ff','ii','ss'))
)
diff --git a/gnuradio-core/src/lib/gengen/gengen_generated.i b/gnuradio-core/src/lib/gengen/gengen_generated.i
index a41f30a3d..d5f874e61 100644
--- a/gnuradio-core/src/lib/gengen/gengen_generated.i
+++ b/gnuradio-core/src/lib/gengen/gengen_generated.i
@@ -56,6 +56,13 @@
#include <gr_packed_to_unpacked_bb.h>
#include <gr_packed_to_unpacked_ii.h>
#include <gr_packed_to_unpacked_ss.h>
+#include <gr_peak_detector_ff.h>
+#include <gr_peak_detector_ii.h>
+#include <gr_peak_detector_ss.h>
+#include <gr_sample_and_hold_bb.h>
+#include <gr_sample_and_hold_ff.h>
+#include <gr_sample_and_hold_ii.h>
+#include <gr_sample_and_hold_ss.h>
#include <gr_sig_source_c.h>
#include <gr_sig_source_f.h>
#include <gr_sig_source_i.h>
@@ -133,6 +140,13 @@
%include <gr_packed_to_unpacked_bb.i>
%include <gr_packed_to_unpacked_ii.i>
%include <gr_packed_to_unpacked_ss.i>
+%include <gr_peak_detector_ff.i>
+%include <gr_peak_detector_ii.i>
+%include <gr_peak_detector_ss.i>
+%include <gr_sample_and_hold_bb.i>
+%include <gr_sample_and_hold_ff.i>
+%include <gr_sample_and_hold_ii.i>
+%include <gr_sample_and_hold_ss.i>
%include <gr_sig_source_c.i>
%include <gr_sig_source_f.i>
%include <gr_sig_source_i.i>
diff --git a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t
new file mode 100644
index 000000000..812ec9fd2
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t
@@ -0,0 +1,110 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME@.h>
+#include <gr_io_signature.h>
+
+@SPTR_NAME@
+gr_make_@BASE_NAME@ (float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha)
+{
+ return @SPTR_NAME@ (new @NAME@ (threshold_factor_rise,
+ threshold_factor_fall,
+ look_ahead, alpha));
+}
+
+@NAME@::@NAME@ (float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha)
+ : gr_sync_block ("@BASE_NAME@",
+ gr_make_io_signature (1, 1, sizeof (@I_TYPE@)),
+ gr_make_io_signature (1, 1, sizeof (@O_TYPE@))),
+ d_threshold_factor_rise(threshold_factor_rise),
+ d_threshold_factor_fall(threshold_factor_fall),
+ d_look_ahead(look_ahead), d_avg_alpha(alpha), d_avg(0), d_found(0)
+{
+}
+
+int
+@NAME@::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0];
+ @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
+
+ memset(optr, 0, noutput_items*sizeof(@O_TYPE@));
+
+ @I_TYPE@ peak_val = -(@I_TYPE@)INFINITY;
+ int peak_ind = 0;
+ unsigned char state = 0;
+ int i = 0;
+
+ //printf("noutput_items %d\n",noutput_items);
+ while(i < noutput_items) {
+ if(state == 0) { // below threshold
+ if(iptr[i] > d_avg*d_threshold_factor_rise) {
+ state = 1;
+ }
+ else {
+ d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg;
+ i++;
+ }
+ }
+ else if(state == 1) { // above threshold, have not found peak
+ //printf("Entered State 1: %f i: %d noutput_items: %d\n", iptr[i], i, noutput_items);
+ if(iptr[i] > peak_val) {
+ peak_val = iptr[i];
+ peak_ind = i;
+ d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg;
+ i++;
+ }
+ else if (iptr[i] > d_avg*d_threshold_factor_fall) {
+ d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg;
+ i++;
+ }
+ else {
+ optr[peak_ind] = (@O_TYPE@)1;
+ state = 0;
+ peak_val = -(@I_TYPE@)INFINITY;
+ //printf("Leaving State 1: Peak: %f Peak Ind: %d i: %d noutput_items: %d\n",
+ //peak_val, peak_ind, i, noutput_items);
+ }
+ }
+ }
+
+ if(state == 0) {
+ //printf("Leave in State 0, produced %d\n",noutput_items);
+ return noutput_items;
+ }
+ else { // only return up to passing the threshold
+ //printf("Leave in State 1, only produced %d of %d\n",peak_ind,noutput_items);
+ return peak_ind;
+ }
+}
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
new file mode 100644
index 000000000..487f98ba0
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.h.t
@@ -0,0 +1,125 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <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,
+ float threshold_factor_fall = 0.40,
+ int look_ahead = 10,
+ float alpha = 0.001);
+
+/*!
+ * \brief Detect the peak of a signal
+ * \ingroup block
+ *
+ * If a peak is detected, this block outputs a 1,
+ * or it outputs 0's.
+ *
+ * \param threshold_factor_rise The threshold factor determins when a peak
+ * has started. An average of the signal is calculated and when the
+ * value of the signal goes over threshold_factor_rise*average, we
+ * start looking for a peak.
+ * \param threshold_factor_fall The threshold factor determins when a peak
+ * has ended. An average of the signal is calculated and when the
+ * value of the signal goes bellow threshold_factor_fall*average, we
+ * stop looking for a peak.
+ * \param look_ahead The look-ahead value is used when the threshold is
+ * found to look if there another peak within this step range.
+ * If there is a larger value, we set that as the peak and look ahead
+ * again. This is continued until the highest point is found with
+ * This look-ahead range.
+ * \param alpha The gain value of a moving average filter
+ */
+class @NAME@ : public gr_sync_block
+{
+ friend @SPTR_NAME@ gr_make_@BASE_NAME@ (float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha);
+
+ @NAME@ (float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha);
+
+ private:
+ float d_threshold_factor_rise;
+ float d_threshold_factor_fall;
+ int d_look_ahead;
+ float d_avg_alpha;
+ float d_avg;
+ unsigned char d_found;
+
+ public:
+
+ /*! \brief Set the threshold factor value for the rise time
+ * \param thr new threshold factor
+ */
+ void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; }
+
+ /*! \brief Set the threshold factor value for the fall time
+ * \param thr new threshold factor
+ */
+ void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; }
+
+ /*! \brief Set the look-ahead factor
+ * \param look new look-ahead factor
+ */
+ void set_look_ahead(int look) { d_look_ahead = look; }
+
+ /*! \brief Set the running average alpha
+ * \param alpha new alpha for running average
+ */
+ void set_alpha(int alpha) { d_avg_alpha = alpha; }
+
+ /*! \brief Get the threshold factor value for the rise time
+ * \return threshold factor
+ */
+ float threshold_factor_rise() { return d_threshold_factor_rise; }
+
+ /*! \brief Get the threshold factor value for the fall time
+ * \return threshold factor
+ */
+ float threshold_factor_fall() { return d_threshold_factor_fall; }
+
+ /*! \brief Get the look-ahead factor value
+ * \return look-ahead factor
+ */
+ int look_ahead() { return d_look_ahead; }
+
+ /*! \brief Get the alpha value of the running average
+ * \return alpha
+ */
+ float alpha() { return d_avg_alpha; }
+
+ 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/gengen/gr_peak_detector_XX.i.t b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.i.t
new file mode 100644
index 000000000..02a559460
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.i.t
@@ -0,0 +1,49 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@)
+
+@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);
+
+class @NAME@ : public gr_sync_block
+{
+ private:
+ @NAME@ (float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha);
+
+ public:
+ void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; }
+ void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; }
+ void set_look_ahead(int look) { d_look_ahead = look; }
+ void set_alpha(int alpha) { d_avg_alpha = alpha; }
+
+ float threshold_factor_rise() { return d_threshold_factor_rise; }
+ float threshold_factor_fall() { return d_threshold_factor_fall; }
+ int look_ahead() { return d_look_ahead; }
+ float alpha() { return d_avg_alpha; }
+};
diff --git a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t
new file mode 100644
index 000000000..3b9715575
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t
@@ -0,0 +1,62 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME@.h>
+#include <gr_io_signature.h>
+
+@SPTR_NAME@
+gr_make_@BASE_NAME@ ()
+{
+ return @SPTR_NAME@ (new @NAME@ ());
+}
+
+@NAME@::@NAME@ ()
+ : gr_sync_block ("@BASE_NAME@",
+ gr_make_io_signature (2, 2, sizeof (@I_TYPE@)),
+ gr_make_io_signature (1, 1, sizeof (@O_TYPE@))),
+ d_data(0)
+{
+}
+
+int
+@NAME@::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0];
+ @I_TYPE@ *ctrl = (@I_TYPE@ *) input_items[1];
+ @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
+
+ for (int i = 0; i < noutput_items; i++){
+ if(ctrl[i] > 0.5) {
+ d_data = iptr[i];
+ }
+ optr[i] = d_data;
+ }
+ return noutput_items;
+}
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
new file mode 100644
index 000000000..9da7e4629
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.h.t
@@ -0,0 +1,57 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gr_sync_block.h>
+
+class @NAME@;
+typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ ();
+
+/*!
+ * \brief sample and hold circuit
+ * \ingroup block
+ *
+ * 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
+{
+ friend @SPTR_NAME@ gr_make_@BASE_NAME@ ();
+
+ @NAME@ ();
+
+ private:
+ @O_TYPE@ d_data;
+
+ 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/gengen/gr_sample_and_hold_XX.i.t b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.i.t
new file mode 100644
index 000000000..307bf2431
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.i.t
@@ -0,0 +1,33 @@
+/* -*- 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@)
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ ();
+
+class @NAME@ : public gr_sync_block
+{
+ private:
+ @NAME@ ();
+};
diff --git a/gnuradio-core/src/lib/io/Makefile.am b/gnuradio-core/src/lib/io/Makefile.am
index 8320375c7..049e6984a 100644
--- a/gnuradio-core/src/lib/io/Makefile.am
+++ b/gnuradio-core/src/lib/io/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2001,2003,2004,2006 Free Software Foundation, Inc.
+# Copyright 2001,2003,2004,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -34,6 +34,7 @@ libio_la_SOURCES = \
gr_file_descriptor_source.cc \
gr_message_sink.cc \
gr_message_source.cc \
+ gr_message_vector_source.cc \
gr_oscope_guts.cc \
gr_oscope_sink_f.cc \
gr_oscope_sink_x.cc \
@@ -59,8 +60,10 @@ grinclude_HEADERS = \
gr_file_source.h \
gr_file_descriptor_sink.h \
gr_file_descriptor_source.h \
+ gr_frame.h \
gr_message_sink.h \
gr_message_source.h \
+ gr_message_vector_source.h \
gr_oscope_guts.h \
gr_oscope_sink_f.h \
gr_oscope_sink_x.h \
@@ -92,6 +95,7 @@ swiginclude_HEADERS = \
gr_file_descriptor_source.i \
gr_message_sink.i \
gr_message_source.i \
+ gr_message_vector_source.i \
gr_oscope_sink.i \
microtune_xxxx_eval_board.i \
microtune_4702_eval_board.i \
diff --git a/gnuradio-core/src/lib/io/gr_frame.h b/gnuradio-core/src/lib/io/gr_frame.h
new file mode 100644
index 000000000..07317e9df
--- /dev/null
+++ b/gnuradio-core/src/lib/io/gr_frame.h
@@ -0,0 +1,41 @@
+/* -*- 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 2, 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_FRAME_H
+#define INCLUDED_GR_FRAME_H
+
+#include <vector>
+
+class gr_frame
+{
+ public:
+ gr_frame(unsigned int mtu)
+ : mtu(mtu), length(0)
+ { }
+
+ unsigned int mtu;
+ unsigned int length;
+ unsigned char data[];
+};
+
+#endif
+
diff --git a/gnuradio-core/src/lib/io/gr_message_vector_source.cc b/gnuradio-core/src/lib/io/gr_message_vector_source.cc
new file mode 100644
index 000000000..69e2bc8df
--- /dev/null
+++ b/gnuradio-core/src/lib/io/gr_message_vector_source.cc
@@ -0,0 +1,97 @@
+/* -*- 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 2, 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_message_vector_source.h>
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+
+
+// public constructor that returns a shared_ptr
+
+gr_message_vector_source_sptr
+gr_make_message_vector_source(size_t max_msg_size, int msgq_limit)
+{
+ return gr_message_vector_source_sptr(new gr_message_vector_source(max_msg_size,msgq_limit));
+}
+
+gr_message_vector_source::gr_message_vector_source (size_t max_msg_size, int msgq_limit)
+ : gr_sync_block("message_vector_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, 2*sizeof(int) + max_msg_size * sizeof(char))), // Make room for length fields
+ d_max_msg_size(max_msg_size), d_msgq(gr_make_msg_queue(msgq_limit)), d_eof(false)
+{
+}
+
+gr_message_vector_source::~gr_message_vector_source()
+{
+}
+
+int
+gr_message_vector_source::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ /*
+ char *out = (char *) output_items[0];
+
+ if (d_eof)
+ return -1;
+
+ gr_message_sptr msg = d_msgq->delete_head();
+
+ if (msg->type() == 1) { // type == 1 sets EOF
+ d_eof = true;
+ }
+
+ assert(msg->length() <= d_max_msg_size);
+ memset((int*)out, msg->length(), 1);
+ memcpy (&out[4], (msg->msg()), msg->length());
+ */
+
+ char *out = (char *) output_items[0];
+ gr_frame *myframe = (gr_frame*)out;
+
+ if (d_eof)
+ return -1;
+
+ gr_message_sptr msg = d_msgq->delete_head();
+
+ if (msg->type() == 1) { // type == 1 sets EOF
+ d_eof = true;
+ }
+
+ assert(msg->length() <= d_max_msg_size);
+ myframe->length = msg->length();
+ myframe->mtu = d_max_msg_size;
+ memcpy (myframe->data, (msg->msg()), msg->length());
+
+ return 1;
+}
diff --git a/gnuradio-core/src/lib/io/gr_message_vector_source.h b/gnuradio-core/src/lib/io/gr_message_vector_source.h
new file mode 100644
index 000000000..8b3465355
--- /dev/null
+++ b/gnuradio-core/src/lib/io/gr_message_vector_source.h
@@ -0,0 +1,63 @@
+/* -*- 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 2, 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_MESSAGE_VECTOR_SOURCE_H
+#define INCLUDED_GR_MESSAGE_VECTOR_SOURCE_H
+
+#include <gr_sync_block.h>
+#include <gr_message.h>
+#include <gr_msg_queue.h>
+#include <gr_frame.h>
+
+class gr_message_vector_source;
+typedef boost::shared_ptr<gr_message_vector_source> gr_message_vector_source_sptr;
+
+gr_message_vector_source_sptr gr_make_message_vector_source (size_t max_msg_size, int msgq_limit=0);
+
+/*!
+ * \brief Turn received messages into vectors
+ * \ingroup source
+ */
+class gr_message_vector_source : public gr_sync_block
+{
+ private:
+ size_t d_max_msg_size;
+ gr_msg_queue_sptr d_msgq;
+ bool d_eof;
+
+ friend gr_message_vector_source_sptr
+ gr_make_message_vector_source(size_t max_msg_size, int msgq_limit);
+
+ protected:
+ gr_message_vector_source (size_t max_msg_size, int msgq_limit);
+
+ public:
+ ~gr_message_vector_source ();
+
+ 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 /* INCLUDED_GR_MESSAGE_VECTOR_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_message_vector_source.i b/gnuradio-core/src/lib/io/gr_message_vector_source.i
new file mode 100644
index 000000000..ff8bd5de5
--- /dev/null
+++ b/gnuradio-core/src/lib/io/gr_message_vector_source.i
@@ -0,0 +1,36 @@
+/* -*- 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 2, 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,message_vector_source);
+
+gr_message_vector_source_sptr gr_make_message_vector_source (size_t max_msg_size, int msgq_limit=0);
+
+class gr_message_vector_source : public gr_sync_block
+{
+ protected:
+ gr_message_vector_source (size_t itemsize, int msgq_limit);
+
+ public:
+ ~gr_message_vector_source ();
+
+ gr_msg_queue_sptr msgq() const;
+};
diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i
index 7baf94ef0..d80f66369 100644
--- a/gnuradio-core/src/lib/io/io.i
+++ b/gnuradio-core/src/lib/io/io.i
@@ -34,8 +34,9 @@
#include <ppio.h>
#include <gr_message_source.h>
#include <gr_message_sink.h>
-#include <gr_udp_sink.h>
-#include <gr_udp_source.h>
+#include <gr_message_vector_source.h>
+#include <gr_udp_sink.cc>
+#include <gr_udp_source.cc>
%}
@@ -50,6 +51,7 @@
%include "gr_oscope_sink.i"
%include "ppio.i"
%include "gr_message_source.i"
+%include "gr_message_vector_source.i"
%include "gr_message_sink.i"
%include "gr_udp_sink.i"
%include "gr_udp_source.i"