forked from MISATOSUSUMI/NakResampler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmfHandler.cpp
More file actions
52 lines (47 loc) · 1.58 KB
/
SmfHandler.cpp
File metadata and controls
52 lines (47 loc) · 1.58 KB
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
#include "SmfHandler.h"
using namespace std;
SmfHandler::SmfHandler(){}
SmfHandler::~SmfHandler(){}
MidiMsg SmfHandler::charToMidiMsg(unsigned char midi_msg)
{
switch(midi_msg>>4) {
case 0x9: return MIDI_MSG_NOTE_ON;
case 0x8: return MIDI_MSG_NOTE_OFF;
case 0xA: return MIDI_MSG_PLY_KEY_PRS;
case 0xB: return MIDI_MSG_CTL_CHG;
case 0xC: return MIDI_MSG_PGM_CHG;
case 0xD: return MIDI_MSG_CHN_PRS;
case 0xE: return MIDI_MSG_PIT_BND_CHG;
}
switch(midi_msg){
case 0xF0: return MIDI_MSG_EXC;
case 0xF1: return MIDI_MSG_QURT_FRM;
case 0xF2: return MIDI_MSG_SNG_POS_PTR;
case 0xF3: return MIDI_MSG_SNG_SEL;
case 0xF6: return MIDI_MSG_TUNE_REQ;
case 0xF7: return MIDI_MSG_END_EXL;
case 0xFF: return MIDI_MSG_META;
}
return MIDI_MSG_UNKNOWN;
}
string SmfHandler::midiMsgToString(MidiMsg midi_msg)
{
switch(midi_msg){
case MIDI_MSG_NOTE_ON: return "Note On";
case MIDI_MSG_NOTE_OFF: return "Note Off";
case MIDI_MSG_PLY_KEY_PRS: return "Polyphonic Key Pressure";
case MIDI_MSG_CTL_CHG: return "Control Change";
case MIDI_MSG_PGM_CHG: return "Program Change";
case MIDI_MSG_CHN_PRS: return "Channel Pressure";
case MIDI_MSG_PIT_BND_CHG: return "Pitchbend Chang";
case MIDI_MSG_EXC: return "Exclusive Message";
case MIDI_MSG_QURT_FRM: return "Quarter Frame";
case MIDI_MSG_SNG_POS_PTR: return "Song Position Pointer";
case MIDI_MSG_SNG_SEL: return "Song Select";
case MIDI_MSG_TUNE_REQ: return "Tune Request";
case MIDI_MSG_END_EXL: return "End of Exclusive";
case MIDI_MSG_META: return "Meta Message";
default:;
}
return "Unkenown Message";
}