1 /* 2 * libInstPatch 3 * Copyright (C) 1999-2014 Element Green <element@elementsofsound.org> 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public License 7 * as published by the Free Software Foundation; version 2.1 8 * of the License only. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 * 02110-1301, USA or on the web at http://www.gnu.org. 19 */ 20 #ifndef __IPATCH_DLS2_CONN_H__ 21 #define __IPATCH_DLS2_CONN_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 27 /* forward type declarations */ 28 29 typedef struct _IpatchDLS2Conn IpatchDLS2Conn; 30 typedef struct _IpatchDLS2ConnInfo IpatchDLS2ConnInfo; 31 32 /* IpatchDLS2Conn has a GObject boxed type */ 33 #define IPATCH_TYPE_DLS2_CONN (ipatch_dls2_conn_get_type ()) 34 35 /* DLS2 connection (to set parameter values and define modulators) */ 36 struct _IpatchDLS2Conn 37 { 38 /*< public >*/ 39 guint16 src; /* source enum */ 40 guint16 ctrlsrc; /* second source enum */ 41 guint16 dest; /* destination enum */ 42 guint16 trans; /* transform enum */ 43 gint32 scale; /* scale value */ 44 }; 45 46 /* Compare two DLS connections to see if they are identical 47 (source, control and dest are identical) */ 48 #define IPATCH_DLS2_CONN_ARE_IDENTICAL(a, b) \ 49 ((a)->src == (b)->src && (a)->ctrlsrc == (b)->ctrlsrc \ 50 && (a)->dest == (b)->dest) 51 52 /* connection info and constraints structure */ 53 struct _IpatchDLS2ConnInfo 54 { 55 /*< public >*/ 56 guint16 type; /* IpatchDLS2ConnDestType */ 57 gint32 min; /* minimum value allowed */ 58 gint32 max; /* maximum value allowed */ 59 gint32 def; /* default value */ 60 int unit; /* #IpatchUnitType type */ 61 char *label; /* short descriptive label */ 62 char *descr; /* more complete description */ 63 }; 64 65 /* source connection types */ 66 typedef enum 67 { 68 IPATCH_DLS2_CONN_SRC_NONE = 0, /* No source */ 69 IPATCH_DLS2_CONN_SRC_LFO = 1, /* Modulation LFO */ 70 IPATCH_DLS2_CONN_SRC_VELOCITY = 2, /* MIDI Note-On velocity */ 71 IPATCH_DLS2_CONN_SRC_NOTE = 3, /* MIDI Note number */ 72 IPATCH_DLS2_CONN_SRC_EG1 = 4, /* Envelope Generator 1 */ 73 IPATCH_DLS2_CONN_SRC_EG2 = 5, /* Envelope Generator 2 */ 74 IPATCH_DLS2_CONN_SRC_PITCH_WHEEL = 6, /* Pitch Wheel */ 75 IPATCH_DLS2_CONN_SRC_POLY_PRESSURE = 7, /* Polyphonic pressure */ 76 IPATCH_DLS2_CONN_SRC_CHANNEL_PRESSURE = 8, /* Channel Pressure */ 77 IPATCH_DLS2_CONN_SRC_VIBRATO = 9, /* Vibrato LFO */ 78 79 /* defined MIDI controller sources */ 80 IPATCH_DLS2_CONN_SRC_CC1 = 0x0081, /* Modulation */ 81 IPATCH_DLS2_CONN_SRC_CC7 = 0x0087, /* Volume */ 82 IPATCH_DLS2_CONN_SRC_CC10 = 0x008A, /* Pan */ 83 IPATCH_DLS2_CONN_SRC_CC11 = 0x008B, /* Expression */ 84 IPATCH_DLS2_CONN_SRC_CC91 = 0x00DB, /* Chorus Send */ 85 IPATCH_DLS2_CONN_SRC_CC93 = 0x00DD, /* Reverb Send */ 86 87 /* MIDI registered parameter numbers */ 88 IPATCH_DLS2_CONN_SRC_RPN0 = 0x0100, /* Pitch bend range */ 89 IPATCH_DLS2_CONN_SRC_RPN1 = 0x0101, /* Fine tune */ 90 IPATCH_DLS2_CONN_SRC_RPN2 = 0x0102 /* Coarse tune */ 91 } IpatchDLS2ConnSrcType; 92 93 /* destination connection types */ 94 typedef enum 95 { 96 IPATCH_DLS2_CONN_DEST_NONE = 0, 97 IPATCH_DLS2_CONN_DEST_GAIN = 1, 98 IPATCH_DLS2_CONN_DEST_RESERVED = 2, 99 IPATCH_DLS2_CONN_DEST_PITCH = 3, 100 IPATCH_DLS2_CONN_DEST_PAN = 4, 101 IPATCH_DLS2_CONN_DEST_NOTE = 5, 102 103 IPATCH_DLS2_CONN_DEST_LEFT = 0x0010, 104 IPATCH_DLS2_CONN_DEST_RIGHT = 0x0011, 105 IPATCH_DLS2_CONN_DEST_CENTER = 0x0012, 106 IPATCH_DLS2_CONN_DEST_LFE_CHANNEL = 0x0013, 107 IPATCH_DLS2_CONN_DEST_LEFT_REAR = 0x0014, 108 IPATCH_DLS2_CONN_DEST_RIGHT_REAR = 0x0015, 109 110 IPATCH_DLS2_CONN_DEST_CHORUS = 0x0080, 111 IPATCH_DLS2_CONN_DEST_REVERB = 0x0081, 112 113 IPATCH_DLS2_CONN_DEST_LFO_FREQ = 0x0104, 114 IPATCH_DLS2_CONN_DEST_LFO_DELAY = 0x0105, 115 116 IPATCH_DLS2_CONN_DEST_VIB_FREQ = 0x0114, 117 IPATCH_DLS2_CONN_DEST_VIB_DELAY = 0x0115, 118 119 IPATCH_DLS2_CONN_DEST_EG1_ATTACK = 0x0206, 120 IPATCH_DLS2_CONN_DEST_EG1_DECAY = 0x0207, 121 IPATCH_DLS2_CONN_DEST_EG1_RESERVED = 0x0208, 122 IPATCH_DLS2_CONN_DEST_EG1_RELEASE = 0x0209, 123 IPATCH_DLS2_CONN_DEST_EG1_SUSTAIN = 0x020A, 124 IPATCH_DLS2_CONN_DEST_EG1_DELAY = 0x020B, 125 IPATCH_DLS2_CONN_DEST_EG1_HOLD = 0x020C, 126 IPATCH_DLS2_CONN_DEST_EG1_SHUTDOWN = 0x020D, 127 128 IPATCH_DLS2_CONN_DEST_EG2_ATTACK = 0x030A, 129 IPATCH_DLS2_CONN_DEST_EG2_DECAY = 0x030B, 130 IPATCH_DLS2_CONN_DEST_EG2_RESERVED = 0x030C, 131 IPATCH_DLS2_CONN_DEST_EG2_RELEASE = 0x030D, 132 IPATCH_DLS2_CONN_DEST_EG2_SUSTAIN = 0x030E, 133 IPATCH_DLS2_CONN_DEST_EG2_DELAY = 0x030F, 134 IPATCH_DLS2_CONN_DEST_EG2_HOLD = 0x0310, 135 136 IPATCH_DLS2_CONN_DEST_FILTER_CUTOFF = 0x0500, 137 IPATCH_DLS2_CONN_DEST_FILTER_Q = 0x0501 138 } IpatchDLS2ConnDestType; 139 140 #define IPATCH_DLS2_CONN_OUTPUT_TRANS_NONE 0 141 142 /* connection transform types */ 143 typedef enum 144 { 145 IPATCH_DLS2_CONN_TRANS_LINEAR = 0, 146 IPATCH_DLS2_CONN_TRANS_CONCAVE = 1, 147 IPATCH_DLS2_CONN_TRANS_CONVEX = 2, 148 IPATCH_DLS2_CONN_TRANS_SWITCH = 3 149 } IpatchDLS2ConnTransformType; 150 151 /* connection polarity types */ 152 typedef enum 153 { 154 IPATCH_DLS2_CONN_POLARITY_UNI = 0, 155 IPATCH_DLS2_CONN_POLARITY_BI = 1 156 } IpatchDLS2ConnPolarityType; 157 158 /* masks for IpatchDLS2Conn->trans field */ 159 typedef enum 160 { 161 IPATCH_DLS2_CONN_MASK_OUTPUT_TRANS = 0x000F, /* Output transform mask */ 162 IPATCH_DLS2_CONN_MASK_CTRLSRC_TRANS = 0x00F0, /* Control transform mask */ 163 IPATCH_DLS2_CONN_MASK_CTRLSRC_POLARITY = 0x0100, /* Control polarity mask */ 164 IPATCH_DLS2_CONN_MASK_CTRLSRC_INVERT = 0x0200, /* Control invert mask */ 165 IPATCH_DLS2_CONN_MASK_SRC_TRANS = 0x3C00, /* Source transform mask */ 166 IPATCH_DLS2_CONN_MASK_SRC_POLARITY = 0x4000, /* Source polarity mask */ 167 IPATCH_DLS2_CONN_MASK_SRC_INVERT = 0x8000 /* Source invert mask */ 168 } IpatchDLS2ConnTransformMasks; 169 170 /* bit shifts for IpatchDLS2Conn->trans field */ 171 typedef enum 172 { 173 IPATCH_DLS2_CONN_SHIFT_OUTPUT_TRANS = 0, /* Output transform shift */ 174 IPATCH_DLS2_CONN_SHIFT_CTRLSRC_TRANS = 4, /* Control transform shift */ 175 IPATCH_DLS2_CONN_SHIFT_CTRLSRC_POLARITY = 8, /* Control polarity shift */ 176 IPATCH_DLS2_CONN_SHIFT_CTRLSRC_INVERT = 9, /* Control invert shift */ 177 IPATCH_DLS2_CONN_SHIFT_SRC_TRANS = 10, /* Source transform shift */ 178 IPATCH_DLS2_CONN_SHIFT_SRC_POLARITY = 14, /* Source polarity shift */ 179 IPATCH_DLS2_CONN_SHIFT_SRC_INVERT = 15 /* Source invert shift */ 180 } IpatchDLS2ConnTransformShifts; 181 182 extern IpatchDLS2ConnInfo ipatch_dls2_conn_info[]; 183 184 GType ipatch_dls2_conn_get_type(void); 185 IpatchDLS2Conn *ipatch_dls2_conn_new(void); 186 void ipatch_dls2_conn_free(IpatchDLS2Conn *conn); 187 IpatchDLS2Conn *ipatch_dls2_conn_duplicate(const IpatchDLS2Conn *conn); 188 189 void ipatch_dls2_conn_list_set(GSList **list, const IpatchDLS2Conn *conn); 190 void ipatch_dls2_conn_list_unset(GSList **list, const IpatchDLS2Conn *conn); 191 GSList *ipatch_dls2_conn_list_duplicate(const GSList *list); 192 GSList *ipatch_dls2_conn_list_duplicate_fast(const GSList *list); 193 void ipatch_dls2_conn_list_free(GSList *list, gboolean free_conns); 194 195 #endif 196