commit 814230e33e49ef00d01110ec32b222ca84e09500
parent ced69572c7a2a67885643e5b8bc769650b1c73f1
Author: Damien Goutte-Gattat <dgouttegattat@incenp.org>
Date: Sat, 29 Oct 2011 19:48:40 +0200
Add M_PGMCHANGE event type
Add a MIDI event type to handle Program Change messages.
Diffstat:
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/Nio/InMgr.cpp b/src/Nio/InMgr.cpp
@@ -8,14 +8,25 @@ using namespace std;
ostream &operator<<(ostream &out, const MidiEvent &ev)
{
- if(ev.type == M_NOTE)
+ switch(ev.type) {
+ case M_NOTE:
out << "MidiNote: note(" << ev.num << ")\n"
<< " channel(" << ev.channel << ")\n"
<< " velocity(" << ev.value << ")";
- else
+ break;
+
+ case M_CONTROLLER:
out << "MidiCtl: controller(" << ev.num << ")\n"
<< " channel(" << ev.channel << ")\n"
<< " value(" << ev.value << ")";
+ break;
+
+ case M_PGMCHANGE:
+ out << "PgmChange: program(" << ev.num << ")\n"
+ << " channel(" << ev.channel << ")";
+ break;
+ }
+
return out;
}
@@ -57,17 +68,23 @@ void InMgr::flush()
queue.pop(ev);
cout << ev << endl;
- if(M_NOTE == ev.type) {
+ switch(ev.type) {
+ case M_NOTE:
dump.dumpnote(ev.channel, ev.num, ev.value);
if(ev.value)
master.noteOn(ev.channel, ev.num, ev.value);
else
master.noteOff(ev.channel, ev.num);
- }
- else {
+ break;
+
+ case M_CONTROLLER:
dump.dumpcontroller(ev.channel, ev.num, ev.value);
master.setController(ev.channel, ev.num, ev.value);
+ break;
+
+ case M_PGMCHANGE:
+ break;
}
}
}
diff --git a/src/Nio/InMgr.h b/src/Nio/InMgr.h
@@ -7,14 +7,15 @@
enum midi_type {
M_NOTE = 1,
- M_CONTROLLER = 2
-}; //type=1 for note, type=2 for controller
+ M_CONTROLLER = 2,
+ M_PGMCHANGE = 3
+}; //type=1 for note, type=2 for controller, type=3 for program change
struct MidiEvent {
MidiEvent();
int channel; //the midi channel for the event
int type; //type=1 for note, type=2 for controller
- int num; //note or contoller number
+ int num; //note, controller or program number
int value; //velocity or controller value
};