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 <score_plugin_faust_export.h>
19#include <verdigris>
20
21#include <faust/dsp/poly-llvm-dsp.h>
22namespace Faust
23{
24class FaustEffectModel;
25}
26
27namespace ossia::nodes
28{
29struct custom_dsp_poly_factory;
30class custom_dsp_poly_effect;
31}
32
33PROCESS_METADATA(
34 , Faust::FaustEffectModel, "5354c61a-1649-4f59-b952-5c2f1b79c1bd", "Faust", "Faust",
35 Process::ProcessCategory::Script, "Plugins",
36 "Faust process. Refer to https://faust.grame.fr", "GRAME and the Faust team",
37 {"Script"}, {}, {}, QUrl("https://ossia.io/score-docs/processes/faust.html"),
39DESCRIPTION_METADATA(, Faust::FaustEffectModel, "Faust")
40namespace Faust
41{
42class SCORE_PLUGIN_FAUST_EXPORT FaustEffectModel : public Process::ProcessModel
43{
44 friend class FaustUI;
45 friend class FaustUpdateUI;
46 W_OBJECT(FaustEffectModel)
47 SCORE_SERIALIZE_FRIENDS
48 PROCESS_METADATA_IMPL(FaustEffectModel)
49
50public:
51 // FIXME implement externalUi when there is a layout.dsp?
52 FaustEffectModel(
53 TimeVal t, const QString& faustProgram, const Id<Process::ProcessModel>&,
54 QObject* parent);
55 ~FaustEffectModel();
56
57 template <typename Impl>
58 FaustEffectModel(Impl& vis, QObject* parent)
59 : Process::ProcessModel{vis, parent}
60 {
61 vis.writeTo(*this);
62 init();
63 }
64
65 QString prettyName() const noexcept override;
66
67 void mapExternalFiles(Process::ExternalFileMap& map) override;
68
69 bool validate(const QString& txt) const noexcept;
70 const QString& script() const { return m_script; }
71 [[nodiscard]] Process::ScriptChangeResult setScript(const QString& txt);
72
73 Process::Inlets& inlets() noexcept { return m_inlets; }
74 Process::Outlets& outlets() noexcept { return m_outlets; }
75 const Process::Inlets& inlets() const noexcept { return m_inlets; }
76 const Process::Outlets& outlets() const noexcept { return m_outlets; }
77
78 std::shared_ptr<llvm_dsp_factory> faust_factory{};
79 std::shared_ptr<llvm_dsp> faust_object{};
80
81 std::shared_ptr<ossia::nodes::custom_dsp_poly_factory> faust_poly_factory{};
82 std::shared_ptr<ossia::nodes::custom_dsp_poly_effect> faust_poly_object{};
83
84 void scriptChanged(const QString& str) W_SIGNAL(scriptChanged, str);
85 void programChanged() W_SIGNAL(programChanged);
86
87 void errorMessage(int line, const QString& e) W_SIGNAL(errorMessage, line, e);
88
89 PROPERTY(QString, script READ script WRITE setScript NOTIFY scriptChanged)
90private:
91 QString effect() const noexcept override;
92 void loadPreset(const Process::Preset& preset) override;
93 Process::Preset savePreset() const noexcept override;
94 bool presetChangesPorts(const Process::Preset& p) const noexcept override
95 {
97 }
98
99 void init();
100 [[nodiscard]] Process::ScriptChangeResult reload();
101
102 QString m_script;
103 QString m_path;
104 QString m_declareName;
105};
106}
107
108namespace Process
109{
110template <>
111QString
112EffectProcessFactory_T<Faust::FaustEffectModel>::customConstructionData() const noexcept;
113
114template <>
115Process::Descriptor
116EffectProcessFactory_T<Faust::FaustEffectModel>::descriptor(QString d) const noexcept;
117}
118
119namespace Faust
120{
122{
123 static constexpr const char* language = "Faust";
124};
125
128 FaustEffectModel, Process::ProcessScriptEditDialog<
129 FaustEffectModel, FaustEffectModel::p_script, LanguageSpec>>;
130}
131
132namespace Execution
133{
135 : public Execution::ProcessComponent_T<Faust::FaustEffectModel, ossia::node_process>
136{
137 W_OBJECT(FaustEffectComponent)
138 COMPONENT_METADATA("eb4f83af-5ddc-4f2f-9426-6f8a599a1e96")
139
140public:
141 static constexpr bool is_unique = true;
142
144 Faust::FaustEffectModel& proc, const Execution::Context& ctx, QObject* parent);
145
146private:
147 int generation{};
148 void reload(Execution::Transaction&);
149 void reloadSynth(Execution::Transaction&);
150 void reloadFx(Execution::Transaction&);
151
152 template <typename Node_T>
153 void setupExecutionControls(const Node_T&, int firstControlIndex);
154 template <typename Node_T>
155 void setupExecutionControlOutlets(const Node_T&, int firstControlIndex);
156
157 std::vector<QMetaObject::Connection> m_controlConnections;
158};
161}
Definition score-plugin-faust/Faust/EffectModel.hpp:136
Definition Process/Execution/ProcessComponent.hpp:131
Definition EffectFactory.hpp:86
Definition EffectFactory.hpp:14
The Process class.
Definition score-lib-process/Process/Process.hpp:82
bool scriptPresetChangesPorts(const Preset &preset) const noexcept
Definition score-lib-process/Process/Process.cpp:271
Definition ScriptEditor.hpp:54
The id_base_t class.
Definition Identifier.hpp:59
Components used for the execution of a score.
Definition PortTap.cpp:24
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:208
Definition Process/Execution/ProcessComponent.hpp:101
Definition ExecutionTransaction.hpp:21
Definition score-plugin-faust/Faust/EffectModel.hpp:122
Definition PortForward.hpp:23
Definition PortForward.hpp:27
Definition ScriptProcess.hpp:14
Definition TimeValue.hpp:21