diff options
author | Tim O'Shea <tim.oshea753@gmail.com> | 2013-09-19 11:59:47 -0400 |
---|---|---|
committer | Tim O'Shea <tim.oshea753@gmail.com> | 2013-11-07 01:10:46 -0500 |
commit | d9168b34dbc1aeeda7077ede8c9534fabb1e7518 (patch) | |
tree | fa3812f3184aad6a684989e463f4d06dadd1e54c /gr-analog | |
parent | 5f724cfd76ad52288db91b535b4366c176717d29 (diff) |
Adding models for sample rate and center frequency drift
Adding hier block "dynamic channel" model which combines these with AWGN and frequency selective fading
Diffstat (limited to 'gr-analog')
-rw-r--r-- | gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t | 2 | ||||
-rw-r--r-- | gr-analog/lib/fastnoise_source_X_impl.cc.t | 30 | ||||
-rw-r--r-- | gr-analog/lib/fastnoise_source_X_impl.h.t | 3 |
3 files changed, 30 insertions, 5 deletions
diff --git a/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t b/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t index c5331fc084..5f94a7eb56 100644 --- a/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t +++ b/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t @@ -55,6 +55,8 @@ namespace gr { */ static sptr make(noise_type_t type, float ampl, long seed = 0, long samples=1024*16); + virtual @TYPE@ sample() = 0; + virtual @TYPE@ sample_unbiased() = 0; virtual void set_type(noise_type_t type) = 0; virtual void set_amplitude(float ampl) = 0; diff --git a/gr-analog/lib/fastnoise_source_X_impl.cc.t b/gr-analog/lib/fastnoise_source_X_impl.cc.t index e6c7f13f34..c7831bb735 100644 --- a/gr-analog/lib/fastnoise_source_X_impl.cc.t +++ b/gr-analog/lib/fastnoise_source_X_impl.cc.t @@ -128,15 +128,35 @@ namespace gr { @TYPE@ *out = (@TYPE@*)output_items[0]; for(int i=0; i<noutput_items; i++) { + out[i] = sample(); + } + + return noutput_items; + } + + @TYPE@ @IMPL_NAME@::sample() + { #ifdef __USE_GNU - size_t idx = lrand48() % d_samples.size(); + size_t idx = lrand48() % d_samples.size(); #else - size_t idx = rand() % d_samples.size(); + size_t idx = rand() % d_samples.size(); #endif - out[i] = d_samples[idx]; - } + return d_samples[idx]; + } - return noutput_items; +#ifndef FASTNOISE_RANDOM_SIGN +#define FASTNOISE_RANDOM_SIGN ((lrand48()%2==0)?1:-1) +#endif + + @TYPE@ @IMPL_NAME@::sample_unbiased() + { +#if @IS_COMPLEX@ + gr_complex s(sample()); + return gr_complex(FASTNOISE_RANDOM_SIGN * s.real(), + FASTNOISE_RANDOM_SIGN * s.imag()); +#else + return FASTNOISE_RANDOM_SIGN * sample(); +#endif } } /* namespace analog */ diff --git a/gr-analog/lib/fastnoise_source_X_impl.h.t b/gr-analog/lib/fastnoise_source_X_impl.h.t index ed342ec176..8ad1e4f8fe 100644 --- a/gr-analog/lib/fastnoise_source_X_impl.h.t +++ b/gr-analog/lib/fastnoise_source_X_impl.h.t @@ -43,6 +43,9 @@ namespace gr { @IMPL_NAME@(noise_type_t type, float ampl, long seed, long samples); ~@IMPL_NAME@(); + @TYPE@ sample(); + @TYPE@ sample_unbiased(); + void set_type(noise_type_t type); void set_amplitude(float ampl); void generate(); |