Loading...
Searching...
No Matches
score-plugin-faust/Faust/EffectModel.hpp
1#pragma once
2#include <Process/Execution/ProcessComponent.hpp>
3#include <Process/GenericProcessFactory.hpp>
4#include <Process/Inspector/ProcessInspectorWidgetDelegate.hpp>
5#include <Process/Inspector/ProcessInspectorWidgetDelegateFactory.hpp>
6#include <Process/Process.hpp>
7#include <Process/Script/ScriptEditor.hpp>
8#include <Process/Script/ScriptProcess.hpp>
9
10#include <Control/DefaultEffectItem.hpp>
11#include <Effect/EffectFactory.hpp>
12
13#include <ossia/dataflow/node_process.hpp>
14
15#include <QDialog>
16
17#include <iostream> // needed by poly-llvm-dsp.h...
18#include <verdigris>
19
20#include <faust/dsp/poly-llvm-dsp.h>
21namespace Faust
22{
23class FaustEffectModel;
24}
25
26namespace ossia::nodes
27{
28struct custom_dsp_poly_factory;
29class custom_dsp_poly_effect;
30}
31
32PROCESS_METADATA(
33 , Faust::FaustEffectModel, "5354c61a-1649-4f59-b952-5c2f1b79c1bd", "Faust", "Faust",
34 Process::ProcessCategory::Script, "Plugins",
35 "Faust process. Refer to https://faust.grame.fr", "GRAME and the Faust team",
36 {"Script"}, {}, {}, QUrl("https://ossia.io/score-docs/processes/faust.html"),
38DESCRIPTION_METADATA(, Faust::FaustEffectModel, "Faust")
39namespace Faust
40{
41class FaustEffectModel : public Process::ProcessModel
42{
43 friend class FaustUI;
44 friend class FaustUpdateUI;
45 W_OBJECT(FaustEffectModel)
46 SCORE_SERIALIZE_FRIENDS
47 PROCESS_METADATA_IMPL(FaustEffectModel)
48
49public:
50 // FIXME implement externalUi when there is a layout.dsp?
51 FaustEffectModel(
52 TimeVal t, const QString& faustProgram, const Id<Process::ProcessModel>&,
53 QObject* parent);
54 ~FaustEffectModel();
55
56 template <typename Impl>
57 FaustEffectModel(Impl& vis, QObject* parent)
58 : Process::ProcessModel{vis, parent}
59 {
60 vis.writeTo(*this);
61 init();
62 }
63
64 QString prettyName() const noexcept override;
65
66 bool validate(const QString& txt) const noexcept;
67 const QString& script() const { return m_script; }
68 [[nodiscard]] Process::ScriptChangeResult setScript(const QString& txt);
69
70 Process::Inlets& inlets() noexcept { return m_inlets; }
71 Process::Outlets& outlets() noexcept { return m_outlets; }
72 const Process::Inlets& inlets() const noexcept { return m_inlets; }
73 const Process::Outlets& outlets() const noexcept { return m_outlets; }
74
75 std::shared_ptr<llvm_dsp_factory> faust_factory{};
76 std::shared_ptr<llvm_dsp> faust_object{};
77
78 std::shared_ptr<ossia::nodes::custom_dsp_poly_factory> faust_poly_factory{};
79 std::shared_ptr<ossia::nodes::custom_dsp_poly_effect> faust_poly_object{};
80
81 void scriptChanged(const QString& str) W_SIGNAL(scriptChanged, str);
82 void programChanged() W_SIGNAL(programChanged);
83
84 void errorMessage(int line, const QString& e) W_SIGNAL(errorMessage, line, e);
85
86 PROPERTY(QString, script READ script WRITE setScript NOTIFY scriptChanged)
87private:
88 QString effect() const noexcept override;
89 void loadPreset(const Process::Preset& preset) override;
90 Process::Preset savePreset() const noexcept override;
91
92 void init();
93 [[nodiscard]] Process::ScriptChangeResult reload();
94
95 QString m_script;
96 QString m_path;
97 QString m_declareName;
98};
99}
100
101namespace Process
102{
103template <>
104QString
105EffectProcessFactory_T<Faust::FaustEffectModel>::customConstructionData() const noexcept;
106
107template <>
108Process::Descriptor
109EffectProcessFactory_T<Faust::FaustEffectModel>::descriptor(QString d) const noexcept;
110}
111
112namespace Faust
113{
115{
116 static constexpr const char* language = "Faust";
117};
118
121 FaustEffectModel, Process::ProcessScriptEditDialog<
122 FaustEffectModel, FaustEffectModel::p_script, LanguageSpec>>;
123}
124
125namespace Execution
126{
128 : public Execution::ProcessComponent_T<Faust::FaustEffectModel, ossia::node_process>
129{
130 W_OBJECT(FaustEffectComponent)
131 COMPONENT_METADATA("eb4f83af-5ddc-4f2f-9426-6f8a599a1e96")
132
133public:
134 static constexpr bool is_unique = true;
135
137 Faust::FaustEffectModel& proc, const Execution::Context& ctx, QObject* parent);
138
139private:
140 int generation{};
141 void reload(Execution::Transaction&);
142 void reloadSynth(Execution::Transaction&);
143 void reloadFx(Execution::Transaction&);
144
145 template <typename Node_T>
146 void setupExecutionControls(const Node_T&, int firstControlIndex);
147 template <typename Node_T>
148 void setupExecutionControlOutlets(const Node_T&, int firstControlIndex);
149
150 std::vector<QMetaObject::Connection> m_controlConnections;
151};
154}
Definition score-plugin-faust/Faust/EffectModel.hpp:129
Definition Process/Execution/ProcessComponent.hpp:123
Definition EffectFactory.hpp:86
Definition EffectFactory.hpp:14
The Process class.
Definition score-lib-process/Process/Process.hpp:62
Definition ScriptEditor.hpp:49
The id_base_t class.
Definition Identifier.hpp:59
Components used for the execution of a score.
Definition ProcessComponent.cpp:14
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
@ DynamicPorts
The process has a variable structure, e.g. its ports can change dynamically.
Definition ProcessFlags.hpp:59
@ ScriptEditingSupported
The process is based on user-editable source code (JS, Faust, etc.)
Definition ProcessFlags.hpp:70
Definition ExecutionContext.hpp:196
Definition Process/Execution/ProcessComponent.hpp:93
Definition ExecutionTransaction.hpp:21
Definition score-plugin-faust/Faust/EffectModel.hpp:115
Definition PortForward.hpp:23
Definition PortForward.hpp:27
Definition ScriptProcess.hpp:14
Definition TimeValue.hpp:21