2 #include <Process/Dataflow/Port.hpp>
3 #include <Process/Dataflow/WidgetInlets.hpp>
5 #include <ossia/dataflow/graph_node.hpp>
6 #include <ossia/dataflow/nodes/faust/faust_utils.hpp>
7 #include <ossia/dataflow/port.hpp>
8 #include <ossia/network/domain/domain.hpp>
12 #include <faust/gui/MetaDataUI.h>
14 #include <string_view>
19 template <
typename Proc,
bool Synth>
31 void openTabBox(
const char* label)
override { }
32 void openHorizontalBox(
const char* label)
override { }
33 void openVerticalBox(
const char* label)
override { }
34 void closeBox()
override { }
35 void declare(FAUSTFLOAT* zone,
const char* key,
const char* val)
override
37 MetaDataUI::declare(zone, key, val);
40 addSoundfile(
const char* label,
const char* filename, Soundfile** sf_zone)
override
44 void addButton(
const char* label, FAUSTFLOAT* zone)
override
48 using namespace std::literals;
49 if(label ==
"Panic"sv || label ==
"gate"sv)
53 auto inl =
new Process::Button{label, getStrongId(fx.inlets()), &fx};
54 fx.inlets().push_back(inl);
57 void addCheckButton(
const char* label, FAUSTFLOAT* zone)
override
59 auto inl =
new Process::Toggle{bool(*zone), label, getStrongId(fx.inlets()), &fx};
60 fx.inlets().push_back(inl);
63 void addVerticalSlider(
64 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
65 FAUSTFLOAT max, FAUSTFLOAT step)
override
67 using namespace std::literals;
70 if(label ==
"gain"sv || label ==
"freq"sv || label ==
"sustain"sv)
79 auto inl =
new Process::FloatKnob{
80 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
81 fx.inlets().push_back(inl);
85 auto inl =
new Process::FloatSlider{
86 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
87 fx.inlets().push_back(inl);
91 void addHorizontalSlider(
92 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
93 FAUSTFLOAT max, FAUSTFLOAT step)
override
95 addVerticalSlider(label, zone, init, min, max, step);
99 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
100 FAUSTFLOAT max, FAUSTFLOAT step)
override
103 addVerticalSlider(label, zone, init, min, max, step);
106 void addHorizontalBargraph(
107 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
override
109 auto inl =
new Process::Bargraph{
110 (float)min, (
float)max, (float)min, label, getStrongId(fx.outlets()), &fx};
111 fx.outlets().push_back(inl);
114 void addVerticalBargraph(
115 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
override
117 addHorizontalBargraph(label, zone, min, max);
121 template <
typename Proc,
bool SetInit>
135 , toRemoveO{toRemoveO}
139 void openTabBox(
const char* label)
override { }
140 void openHorizontalBox(
const char* label)
override { }
141 void openVerticalBox(
const char* label)
override { }
142 void closeBox()
override { }
143 void declare(FAUSTFLOAT* zone,
const char* key,
const char* val)
override
145 MetaDataUI::declare(zone, key, val);
148 addSoundfile(
const char* label,
const char* filename, Soundfile** sf_zone)
override
154 toRemove.push_back(oldinl);
160 toRemoveO.push_back(oldoutl);
164 void addButton(
const char* label, FAUSTFLOAT* zone)
override
166 if(i < fx.inlets().size())
168 if(
auto inlet =
dynamic_cast<Process::Button*
>(fx.inlets()[i]))
170 inlet->setName(label);
174 auto id = fx.inlets()[i]->id();
175 replace(fx.inlets()[i],
new Process::Button{label, id, &fx});
180 auto inl =
new Process::Button{label, getStrongId(fx.inlets()), &fx};
181 fx.inlets().push_back(inl);
182 fx.controlAdded(inl->id());
187 void addCheckButton(
const char* label, FAUSTFLOAT* zone)
override
189 if(i < fx.inlets().size())
191 if(
auto inlet =
dynamic_cast<Process::Toggle*
>(fx.inlets()[i]))
193 inlet->setName(label);
194 if constexpr(SetInit)
195 inlet->setValue(
bool(*zone));
199 auto id = fx.inlets()[i]->id();
200 replace(fx.inlets()[i],
new Process::Toggle{bool(*zone), label, id, &fx});
205 auto inl =
new Process::Toggle{bool(*zone), label, getStrongId(fx.inlets()), &fx};
206 fx.inlets().push_back(inl);
207 fx.controlAdded(inl->id());
212 void addVerticalSlider(
213 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
214 FAUSTFLOAT max, FAUSTFLOAT step)
override
216 if(i < fx.inlets().size())
218 if(Process::FloatSlider
219 * slider{
dynamic_cast<Process::FloatSlider*
>(fx.inlets()[i])})
223 auto id = fx.inlets()[i]->id();
224 auto inl =
new Process::FloatKnob{
225 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
226 replace(fx.inlets()[i], inl);
230 slider->setName(label);
231 slider->setDomain(ossia::make_domain(min, max));
232 if constexpr(SetInit)
233 slider->setValue(init);
237 Process::FloatKnob * knob{
dynamic_cast<Process::FloatKnob*
>(fx.inlets()[i])})
241 knob->setName(label);
242 knob->setDomain(ossia::make_domain(min, max));
243 if constexpr(SetInit)
244 knob->setValue(init);
248 auto id = fx.inlets()[i]->id();
249 auto inl =
new Process::FloatSlider{
250 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
251 replace(fx.inlets()[i], inl);
256 auto id = fx.inlets()[i]->id();
259 auto inl =
new Process::FloatKnob{
260 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
261 replace(fx.inlets()[i], inl);
265 auto inl =
new Process::FloatSlider{
266 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
267 replace(fx.inlets()[i], inl);
275 auto inl =
new Process::FloatKnob{
276 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
277 fx.inlets().push_back(inl);
278 fx.controlAdded(inl->id());
282 auto inl =
new Process::FloatSlider{
283 (float)min, (
float)max, (float)init, label, getStrongId(fx.inlets()), &fx};
284 fx.inlets().push_back(inl);
285 fx.controlAdded(inl->id());
292 void addHorizontalSlider(
293 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
294 FAUSTFLOAT max, FAUSTFLOAT step)
override
296 addVerticalSlider(label, zone, init, min, max, step);
300 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
301 FAUSTFLOAT max, FAUSTFLOAT step)
override
303 addVerticalSlider(label, zone, init, min, max, step);
306 void addHorizontalBargraph(
307 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
override
309 if(o < fx.outlets().size())
311 if(
auto outlet =
dynamic_cast<Process::Bargraph*
>(fx.outlets()[o]))
313 outlet->setName(label);
314 outlet->setDomain(ossia::make_domain(min, max));
318 auto id = fx.outlets()[o]->id();
320 =
new Process::Bargraph{(float)min, (
float)max, (float)min, label,
id, &fx};
321 replace(fx.outlets()[o], inl);
326 auto inl =
new Process::Bargraph{
327 (float)min, (
float)max, (float)min, label, getStrongId(fx.outlets()), &fx};
328 fx.outlets().push_back(inl);
329 fx.controlAdded(inl->id());
334 void addVerticalBargraph(
335 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
override
337 addHorizontalBargraph(label, zone, min, max);
Definition: score-plugin-faust/Faust/Utils.hpp:23
Definition: score-plugin-faust/Faust/Utils.hpp:125
Definition: PortForward.hpp:23
Definition: PortForward.hpp:27