2#include <ossia/dataflow/graph_node.hpp>
3#include <ossia/dataflow/nodes/faust/faust_utils.hpp>
8 = ossia::small_vector<std::pair<ossia::value_port*, FAUSTFLOAT*>, 8>;
9class faust_mono_fx final :
public ossia::graph_node
12 std::shared_ptr<dsp> m_dsp{};
13 faust_port_array controls;
14 faust_port_array displays;
18 explicit clone(dsp* f,
const clone& orig)
21 controls = orig.controls;
22 displays = orig.displays;
24 fx->init(orig.fx->getSampleRate());
26 faust_exec_ui_clone<clone> ex{*
this};
27 fx->buildUserInterface(&ex);
30 clone(dsp* f,
const faust_port_array& controls,
const faust_port_array& disps)
38 faust_port_array controls;
39 faust_port_array displays;
42 void set_control(
int i,
int v)
noexcept
43 { set_control(i, (
float) v); }
44 void set_control(
int i,
bool v)
noexcept
45 { set_control(i, v ? 1.f : 0.f); }
46 void set_control(
int i,
const std::string& v)
noexcept
48 void set_control(
int i, ossia::impulse v)
noexcept
50 template<std::
size_t N>
51 void set_control(
int i,
const std::array<float, N>& v)
noexcept
53 *controls[i].second = v[0];
54 for(std::size_t c = 0, n = std::min(clones.size(), N); c < n; c++)
56 *clones[c].controls[i].second = v[c];
59 void set_control(
int i,
const std::vector<ossia::value>& v)
noexcept
62 *controls[i].second = ossia::convert<float>(v[0]);
63 for(std::size_t c = 0, n = std::min(clones.size(), v.size()); c < n; c++)
65 *clones[c].controls[i].second = ossia::convert<float>(v[c]);
68 void set_control(
int i,
const ossia::value_map_type& v)
noexcept
73 void set_control(
int i,
float v)
noexcept
75 *controls[i].second = v;
76 for(std::size_t c = 1; c < clones.size(); c++)
78 *clones[c].controls[i].second = v;
82 std::vector<clone> clones;
83 faust_mono_fx(std::shared_ptr<dsp> dsp)
84 : m_dsp{std::move(dsp)}
86 m_inlets.push_back(
new ossia::audio_inlet);
87 m_outlets.push_back(
new ossia::audio_outlet);
90 faust_exec_ui<faust_mono_fx, false> ex{*
this};
91 m_dsp->buildUserInterface(&ex);
94 clones.emplace_back(m_dsp.get(), controls, displays);
95 clones.emplace_back(m_dsp->clone(), clones[0]);
98 void run(
const ossia::token_request& tk, ossia::exec_state_facade e)
noexcept override
100 faust_node_utils{}.exec_mono_fx(*
this, *m_dsp, tk, e);
103 [[nodiscard]] std::string label() const noexcept
override {
return "Faust"; }
105 void all_notes_off() noexcept
override { }
110 for(std::size_t i = 1; i < clones.size(); i++)
115class faust_fx final :
public ossia::graph_node
117 std::shared_ptr<dsp> m_dsp{};
120 faust_port_array controls;
121 faust_port_array displays;
122 faust_fx(std::shared_ptr<dsp> dsp)
123 : m_dsp{std::move(dsp)}
125 m_inlets.push_back(
new ossia::audio_inlet);
126 m_outlets.push_back(
new ossia::audio_outlet);
127 faust_exec_ui<faust_fx, false> ex{*
this};
128 m_dsp->buildUserInterface(&ex);
131 void set_control(
int i,
float v)
noexcept { *controls[i].second = v; }
132 void run(
const ossia::token_request& tk, ossia::exec_state_facade e)
noexcept override
134 faust_node_utils{}.exec(*
this, *m_dsp, tk, e);
137 [[nodiscard]] std::string label() const noexcept
override {
return "Faust"; }
139 void all_notes_off() noexcept
override { }
142class faust_synth final :
public ossia::graph_node
144 std::shared_ptr<ossia::nodes::custom_dsp_poly_effect> m_dsp{};
147 faust_port_array controls;
148 faust_port_array displays;
150 void set_control(
int i,
float v)
noexcept { *controls[i].second = v; }
151 std::array<int8_t, 128> in_flight{};
152 faust_synth(std::shared_ptr<ossia::nodes::custom_dsp_poly_effect> dsp)
153 : m_dsp{std::move(dsp)}
155 m_inlets.push_back(
new ossia::audio_inlet);
156 m_inlets.push_back(
new ossia::midi_inlet);
157 m_outlets.push_back(
new ossia::audio_outlet);
158 faust_exec_ui<faust_synth, true> ex{*
this};
159 m_dsp->buildUserInterface(&ex);
162 void run(
const ossia::token_request& tk, ossia::exec_state_facade e)
noexcept override
164 faust_node_utils{}.exec_synth(*
this, *m_dsp, tk, e);
167 [[nodiscard]] std::string label() const noexcept
override {
return "Faust Synth"; }
169 void all_notes_off() noexcept
override
171 faust_node_utils{}.all_notes_off(*
this, *m_dsp);