Loading...
Searching...
No Matches
PatternModel.hpp
1#pragma once
2#include <Process/Process.hpp>
3
4#include <Patternist/PatternMetadata.hpp>
5
6#include <score_plugin_midi_export.h>
7
8#include <verdigris>
9
10namespace Process
11{
12class ControlInlet;
13class ValueOutlet;
14}
15namespace Patternist
16{
17
18enum class Note : uint8_t
19{
20 Rest,
21 Note,
22 Legato
23};
24
25struct Lane
26{
27 std::vector<Patternist::Note> pattern;
28 uint8_t note{};
29
30 bool operator==(const Lane& other) const noexcept
31 {
32 return note == other.note && pattern == other.pattern;
33 }
34};
35
36struct Pattern
37{
38 int length{16};
39 int division{16};
40 std::vector<Lane> lanes;
41
42 bool operator==(const Pattern& other) const noexcept
43 {
44 return length == other.length && division == other.division && lanes == other.lanes;
45 }
46};
47
48class SCORE_PLUGIN_MIDI_EXPORT ProcessModel final : public Process::ProcessModel
49{
50 SCORE_SERIALIZE_FRIENDS
51 W_OBJECT(ProcessModel)
52
53public:
55 static const constexpr int maxPatterns = 128;
56
57 PROCESS_METADATA_IMPL(Patternist::ProcessModel)
58 explicit ProcessModel(
59 const TimeVal& duration, const Id<Process::ProcessModel>& id, QObject* parent);
60 explicit ProcessModel(
61 const TimeVal& duration, const QString& custom,
62 const Id<Process::ProcessModel>& id, QObject* parent);
63
64 template <typename Impl>
65 explicit ProcessModel(Impl& vis, QObject* parent)
66 : Process::ProcessModel{vis, parent}
67 {
68 vis.writeTo(*this);
69 init();
70 }
71
72 void init();
73
74 ~ProcessModel() override;
75
76 void setChannel(int n);
77 int channel() const noexcept;
78
79 void setCurrentPattern(int n);
80 int currentPattern() const noexcept;
81
82 void setPattern(int n, Pattern p);
83 void setPatterns(const std::vector<Pattern>& n);
84 const std::vector<Pattern>& patterns() const noexcept;
85
86 std::unique_ptr<Process::ControlInlet> patternSelect;
87 std::unique_ptr<Process::ControlInlet> switchQuantification;
88 std::unique_ptr<Process::MidiOutlet> outlet;
89 std::unique_ptr<Process::Outlet> accent;
90 std::unique_ptr<Process::Outlet> slide;
91
92public:
93 void channelChanged(int arg_1) W_SIGNAL(channelChanged, arg_1);
94 void currentPatternChanged(int arg_1) W_SIGNAL(currentPatternChanged, arg_1);
95 void execPosition(int arg_1) W_SIGNAL(execPosition, arg_1);
96 void patternsChanged() W_SIGNAL(patternsChanged);
97
98 PROPERTY(int, channel READ channel WRITE setChannel NOTIFY channelChanged, W_Final)
99 PROPERTY(
100 int,
101 currentPattern READ currentPattern WRITE setCurrentPattern NOTIFY
102 currentPatternChanged,
103 W_Final)
104private:
105 void setDurationAndScale(const TimeVal& newDuration) noexcept override;
106 void setDurationAndGrow(const TimeVal& newDuration) noexcept override;
107 void setDurationAndShrink(const TimeVal& newDuration) noexcept override;
108
109 int m_channel{1};
110 int m_currentPattern{};
111 std::vector<Pattern> m_patterns;
112};
113}
Definition PatternModel.hpp:49
The Process class.
Definition score-lib-process/Process/Process.hpp:80
The id_base_t class.
Definition Identifier.hpp:59
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
STL namespace.
Definition PatternModel.hpp:26
Definition PatternModel.hpp:37
Definition TimeValue.hpp:21