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 >
Wrap
C/C++ Source or Header
|
1991-08-27
|
4KB
|
95 lines
/*
* Copyright (c) 1990-1991 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Lawrence Berkeley Laboratory,
* Berkeley, CA. The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: midi.h,v 1.4 91/08/27 00:37:04 mccanne Exp $ (LBL)
*/
/*
* The midi_msg structure below is used to communicate with the driver.
* Each struct element must be a whole midi message, with the first byte
* being a midi command. The driver looks at the command to know how many
* remaining bytes to output. Redundant status bytes are will be pruned
* from the output stream. System exclusives (mm_data[0] == 0xf0) are
* formed by "extending" the mm_data field beyond the end of the struct
* to an eight byte multiple. The message must be terminated by EOX (0xf7)
* and can be at most BMD_MAXMSGLEN bytes in length. (Longer sysexs
* cannot possibly be real-time and therefore really shouldn't be using
* this driver. Patch dumps etc. should just read and write the raw device.)
*
* On the read side, whole messages are also returned. The midi command
* byte is always in mm_data[0]. Sysexs are laid out as above, and
* are truncated to BMD_MAXMSGLEN bytes.
*/
#define BMD_MAXMSGLEN 60
struct midi_msg {
u_long mm_time;
u_char mm_data[4];
#define mm_cmd mm_data[0]
};
struct midibuf {
u_long mm_time;
u_char mm_data[BMD_MAXMSGLEN];
};
/*
* Ioctls. You need to include <ioctl.h>.
*/
#if defined(sun) && !defined(__STDC__)
#define BMDGTIME _IOR(Q, 0, u_long)
#define BMDSTIME _IOW(Q, 1, u_long)
#define BMDFLUSH _IO(Q, 2)
#define BMDRATE _IOWR(Q, 3, u_int)
#define BMDFILTER _IOW(Q, 4, u_long)
#define BMDPAUSE _IO(Q, 5)
#define BMDRESUME _IO(Q, 6)
#define BMDNWRITE _IOR(Q, 7, u_int)
#define BMDECHO _IOW(Q, 8, u_int)
#define BMDATTACH _IOW(Q, 9, u_int)
#define BMDNBUF _IOWR(Q, 10, u_int)
#define BMDWLO _IOWR(Q, 11, u_int)
#else
#define BMDGTIME _IOR('Q', 0, u_long)
#define BMDSTIME _IOW('Q', 1, u_long)
#define BMDFLUSH _IO('Q', 2)
#define BMDRATE _IOWR('Q', 3, u_int)
#define BMDFILTER _IOW('Q', 4, u_long)
#define BMDPAUSE _IO('Q', 5)
#define BMDRESUME _IO('Q', 6)
#define BMDNWRITE _IOR('Q', 7, u_int)
#define BMDECHO _IOW('Q', 8, u_int)
#define BMDATTACH _IOW('Q', 9, u_int)
#define BMDNBUF _IOWR('Q', 10, u_int)
#define BMDWLO _IOWR('Q', 11, u_int)
#endif
#define MIDIMASK(c) ((c)<0xf0?(1<<((c)>>4)):((0x10000<<((c)&0xf)))|0x8000)
#define BMD_FILTER MIDIMASK(0xfe)
#define BMDCHUNK sizeof(struct midi_msg)
#define BMDALIGN(off) ((off + (BMDCHUNK-1)) & ~(BMDCHUNK-1))
/*
* Comparison macros that bypass wraparound.
* We assume we're comparing two timestamps that are
* within MAXINT/2 ticks of eachother.
*/
#define BMD_TGT(t1, t2) ((long)(t1 - t2) > 0)
#define BMD_TGE(t1, t2) ((long)(t1 - t2) >= 0)
#define BMD_TLT(t1, t2) ((long)(t1 - t2) < 0)
#define BMD_TLE(t1, t2) ((long)(t1 - t2) <= 0)