summaryrefslogtreecommitdiff
path: root/gr-analog/lib/fastnoise_source_impl.h
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2021-03-25 18:13:35 +0100
committerGitHub <noreply@github.com>2021-03-25 13:13:35 -0400
commit4dd02dac2fcaf45f398c074735a7359330f78d77 (patch)
treeb09529d96288fbdfb3ad703c3475fbb1154e2548 /gr-analog/lib/fastnoise_source_impl.h
parent9a08594ae534c41d20e21187618de9ff3cc67336 (diff)
analog/fastnoise: avoid modulo operation when picking indices
When the pool is power-of-2-sized, index generation can be done using a simple bitmask. Document this, add logging info. - use unsigned and fixed-length int where due - avoid expensive integer modulo operation when possible - extract power-of-two constexpr - don't clutter the logs for small pool sizes Signed-off-by: Marcus Müller <marcus@hostalia.de>
Diffstat (limited to 'gr-analog/lib/fastnoise_source_impl.h')
-rw-r--r--gr-analog/lib/fastnoise_source_impl.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/gr-analog/lib/fastnoise_source_impl.h b/gr-analog/lib/fastnoise_source_impl.h
index 872f41e4b1..d20a1178ec 100644
--- a/gr-analog/lib/fastnoise_source_impl.h
+++ b/gr-analog/lib/fastnoise_source_impl.h
@@ -28,9 +28,10 @@ private:
gr::random d_rng;
std::vector<T> d_samples;
uint64_t d_state[2];
+ size_t d_bitmask;
public:
- fastnoise_source_impl(noise_type_t type, float ampl, long seed, long samples);
+ fastnoise_source_impl(noise_type_t type, float ampl, uint64_t seed, size_t samples);
~fastnoise_source_impl() override;
T sample() override;