home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 127.lha / Midi_1.5 / h / midi.h next >
Encoding:
C/C++ Source or Header  |  1986-11-21  |  7.4 KB  |  311 lines

  1. #ifndef MIDI_MIDI_H
  2. #define MIDI_MIDI_H
  3.  
  4. #ifndef EXEC_LISTS_H
  5.  #include <exec/lists.h>
  6. #endif
  7.  
  8. #ifndef EXEC_PORTS_H
  9.  #include <exec/ports.h>
  10. #endif
  11.  
  12. /*
  13.     Definitions pertaining to MIDI are derived from MIDI 1.0 Detailed
  14.     Specification (published by the Internation MIDI Association) and is
  15.     current as of 12-Feb-87 except where noted.
  16.  
  17.     v1.5 - 22-Apr-88
  18. */
  19.  
  20.  
  21. /* midi.library structures & defines */
  22.  
  23. #define MIDINAME    "midi.library"
  24. #define MIDIVERSION 2L
  25.  
  26.  
  27. struct MSource {
  28.     struct Node Node;
  29.     struct Image *Image;
  30.     struct MinList RPList;
  31.     APTR UserData;        /* user data extension */
  32. };
  33.  
  34. /* node types for Source */
  35. #define NT_MSOURCE    0x20
  36. #define NT_PERMMSOURCE    0x21
  37.  
  38. struct MDest {
  39.     struct Node Node;
  40.     struct Image *Image;
  41.     struct MinList RPList;
  42.     struct MsgPort *DestPort;
  43.     APTR UserData;        /* user data extension */
  44. };
  45.  
  46. /* node types for Dest */
  47. #define NT_MDEST    0x22
  48. #define NT_PERMMDEST    0x23
  49.  
  50.  
  51. /* Route Stuff */
  52.  
  53. #define RIM_MAXCOUNT 3
  54.  
  55. struct RIMatch {
  56.     UBYTE flags;        /* flag bits defined below */
  57.     UBYTE match[RIM_MAXCOUNT];
  58. };
  59.  
  60. #define RIMF_COUNTBITS 0x03    /* mask for # of match values (0 for match all) */
  61. #define RIMF_EXTID     0x40    /* indicates all 3 bytes of match[] == one 3 byte manuf. id (not valid for CtrlMatch) */
  62. #define RIMF_EXCLUDE   0x80    /* reverses logic of RIMatch so that all except those specified pass */
  63.  
  64.  
  65. struct MRouteInfo {
  66.     UWORD MsgFlags;
  67.     UWORD ChanFlags;
  68.     BYTE  ChanOffset;
  69.     BYTE  NoteOffset;
  70.     struct RIMatch SysExMatch;
  71.     struct RIMatch CtrlMatch;
  72. };
  73.  
  74. /* Msg Flags for MRouteInfo structure and returned by MidiMsgType */
  75.  
  76. #define MMF_CHAN    0x00ff
  77. #define MMF_NOTEOFF    0x0001
  78. #define MMF_NOTEON    0x0002
  79. #define MMF_POLYPRESS    0x0004
  80. #define MMF_CTRL    0x0008
  81. #define MMF_PROG    0x0010
  82. #define MMF_CHANPRESS    0x0020
  83. #define MMF_PITCHBEND    0x0040
  84. #define MMF_MODE    0x0080
  85.  
  86. #define MMF_SYSCOM    0x0100
  87. #define MMF_SYSRT    0x0200
  88. #define MMF_SYSEX    0x0400
  89.  
  90. struct MRoutePtr {
  91.     struct MinNode node;
  92.     struct MRoute *Route;
  93. };
  94.  
  95. struct MRoute {
  96.     struct MSource *Source;
  97.     struct MDest *Dest;
  98.     struct MRoutePtr SRoutePtr, DRoutePtr;
  99.     struct MRouteInfo RouteInfo;
  100. };
  101.  
  102.  
  103.  
  104. /* MIDI message defininition */
  105.  
  106. /* Status Bytes */
  107.  
  108.     /* Channel Voice Messages (1sssnnnn) */
  109. #define MS_NOTEOFF    0x80
  110. #define MS_NOTEON     0x90
  111. #define MS_POLYPRESS  0xA0
  112. #define MS_CTRL       0xB0
  113. #define MS_MODE       0xB0
  114. #define MS_PROG       0xC0
  115. #define MS_CHANPRESS  0xD0
  116. #define MS_PITCHBEND  0xE0
  117.  
  118.     /* System Common Messages */
  119. #define MS_SYSEX      0xF0
  120. #define MS_QTRFRAME   0xF1
  121. #define MS_SONGPOS    0xF2
  122. #define MS_SONGSELECT 0xF3
  123. #define MS_TUNEREQ    0xF6
  124. #define MS_EOX          0xF7
  125.  
  126.     /* System Real Time Messages */
  127. #define MS_CLOCK      0xF8
  128. #define MS_START      0xFA
  129. #define MS_CONTINUE   0xFB
  130. #define MS_STOP       0xFC
  131. #define MS_ACTVSENSE  0xFE
  132. #define MS_RESET      0xFF
  133.  
  134. /* Note Numbers */
  135.  
  136. #define MIDDLEC 60
  137.  
  138.  
  139. /* Standard Controllers */
  140.  
  141.     /* continuous 14 bit - MSB: 0-1f, LSB: 20-3f */
  142. #define MC_MODWHEEL  0x01
  143. #define MC_BREATH    0x02
  144. #define MC_FOOT      0x04
  145. #define MC_PORTATIME 0x05
  146. #define MC_DATAENTRY 0x06
  147. #define MC_VOLUME    0x07
  148. #define MC_BALANCE   0x08
  149. #define MC_PAN         0x0a
  150. #define MC_EXPRESSION 0x0b
  151. #define MC_GENERAL1  0x10
  152. #define MC_GENERAL2  0x11
  153. #define MC_GENERAL3  0x12
  154. #define MC_GENERAL4  0x13
  155.  
  156.     /* continuous 7 bit (switches: 0-3f=off, 40-7f=on) */
  157. #define MC_SUSTAIN   0x40
  158. #define MC_PORTA     0x41
  159. #define MC_SUSTENUTO 0x42
  160. #define MC_SOFTPEDAL 0x43
  161. #define MC_HOLD2     0x45
  162. #define MC_GENERAL5  0x50
  163. #define MC_GENERAL6  0x51
  164. #define MC_GENERAL7  0x52
  165. #define MC_GENERAL8  0x53
  166. #define MC_TREMOLODEPTH 0x5c
  167. #define MC_CHORUSDEPTH    0x5d
  168. #define MC_CELESTEDEPTH 0x5e
  169. #define MC_PHASERDEPTH    0x5f
  170.  
  171.     /* parameters */
  172. #define MC_DATAINCR  0x60
  173. #define MC_DATADECR  0x61
  174. #define MC_NRPNL     0x62
  175. #define MC_NRPNH     0x63
  176. #define MC_RPNL      0x64
  177. #define MC_RPNH      0x65
  178.  
  179.  
  180. /* Channel Modes */
  181. /* updated from IMA Bulletin V4 06 (July 87) */
  182.  
  183. #define MM_RESETCTRL 0x79
  184. #define MM_LOCAL     0x7a
  185. #define MM_ALLOFF    0x7b
  186. #define MM_OMNIOFF   0x7c
  187. #define MM_OMNION    0x7d
  188. #define MM_MONO      0x7e
  189. #define MM_POLY      0x7f
  190.  
  191.  
  192. /* Registered Parameter Numbers */
  193. /*
  194.     These are 16 bit values that need to be separated into two bytes for
  195.     use with the MC_RPNH & MC_RPNL messages using 8 bit math (hi = MRP_
  196.     >> 8, lo = MRP_ & 0xff) as opposed to 7 bit math.  This is done
  197.     so that the defines match the numbers from the MMA.  See MIDI 1.0
  198.     Detailed Spec p50 for more info.
  199.  
  200.     updated from IMA Bulletin V4 06 (July 87)
  201. */
  202.  
  203. #define MRP_PBSENS    0x0000
  204. #define MRP_FINETUNE    0x0001
  205. #define MRP_COURSETUNE    0x0002
  206.  
  207.  
  208. /* Sys/Ex ID numbers */
  209. /*
  210.     Now includes 3 byte extension for North America.  This new format
  211.     uses a 0x00 as the sys/ex id followed by two additional bytes that
  212.     actually identify the manufacturer.  These new extended id constants
  213.     are 16 bit values (as opposed to 14 bit) that you will have to break
  214.     apart yourself (like with the RPN's above).  Again, these are
  215.     defined this way so that they match the MMA's listings.
  216.  
  217.     The extended id's cannot be used in sys/ex number filtering (since it's
  218.     only designed to handle single byte id's).  You can however use the
  219.     MID_EXTENSION to filter only those manufactures that have one of the
  220.     new id's.
  221.  
  222.     updated from IMA Bulletin V4 10 (Nov 87)
  223. */
  224.  
  225.     /* North America */
  226. #define MID_EXTENSION 0x00
  227. #define MID_SEQUENTIAL 0x01
  228. #define MID_IDP      0x02
  229. #define MID_OCTAVEPLATEAU 0x03
  230. #define MID_MOOG     0x04
  231. #define MID_PASSPORT 0x05
  232. #define MID_LEXICON  0x06
  233. #define MID_KURZWEIL 0x07
  234. #define MID_FENDER   0x08
  235. #define MID_AKG      0x0a
  236. #define MID_VOYCE    0x0b
  237. #define MID_WAVEFRAME 0x0c
  238. #define MID_ADA      0x0d
  239. #define MID_GARFIELD 0x0e
  240. #define MID_ENSONIQ  0x0f
  241. #define MID_OBERHEIM 0x10
  242. #define MID_APPLE    0x11
  243. #define MID_GREYMATTER 0x12
  244. #define MID_PALMTREE 0x14
  245. #define MID_JLCOOPER 0x15
  246. #define MID_LOWREY   0x16
  247. #define MID_ADAMSSMITH 0x17
  248. #define MID_EMU      0x18
  249. #define MID_HARMONY  0x19
  250. #define MID_ART      0x1a
  251. #define MID_BALDWIN  0x1b
  252. #define MID_EVENTIDE 0x1c
  253. #define MID_INVENTRONICS 0x1d
  254. #define MID_CLARITY  0x1f
  255.  
  256. #define MIDX_PERFECTFRET 0x0014
  257.  
  258.     /* Europe */
  259. #define MID_SIEL     0x21
  260. #define MID_SYNTHAXE 0x22
  261. #define MID_STEPP    0x23
  262. #define MID_HOHNER   0x24
  263. #define MID_TWISTER  0x25
  264. #define MID_SOLTON   0x26
  265. #define MID_JELLINGHAUS 0x27
  266. #define MID_SOUTHWORTH 0x28
  267. #define MID_PPG      0x29
  268. #define MID_JEN      0x2a
  269. #define MID_SSL      0x2b
  270. #define MID_AUDIOVERITRIEB 0x2c
  271. #define MID_ELKA     0x2f
  272. #define MID_DYNACORD 0x30
  273.  
  274.     /* Japan */
  275. #define MID_KAWAI    0x40
  276. #define MID_ROLAND   0x41
  277. #define MID_KORG     0x42
  278. #define MID_YAMAHA   0x43
  279. #define MID_CASIO    0x44
  280. #define MID_KAMIYA   0x46
  281. #define MID_AKAI     0x47
  282. #define MID_JAPANVICTOR 0x48
  283. #define MID_MESOSHA  0x49
  284.  
  285. /* special Sys/Ex ID numbers: Non-Commercial, Non-Real Time, Real Time */
  286. #define MID_NC    0x7d
  287. #define MID_NRT 0x7e
  288. #define MID_RT    0x7f
  289.  
  290.  
  291. /* handy macros */
  292.  
  293.     /* pack high/low bytes of a word into midi format (7/14 bit math) */
  294. #define MIDI_HIBYTE(word) ( (word) >> 7 & 0x7f )
  295. #define MIDI_LOBYTE(word) ( (word) & 0x7f )
  296.  
  297.     /* unpack 2 midi bytes into a word (7/14 bit math) */
  298. #define MIDI_WORD(hi,lo) ( (hi & 0x7f) << 7 | (lo & 0x7f) )
  299.  
  300.  
  301. /* midi.library routine declarations */
  302.  
  303. struct MSource *CreateMSource(), *FindMSource();
  304. struct MDest *CreateMDest(), *FindMDest();
  305. struct MRoute *CreateMRoute(), *MRouteSource(), *MRouteDest(), *MRoutePublic();
  306. UBYTE *GetMidiMsg();
  307. BOOL PutMidiMsg();
  308. ULONG MidiMsgLength(), MidiMsgType();
  309.  
  310. #endif
  311.