-
Notifications
You must be signed in to change notification settings - Fork 0
/
MetaEvent.cpp
274 lines (198 loc) · 6.57 KB
/
MetaEvent.cpp
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//
// Created by madsy on 20.03.17.
//
#include "MetaEvent.h"
MetaEvtSequenceNumber::MetaEvtSequenceNumber(unsigned int timestamp, unsigned int sequenceNum) :
MidiEvent(timestamp), pSequenceNumber(sequenceNum){
}
MetaEvtText::MetaEvtText(unsigned int timestamp, const std::string &text) :
MidiEvent(timestamp), pText(text){
}
MetaEvtCopyright::MetaEvtCopyright(unsigned int timestamp, const std::string ©right) :
MidiEvent(timestamp), pCopyright(copyright) {
}
MetaEvtTrackName::MetaEvtTrackName(unsigned int timestamp, const std::string &trackName) :
MidiEvent(timestamp), pTrackName(trackName) {
}
MetaEvtInstrumentName::MetaEvtInstrumentName(unsigned int timestamp, const std::string &instrumentName) :
MidiEvent(timestamp), pInstrumentName(instrumentName) {
}
MetaEvtLyrics::MetaEvtLyrics(unsigned int timestamp, const std::string &lyrics) :
MidiEvent(timestamp), pLyrics(lyrics) {
}
MetaEvtMarker::MetaEvtMarker(unsigned int timestamp, const std::string &marker) :
MidiEvent(timestamp), pMarker(marker) {
}
MetaEvtMidiChannelPrefix::MetaEvtMidiChannelPrefix(unsigned int timestamp, unsigned int channel) :
MidiEvent(timestamp), pChannel(channel) {
}
MetaEvtEndOfTrack::MetaEvtEndOfTrack(unsigned int timestamp) :
MidiEvent(timestamp) {
}
MetaEvtSetTempo::MetaEvtSetTempo(unsigned int timestamp, unsigned int tempo) :
MidiEvent(timestamp), pTempo(tempo){
}
MetaEvtCuePoint::MetaEvtCuePoint(unsigned int timestamp, const std::string &cue) :
MidiEvent(timestamp), pCuePoint(cue) {
}
MetaEvtSMPTEOffset::MetaEvtSMPTEOffset(
unsigned int timestamp,
unsigned int hours,
unsigned int minutes,
unsigned int seconds,
unsigned int frames,
unsigned int frame_fraction
) :
MidiEvent(timestamp),
pHours(hours),
pMinutes(minutes),
pSeconds(seconds),
pFrames(frames),
pFractionFrames(frame_fraction)
{
}
MetaEvtTimeSignature::MetaEvtTimeSignature(
unsigned int timestamp,
unsigned int numerator,
unsigned int denominator,
unsigned int clocks_per_tick,
unsigned int notes_per_clock
) :
MidiEvent(timestamp),
pNumerator(numerator),
pDenominator(denominator),
pClocksPerTick(clocks_per_tick),
pNotesPerClock(notes_per_clock){
}
MetaEvtKeySignature::MetaEvtKeySignature(unsigned int timestamp, unsigned int sharpflats, unsigned int minormajor) :
MidiEvent(timestamp), pSharpFlats(sharpflats), pMinorMajor(minormajor){
}
MetaEvtSequencerSpecific::MetaEvtSequencerSpecific(
unsigned int timestamp,
const std::vector<unsigned char> &data) :
MidiEvent(timestamp), pData(data){
}
void MetaEvtSequenceNumber::print() {
printf("Sequence Number\n");
}
void MetaEvtText::print() {
printf("Text: \"%s\"\n", this->getText().c_str());
}
void MetaEvtCopyright::print() {
printf("Copyright: %s\n", this->getCopyRight().c_str());
}
void MetaEvtTrackName::print() {
printf("Track Name: %s\n", this->getTrackName().c_str());
}
void MetaEvtInstrumentName::print() {
printf("Instrument Name: %s\n", this->getInstrumentName().c_str());
}
void MetaEvtLyrics::print() {
printf("Lyrics: %s\n", this->getLyrics().c_str());
}
void MetaEvtMarker::print() {
printf("Marker: %s\n", this->getMarker().c_str());
}
void MetaEvtCuePoint::print() {
printf("Cue Point: %s\n", this->getCuePoint().c_str());
}
void MetaEvtMidiChannelPrefix::print() {
printf("Channel Prefix: %u\n", this->getChannel());
}
void MetaEvtEndOfTrack::print() {
printf("End Of Track\n");
}
void MetaEvtSetTempo::print() {
printf("New Tempo: %u\n", this->getTempo());
}
void MetaEvtSMPTEOffset::print() {
printf("SMPTEOffset: %u:%u:%u:%u:%u\n", this->getHours(), this->getMinutes(), this->getSeconds(), this->getFrames(), this->getSubFrames());
}
void MetaEvtTimeSignature::print() {
printf("Time Signature: %u/%u, CLK/Tick %u, Notes/Clock %u\n", this->getNumerator(), this->getDenominator(), this->getClocksPerTick(),
this->getNotesPerClock());
}
void MetaEvtSequencerSpecific::print() {
printf("Sequencer Specific Info: ");
const std::vector<unsigned char> d = this->getData();
if(d.size()) printf("%02X", d[0]);
for(size_t i = 1; i <d.size(); i++){
printf(", %02X", d[i]);
}
printf("\n");
}
void MetaEvtKeySignature::print() {
MidiEvent::print();
}
unsigned int MetaEvtSequenceNumber::getSequenceNumber() const {
return pSequenceNumber;
}
const std::string &MetaEvtText::getText() const {
return pText;
}
const std::string &MetaEvtCopyright::getCopyRight() const {
return pCopyright;
}
const std::string &MetaEvtTrackName::getTrackName() const {
return pTrackName;
}
const std::string &MetaEvtInstrumentName::getInstrumentName() const {
return pInstrumentName;
}
const std::string &MetaEvtLyrics::getLyrics() const {
return pLyrics;
}
const std::string &MetaEvtMarker::getMarker() const {
return pMarker;
}
const std::string &MetaEvtCuePoint::getCuePoint() const {
return pCuePoint;
}
unsigned int MetaEvtMidiChannelPrefix::getChannel() const {
return pChannel;
}
unsigned int MetaEvtSetTempo::getTempo() const {
return pTempo;
}
unsigned int MetaEvtSMPTEOffset::getHours() const {
return pHours;
}
unsigned int MetaEvtSMPTEOffset::getMinutes() const {
return pMinutes;
}
unsigned int MetaEvtSMPTEOffset::getSeconds() const {
return pSeconds;
}
unsigned int MetaEvtSMPTEOffset::getFrames() const {
return pFrames;
}
unsigned int MetaEvtSMPTEOffset::getSubFrames() const {
return pFractionFrames;
}
unsigned int MetaEvtTimeSignature::getNumerator() const {
return pNumerator;
}
unsigned int MetaEvtTimeSignature::getDenominator() const {
return pDenominator;
}
unsigned int MetaEvtTimeSignature::getClocksPerTick() const {
return pClocksPerTick;
}
unsigned int MetaEvtTimeSignature::getNotesPerClock() const {
return pNotesPerClock;
}
unsigned int MetaEvtKeySignature::getSharpFlats() const {
return pSharpFlats;
}
unsigned int MetaEvtKeySignature::getMinorMajor() const {
return pMinorMajor;
}
unsigned int MetaEvtSequencerSpecific::getManufacturerID() const {
/* Not implemented yet, because it's not obvious how to parse the manufacturer field. It can be 1 or 3 bytes
* The length field of a sequencer specific event is the length of the manufacturer id and the data combined,
* so the id is in the data array */
return 0;
}
const std::vector<unsigned char> &MetaEvtSequencerSpecific::getData() const {
return pData;
}