summaryrefslogtreecommitdiffstats
path: root/src/sound/Midi.h
blob: 65bfe936eac4e7af4f99532cee50f72601cb1268 (plain)
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
// -*- c-indentation-style:"stroustrup" c-basic-offset: 4 -*-
/*
  Rosegarden
  A sequencer and musical notation editor.

  This program is Copyright 2000-2008
  Guillaume Laurent   <[email protected]>,
  Chris Cannam        <[email protected]>,
  Richard Bown        <[email protected]>

  The moral right of the authors to claim authorship of this work
  has been asserted.

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License as
  published by the Free Software Foundation; either version 2 of the
  License, or (at your option) any later version.  See the file
  COPYING included with this distribution for more information.
*/


#ifndef _ROSEGARDEN_MIDI_H_
#define _ROSEGARDEN_MIDI_H_

#include "Instrument.h" // for MidiByte
#include <string>

// Yes we use the STL here.  Don't worry, it's fine.
//
//

namespace Rosegarden
{
// Within the namespace we define our static MIDI messages 
// that'll help us create and understand MIDI files.
//
// CreateMessageByte(MSG, CHANNEL)  = (MSG) | (CHANNEL)
//
//

const std::string MIDI_FILE_HEADER              = "MThd";
const std::string MIDI_TRACK_HEADER             = "MTrk";

const MidiByte MIDI_STATUS_BYTE_MASK       = 0x80;
const MidiByte MIDI_MESSAGE_TYPE_MASK      = 0xF0;
const MidiByte MIDI_CHANNEL_NUM_MASK       = 0x0F;

// our basic MIDI messages
//
const MidiByte MIDI_NOTE_OFF               = 0x80;
const MidiByte MIDI_NOTE_ON                = 0x90;
const MidiByte MIDI_POLY_AFTERTOUCH        = 0xA0;
const MidiByte MIDI_CTRL_CHANGE            = 0xB0;
const MidiByte MIDI_PROG_CHANGE            = 0xC0;
const MidiByte MIDI_CHNL_AFTERTOUCH        = 0xD0;
const MidiByte MIDI_PITCH_BEND             = 0xE0;

// channel mode
//
const MidiByte MIDI_SELECT_CHNL_MODE       = 0xB0;

// system messages
const MidiByte MIDI_SYSTEM_EXCLUSIVE       = 0xF0;
const MidiByte MIDI_TC_QUARTER_FRAME       = 0xF1;
const MidiByte MIDI_SONG_POSITION_PTR      = 0xF2;
const MidiByte MIDI_SONG_SELECT            = 0xF3;
const MidiByte MIDI_TUNE_REQUEST           = 0xF6;
const MidiByte MIDI_END_OF_EXCLUSIVE       = 0xF7;

const MidiByte MIDI_TIMING_CLOCK           = 0xF8;
const MidiByte MIDI_START                  = 0xFA;
const MidiByte MIDI_CONTINUE               = 0xFB;
const MidiByte MIDI_STOP                   = 0xFC;
const MidiByte MIDI_ACTIVE_SENSING         = 0xFE;
const MidiByte MIDI_SYSTEM_RESET           = 0xFF;

// System Exclusive Extensions
//

// Non-commercial use
//
const MidiByte MIDI_SYSEX_NONCOMMERCIAL    = 0x7D;

// Universal non-real time use
// Format:
//
//   0xF0 0x7E <device id> <sub id #1> <sub id #2> <data> 0xF7
//
const MidiByte MIDI_SYSEX_NON_RT           = 0x7E;

// RealTime e.g Midi Machine Control (MMC)
//
//   0xF0 0x7F <device id> <sub id #1> <sub id #2> <data> 0xF7
//
const MidiByte MIDI_SYSEX_RT               = 0x7F;

// Sub IDs for RealTime SysExs
//
const MidiByte MIDI_SYSEX_RT_COMMAND       = 0x06;
const MidiByte MIDI_SYSEX_RT_RESPONSE      = 0x07;

// MMC commands
//
const MidiByte MIDI_MMC_STOP               = 0x01;
const MidiByte MIDI_MMC_PLAY               = 0x02;
const MidiByte MIDI_MMC_DEFERRED_PLAY      = 0x03;
const MidiByte MIDI_MMC_FAST_FORWARD       = 0x04;
const MidiByte MIDI_MMC_REWIND             = 0x05;
const MidiByte MIDI_MMC_RECORD_STROBE      = 0x06; // punch in
const MidiByte MIDI_MMC_RECORD_EXIT        = 0x07; // punch out
const MidiByte MIDI_MMC_RECORD_PAUSE       = 0x08;
const MidiByte MIDI_MMC_PAUSE              = 0x08;
const MidiByte MIDI_MMC_EJECT              = 0x0A;
const MidiByte MIDI_MMC_LOCATE             = 0x44; // jump to


// Midi Event Code for META Event
//
const MidiByte MIDI_FILE_META_EVENT        = 0xFF;

// META Event Codes
//
const MidiByte MIDI_SEQUENCE_NUMBER        = 0x00;
const MidiByte MIDI_TEXT_EVENT             = 0x01;
const MidiByte MIDI_COPYRIGHT_NOTICE       = 0x02;
const MidiByte MIDI_TRACK_NAME             = 0x03;
const MidiByte MIDI_INSTRUMENT_NAME        = 0x04;
const MidiByte MIDI_LYRIC                  = 0x05;
const MidiByte MIDI_TEXT_MARKER            = 0x06;
const MidiByte MIDI_CUE_POINT              = 0x07;
const MidiByte MIDI_CHANNEL_PREFIX         = 0x20;

// There is contention over what 0x21 really means.
// It's either a miswritten CHANNEL PREFIX or it's
// a non-standard PORT MAPPING used by a sequencer.
// Either way we include it (and generally ignore it)
// as it's a part of many MIDI files that already 
// exist.
const MidiByte MIDI_CHANNEL_PREFIX_OR_PORT = 0x21;

const MidiByte MIDI_END_OF_TRACK           = 0x2F;
const MidiByte MIDI_SET_TEMPO              = 0x51;
const MidiByte MIDI_SMPTE_OFFSET           = 0x54;
const MidiByte MIDI_TIME_SIGNATURE         = 0x58;
const MidiByte MIDI_KEY_SIGNATURE          = 0x59;
const MidiByte MIDI_SEQUENCER_SPECIFIC     = 0x7F;

// Some controllers
//
const MidiByte MIDI_CONTROLLER_BANK_MSB      = 0x00;
const MidiByte MIDI_CONTROLLER_VOLUME        = 0x07;
const MidiByte MIDI_CONTROLLER_BANK_LSB      = 0x20;
const MidiByte MIDI_CONTROLLER_MODULATION    = 0x01;
const MidiByte MIDI_CONTROLLER_PAN           = 0x0A;
const MidiByte MIDI_CONTROLLER_SUSTAIN       = 0x40;
const MidiByte MIDI_CONTROLLER_RESONANCE     = 0x47;
const MidiByte MIDI_CONTROLLER_RELEASE       = 0x48;
const MidiByte MIDI_CONTROLLER_ATTACK        = 0x49;
const MidiByte MIDI_CONTROLLER_FILTER        = 0x4A;
const MidiByte MIDI_CONTROLLER_REVERB        = 0x5B;
const MidiByte MIDI_CONTROLLER_CHORUS        = 0x5D;

// Registered and Non-Registered Parameter Controllers
//
const MidiByte MIDI_CONTROLLER_NRPN_1        = 0x62;
const MidiByte MIDI_CONTROLLER_NRPN_2        = 0x63;
const MidiByte MIDI_CONTROLLER_RPN_1         = 0x64;
const MidiByte MIDI_CONTROLLER_RPN_2         = 0x65;

const MidiByte MIDI_CONTROLLER_SOUNDS_OFF    = 0x78;
const MidiByte MIDI_CONTROLLER_RESET         = 0x79; // reset all controllers
const MidiByte MIDI_CONTROLLER_LOCAL         = 0x7A; // 0 = off, 127 = on
const MidiByte MIDI_CONTROLLER_ALL_NOTES_OFF = 0x7B;


// MIDI percussion channel
const MidiByte MIDI_PERCUSSION_CHANNEL     = 9;



}


#endif // _ROSEGARDEN_MIDI_H_