Smooth.hpp
1 #pragma once
2 #include <Fx/NoiseFilter.hpp>
3 #include <Fx/Types.hpp>
4 
5 #include <ossia/dataflow/value_port.hpp>
6 #include <ossia/detail/logger.hpp>
7 
8 #include <halp/controls.hpp>
9 #include <halp/meta.hpp>
10 
11 namespace Nodes::Smooth
12 {
13 using namespace dno;
14 
15 namespace v1
16 {
17 struct Node : NoiseState
18 {
19  halp_meta(name, "Smooth (old)")
20  halp_meta(c_name, "ValueFilter")
21  halp_meta(category, "Control/Mappings")
22  halp_meta(author, "ossia score")
23  halp_meta(manual_url, "https://ossia.io/score-docs/processes/smooth.html#smooth")
24  halp_meta(description, "Filter noisy value stream")
25  halp_meta(uuid, "809c014d-7d02-45dc-8849-de7a7db5fe67")
26  halp_flag(deprecated);
27 
28  struct
29  {
30  // FIXME all incorrect when token_request smaller than tick
31  struct : halp::val_port<"in", ossia::value>
32  {
33  // Messages to this port trigger a new computation cycle with updated timestamps
34  halp_flag(active_port);
35  } port;
36  halp::enum_t<dno::type, "Type"> type;
37  halp::knob_f32<"Amount", halp::range{0., 1., 0.1}> amount;
38  halp::log_hslider_f32<"Freq (1e/LP)", halp::range{0.001, 300., 120.}> freq;
39  halp::log_hslider_f32<"Cutoff (1e/LP)", halp::range{0.001, 10., 1.}> cutoff;
40  halp::hslider_f32<"Beta (1e only)", halp::range{0.001, 10., 1.}> beta;
41  } inputs;
42  struct
43  {
44  value_out port{};
45  } outputs;
46 
47  void operator()()
48  {
49  auto& v = this->inputs.port.value;
50 
51  auto filtered = this->filter(
52  v, inputs.type, inputs.amount, inputs.freq, inputs.cutoff, inputs.beta);
53  outputs.port(std::move(filtered)); // TODO fix accuracy of timestamp
54 
55  this->last = v;
56  }
57 };
58 }
59 }
Definition: NoiseFilter.hpp:128
Definition: Smooth.hpp:18