Loading...
Searching...
No Matches
Bytebeat.hpp
1#pragma once
2#include <Process/Execution/ProcessComponent.hpp>
3#include <Process/GenericProcessFactory.hpp>
4#include <Process/Process.hpp>
5#include <Process/ProcessMetadata.hpp>
6#include <Process/Script/ScriptEditor.hpp>
7
8#include <Scenario/Commands/ScriptEditCommand.hpp>
9
10#include <Control/DefaultEffectItem.hpp>
11#include <Effect/EffectFactory.hpp>
12#include <JitCpp/EditScript.hpp>
13
14#include <ossia/dataflow/execution_state.hpp>
15#include <ossia/dataflow/graph_node.hpp>
16#include <ossia/dataflow/node_process.hpp>
17
18#include <verdigris>
19
20namespace Jit
21{
22class BytebeatModel;
23}
24PROCESS_METADATA(
25 , Jit::BytebeatModel, "608beeb7-e5c2-40a5-bd1a-aa7aec80f864", "Jit", "Bytebeat",
26 Process::ProcessCategory::Script, "Audio/Generators", "Run bytebeat code",
27 "ossia score", QStringList{}, {}, {}, QUrl("https://ossia.io/score-docs/processes/bytebeat.html#what-is-bytebeat"), Process::ProcessFlags::SupportsAll)
28namespace Jit
29{
30struct Driver;
31using BytebeatFunction = void(double* input, int size, int time);
32using BytebeatCompiler = Driver;
33using BytebeatFactory = std::function<BytebeatFunction>;
34class BytebeatModel : public Process::ProcessModel
35{
36 friend class JitUI;
37 friend class JitUpdateUI;
38 SCORE_SERIALIZE_FRIENDS
39 PROCESS_METADATA_IMPL(BytebeatModel)
40
41 W_OBJECT(BytebeatModel)
42public:
43 BytebeatModel(
44 TimeVal t, const QString& jitProgram, const Id<Process::ProcessModel>&,
45 QObject* parent);
46 ~BytebeatModel() override;
47
48 BytebeatModel(DataStream::Deserializer& vis, QObject* parent);
49 BytebeatModel(JSONObject::Deserializer& vis, QObject* parent);
50 BytebeatModel(DataStream::Deserializer&& vis, QObject* parent);
51 BytebeatModel(JSONObject::Deserializer&& vis, QObject* parent);
52
53 const QString& script() const noexcept { return m_text; }
54 [[nodiscard]] Process::ScriptChangeResult setScript(const QString& txt);
55 void scriptChanged(const QString& txt) W_SIGNAL(scriptChanged, txt);
56
57 static constexpr bool hasExternalUI() noexcept { return true; }
58
59 bool validate(const QString& txt) const noexcept;
60
61 QString prettyName() const noexcept override;
62 void programChanged() W_SIGNAL(programChanged);
63
64 BytebeatFactory factory;
65
66 void errorMessage(int line, const QString& e) W_SIGNAL(errorMessage, line, e);
67
68 PROPERTY(QString, script READ script WRITE setScript NOTIFY scriptChanged)
69private:
70 QString effect() const noexcept override;
71 void loadPreset(const Process::Preset& preset) override;
72 Process::Preset savePreset() const noexcept override;
73 void init();
74 [[nodiscard]] Process::ScriptChangeResult reload();
75 QString m_text;
76 std::unique_ptr<BytebeatCompiler> m_compiler;
77};
78}
79
80namespace Process
81{
82template <>
83QString
84EffectProcessFactory_T<Jit::BytebeatModel>::customConstructionData() const noexcept;
85
86template <>
87Process::Descriptor
88EffectProcessFactory_T<Jit::BytebeatModel>::descriptor(QString d) const noexcept;
89
90template <>
91Process::Descriptor EffectProcessFactory_T<Jit::BytebeatModel>::descriptor(
92 const Process::ProcessModel& d) const noexcept;
93}
94class QPlainTextEdit;
95namespace Jit
96{
97
99{
100 static constexpr const char* language = "C++";
101};
102
105 BytebeatModel, Process::DefaultEffectItem,
107 BytebeatModel, BytebeatModel::p_script, BytebeatLanguageSpec>>;
108
110 : public Execution::ProcessComponent_T<Jit::BytebeatModel, ossia::node_process>
111{
112 COMPONENT_METADATA("dc4f88ae-ca36-4330-b0e7-8093a1793521")
113
114public:
115 static constexpr bool is_unique = true;
116
118 Jit::BytebeatModel& proc, const Execution::Context& ctx, QObject* parent);
119 ~BytebeatExecutor() override;
120};
122}
123
124namespace Jit
125{
126class EditBytebeat : public Scenario::EditScript<BytebeatModel, BytebeatModel::p_script>
127{
128 SCORE_COMMAND_DECL(CommandFactoryName(), EditBytebeat, "Edit a bytebeat")
129public:
130 using Scenario::EditScript<BytebeatModel, BytebeatModel::p_script>::EditScript;
131};
132
133}
134
135namespace score
136{
137template <>
138struct StaticPropertyCommand<Jit::BytebeatModel::p_script> : Jit::EditBytebeat
139{
140 using Jit::EditBytebeat::EditBytebeat;
141};
142}
Definition DataStreamVisitor.hpp:202
Definition Process/Execution/ProcessComponent.hpp:119
Definition JSONVisitor.hpp:423
Definition Bytebeat.hpp:111
Definition Bytebeat.hpp:127
Definition DefaultEffectItem.hpp:26
Definition EffectFactory.hpp:67
Definition EffectFactory.hpp:14
The Process class.
Definition score-lib-process/Process/Process.hpp:61
Definition ScriptEditor.hpp:42
Definition ScriptEditCommand.hpp:18
The id_base_t class.
Definition Identifier.hpp:57
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Base toolkit upon which the software is built.
Definition Application.cpp:90
STL namespace.
Definition ExecutionContext.hpp:76
Definition Process/Execution/ProcessComponent.hpp:89
Definition Bytebeat.hpp:99
Definition ScriptProcess.hpp:14
Definition TimeValue.hpp:21
Definition PropertyCommand.hpp:112