Mercurial > hg > svcore
diff data/midi/MIDIEvent.h @ 1069:32ab6c48efaa
Merge from branch tonioni
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:11:34 +0100 |
parents | cc27f35aa75c |
children | 48e9f538e6e9 |
line wrap: on
line diff
--- a/data/midi/MIDIEvent.h Mon Mar 02 17:21:34 2015 +0000 +++ b/data/midi/MIDIEvent.h Mon Apr 20 09:11:34 2015 +0100 @@ -25,6 +25,8 @@ #include <QString> #include <string> #include <iostream> +#include <stdexcept> + #include "base/Debug.h" typedef unsigned char MIDIByte; @@ -118,16 +120,22 @@ { public: MIDIEvent(unsigned long deltaTime, - MIDIByte eventCode, - MIDIByte data1 = 0, - MIDIByte data2 = 0) : + int eventCode, + int data1 = 0, + int data2 = 0) : m_deltaTime(deltaTime), m_duration(0), - m_eventCode(eventCode), - m_data1(data1), - m_data2(data2), m_metaEventCode(0) - { } + { + if (eventCode < 0 || eventCode > 0xff || + data1 < 0 || data1 > 0xff || + data2 < 0 || data2 > 0xff) { + throw std::domain_error("not all args within byte range"); + } + m_eventCode = MIDIByte(eventCode); + m_data1 = MIDIByte(data1); + m_data2 = MIDIByte(data2); + } MIDIEvent(unsigned long deltaTime, MIDIByte eventCode,