diff options
Diffstat (limited to 'gr-analog/lib/fastnoise_source_X_impl.cc.t')
-rw-r--r-- | gr-analog/lib/fastnoise_source_X_impl.cc.t | 30 |
1 files changed, 25 insertions, 5 deletions
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 */ |