2 #include <Fx/MathHelpers.hpp>
3 #include <Fx/MathMapping_generic.hpp>
4 #include <Fx/Types.hpp>
6 #include <ossia/dataflow/value_port.hpp>
8 #include <halp/layout.hpp>
12 namespace MathGenerator
16 halp_meta(name,
"Expression Value Generator")
17 halp_meta(c_name,
"MathGenerator")
18 halp_meta(category,
"Control/Generators")
19 halp_meta(manual_url,
"https://ossia.io/score-docs/processes/exprtk.html#exprtk-support")
20 halp_meta(author,
"ossia score, ExprTK (Arash Partow)")
21 static const constexpr
auto description
22 =
"Generate a signal from a math expression.\n"
23 "Available variables: a,b,c, t (samples), dt (delta), pos (position "
25 "See the documentation at http://www.partow.net/programming/exprtk";
26 halp_meta(uuid,
"d757bd0d-c0a1-4aec-bf72-945b722ab85b")
30 halp::lineedit<
"Expression (ExprTK)",
"cos(t) + log(pos * (1+abs(x)) / dt)"> expr;
31 halp::hslider_f32<
"Param (a)", halp::range{0., 1., 0.5}> a;
32 halp::hslider_f32<
"Param (b)", halp::range{0., 1., 0.5}> b;
33 halp::hslider_f32<
"Param (c)", halp::range{0., 1., 0.5}> c;
45 expr.add_vector(
"pov", pov);
46 expr.add_variable(
"po", po);
48 expr.add_variable(
"t", cur_time);
49 expr.add_variable(
"dt", cur_deltatime);
50 expr.add_variable(
"pos", cur_pos);
52 expr.add_variable(
"a", a);
53 expr.add_variable(
"b", b);
54 expr.add_variable(
"c", c);
55 expr.add_variable(
"pa", pa);
56 expr.add_variable(
"pb", pb);
57 expr.add_variable(
"pc", pc);
59 expr.add_variable(
"m1", m1);
60 expr.add_variable(
"m2", m2);
61 expr.add_variable(
"m3", m3);
63 expr.register_symbol_table();
65 std::vector<double> pov;
69 double cur_deltatime{};
73 double pa{}, pb{}, pc{};
75 double m1{}, m2{}, m3{};
76 ossia::math_expression expr;
80 using tick = halp::tick_flicks;
82 void operator()(
const tick& tk)
84 auto&
self = this->state;
85 if(!
self.expr.set_expression(this->inputs.expr))
88 setMathExpressionTiming(
self, tk);
89 self.a = this->inputs.a;
90 self.b = this->inputs.b;
91 self.c = this->inputs.c;
93 auto res =
self.expr.result();
105 halp_meta(layout, halp::layouts::vbox)
108 halp_meta(layout, halp::layouts::hbox)
109 halp::control<&ins::a> a;
110 halp::control<&ins::b> b;
111 halp::control<&ins::c> c;
114 struct : halp::control<&ins::expr>
116 halp_flag(dynamic_size);
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33
Definition: MathMapping_generic.hpp:12
Definition: MathGenerator.hpp:104
Definition: MathGenerator.hpp:15