2#include <ossia/dataflow/graph_node.hpp>
3#include <ossia/dataflow/port.hpp>
9struct rand_float final :
public ossia::nonowning_graph_node
11 ossia::value_outlet value_out;
14 std::uniform_real_distribution<float> dist;
15 rand_float(
float min,
float max)
18 m_outlets.push_back(&value_out);
21 std::string label() const noexcept
override {
return "rand_float"; }
22 void run(
const ossia::token_request& t, ossia::exec_state_facade e)
noexcept override
24 auto& out = *value_out.target<ossia::value_port>();
25 auto tm = e.timings(t);
26#if defined(OSSIA_FREESTANDING)
27 out.write_value((rand() - dist.a()) / (dist.b() - dist.a()), tm.start_sample);
29 thread_local std::mt19937 gen;
30 out.write_value(dist(gen), tm.start_sample);
OSSIA_INLINE constexpr auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition math.hpp:125
OSSIA_INLINE constexpr auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition math.hpp:96