2#include <State/Domain.hpp>
4#include <Process/Dataflow/Port.hpp>
5#include <Process/Dataflow/WidgetInlets.hpp>
7#include <JS/Qml/QtMetatypes.hpp>
9#if defined(SCORE_HAS_GPU_JS)
10#include <Gfx/TexturePort.hpp>
15#include <score/tools/Debug.hpp>
17#include <ossia/detail/math.hpp>
18#include <ossia/detail/ssize.hpp>
19#include <ossia/network/domain/domain.hpp>
20#include <ossia-qt/js_utilities.hpp>
24#include <QQmlListProperty>
28#include <libremidi/message.hpp>
30#include <score_plugin_js_export.h>
31#include <wobjectimpl.h>
38class SCORE_PLUGIN_JS_EXPORT
Inlet :
public QObject
43 using QObject::QObject;
46 virtual bool isEvent()
const {
return false; }
48 W_INLINE_PROPERTY_CREF(QString, address, {}, address, setAddress, addressChanged)
51class SCORE_PLUGIN_JS_EXPORT
Outlet :
public QObject
56 using QObject::QObject;
60 W_INLINE_PROPERTY_CREF(QString, address, {}, address, setAddress, addressChanged)
70 W_PROPERTY(qreal, timestamp MEMBER timestamp)
71 W_PROPERTY(QVariant, value MEMBER value)
81 W_PROPERTY(qreal, timestamp MEMBER timestamp)
82 W_PROPERTY(QJSValue, value MEMBER value)
90 QVariantList m_values;
93 explicit ValueInlet(QObject* parent =
nullptr);
95 QVariant value()
const;
96 QVariantList values()
const {
return m_values; }
103 int length()
const noexcept;
106 QVariant at(
int index)
const noexcept;
109 void clear() { m_values.clear(); }
110 void setValue(QVariant value);
111 void addValue(QVariant&& val) { m_values.append(std::move(val)); }
112 void valueChanged(QVariant value) W_SIGNAL(valueChanged, value);
114 W_PROPERTY(QVariantList, values READ values)
115 W_PROPERTY(QVariant, value READ value NOTIFY valueChanged)
127 QVariant value()
const noexcept;
134 void clear() { m_value = QVariant{}; }
135 virtual void setValue(QVariant value);
136 void valueChanged(QVariant value) W_SIGNAL(valueChanged, value);
138 W_PROPERTY(QVariant, value READ value NOTIFY valueChanged)
141template <
typename Impl,
typename ValueType>
147 using ControlInlet::ControlInlet;
149 bool isEvent()
const override {
return true; }
152 return new Impl(
id, parent);
155 void clear() { m_value = {}; }
156 ValueType value()
const noexcept {
return m_value; }
157 void setValue(QVariant value)
override
159 auto conv = value.value<ValueType>();
163 m_value = std::move(conv);
164 valueChanged(m_value);
166 void setValue(ValueType value)
172 valueChanged(m_value);
174 void valueChanged(ValueType value) W_SIGNAL(valueChanged, value);
176 W_PROPERTY(ValueType, value READ value NOTIFY valueChanged)
186 using GenericControlInlet::GenericControlInlet;
192 using GenericControlInlet::GenericControlInlet;
198 using GenericControlInlet::GenericControlInlet;
204 using GenericControlInlet::GenericControlInlet;
210 using GenericControlInlet::GenericControlInlet;
216 using GenericControlInlet::GenericControlInlet;
222 using GenericControlInlet::GenericControlInlet;
228 using GenericControlInlet::GenericControlInlet;
234 using GenericControlInlet::GenericControlInlet;
240 using GenericControlInlet::GenericControlInlet;
246 using GenericControlInlet::GenericControlInlet;
252 using GenericControlInlet::GenericControlInlet;
255template <
typename Impl = Process::FloatSl
ider>
263 bool isEvent()
const override {
return true; }
267 return new Impl{(float)m_min, (
float)m_max, (float)m_init,
268 this->objectName(), id, parent};
271 W_INLINE_PROPERTY_VALUE(qreal, init, {0.5}, init, setInit, initChanged)
272 W_INLINE_PROPERTY_VALUE(qreal, min, {0.}, getMin, setMin, minChanged)
273 W_INLINE_PROPERTY_VALUE(qreal, max, {1.}, getMax, setMax, maxChanged)
277template <
typename Impl = Process::IntSl
ider>
285 bool isEvent()
const override {
return true; }
289 return new Impl{m_min, m_max, m_init, this->objectName(), id, parent};
292 W_INLINE_PROPERTY_VALUE(
int, init, {0}, init, setInit, initChanged)
293 W_INLINE_PROPERTY_VALUE(
int, min, {0}, getMin, setMin, minChanged)
294 W_INLINE_PROPERTY_VALUE(
int, max, {127}, getMax, setMax, maxChanged)
303 using ControlInlet::ControlInlet;
304 virtual ~Enum()
override;
305 bool isEvent()
const override {
return true; }
309 return new Process::Enum{m_choices, {}, current(), objectName(), id, parent};
312 auto getValues()
const {
return choices(); }
314 std::string current()
const
316 if(!m_choices.isEmpty() && ossia::valid_index(m_index, m_choices))
318 return m_choices[m_index].toStdString();
323 W_INLINE_PROPERTY_VALUE(
int, index, {}, index, setIndex, indexChanged)
324 W_INLINE_PROPERTY_CREF(QStringList, choices, {}, choices, setChoices, choicesChanged)
332 using ControlInlet::ControlInlet;
334 bool isEvent()
const override {
return true; }
337 return new Process::Toggle{m_checked, objectName(), id, parent};
340 W_INLINE_PROPERTY_VALUE(
bool, checked, {}, checked, setChecked, checkedChanged)
348 using ControlInlet::ControlInlet;
350 bool isEvent()
const override {
return true; }
353 return new Process::Button{objectName(), id, parent};
356 W_INLINE_PROPERTY_VALUE(
bool, checked, {}, checked, setChecked, checkedChanged)
364 using ControlInlet::ControlInlet;
366 bool isEvent()
const override {
return false; }
369 return new Process::ImpulseButton{objectName(), id, parent};
372 void impulse() W_SIGNAL(impulse);
380 using ControlInlet::ControlInlet;
382 bool isEvent()
const override {
return true; }
385 return new Process::LineEdit{m_text, objectName(), id, parent};
388 W_INLINE_PROPERTY_CREF(QString, text, {}, text, setText, textChanged)
398 std::vector<OutValueMessage> values;
402 const QJSValue& value()
const;
405 m_value = QJSValue{};
414 void setValue(
const QJSValue& value);
416 void addValue(qreal timestamp, QJSValue t);
419 W_PROPERTY(QJSValue, value READ value WRITE setValue)
427 explicit AudioInlet(QObject* parent =
nullptr);
429 const QVector<QVector<double>>& audio()
const;
430 void setAudio(
const QVector<QVector<double>>& audio);
432 QVector<double> channel(
int i)
const
434 if(m_audio.size() > i)
438 W_INVOKABLE(channel);
446 QVector<QVector<double>> m_audio;
460 p->setPropagate(
true);
464 const QVector<QVector<double>>& audio()
const;
466 void setChannel(
int i,
const QJSValue& v);
467 W_INVOKABLE(setChannel)
469 QVector<QVector<double>> m_audio;
479 W_PROPERTY(QByteArray, bytes MEMBER bytes)
487 explicit MidiInlet(QObject* parent =
nullptr);
489 template <
typename T>
490 void setMidi(
const T& arr)
493 for(
const libremidi::message& mess : arr)
495 const auto N = mess.size();
499 for(std::size_t i = 0; i < N; i++)
500 m[i] = mess.bytes[i];
502 m_midi.push_back(QVariant::fromValue(m));
506 QVariantList messages()
const {
return m_midi; }
507 W_INVOKABLE(messages);
523 explicit MidiOutlet(QObject* parent =
nullptr);
531 const QVector<QVector<int>>& midi()
const;
533 void setMessages(
const QVariantList m)
538 if(v.canConvert<QVector<int>>())
539 m_midi.push_back(v.value<QVector<int>>());
542 W_INVOKABLE(setMessages);
544 void add(QVector<int> m) { m_midi.push_back(std::move(m)); }
548 QVector<QVector<int>> m_midi;
551#if defined(SCORE_HAS_GPU_JS)
552class TextureOutlet :
public Outlet
554 W_OBJECT(TextureOutlet)
557 explicit TextureOutlet(QObject* parent =
nullptr);
558 virtual ~TextureOutlet()
override;
561 auto p =
new Gfx::TextureOutlet(
id, parent);
565 QQuickItem* item() noexcept {
return m_item; }
566 void setItem(QQuickItem* v) { m_item = v; }
568 W_PROPERTY(QQuickItem*, item READ item WRITE setItem CONSTANT)
570 QQuickItem* m_item{};
577 W_CLASSINFO(
"DefaultProperty",
"data")
579 "qt_QmlJSWrapperFactoryMethod",
"_q_createJSWrapper(QV4::ExecutionEngine*)")
582 QQmlListProperty<QObject> data()
noexcept {
return {
this, &m_data}; }
584 QJSValue& tick()
noexcept {
return m_tick; }
585 void setTick(
const QJSValue& v) { m_tick = v; }
586 QJSValue& start()
noexcept {
return m_start; }
587 void setStart(
const QJSValue& v) { m_start = v; }
588 QJSValue& stop()
noexcept {
return m_stop; }
589 void setStop(
const QJSValue& v) { m_stop = v; }
590 QJSValue& pause()
noexcept {
return m_pause; }
591 void setPause(
const QJSValue& v) { m_pause = v; }
592 QJSValue& resume()
noexcept {
return m_resume; }
593 void setResume(
const QJSValue& v) { m_resume = v; }
594 W_PROPERTY(QJSValue, tick READ tick WRITE setTick CONSTANT)
595 W_PROPERTY(QJSValue, start READ start WRITE setStart CONSTANT)
596 W_PROPERTY(QJSValue, stop READ stop WRITE setStop CONSTANT)
597 W_PROPERTY(QJSValue, pause READ pause WRITE setPause CONSTANT)
598 W_PROPERTY(QJSValue, resume READ resume WRITE setResume CONSTANT)
599 W_PROPERTY(QQmlListProperty<QObject>, data READ data)
602 QList<QObject*> m_data;
611inline QDataStream& operator<<(QDataStream& i,
const JS::MidiMessage& sel)
Definition QmlObjects.hpp:423
Definition QmlObjects.hpp:450
Definition QmlObjects.hpp:119
Definition QmlObjects.hpp:299
Definition QmlObjects.hpp:257
Definition QmlObjects.hpp:143
Definition QmlObjects.hpp:360
Definition QmlObjects.hpp:39
Definition QmlObjects.hpp:279
Definition QmlObjects.hpp:376
Definition QmlObjects.hpp:483
Definition QmlObjects.hpp:473
Definition QmlObjects.hpp:519
Definition QmlObjects.hpp:52
Definition QmlObjects.hpp:575
Definition QmlObjects.hpp:328
Definition QmlObjects.hpp:86
Definition QmlObjects.hpp:392
The id_base_t class.
Definition Identifier.hpp:57
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Definition QmlObjects.hpp:244
Definition QmlObjects.hpp:238
Definition QmlObjects.hpp:184
Definition QmlObjects.hpp:202
Definition QmlObjects.hpp:64
Definition QmlObjects.hpp:190
Definition QmlObjects.hpp:196
Definition QmlObjects.hpp:232
Definition QmlObjects.hpp:75
Definition QmlObjects.hpp:250
Definition QmlObjects.hpp:208
Definition QmlObjects.hpp:220
Definition QmlObjects.hpp:214
Definition QmlObjects.hpp:226