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 void mapExternalFiles(Process::ExternalFileMap& map) override;
67
68 bool validate(const QString& txt) const noexcept;
69 const QString& script() const { return m_script; }
70 [[nodiscard]] Process::ScriptChangeResult setScript(const QString& txt);
71
72 Process::Inlets& inlets() noexcept { return m_inlets; }
73 Process::Outlets& outlets() noexcept { return m_outlets; }
74 const Process::Inlets& inlets() const noexcept { return m_inlets; }
75 const Process::Outlets& outlets() const noexcept { return m_outlets; }
76
77 std::shared_ptr<llvm_dsp_factory> faust_factory{};
78 std::shared_ptr<llvm_dsp> faust_object{};
79
80 std::shared_ptr<ossia::nodes::custom_dsp_poly_factory> faust_poly_factory{};
81 std::shared_ptr<ossia::nodes::custom_dsp_poly_effect> faust_poly_object{};
82
83 void scriptChanged(const QString& str) W_SIGNAL(scriptChanged, str);
84 void programChanged() W_SIGNAL(programChanged);
85
86 void errorMessage(int line, const QString& e) W_SIGNAL(errorMessage, line, e);
87
88 PROPERTY(QString, script READ script WRITE setScript NOTIFY scriptChanged)
89private:
90 QString effect() const noexcept override;
91 void loadPreset(const Process::Preset& preset) override;
92 Process::Preset savePreset() const noexcept override;
93
94 void init();
95 [[nodiscard]] Process::ScriptChangeResult reload();
96
97 QString m_script;
98 QString m_path;
99 QString m_declareName;
100};
101}
102
103namespace Process
104{
105template <>
106QString
107EffectProcessFactory_T<Faust::FaustEffectModel>::customConstructionData() const noexcept;
108
109template <>
110Process::Descriptor
111EffectProcessFactory_T<Faust::FaustEffectModel>::descriptor(QString d) const noexcept;
112}
113
114namespace Faust
115{
117{
118 static constexpr const char* language = "Faust";
119};
120
123 FaustEffectModel, Process::ProcessScriptEditDialog<
124 FaustEffectModel, FaustEffectModel::p_script, LanguageSpec>>;
125}
126
127namespace Execution
128{
130 : public Execution::ProcessComponent_T<Faust::FaustEffectModel, ossia::node_process>
131{
132 W_OBJECT(FaustEffectComponent)
133 COMPONENT_METADATA("eb4f83af-5ddc-4f2f-9426-6f8a599a1e96")
134
135public:
136 static constexpr bool is_unique = true;
137
139 Faust::FaustEffectModel& proc, const Execution::Context& ctx, QObject* parent);
140
141private:
142 int generation{};
143 void reload(Execution::Transaction&);
144 void reloadSynth(Execution::Transaction&);
145 void reloadFx(Execution::Transaction&);
146
147 template <typename Node_T>
148 void setupExecutionControls(const Node_T&, int firstControlIndex);
149 template <typename Node_T>
150 void setupExecutionControlOutlets(const Node_T&, int firstControlIndex);
151
152 std::vector<QMetaObject::Connection> m_controlConnections;
153};
156}
Definition score-plugin-faust/Faust/EffectModel.hpp:131
Definition Process/Execution/ProcessComponent.hpp:123
Definition EffectFactory.hpp:86
Definition EffectFactory.hpp:14
The Process class.
Definition score-lib-process/Process/Process.hpp:75
Definition ScriptEditor.hpp:51
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:117
Definition PortForward.hpp:23
Definition PortForward.hpp:27
Definition ScriptProcess.hpp:14
Definition TimeValue.hpp:21