Annotation of sys/sys/midiio.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: midiio.h,v 1.3 2005/12/13 00:35:23 millert Exp $ */
! 2: /* $NetBSD: midiio.h,v 1.7 1998/11/25 22:17:07 augustss Exp $ */
! 3:
! 4: /*-
! 5: * Copyright (c) 1998 The NetBSD Foundation, Inc.
! 6: * All rights reserved.
! 7: *
! 8: * This code is derived from software contributed to The NetBSD Foundation
! 9: * by Lennart Augustsson (augustss@netbsd.org).
! 10: *
! 11: * Redistribution and use in source and binary forms, with or without
! 12: * modification, are permitted provided that the following conditions
! 13: * are met:
! 14: * 1. Redistributions of source code must retain the above copyright
! 15: * notice, this list of conditions and the following disclaimer.
! 16: * 2. Redistributions in binary form must reproduce the above copyright
! 17: * notice, this list of conditions and the following disclaimer in the
! 18: * documentation and/or other materials provided with the distribution.
! 19: * 3. All advertising materials mentioning features or use of this software
! 20: * must display the following acknowledgement:
! 21: * This product includes software developed by the NetBSD
! 22: * Foundation, Inc. and its contributors.
! 23: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 24: * contributors may be used to endorse or promote products derived
! 25: * from this software without specific prior written permission.
! 26: *
! 27: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
! 28: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 29: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 30: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
! 31: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 32: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 33: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 34: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 35: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 36: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 37: * POSSIBILITY OF SUCH DAMAGE.
! 38: */
! 39:
! 40: #ifndef _SYS_MIDIIO_H_
! 41: #define _SYS_MIDIIO_H_
! 42:
! 43: /*
! 44: * The API defined here is compatible with the OSS MIDI API except
! 45: * for naming.
! 46: */
! 47:
! 48: #include <sys/cdefs.h>
! 49: #include <machine/endian.h> /* for _QUAD_LOWWORD */
! 50:
! 51: /*
! 52: * ioctl() commands for /dev/midi##
! 53: */
! 54: typedef struct {
! 55: unsigned char cmd;
! 56: char nr_args, nr_returns;
! 57: unsigned char data[30];
! 58: } mpu_command_rec;
! 59:
! 60: #define MIDI_PRETIME _IOWR('m', 0, int)
! 61: #define MIDI_MPUMODE _IOWR('m', 1, int)
! 62: #define MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec)
! 63:
! 64:
! 65: /* The MPU401 command acknowledge and active sense command */
! 66: #define MIDI_ACK 0xfe
! 67:
! 68:
! 69: /* Sequencer */
! 70: #define SEQUENCER_RESET _IO ('Q', 0)
! 71: #define SEQUENCER_SYNC _IO ('Q', 1)
! 72: #define SEQUENCER_INFO _IOWR('Q', 2, struct synth_info)
! 73: #define SEQUENCER_CTRLRATE _IOWR('Q', 3, int)
! 74: #define SEQUENCER_GETOUTCOUNT _IOR ('Q', 4, int)
! 75: #define SEQUENCER_GETINCOUNT _IOR ('Q', 5, int)
! 76: /*#define SEQUENCER_PERCMODE _IOW ('Q', 6, int)*/
! 77: /*#define SEQUENCER_TESTMIDI _IOW ('Q', 8, int)*/
! 78: #define SEQUENCER_RESETSAMPLES _IOW ('Q', 9, int)
! 79: #define SEQUENCER_NRSYNTHS _IOR ('Q',10, int)
! 80: #define SEQUENCER_NRMIDIS _IOR ('Q',11, int)
! 81: /*#define SEQUENCER_MIDI_INFO _IOWR('Q',12, struct midi_info)*/
! 82: #define SEQUENCER_THRESHOLD _IOW ('Q',13, int)
! 83: #define SEQUENCER_MEMAVL _IOWR('Q',14, int)
! 84: /*#define SEQUENCER_FM_4OP_ENABLE _IOW ('Q',15, int)*/
! 85: #define SEQUENCER_PANIC _IO ('Q',17)
! 86: #define SEQUENCER_OUTOFBAND _IOW ('Q',18, struct seq_event_rec)
! 87: #define SEQUENCER_GETTIME _IOR ('Q',19, int)
! 88: /*#define SEQUENCER_ID _IOWR('Q',20, struct synth_info)*/
! 89: /*#define SEQUENCER_CONTROL _IOWR('Q',21, struct synth_control)*/
! 90: /*#define SEQUENCER_REMOVESAMPLE _IOWR('Q',22, struct remove_sample)*/
! 91:
! 92: #if 0
! 93: typedef struct synth_control {
! 94: int devno; /* Synthesizer # */
! 95: char data[4000]; /* Device specific command/data record */
! 96: } synth_control;
! 97:
! 98: typedef struct remove_sample {
! 99: int devno; /* Synthesizer # */
! 100: int bankno; /* MIDI bank # (0=General MIDI) */
! 101: int instrno; /* MIDI instrument number */
! 102: } remove_sample;
! 103: #endif
! 104:
! 105: #define CMDSIZE 8
! 106: typedef struct seq_event_rec {
! 107: u_char arr[CMDSIZE];
! 108: } seq_event_rec;
! 109:
! 110: struct synth_info {
! 111: char name[30];
! 112: int device;
! 113: int synth_type;
! 114: #define SYNTH_TYPE_FM 0
! 115: #define SYNTH_TYPE_SAMPLE 1
! 116: #define SYNTH_TYPE_MIDI 2
! 117:
! 118: int synth_subtype;
! 119: #define SYNTH_SUB_FM_TYPE_ADLIB 0x00
! 120: #define SYNTH_SUB_FM_TYPE_OPL3 0x01
! 121: #define SYNTH_SUB_MIDI_TYPE_MPU401 0x401
! 122:
! 123: #define SYNTH_SUB_SAMPLE_TYPE_BASIC 0x10
! 124: #define SYNTH_SUB_SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
! 125:
! 126: int nr_voices;
! 127: int instr_bank_size;
! 128: u_int capabilities;
! 129: #define SYNTH_CAP_OPL3 0x00000002
! 130: #define SYNTH_CAP_INPUT 0x00000004
! 131: };
! 132:
! 133: /* Sequencer timer */
! 134: #define SEQUENCER_TMR_TIMEBASE _IOWR('T', 1, int)
! 135: #define SEQUENCER_TMR_START _IO ('T', 2)
! 136: #define SEQUENCER_TMR_STOP _IO ('T', 3)
! 137: #define SEQUENCER_TMR_CONTINUE _IO ('T', 4)
! 138: #define SEQUENCER_TMR_TEMPO _IOWR('T', 5, int)
! 139: #define SEQUENCER_TMR_SOURCE _IOWR('T', 6, int)
! 140: # define SEQUENCER_TMR_INTERNAL 0x00000001
! 141: #if 0
! 142: # define SEQUENCER_TMR_EXTERNAL 0x00000002
! 143: # define SEQUENCER_TMR_MODE_MIDI 0x00000010
! 144: # define SEQUENCER_TMR_MODE_FSK 0x00000020
! 145: # define SEQUENCER_TMR_MODE_CLS 0x00000040
! 146: # define SEQUENCER_TMR_MODE_SMPTE 0x00000080
! 147: #endif
! 148: #define SEQUENCER_TMR_METRONOME _IOW ('T', 7, int)
! 149: #define SEQUENCER_TMR_SELECT _IOW ('T', 8, int)
! 150:
! 151:
! 152: #define MIDI_CTRL_ALLOFF 123
! 153: #define MIDI_CTRL_RESET 121
! 154: #define MIDI_BEND_NEUTRAL (1<<13)
! 155:
! 156: #define MIDI_NOTEOFF 0x80
! 157: #define MIDI_NOTEON 0x90
! 158: #define MIDI_KEY_PRESSURE 0xA0
! 159: #define MIDI_CTL_CHANGE 0xB0
! 160: #define MIDI_PGM_CHANGE 0xC0
! 161: #define MIDI_CHN_PRESSURE 0xD0
! 162: #define MIDI_PITCH_BEND 0xE0
! 163: #define MIDI_SYSTEM_PREFIX 0xF0
! 164:
! 165: #define MIDI_IS_STATUS(d) ((d) >= 0x80)
! 166: #define MIDI_IS_COMMON(d) ((d) >= 0xf0)
! 167:
! 168: #define MIDI_SYSEX_START 0xF0
! 169: #define MIDI_SYSEX_END 0xF7
! 170:
! 171: #define MIDI_GET_STATUS(d) ((d) & 0xf0)
! 172: #define MIDI_GET_CHAN(d) ((d) & 0x0f)
! 173:
! 174: #define MIDI_HALF_VEL 64
! 175:
! 176: #define SEQ_LOCAL 0x80
! 177: #define SEQ_TIMING 0x81
! 178: #define SEQ_CHN_COMMON 0x92
! 179: #define SEQ_CHN_VOICE 0x93
! 180: #define SEQ_SYSEX 0x94
! 181: #define SEQ_FULLSIZE 0xfd
! 182:
! 183: #define SEQ_MK_CHN_VOICE(e, unit, cmd, chan, key, vel) (\
! 184: (e)->arr[0] = SEQ_CHN_VOICE, (e)->arr[1] = (unit), (e)->arr[2] = (cmd),\
! 185: (e)->arr[3] = (chan), (e)->arr[4] = (key), (e)->arr[5] = (vel),\
! 186: (e)->arr[6] = 0, (e)->arr[7] = 0)
! 187: #define SEQ_MK_CHN_COMMON(e, unit, cmd, chan, p1, p2, w14) (\
! 188: (e)->arr[0] = SEQ_CHN_COMMON, (e)->arr[1] = (unit), (e)->arr[2] = (cmd),\
! 189: (e)->arr[3] = (chan), (e)->arr[4] = (p1), (e)->arr[5] = (p2),\
! 190: *(short *)&(e)->arr[6] = (w14))
! 191:
! 192: #if _QUAD_LOWWORD == 1
! 193: /* big endian */
! 194: #define SEQ_PATCHKEY(id) (0xfd00|id)
! 195: #else
! 196: /* little endian */
! 197: #define SEQ_PATCHKEY(id) ((id<<8)|0xfd)
! 198: #endif
! 199: struct sysex_info {
! 200: u_int16_t key; /* Use SYSEX_PATCH or MAUI_PATCH here */
! 201: #define SEQ_SYSEX_PATCH SEQ_PATCHKEY(0x05)
! 202: #define SEQ_MAUI_PATCH SEQ_PATCHKEY(0x06)
! 203: int16_t device_no; /* Synthesizer number */
! 204: int32_t len; /* Size of the sysex data in bytes */
! 205: u_char data[1]; /* Sysex data starts here */
! 206: };
! 207: #define SEQ_SYSEX_HDRSIZE ((u_long)((struct sysex_info *)0)->data)
! 208:
! 209: typedef unsigned char sbi_instr_data[32];
! 210: struct sbi_instrument {
! 211: u_int16_t key; /* FM_PATCH or OPL3_PATCH */
! 212: #define SBI_FM_PATCH SEQ_PATCHKEY(0x01)
! 213: #define SBI_OPL3_PATCH SEQ_PATCHKEY(0x03)
! 214: int16_t device;
! 215: int32_t channel;
! 216: sbi_instr_data operators;
! 217: };
! 218:
! 219: #define TMR_RESET 0
! 220: #define TMR_WAIT_REL 1 /* Time relative to the prev time */
! 221: #define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */
! 222: #define TMR_STOP 3
! 223: #define TMR_START 4
! 224: #define TMR_CONTINUE 5
! 225: #define TMR_TEMPO 6
! 226: #define TMR_ECHO 8
! 227: #define TMR_CLOCK 9 /* MIDI clock */
! 228: #define TMR_SPP 10 /* Song position pointer */
! 229: #define TMR_TIMESIG 11 /* Time signature */
! 230:
! 231: /* Old sequencer definitions */
! 232: #define SEQOLD_CMDSIZE 4
! 233:
! 234: #define SEQOLD_NOTEOFF 0
! 235: #define SEQOLD_NOTEON 1
! 236: #define SEQOLD_WAIT TMR_WAIT_ABS
! 237: #define SEQOLD_PGMCHANGE 3
! 238: #define SEQOLD_SYNCTIMER TMR_START
! 239: #define SEQOLD_MIDIPUTC 5
! 240: #define SEQOLD_ECHO TMR_ECHO
! 241: #define SEQOLD_AFTERTOUCH 9
! 242: #define SEQOLD_CONTROLLER 10
! 243: #define SEQOLD_PRIVATE 0xfe
! 244: #define SEQOLD_EXTENDED 0xff
! 245:
! 246: #endif /* !_SYS_MIDIIO_H_ */
CVSweb