2 #include <ossia/dataflow/exec_state_facade.hpp>
3 #include <ossia/dataflow/execution_state.hpp>
4 #include <ossia/network/common/path.hpp>
6 #include <QCoreApplication>
9 #include <AvndProcesses/AddressTools.hpp>
10 #include <halp/audio.hpp>
11 #include <halp/controls.hpp>
12 #include <halp/meta.hpp>
13 #include <rnd/random.hpp>
26 halp_meta(name,
"Sweeper")
27 halp_meta(author,
"ossia team")
28 halp_meta(category,
"Control/Data processing")
29 halp_meta(description,
"Sweep a message to all nodes matching a pattern")
30 halp_meta(c_name,
"avnd_pattern_sweep")
31 halp_meta(uuid,
"55f4fe13-f71b-4c20-ac32-74668e82664c")
32 halp_meta(manual_url,
"https://ossia.io/score-docs/processes/sweeper.html")
36 halp::val_port<
"Input", ossia::value> input;
39 halp::time_chooser<
"Interval"> time;
42 halp__enum(
"Mode", Upwards, Upwards, Downwards, UpDown, RandomWalk, Random);
51 std::size_t current_parameter = 0;
52 double last_message_sent_pos = std::numeric_limits<double>::lowest();
62 std::random_device dev;
68 if(this->roots.size() <= 1)
70 current_parameter = 0;
73 using mode = decltype(inputs.mode)::enum_type;
78 current_parameter = current_parameter % this->roots.size();
81 if(current_parameter == 0)
82 current_parameter = this->roots.size() - 1;
90 if(current_parameter + 1 == this->roots.size())
102 if(current_parameter == 0)
114 case mode::RandomWalk: {
115 if(std::bernoulli_distribution{}(pcg_state))
123 auto dist = std::uniform_int_distribution<int>(0, std::ssize(this->roots) - 1);
124 current_parameter = dist(pcg_state);
130 using tick = halp::tick_musical;
131 void operator()(
const halp::tick_musical& tk)
133 auto elapsed_ns = (tk.position_in_nanoseconds - last_message_sent_pos);
134 if(!m_path || this->roots.empty())
137 if(elapsed_ns < inputs.time.value * 1e9)
139 last_message_sent_pos = tk.position_in_nanoseconds;
141 if(current_parameter >= 0 && current_parameter < this->roots.size())
143 if(
auto p = roots[current_parameter]->get_parameter())
145 p->push_value(inputs.input.value);