1 /* $OpenBSD: sysex.h,v 1.2 2011/06/27 07:17:44 ratchov Exp $ */ 2 /* 3 * Copyright (c) 2011 Alexandre Ratchov <alex@caoua.org> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 #ifndef AUCAT_SYSEX_H 18 #define AUCAT_SYSEX_H 19 20 #include <stdint.h> 21 22 /* 23 * start and end markers 24 */ 25 #define SYSEX_START 0xf0 26 #define SYSEX_END 0xf7 27 28 /* 29 * type/vendor namespace IDs we use 30 */ 31 #define SYSEX_TYPE_RT 0x7f /* real-time universal */ 32 #define SYSEX_TYPE_EDU 0x7d /* non-comercial */ 33 34 /* 35 * realtime messages in the "universal real-time" namespace 36 */ 37 #define SYSEX_MTC 0x01 /* mtc messages */ 38 #define SYSEX_MTC_FULL 0x01 /* mtc full frame message */ 39 #define SYSEX_MMC 0x06 40 #define SYSEX_MMC_STOP 0x01 41 #define SYSEX_MMC_START 0x02 42 #define SYSEX_MMC_LOC 0x44 43 #define SYSEX_MMC_LOC_LEN 0x06 44 #define SYSEX_MMC_LOC_CMD 0x01 45 46 /* 47 * aucat-specific messages, in the "edu" namespace 48 */ 49 #define SYSEX_AUCAT 0x23 /* aucat-specific */ 50 #define SYSEX_AUCAT_MIXINFO 0x01 /* mixer info */ 51 #define SYSEX_AUCAT_DUMPREQ 0x02 /* dump request */ 52 #define SYSEX_AUCAT_DUMPEND 0x03 /* end of dump */ 53 54 /* 55 * minimum size of sysex message we accept 56 */ 57 #define SYSEX_SIZE(m) (5 + sizeof(struct sysex_ ## m)) 58 59 /* 60 * all possible system exclusive messages we support. For aucat-specific 61 * messages we use the same header as real-time messages to simplify the 62 * message parser 63 */ 64 struct sysex { 65 uint8_t start; 66 uint8_t type; /* type or vendor id */ 67 uint8_t dev; /* device or product id */ 68 uint8_t id0; /* message id */ 69 uint8_t id1; /* sub-id */ 70 union sysex_all { 71 struct sysex_empty { 72 uint8_t end; 73 } empty; 74 struct sysex_start { 75 uint8_t end; 76 } start; 77 struct sysex_stop { 78 uint8_t end; 79 } stop; 80 struct sysex_loc { 81 uint8_t len; 82 uint8_t cmd; 83 uint8_t hr; 84 uint8_t min; 85 uint8_t sec; 86 uint8_t fr; 87 uint8_t cent; 88 uint8_t end; 89 } loc; 90 struct sysex_full { 91 uint8_t hr; 92 uint8_t min; 93 uint8_t sec; 94 uint8_t fr; 95 uint8_t end; 96 } full; 97 struct sysex_mixinfo { 98 uint8_t chan; /* channel */ 99 uint8_t vol; /* current volume */ 100 #define SYSEX_NAMELEN 10 /* \0 included */ 101 uint8_t name[SYSEX_NAMELEN]; /* stream name */ 102 uint8_t end; 103 } mixinfo; 104 struct sysex_dumpreq { 105 uint8_t end; 106 } dumpreq; 107 struct sysex_dumpend { 108 uint8_t end; 109 } dumpend; 110 } u; 111 }; 112 113 #endif /* !defined(AUCAT_SYSEX_H) */ 114