7#include "xorshift128p.hpp"
8#include "../utility/utility.hpp"
9#include "../macros.hpp"
10#include <hikocpu/hikocpu.hpp>
14hi_export_module(hikogui.random.dither);
16hi_export
namespace hi::inline
v1 {
43 hi_axiom(num_bits > 0);
44 auto maximum_value =
static_cast<float>((1_uz << num_bits) - 1);
47 maximum_value *= 127.0f;
50 maximum_value *= 2.0f;
52 _multiplier = f32x4::broadcast(1.0f / maximum_value);
80 [[nodiscard]] f32x4
next(f32x4 samples)
noexcept
82 return samples + next();
90 [[nodiscard]]
float next(
float sample)
noexcept
92 return get<0>(f32x4::broadcast(sample) + next());
96 f32x4 _multiplier = {};
98 xorshift128p _state = {};
99 unsigned char _counter = 0;
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
An object that create dither values to add to samples before rounding.
Definition dither.hpp:29
dither(int num_bits) noexcept
Create a dither object.
Definition dither.hpp:41
f32x4 next() noexcept
Get 8 floating point number to add to a samples.
Definition dither.hpp:58
f32x4 next(f32x4 samples) noexcept
Add dither to the given samples.
Definition dither.hpp:80
float next(float sample) noexcept
Add dither to the given samples.
Definition dither.hpp:90