Loading...
Searching...
No Matches
Arraygen.hpp
1#pragma once
2#include <Fx/MathMapping_generic.hpp>
3#include <Fx/Types.hpp>
4
5#include <boost/container/static_vector.hpp>
6
7#include <halp/layout.hpp>
8
9namespace Nodes::ArrayGenerator
10{
11struct Node
12{
13 halp_meta(name, "Arraygen")
14 halp_meta(c_name, "ArrayGenerator")
15 halp_meta(category, "Control/Generators")
16 halp_meta(
17 manual_url, "https://ossia.io/score-docs/processes/exprtk.html#array-handling")
18 halp_meta(author, "ossia score, ExprTK (Arash Partow)")
19 halp_meta(description, "Applies a math expression to each member of an input.");
20 halp_meta(uuid, "cf3df02f-a563-4e92-a739-b321d3a84252");
21
22 struct ins
23 {
24 halp::lineedit<"Expression", "i"> expr;
25 halp::spinbox_i32<"Size", halp::irange{0, 1024, 12}> sz;
26 } inputs;
27
28 struct
29 {
30 value_out port{};
31 } outputs;
32
33 struct State
34 {
35 struct Expr
36 {
37 void init(double& cur_time, double& cur_deltatime, double& cur_pos, double& count)
38 {
39 expr.add_variable("i", instance);
40 expr.add_variable("n", count);
41
42 expr.add_variable("po", po);
43
44 expr.add_variable("t", cur_time);
45 expr.add_variable("dt", cur_deltatime);
46 expr.add_variable("pos", cur_pos);
47 expr.add_constants();
48
49 expr.register_symbol_table();
50 }
51 double instance;
52
53 double po;
54
55 ossia::math_expression expr;
56 };
57
58 boost::container::static_vector<Expr, 1024> expressions;
59 double count{};
60 double cur_time{};
61 double cur_deltatime{};
62 double cur_pos{};
63
64 int64_t last_value_time{};
65 std::string last_expression;
66 } state;
67
68 ossia::exec_state_facade ossia_state;
69
70 using tick = halp::tick_flicks;
71 void operator()(const tick& tk)
72 {
73 GenericMathMapping<State>::run_polyphonic(
74 inputs.sz.value, outputs.port.call, inputs.expr.value, tk, state);
75 }
76
77 struct ui
78 {
79 halp_meta(layout, halp::layouts::vbox)
80
81 struct : halp::control<&ins::expr>
82 {
83 halp_flag(dynamic_size);
84 } expr;
85 halp::control<&ins::sz> sz;
86 };
87};
88}
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:33
Definition Arraygen.hpp:23
Definition Arraygen.hpp:78
Definition Arraygen.hpp:12