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