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_SF2_H__ 21 #define __IPATCH_SF2_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 #include <libinstpatch/IpatchBase.h> 26 #include <libinstpatch/IpatchSF2Preset.h> 27 #include <libinstpatch/IpatchSF2Inst.h> 28 #include <libinstpatch/IpatchSF2Sample.h> 29 #include <libinstpatch/IpatchSF2File.h> 30 31 /* forward type declarations */ 32 33 typedef struct _IpatchSF2 IpatchSF2; 34 typedef struct _IpatchSF2Class IpatchSF2Class; 35 36 #define IPATCH_TYPE_SF2 (ipatch_sf2_get_type ()) 37 #define IPATCH_SF2(obj) \ 38 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPATCH_TYPE_SF2, IpatchSF2)) 39 #define IPATCH_SF2_CLASS(klass) \ 40 (G_TYPE_CHECK_CLASS_CAST ((klass), IPATCH_TYPE_SF2, IpatchSF2Class)) 41 #define IPATCH_IS_SF2(obj) \ 42 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPATCH_TYPE_SF2)) 43 #define IPATCH_IS_SF2_CLASS(klass) \ 44 (G_TYPE_CHECK_CLASS_TYPE ((klass), IPATCH_TYPE_SF2)) 45 #define IPATCH_SF2_GET_CLASS(obj) \ 46 (G_TYPE_INSTANCE_GET_CLASS ((obj), IPATCH_TYPE_SF2, IpatchSF2Class)) 47 48 /* SoundFont object */ 49 struct _IpatchSF2 50 { 51 /*< public >*/ 52 IpatchBase parent_instance; 53 54 guint16 ver_major, ver_minor; /* SoundFont version */ 55 guint16 romver_major, romver_minor; /* ROM version (if any) */ 56 57 GHashTable *info; /* hash of info strings by 4 char ID */ 58 GSList *presets; /* list of #IpatchSF2Preset structures */ 59 GSList *insts; /* list of #IpatchSF2Inst structures */ 60 GSList *samples; /* list of #IpatchSF2Sample structures */ 61 }; 62 63 /* SoundFont class */ 64 struct _IpatchSF2Class 65 { 66 IpatchBaseClass parent_class; 67 }; 68 69 /** 70 * IpatchSF2Flags: 71 * @IPATCH_SF2_SAMPLES_24BIT: SoundFont 24 bit samples enabled flag 72 */ 73 typedef enum 74 { 75 IPATCH_SF2_SAMPLES_24BIT = 1 << IPATCH_BASE_UNUSED_FLAG_SHIFT 76 } IpatchSF2Flags; 77 78 /** 79 * IPATCH_SF2_UNUSED_FLAG_SHIFT: (skip) 80 */ 81 /* we reserve a couple flags for backwards compatible expansion */ 82 #define IPATCH_SF2_UNUSED_FLAG_SHIFT (IPATCH_BASE_UNUSED_FLAG_SHIFT + 3) 83 84 85 /* SoundFont INFO enums (keep order synced with IpatchSF2.c) */ 86 typedef enum 87 { 88 IPATCH_SF2_UNKNOWN, /* unknown chunk ("NULL" value) */ 89 IPATCH_SF2_VERSION = IPATCH_SFONT_FOURCC_IFIL, /* SoundFont version */ 90 IPATCH_SF2_ENGINE = IPATCH_SFONT_FOURCC_ISNG,/* target sound engine */ 91 IPATCH_SF2_NAME = IPATCH_SFONT_FOURCC_INAM, /* SoundFont name */ 92 IPATCH_SF2_ROM_NAME = IPATCH_SFONT_FOURCC_IROM, /* ROM name */ 93 IPATCH_SF2_ROM_VERSION = IPATCH_SFONT_FOURCC_IVER, /* ROM version */ 94 IPATCH_SF2_DATE = IPATCH_SFONT_FOURCC_ICRD, /* creation date */ 95 IPATCH_SF2_AUTHOR = IPATCH_SFONT_FOURCC_IENG,/* sound designers/engineers */ 96 IPATCH_SF2_PRODUCT = IPATCH_SFONT_FOURCC_IPRD, /* product intended for */ 97 IPATCH_SF2_COPYRIGHT = IPATCH_SFONT_FOURCC_ICOP, /* copyright message */ 98 IPATCH_SF2_COMMENT = IPATCH_SFONT_FOURCC_ICMT, /* comments */ 99 IPATCH_SF2_SOFTWARE = IPATCH_SFONT_FOURCC_ISFT /* software "create:modify" */ 100 } IpatchSF2InfoType; 101 102 /** 103 * IPATCH_SF2_INFO_COUNT: (skip) 104 */ 105 #define IPATCH_SF2_INFO_COUNT 11 106 107 /** 108 * IPATCH_SF2_DEFAULT_ENGINE: (skip) 109 */ 110 #define IPATCH_SF2_DEFAULT_ENGINE "EMU8000" 111 112 /* structure used for ipatch_sf2_get_info_array */ 113 typedef struct 114 { 115 guint32 id; /* FOURCC info id */ 116 char *val; /* info string value */ 117 } IpatchSF2Info; 118 119 GType ipatch_sf2_get_type(void); 120 IpatchSF2 *ipatch_sf2_new(void); 121 122 #define ipatch_sf2_get_presets(sfont) \ 123 ipatch_container_get_children (IPATCH_CONTAINER (sfont), \ 124 IPATCH_TYPE_SF2_PRESET) 125 #define ipatch_sf2_get_insts(sfont) \ 126 ipatch_container_get_children (IPATCH_CONTAINER (sfont), \ 127 IPATCH_TYPE_SF2_INST) 128 #define ipatch_sf2_get_samples(sfont) \ 129 ipatch_container_get_children (IPATCH_CONTAINER (sfont), \ 130 IPATCH_TYPE_SF2_SAMPLE) 131 132 void ipatch_sf2_set_file(IpatchSF2 *sf, IpatchSF2File *file); 133 IpatchSF2File *ipatch_sf2_get_file(IpatchSF2 *sf); 134 135 char *ipatch_sf2_get_info(IpatchSF2 *sf, IpatchSF2InfoType id); 136 void ipatch_sf2_set_info(IpatchSF2 *sf, IpatchSF2InfoType id, 137 const char *val); 138 IpatchSF2Info *ipatch_sf2_get_info_array(IpatchSF2 *sf); 139 void ipatch_sf2_free_info_array(IpatchSF2Info *array); 140 gboolean ipatch_sf2_info_id_is_valid(guint32 id); 141 int ipatch_sf2_get_info_max_size(IpatchSF2InfoType infotype); 142 143 IpatchSF2Preset *ipatch_sf2_find_preset(IpatchSF2 *sf, const char *name, 144 int bank, int program, 145 const IpatchSF2Preset *exclude); 146 IpatchSF2Inst *ipatch_sf2_find_inst(IpatchSF2 *sf, const char *name, 147 const IpatchSF2Inst *exclude); 148 IpatchSF2Sample *ipatch_sf2_find_sample(IpatchSF2 *sf, const char *name, 149 const IpatchSF2Sample *exclude); 150 IpatchList *ipatch_sf2_get_zone_references(IpatchItem *item); 151 152 char *ipatch_sf2_make_unique_name(IpatchSF2 *sfont, GType child_type, 153 const char *name, 154 const IpatchItem *exclude); 155 #endif 156