-
Notifications
You must be signed in to change notification settings - Fork 0
/
maPattern.h
184 lines (149 loc) · 5.93 KB
/
maPattern.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//
// MultiArp - Another step in the Great Midi Adventure!
// Copyright (C) 2017, 2018 Barry Neilsen
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef MAPATTERN_H_INCLUDED
#define MAPATTERN_H_INCLUDED
#include <vector>
#include <string>
#include <map>
#include "maCursorKeys.h"
#include "maFeelMap.h"
#include "maNotes.h"
#include "maTranslateTable.h"
#include "maTrigList.h"
struct Pattern
{
std::vector<StepList>::size_type m_Pos;
std::vector<StepList>::size_type m_PosEdit;
std::vector<RealTimeList>::size_type m_PosRealTimeEdit;
std::vector<StepList>::size_type m_LastRequestedPos;
// std::vector<int> m_Trigs;
std::vector<StepList> m_StepListSet;
std::vector<RealTimeList> m_RealTimeSet;
std::string m_Label;
double m_StepValue;
double m_Gate;
bool m_GateHold;
unsigned char m_Velocity;
FeelMap m_FeelMap;
TranslateTable m_TranslateTable;
TrigList m_TrigList;
unsigned m_DisplayStartStep = 0;
unsigned m_DisplayStartRealTime = 0;
double m_RealTimeBeat = 0; // Tracks beat for real time lists. Can be reset.
double m_LastRealTimeBeat = 0;
double m_RealTimeBeatStart = 0;
double LastRealTimeBeat() { return m_LastRealTimeBeat; }
bool m_RealTimeComplete = false;
void StoreStepValue( double val );
void StoreGate( double gate);
void StoreGateHold( bool val );
void StoreVelocity( unsigned char vel );
void StoreTranslateTable( TranslateTable & table );
double StepValue() { return m_StepValue; }
double Gate() { return m_Gate; }
bool GateHold() { return m_GateHold; }
unsigned char Velocity() { return m_Velocity; }
StepList & StepListForEdit() { return m_StepListSet.at(m_PosEdit); }
RealTimeList & RTListForEdit() { return m_RealTimeSet.at(m_PosRealTimeEdit); }
TranslateTable & PatternTranslateTable() { return m_TranslateTable; }
FeelMap & PatternFeelMap() { return m_FeelMap; }
TrigList & PatternTrigList() { return m_TrigList; }
Pattern():
m_Pos(0),
m_PosEdit(0),
m_PosRealTimeEdit(0),
m_LastRequestedPos(0),
m_StepValue(16),
m_Gate(0.5),
m_GateHold(false),
m_Velocity(64)
{
// NewList();
}
void Clear()
{
m_Label.clear();
m_StepListSet.clear();
m_RealTimeSet.clear();
ResetPosition();
m_TranslateTable.Reset();
m_TrigList.Clear();
m_StepValue = 4.0;
m_Gate = 0.5;
m_GateHold = false;
m_Velocity = 64;
}
void SetLabel(const char * label) { m_Label = label; }
void SetEditPos( std::vector<int>::size_type p )
{
if ( p >= 0 && p < m_StepListSet.size() )
m_PosEdit = p;
}
void SetRealTimeEditPos( std::vector<int>::size_type p )
{
if ( p >= 0 && p < m_RealTimeSet.size() )
m_PosRealTimeEdit = p;
}
void SetStepValue( double val ) { m_StepValue = val; }
int StepListCount() { return m_StepListSet.size(); }
int RealTimeListCount() { return m_RealTimeSet.size(); }
int TrigListCount() { return m_TrigList.Size(); }
void ResetPosition()
{
m_Pos = 0;
m_TrigList.ResetPosition();
for ( auto stepList = m_StepListSet.begin(); stepList != m_StepListSet.end(); stepList++ )
stepList->ResetPosition();
m_RealTimeBeat = m_RealTimeBeatStart;
m_RealTimeComplete = false;
// for ( auto rtList = m_RealTimeSet.begin(); rtList != m_RealTimeSet.end(); rtList++ )
// rtList->ResetPosition();
}
void Step(Cluster & cluster, TrigRepeater & repeater, double & stepValueMultiplier, double phase, double stepValue, double globalBeat);
bool LabelEmpty()
{
return m_Label.empty();
}
size_t TrigPlayPosition() { return m_TrigList.PlayPosition(); }
std::string Label() { return m_Label; }
std::string Label(size_t width);
std::string TrigsToStringForDisplay();
std::string ToString(const char * prefix);
std::string Display(int mode, std::vector<PosInfo2> & highlights, int centre = 30, int width = 80, int rows = 11);
bool FromString(std::string s, int & updates);
void AddRealTimeList(std::map<double,Note> realTimeList, double quantum);
void AddRealTimeListFromString(std::vector<RealTimeList>::size_type index, std::string s);
void AddRealTimeListFromMidiFile(std::string s);
void SetRealTimeMultipliers(std::vector<std::string>::iterator token, std::vector<std::string>::iterator last);
void SetRealTimeQuantum(std::string & token);
void SetRealTimeStartPhase(std::string & token);
void StartRealTimeEcho(std::vector<std::string>::iterator token, std::vector<std::string>::iterator last);
void AddListFromString(std::vector<int>::size_type index, std::string s);
void SetFieldsFromString(std::string s);
void ReplaceList(StepList & noteList);
int NewList();
void DeleteCurrentList();
void DeleteCurrentRealTimeList();
bool AllListsComplete();
void UpEditPos() { SetEditPos( m_PosEdit + 1); }
void DownEditPos() { SetEditPos( m_PosEdit - 1); }
void UpRTEditPos() { SetRealTimeEditPos( m_PosRealTimeEdit + 1); }
void DownRTEditPos() { SetRealTimeEditPos( m_PosRealTimeEdit - 1); }
};
#endif // MAPATTERN_H_INCLUDED