27#ifndef FAUST_OSSIAUI_H
28#define FAUST_OSSIAUI_H
31#define FAUSTFLOAT float
34#include "faust/gui/PathBuilder.h"
35#include "faust/gui/UI.h"
37#include <ossia/network/domain/domain.hpp>
38#include <ossia/network/generic/generic_device.hpp>
39#include <ossia/network/generic/generic_node.hpp>
40#include <ossia/network/generic/generic_parameter.hpp>
41#include <ossia/network/oscquery/oscquery_server.hpp>
43class OssiaUI final :
public PathBuilder,
public UI
45 ossia::net::generic_device m_dev;
48 std::vector<std::pair<ossia::net::parameter_base*, FAUSTFLOAT*>> m_values;
49 std::atomic_bool m_running;
52 OssiaUI(uint16_t osc_port, uint16_t ws_port)
53 : m_dev{std::make_unique<
ossia::oscquery::oscquery_server_protocol>(osc_port, ws_port),
"Faust"}
54 , m_curNode{&m_dev.get_root_node()}
66 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
67 for(
auto p : m_values)
73 void openTabBox(
const char* label)
override
75 m_curNode = m_curNode->create_child(label);
77 void openHorizontalBox(
const char* label)
override
79 m_curNode = m_curNode->create_child(label);
81 void openVerticalBox(
const char* label)
override
83 m_curNode = m_curNode->create_child(label);
85 void closeBox()
override
87 m_curNode = m_curNode->get_parent();
91 void addButton(
const char* label, FAUSTFLOAT* zone)
override
93 auto n = m_curNode->create_child(label);
96 [zone](
const ossia::value& val) { *zone = val.get<
bool>() ? 1.0 : 0.0; });
99 void addCheckButton(
const char* label, FAUSTFLOAT* zone)
override
101 addButton(label, zone);
104 void addVerticalSlider(
105 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
106 FAUSTFLOAT max, FAUSTFLOAT step)
override
108 auto n = m_curNode->create_child(label);
109 auto a = n->create_parameter(ossia::val_type::FLOAT);
110 ossia::net::set_default_value(*n, init);
111 ossia::net::set_domain(*n, ossia::make_domain(min, max));
112 ossia::net::set_value_step_size(*n, step);
113 a->add_callback([zone](
const ossia::value& val) { *zone = val.get<
float>(); });
116 void addHorizontalSlider(
117 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
118 FAUSTFLOAT max, FAUSTFLOAT step)
override
120 addVerticalSlider(label, zone, init, min, max, step);
124 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min,
125 FAUSTFLOAT max, FAUSTFLOAT step)
override
127 addVerticalSlider(label, zone, init, min, max, step);
131 void addHorizontalBargraph(
132 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
override
134 auto n = m_curNode->create_child(label);
135 auto a = n->create_parameter(ossia::val_type::FLOAT);
136 ossia::net::set_domain(*n, ossia::make_domain(min, max));
139 m_values.push_back({a, zone});
141 void addVerticalBargraph(
142 const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
override
144 addHorizontalBargraph(label, zone, min, max);
148 void declare(FAUSTFLOAT* zone,
const char* key,
const char* val)
override
150 std::cout <<
"declare key : " << key <<
" val : " << val << std::endl;
The node_base class.
Definition node.hpp:48
The value class.
Definition value.hpp:173
@ GET
The value can be retrieved and changed.
OSSIA_EXPORT void push_value(const ossia::destination &addr, const ossia::value_with_unit &)
Send a value to a given destination.
Definition ossia/network/base/parameter.cpp:151