home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / bmd-1.0beta.tar.Z / bmd-1.0beta.tar / bmd-1.0beta / sundev / midi.h < prev    next >
C/C++ Source or Header  |  1991-08-27  |  4KB  |  95 lines

  1. /*
  2.  * Copyright (c) 1990-1991 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Lawrence Berkeley Laboratory,
  11.  * Berkeley, CA.  The name of the University may not be used to
  12.  * endorse or promote products derived from this software without
  13.  * specific prior written permission.
  14.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17.  *
  18.  * @(#) $Header: midi.h,v 1.4 91/08/27 00:37:04 mccanne Exp $ (LBL)
  19.  */
  20.  
  21.  
  22. /*
  23.  * The midi_msg structure below is used to communicate with the driver.
  24.  * Each struct element must be a whole midi message, with the first byte
  25.  * being a midi command.  The driver looks at the command to know how many
  26.  * remaining bytes to output.  Redundant status bytes are will be pruned
  27.  * from the output stream.  System exclusives (mm_data[0] == 0xf0) are
  28.  * formed by "extending" the mm_data field beyond the end of the struct
  29.  * to an eight byte multiple.  The message must be terminated by EOX (0xf7)
  30.  * and can be at most BMD_MAXMSGLEN bytes in length.  (Longer sysexs
  31.  * cannot possibly be real-time and therefore really shouldn't be using
  32.  * this driver.  Patch dumps etc. should just read and write the raw device.)
  33.  *
  34.  * On the read side, whole messages are also returned.  The midi command
  35.  * byte is always in mm_data[0].  Sysexs are laid out as above, and
  36.  * are truncated to BMD_MAXMSGLEN bytes.
  37.  */
  38. #define BMD_MAXMSGLEN 60
  39. struct midi_msg {
  40.     u_long mm_time;
  41.     u_char mm_data[4];
  42. #define mm_cmd mm_data[0]
  43. };
  44. struct midibuf {
  45.     u_long mm_time;
  46.     u_char mm_data[BMD_MAXMSGLEN];
  47. };
  48.  
  49. /*
  50.  * Ioctls.  You need to include <ioctl.h>.
  51.  */
  52. #if defined(sun) && !defined(__STDC__)
  53. #define BMDGTIME     _IOR(Q, 0, u_long)
  54. #define BMDSTIME     _IOW(Q, 1, u_long)
  55. #define BMDFLUSH     _IO(Q, 2)
  56. #define BMDRATE     _IOWR(Q, 3, u_int)
  57. #define BMDFILTER     _IOW(Q, 4, u_long)
  58. #define BMDPAUSE    _IO(Q, 5)
  59. #define BMDRESUME    _IO(Q, 6)
  60. #define BMDNWRITE    _IOR(Q, 7, u_int)
  61. #define BMDECHO        _IOW(Q, 8, u_int)
  62. #define BMDATTACH    _IOW(Q, 9, u_int)
  63. #define BMDNBUF        _IOWR(Q, 10, u_int)
  64. #define BMDWLO        _IOWR(Q, 11, u_int)
  65. #else
  66. #define BMDGTIME     _IOR('Q', 0, u_long)
  67. #define BMDSTIME     _IOW('Q', 1, u_long)
  68. #define BMDFLUSH     _IO('Q', 2)
  69. #define BMDRATE     _IOWR('Q', 3, u_int)
  70. #define BMDFILTER     _IOW('Q', 4, u_long)
  71. #define BMDPAUSE    _IO('Q', 5)
  72. #define BMDRESUME    _IO('Q', 6)
  73. #define BMDNWRITE    _IOR('Q', 7, u_int)
  74. #define BMDECHO        _IOW('Q', 8, u_int)
  75. #define BMDATTACH    _IOW('Q', 9, u_int)
  76. #define BMDNBUF        _IOWR('Q', 10, u_int)
  77. #define BMDWLO        _IOWR('Q', 11, u_int)
  78. #endif
  79.  
  80. #define MIDIMASK(c) ((c)<0xf0?(1<<((c)>>4)):((0x10000<<((c)&0xf)))|0x8000)
  81. #define BMD_FILTER MIDIMASK(0xfe)
  82.  
  83. #define BMDCHUNK sizeof(struct midi_msg)
  84. #define BMDALIGN(off)    ((off + (BMDCHUNK-1)) & ~(BMDCHUNK-1))
  85.  
  86. /*
  87.  * Comparison macros that bypass wraparound.
  88.  * We assume we're comparing two timestamps that are
  89.  * within MAXINT/2 ticks of eachother.
  90.  */
  91. #define BMD_TGT(t1, t2) ((long)(t1 - t2) > 0)
  92. #define BMD_TGE(t1, t2) ((long)(t1 - t2) >= 0)
  93. #define BMD_TLT(t1, t2) ((long)(t1 - t2) < 0)
  94. #define BMD_TLE(t1, t2) ((long)(t1 - t2) <= 0)
  95.