comparison data/midi/MIDIEvent.h @ 1450:a12fd0456f0c streaming-csv-writer

Merge from default branch
author Chris Cannam
date Tue, 17 Apr 2018 10:35:42 +0100
parents 48e9f538e6e9
children c01cbe41aeb5
comparison
equal deleted inserted replaced
1449:deabf9fd3d28 1450:a12fd0456f0c
121 public: 121 public:
122 MIDIEvent(unsigned long deltaTime, 122 MIDIEvent(unsigned long deltaTime,
123 int eventCode, 123 int eventCode,
124 int data1 = 0, 124 int data1 = 0,
125 int data2 = 0) : 125 int data2 = 0) :
126 m_deltaTime(deltaTime), 126 m_deltaTime(deltaTime),
127 m_duration(0), 127 m_duration(0),
128 m_metaEventCode(0) 128 m_metaEventCode(0)
129 { 129 {
130 if (eventCode < 0 || eventCode > 0xff || 130 if (eventCode < 0 || eventCode > 0xff ||
131 data1 < 0 || data1 > 0xff || 131 data1 < 0 || data1 > 0xff ||
132 data2 < 0 || data2 > 0xff) { 132 data2 < 0 || data2 > 0xff) {
133 throw std::domain_error("not all args within byte range"); 133 throw std::domain_error("not all args within byte range");
139 139
140 MIDIEvent(unsigned long deltaTime, 140 MIDIEvent(unsigned long deltaTime,
141 MIDIByte eventCode, 141 MIDIByte eventCode,
142 MIDIByte metaEventCode, 142 MIDIByte metaEventCode,
143 const std::string &metaMessage) : 143 const std::string &metaMessage) :
144 m_deltaTime(deltaTime), 144 m_deltaTime(deltaTime),
145 m_duration(0), 145 m_duration(0),
146 m_eventCode(eventCode), 146 m_eventCode(eventCode),
147 m_data1(0), 147 m_data1(0),
148 m_data2(0), 148 m_data2(0),
149 m_metaEventCode(metaEventCode), 149 m_metaEventCode(metaEventCode),
150 m_metaMessage(metaMessage) 150 m_metaMessage(metaMessage)
151 { } 151 { }
152 152
153 MIDIEvent(unsigned long deltaTime, 153 MIDIEvent(unsigned long deltaTime,
154 MIDIByte eventCode, 154 MIDIByte eventCode,
155 const std::string &sysEx) : 155 const std::string &sysEx) :
156 m_deltaTime(deltaTime), 156 m_deltaTime(deltaTime),
157 m_duration(0), 157 m_duration(0),
158 m_eventCode(eventCode), 158 m_eventCode(eventCode),
159 m_data1(0), 159 m_data1(0),
160 m_data2(0), 160 m_data2(0),
161 m_metaEventCode(0), 161 m_metaEventCode(0),
162 m_metaMessage(sysEx) 162 m_metaMessage(sysEx)
163 { } 163 { }
164 164
165 ~MIDIEvent() { } 165 ~MIDIEvent() { }
166 166
167 void setTime(const unsigned long &time) { m_deltaTime = time; } 167 void setTime(const unsigned long &time) { m_deltaTime = time; }
168 void setDuration(const unsigned long& duration) { m_duration = duration;} 168 void setDuration(const unsigned long& duration) { m_duration = duration;}
169 unsigned long addTime(const unsigned long &time) { 169 unsigned long addTime(const unsigned long &time) {
170 m_deltaTime += time; 170 m_deltaTime += time;
171 return m_deltaTime; 171 return m_deltaTime;
172 } 172 }
173 173
174 MIDIByte getMessageType() const 174 MIDIByte getMessageType() const
175 { return (m_eventCode & MIDIConstants::MIDI_MESSAGE_TYPE_MASK); } 175 { return (m_eventCode & MIDIConstants::MIDI_MESSAGE_TYPE_MASK); }
176 176
220 class MIDIException : virtual public std::exception 220 class MIDIException : virtual public std::exception
221 { 221 {
222 public: 222 public:
223 MIDIException(QString message) throw() : m_message(message) { 223 MIDIException(QString message) throw() : m_message(message) {
224 std::cerr << "WARNING: MIDI exception: " 224 std::cerr << "WARNING: MIDI exception: "
225 << message.toLocal8Bit().data() << std::endl; 225 << message.toLocal8Bit().data() << std::endl;
226 } 226 }
227 virtual ~MIDIException() throw() { } 227 virtual ~MIDIException() throw() { }
228 228
229 virtual const char *what() const throw() { 229 virtual const char *what() const throw() {
230 return m_message.toLocal8Bit().data(); 230 return m_message.toLocal8Bit().data();
231 } 231 }
232 232
233 protected: 233 protected:
234 QString m_message; 234 QString m_message;
235 }; 235 };