31class js_node final :
public ossia::graph_node
34 explicit js_node(ossia::execution_state& st);
37 [[nodiscard]] std::string label()
const noexcept override {
return "javascript"; }
39 void run(
const ossia::token_request& t, ossia::exec_state_facade)
noexcept override;
40 void setupComponent();
41 void setScript(
const QString& val);
43 ossia::execution_state& m_st;
45 QQmlEngine* m_engine{};
46 std::vector<Inlet*> m_jsInlets;
47 std::vector<std::pair<ControlInlet*, ossia::inlet_ptr>> m_ctrlInlets;
48 std::vector<std::pair<Impulse*, ossia::inlet_ptr>> m_impulseInlets;
49 std::vector<std::pair<ValueInlet*, ossia::inlet_ptr>> m_valInlets;
50 std::vector<std::pair<ValueOutlet*, ossia::outlet_ptr>> m_valOutlets;
51 std::vector<std::pair<AudioInlet*, ossia::inlet_ptr>> m_audInlets;
52 std::vector<std::pair<AudioOutlet*, ossia::outlet_ptr>> m_audOutlets;
53 std::vector<std::pair<MidiInlet*, ossia::inlet_ptr>> m_midInlets;
54 std::vector<std::pair<MidiOutlet*, ossia::outlet_ptr>> m_midOutlets;
56 ossia::qt::qml_engine_functions* m_execFuncs{};
57 QJSValueList m_tickCall;
58 std::size_t m_gcIndex{};
65 void setControl(std::size_t index,
const QVariant& val)
67 if(index > m_jsInlets.size())
69 if(
auto v = qobject_cast<ValueInlet*>(m_jsInlets[index]))
71 else if(
auto v = qobject_cast<ControlInlet*>(m_jsInlets[index]))
74 void impulse(std::size_t index)
76 if(index > m_jsInlets.size())
78 if(
auto v = qobject_cast<Impulse*>(m_jsInlets[index]))
85 using node_process::node_process;
87 void start()
override { js().triggerStart =
true; }
88 void stop()
override { js().triggerStop =
true; }
89 void pause()
override { js().triggerPause =
true; }
90 void resume()
override { js().triggerResume =
true; }
91 void transport_impl(ossia::time_value date)
override
93 QMetaObject::invokeMethod(
94 js().m_object,
"transport", Qt::DirectConnection,
95 Q_ARG(QVariant,
double(date.impl)));
97 void offset_impl(ossia::time_value date)
override
99 QMetaObject::invokeMethod(
100 js().m_object,
"offset", Qt::DirectConnection,
101 Q_ARG(QVariant,
double(date.impl)));