1 /* 2 * libInstPatch 3 * Copyright (C) 1999-2014 Element Green <element@elementsofsound.org> 4 * 5 * Author of this file: (C) 2012 BALATON Zoltan <balaton@eik.bme.hu> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public License 9 * as published by the Free Software Foundation; version 2.1 10 * of the License only. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 * 02110-1301, USA or on the web at http://www.gnu.org. 21 */ 22 #ifndef __IPATCH_SLI_FILE_PRIV_H__ 23 #define __IPATCH_SLI_FILE_PRIV_H__ 24 25 #include <glib.h> 26 27 /* forward type declarations */ 28 29 typedef struct _IpatchSLISiFi IpatchSLISiFi; 30 typedef struct _IpatchSLISiIg IpatchSLISiIg; 31 typedef struct _IpatchSLIInstHeader IpatchSLIInstHeader; 32 typedef struct _IpatchSLIZoneParams IpatchSLIZoneParams; 33 typedef struct _IpatchSLIModParams IpatchSLIModParams; 34 typedef struct _IpatchSLIZoneHeader IpatchSLIZoneHeader; 35 typedef struct _IpatchSLISampleHeader IpatchSLISampleHeader; 36 typedef struct _IpatchSLISiDp IpatchSLISiDp; 37 38 /* Spectralis file header */ 39 struct _IpatchSLISiFi 40 { 41 guint32 ckid; /* chunk id 'SiFi' */ 42 guint32 cklen; /* chunk (whole file - 8) length */ 43 guint16 spechdr; /* version? always 0x100 */ 44 guint16 unused; /* 0 */ 45 guint16 ignum; /* number of instrument groups */ 46 guint16 igstart_offs; /* offset in file for start of inst. groups */ 47 }; 48 49 /* Spectralis instrument group header */ 50 struct _IpatchSLISiIg 51 { 52 guint32 ckid; /* chunk id 'SiIg' */ 53 guint32 cklen; /* number of bytes in chunk */ 54 guint16 spechdr; /* version? always 0x100 */ 55 guint16 unused1; /* 0 */ 56 guint16 inst_offs; /* offset in chunk for start of inst. headers */ 57 guint16 instnum; /* number of instruments in group */ 58 guint16 zones_offs; /* offset to zone headers */ 59 guint16 allzones_num; /* total number of zones in group */ 60 guint16 smphdr_offs; /* offset to sample headers */ 61 guint16 maxzones_num; /* largest number of zones in one inst */ 62 guint16 smpdata_offs; /* offset to start of sample data */ 63 guint16 unused2; /* 0 */ 64 }; 65 66 /* Spectralis instrument header */ 67 struct _IpatchSLIInstHeader 68 { 69 char name[24]; /* name of instrument */ 70 guint32 sound_id; /* unique? id of the instrument */ 71 guint32 unused1; /* 0 */ 72 guint16 category; /* category code for sub and main category */ 73 guint16 unused2; /* 0 */ 74 guint16 zone_idx; /* index of first zone header for this inst. */ 75 guint16 zones_num; /* number of zones for this inst. */ 76 }; 77 78 /* Spectralis zone params */ 79 struct _IpatchSLIZoneParams 80 { 81 guint8 keyrange_low; 82 guint8 keyrange_high; 83 guint8 velrange_low; 84 guint8 velrange_high; 85 guint32 start_offs1; 86 guint32 start_offs2; 87 guint32 unknown1; 88 guint32 unknown2; 89 gint8 coarse_tune1; 90 gint8 fine_tune1; 91 guint8 sample_modes; 92 gint8 root_note; 93 guint16 scale_tuning; 94 gint8 coarse_tune2; 95 gint8 fine_tune2; 96 }; 97 98 /* Spectralis mod params */ 99 struct _IpatchSLIModParams 100 { 101 gint16 modLfoToPitch; 102 gint16 vibLfoToPitch; 103 gint16 modEnvToPitch; 104 guint16 initialFilterFc; 105 guint16 initialFilterQ; 106 gint16 modLfoToFilterFc; 107 gint16 modEnvToFilterFc; 108 gint16 modLfoToVolume; 109 gint16 freqModLfo; 110 gint16 freqVibLfo; 111 guint16 sustainModEnv; 112 gint16 keynumToModEnvHold; 113 gint16 keynumToModEnvDecay; 114 guint16 sustainVolEnv; 115 gint16 keynumToVolEnvHold; 116 gint16 keynumToVolEnvDecay; 117 gint8 pan; 118 gint8 delayModLfo; 119 gint8 delayVibLfo; 120 gint8 attackModEnv; 121 gint8 holdModEnv; 122 gint8 decayModEnv; 123 gint8 releaseModEnv; 124 gint8 attackVolEnv; 125 gint8 holdVolEnv; 126 gint8 decayVolEnv; 127 gint8 releaseVolEnv; 128 guint8 initialAttenuation; 129 }; 130 131 /* Spectralis Zone header */ 132 struct _IpatchSLIZoneHeader 133 { 134 IpatchSLIZoneParams zone_params; 135 IpatchSLIModParams mod_params; 136 guint16 sample_idx; 137 guint16 unused; 138 }; 139 140 /* Spectralis file sample header */ 141 struct _IpatchSLISampleHeader 142 { 143 char name[24]; /* sample name */ 144 guint32 start; /* offset to start of sample */ 145 guint32 end; /* offset to end of sample */ 146 guint32 loop_start; /* offset to start of loop */ 147 guint32 loop_end; /* offset to end of loop */ 148 gint8 fine_tune; /* pitch correction in cents */ 149 guint8 root_note; /* root midi note number */ 150 guint8 channels; /* number of channels */ 151 guint8 bits_per_sample; /* number of bits per sample */ 152 guint32 sample_rate; /* sample rate recorded at */ 153 }; 154 155 /* Spectralis Instrument End header */ 156 struct _IpatchSLISiDp 157 { 158 guint32 ckid; /* chunk id 'SiDp' */ 159 guint32 cklen; /* number of bytes in chunk */ 160 guint16 spechdr; /* version? always 0x100 */ 161 guint16 unused; /* 0 */ 162 }; 163 164 165 /* Spectralis chunk FOURCC guint32 integers */ 166 #define IPATCH_SLI_FOURCC_SIFI IPATCH_FOURCC ('S','i','F','i') 167 #define IPATCH_SLI_FOURCC_SIIG IPATCH_FOURCC ('S','i','I','g') 168 #define IPATCH_SLI_FOURCC_SIDP IPATCH_FOURCC ('S','i','D','p') 169 170 #define IPATCH_SLI_SPECHDR_VAL 0x100 171 172 /* Spectralis file chunk sizes */ 173 #define IPATCH_SLI_SIFI_SIZE 8 /* file info header size (w/o RIFF header) */ 174 #define IPATCH_SLI_SIIG_SIZE 28 /* inst. group header size */ 175 #define IPATCH_SLI_INST_SIZE 40 /* instrument header size */ 176 #define IPATCH_SLI_ZONE_SIZE 76 /* zone params header size */ 177 #define IPATCH_SLI_SMPL_SIZE 48 /* sample data header size */ 178 #define IPATCH_SLI_SIDP_SIZE 12 /* instrument terminator size */ 179 #define IPATCH_SLI_HEAD_SIZE 64*1024 /* maximal size of headers */ 180 181 #endif 182