1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - SND - demos - seq
3   File:     smfdefine.h
4 
5   Copyright 2007-2008 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 #ifndef SMFDEFINE_H_
18 #define SMFDEFINE_H_
19 
20 #ifdef SDK_TWL
21 #include <twl.h>
22 #else
23 #include <nitro.h>
24 #endif
25 
26 /*------------------------------------------------------------------*/
27 /*                                                                  */
28 /* MIDI data structure definition                                               */
29 /*                                                                  */
30 /*------------------------------------------------------------------*/
31 
32 
33 /*--------------------------------------------------------------------*/
34 /* Definition used for MIDI standard                                               */
35 /*--------------------------------------------------------------------*/
36 
37 /* Upper 4-bit definition */
38 #define MIDI_NOTEOFF            0x80   /* Note off */
39 #define MIDI_NOTEON             0x90   /* Note on */
40 #define MIDI_POLYPRESS          0xA0   /* Key polyphonic pressure */
41 #define MIDI_CONTROLCHANGE      0xB0   /* Control change */
42 #define MIDI_PROGRAMCHANGE      0xC0   /* Program change */
43 #define MIDI_CANNELPRESS        0xD0   /* Channel pressure */
44 #define MIDI_PITCHBEND          0xE0   /* Pitch bend */
45 #define MIDI_SYSTEMMESSAGE      0xF0   /* System message */
46 
47 /* MIDI_SYSTEMMESSAGE */
48 #define MIDI_SYSX               0xF0   /* Exclusive message */
49 /* COMMON MESSAGE */
50 #define MIDI_MTC                0xF1   /* MIDI time code */
51 #define MIDI_SONG_POSITION      0xF2   /* Song position pointer */
52 #define MIDI_SONG_SELECT        0xF3   /* Song select */
53 #define MIDI_UNDEFINED_F4       0xF4   /* Undefined */
54 #define MIDI_UNDEFINED_F5       0xF5   /* Undefined */
55 #define MIDI_TUNE_REQUEST       0xF6   /* Tune request */
56 #define MIDI_END_OF_SYSX        0xF7   /* End of exclusive */
57 /* REALTIME MESSAGE */
58 #define MIDI_TIMING_CLOCK       0xF8   /* Timing clock */
59 #define MIDI_UNDEFINED_F9       0xF9   /* Undefined */
60 #define MIDI_START              0xFA   /* Start */
61 #define MIDI_CONTINUE           0xFB   /* Continue */
62 #define MIDI_STOP               0xFC   /* Stop */
63 #define MIDI_UNDEFINED_FD       0xFD   /* Undefined */
64 #define MIDI_ACTIVESENSING      0xFE   /* Active sensing */
65 #define MIDI_SYSTEMRESET        0xFF   /* System reset */
66 
67 /* Control Change */
68 /* Continuous cc */
69 #define MIDI_CC_BANKSELECT_MSB  0x00   /*   0: Bank select */
70 #define MIDI_CC_BANKSELECT_LSB  0x20   /*  32: Bank select */
71 #define MIDI_CC_MODURATION      0x01   /*   1: Modulation wheel */
72 #define MIDI_CC_BREATH_CONTROL  0x02   /*   2: Breath control */
73 #define MIDI_CC_FOOT_CONTROL    0x04   /*   4: Foot control */
74 #define MIDI_CC_PORTAMENT_TIME  0x05   /*   5: Portamento time */
75 #define MIDI_CC_VOLUME          0x07   /*   7: Volume */
76 #define MIDI_CC_BALANCE         0x08   /*   8: Balance */
77 #define MIDI_CC_PAN             0x0A   /*  10: Pan */
78 #define MIDI_CC_EXPRESSION      0x0B   /*  11: Expression */
79 #define MIDI_CC_GENERAL1        0x10   /*  16: General purpose 1 */
80 #define MIDI_CC_GENERAL2        0x11   /*  17: General purpose 2 */
81 #define MIDI_CC_GENERAL3        0x12   /*  18: General purpose 3 */
82 #define MIDI_CC_GENERAL4        0x13   /*  19: General purpose 4 */
83 /* switched cc */
84 #define MIDI_CC_HOLD1           0x40   /*  64: Hold (damper) */
85 #define MIDI_CC_PORTAMENT       0x41   /*  65: Portamento switch */
86 #define MIDI_CC_SOSTENUTO       0x42   /*  66: Sostenuto */
87 #define MIDI_CC_SOFT_PEDAL      0x43   /*  67: Soft pedal */
88 #define MIDI_CC_LEGATO          0x44   /*  68: Legato foot switch */
89 #define MIDI_CC_HOLD2           0x45   /*  69: Hold (freeze) */
90 /* Sound controller cc */
91 #define MIDI_CC_SOUND_CONTROL1  0x46   /*  70: Sound controller 1 */
92 #define MIDI_CC_SOUND_CONTROL2  0x47   /*  71: Sound controller 2 */
93 #define MIDI_CC_SOUND_CONTROL3  0x48   /*  72: Sound controller 3 */
94 #define MIDI_CC_SOUND_CONTROL4  0x49   /*  73: Sound controller 4 */
95 #define MIDI_CC_SOUND_CONTROL5  0x4A   /*  74: Sound controller 5 */
96 #define MIDI_CC_SOUND_CONTROL6  0x4B   /*  75: Sound controller 6 */
97 #define MIDI_CC_SOUND_CONTROL7  0x4C   /*  76: Sound controller 7 */
98 #define MIDI_CC_SOUND_CONTROL8  0x4D   /*  77: Sound controller 8 */
99 #define MIDI_CC_SOUND_CONTROL9  0x4E   /*  78: Sound controller 9 */
100 #define MIDI_CC_SOUND_CONTROL10 0x4F   /*  79: Sound controller 10 */
101 #define MIDI_CC_SOUND_VARIATION 0x46   /*  70: Sound variation */
102 #define MIDI_CC_RESONANCE       0x47   /*  71: Resonance */
103 #define MIDI_CC_RELEASE_TIME    0x48   /*  72: Release time */
104 #define MIDI_CC_ATTACK_TIME     0x49   /*  73: Attack time */
105 #define MIDI_CC_BRIGHTNESS      0x4A   /*  74: Filter cut-off */
106 #define MIDI_CC_DECAY_TIME      0x4B   /*  75: Decay time */
107 #define MIDI_CC_VIBRATO_RATE    0x4C   /*  76: Vibrato rate (speed) */
108 #define MIDI_CC_VIBRATO_DEPTH   0x4D   /*  77: Vibrato depth */
109 #define MIDI_CC_VIBRATO_DELAY   0x4E   /*  78: Vibrato delay */
110 /* Portament_control */
111 #define MIDI_CC_PORTAMENT_CTRL  0x54   /*  84: Portamento control */
112 /* Effect controller cc */
113 #define MIDI_CC_EFFECT_CONTROL1 0x0C   /*  12: Effect controller 1 */
114 #define MIDI_CC_EFFECT_CONTROL2 0x0D   /*  13: Effect controller 2 */
115 #define MIDI_CC_REVERB_SEND     0x5B   /*  91: Reverb send level */
116 #define MIDI_CC_TREMOLO_DEPTH   0x5C   /*  92: Tremolo depth */
117 #define MIDI_CC_CHORUS_SEND     0x5D   /*  93: Chorus send level */
118 #define MIDI_CC_DELAY_SEND      0x5E   /*  94: Delay send level */
119 #define MIDI_CC_PHASER_DEPTH    0x5F   /*  95: Phaser depth */
120 /* Parameter control */
121 #define MIDI_CC_DATA_ENTRY_MSB  0x06   /*   6: Data entry */
122 #define MIDI_CC_DATA_ENTRY_LSB  0x26   /*  38: Data entry */
123 #define MIDI_CC_DATA_INCREMENT  0x60   /*  96: Increment */
124 #define MIDI_CC_DATA_DECREMENT  0x61   /*  97: Decrement */
125 #define MIDI_CC_RPN_MSB         0x65   /* 101: RPN MSB */
126 #define MIDI_CC_RPN_LSB         0x64   /* 100: RPN LSB */
127 #define MIDI_CC_NRPN_MSB        0x63   /*  99: NRPN MSB */
128 #define MIDI_CC_NRPN_LSB        0x62   /*  98: NRPN LSB */
129 /* Mode message */
130 #define MIDI_CC_ALL_SOUND_OFF   0x78   /* 120: All sound off */
131 #define MIDI_CC_RESET_ALL_CTRL  0x79   /* 121: Reset all controllers */
132 #define MIDI_CC_ROCAL_CONTROL   0x7A   /* 122: Local control */
133 #define MIDI_CC_ALL_NOTE_OFF    0x7B   /* 123: All notes off */
134 #define MIDI_CC_OMNI_ON         0x7C   /* 124: Omni-mode on */
135 #define MIDI_CC_OMNI_OFF        0x7D   /* 125: Omni-mode off */
136 #define MIDI_CC_MONO_MODE       0x7E   /* 126: Mono-mode on */
137 #define MIDI_CC_POLY_MODE       0x7F   /* 127: Poly-mode on */
138 /* RPN */
139 #define MIDI_RPN_PITCHBEND_SENS 0x0000 /* RPN: Pitch bend sensitivity */
140 #define MIDI_RPN_FINE_TUNE      0x0001 /* RPN: Fine tune */
141 #define MIDI_RPN_COASE_TUNE     0x0002 /* RPN: Coarse tune */
142 #define MIDI_RPN_TUNING_PROGRAM 0x0003 /* RPN: Tuning program select */
143 #define MIDI_RPN_TUNING_BANK    0x0004 /* RPN: Tuning bank select */
144 #define MIDI_RPN_MODURATION_SENS 0x0005 /* RPN: Modulation sensitivity */
145 
146 
147 
148 /*--------------------------------------------------------------------*/
149 /* Definitions for standard MIDI File format                        */
150 /*--------------------------------------------------------------------*/
151 
152 #define SMF_FORMAT0             0      /* SMF format0 */
153 #define SMF_FORMAT1             1      /* SMF format1 */
154 #define SMF_FORMAT2             2      /* SMF format2 */
155 
156 #define SMF_NOTEOFF             0x80   /* Note off */
157 #define SMF_NOTEON              0x90   /* Note on */
158 #define SMF_POLYPRESS           0xA0   /* Key polyphonic pressure */
159 #define SMF_CONTROLCHANGE       0xB0   /* Control change */
160 #define SMF_PROGRAMCHANGE       0xC0   /* Program change */
161 #define SMF_CANNELPRESS         0xD0   /* Channel pressure */
162 #define SMF_PITCHBEND           0xE0   /* Pitch bend */
163 #define SMF_SYSX                0xF0   /* Exclusive message */
164 #define SMF_MTC                 0xF1   /* MIDI time code */
165 #define SMF_SONGPOSITION        0xF2   /* Song position pointer */
166 #define SMF_SONGSELECT          0xF3   /* Song select */
167 #define SMF_UNDEFINED_F4        0xF4   /* Undefined */
168 #define SMF_UNDEFINED_F5        0xF5   /* Undefined */
169 #define SMF_TUNEREQUEST         0xF6   /* Tune request */
170 #define SMF_ENDOFSYSX           0xF7   /* End of exclusive */
171 #define SMF_TIMINGCLOCK         0xF8   /* Timing clock */
172 #define SMF_UNDEFINED_F9        0xF9   /* Undefined */
173 #define SMF_START               0xFA   /* Start */
174 #define SMF_CONTINUE            0xFB   /* Continue */
175 #define SMF_STOP                0xFC   /* Stop */
176 #define SMF_UNDEFINED_FD        0xFD   /* Undefined */
177 #define SMF_ACTIVESENSING       0xFE   /* Active sensing */
178 #define SMF_META                0xFF   /* Meta-event */
179 
180 #define SMF_META_SEQ_NUM        0x00   /* Sequence number */
181 #define SMF_META_TEXT           0x01   /* Text event */
182 #define SMF_META_COPYRIGHT      0x02   /* Display copyrights */
183 #define SMF_META_SEQ_NAME       0x03   /* Sequence name / track name */
184 #define SMF_META_INST_NAME      0x04   /* +Instrument name */
185 #define SMF_META_LYRIC          0x05   /* Lyrics */
186 #define SMF_META_MARKER         0x06   /* Marker */
187 #define SMF_META_QUE            0x07   /* Queue point */
188 #define SMF_META_PREFIX         0x20   /* Channel prefix */
189 #define SMF_META_ENDOFTRACK     0x2F   /* End of track */
190 #define SMF_META_TEMPO          0x51   /* Set tempo */
191 #define SMF_META_SMPTE          0x54   /* SMPTE offset */
192 #define SMF_META_BEAT           0x58   /* Tempo / Metronome settings */
193 #define SMF_META_KEY            0x59   /* Pitch */
194 #define SMF_META_OTHER          0x7F   /* Sequencer specific meta event */
195 
196 
197 #ifdef __cplusplus
198 extern "C" {
199 #endif
200 /*------------------------------------------------------------------*/
201 /* Structure Definitions                                                       */
202 /*------------------------------------------------------------------*/
203 
204 /* SMF chunk tag structure */
205 typedef struct tSMFChunkTag
206 {
207     char    chunkType[4];              /* Chunk type string (MThd, MTrk) */
208     unsigned long length;              /* Data length of the chunk */
209 }
210 SMFChunkTag;
211 
212 /* Header chunk structure. */
213 typedef struct tSMFHeaderChunk
214 {
215     unsigned short format;             /* File format */
216     unsigned short ntracks;            /* Track count */
217     unsigned short division;           /* Quarter note resolution. */
218 }
219 SMFHeaderChunk;
220 
221 
222 #ifdef __cplusplus
223 }      /* extern "C" */
224 #endif
225 
226 #endif // SMFDEFINE_H_
227