Loading...
Searching...
No Matches
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
11namespace Nodes::Smooth
12{
13using namespace dno;
14
15namespace v1
16{
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 void update(Node& self) { self.trigger = true; }
36 } port;
37 halp::enum_t<dno::type, "Type"> type;
38 halp::knob_f32<"Amount", halp::range{0., 1., 0.1}> amount;
39 halp::log_hslider_f32<"Freq (1e/LP)", halp::range{0.001, 300., 120.}> freq;
40 halp::log_hslider_f32<"Cutoff (1e/LP)", halp::range{0.001, 10., 1.}> cutoff;
41 halp::hslider_f32<"Beta (1e only)", halp::range{0.001, 10., 1.}> beta;
42 } inputs;
43 struct
44 {
45 value_out port{};
46 } outputs;
47 bool trigger{false};
48
49 void operator()()
50 {
51 if(!std::exchange(trigger, false))
52 return;
53 auto& v = this->inputs.port.value;
54
55 auto filtered = this->filter(
56 v, inputs.type, inputs.amount, inputs.freq, inputs.cutoff, inputs.beta);
57 outputs.port(std::move(filtered)); // TODO fix accuracy of timestamp
58
59 this->last = v;
60 }
61};
62}
63}
Definition NoiseFilter.hpp:128
Definition Smooth.hpp:18