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_INST_H__
23 #define __IPATCH_SLI_INST_H__
24 
25 #include <stdarg.h>
26 #include <glib.h>
27 #include <glib-object.h>
28 #include <libinstpatch/IpatchContainer.h>
29 #include <libinstpatch/IpatchSLIZone.h>
30 #include <libinstpatch/IpatchSLISample.h>
31 
32 /* forward type declarations */
33 typedef struct _IpatchSLIInst IpatchSLIInst;
34 typedef struct _IpatchSLIInstClass IpatchSLIInstClass;
35 typedef struct _IpatchSLIInstCatMapEntry IpatchSLIInstCatMapEntry;
36 
37 #define IPATCH_TYPE_SLI_INST   (ipatch_sli_inst_get_type ())
38 #define IPATCH_SLI_INST(obj) \
39   (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPATCH_TYPE_SLI_INST, \
40   IpatchSLIInst))
41 #define IPATCH_SLI_INST_CLASS(klass) \
42   (G_TYPE_CHECK_CLASS_CAST ((klass), IPATCH_TYPE_SLI_INST, \
43   IpatchSLIInstClass))
44 #define IPATCH_IS_SLI_INST(obj) \
45   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPATCH_TYPE_SLI_INST))
46 #define IPATCH_IS_SLI_INST_CLASS(klass) \
47   (G_TYPE_CHECK_CLASS_TYPE ((klass), IPATCH_TYPE_SLI_INST))
48 #define IPATCH_SLI_INST_GET_CLASS(obj) \
49   (G_TYPE_INSTANCE_GET_CLASS ((obj), IPATCH_TYPE_SLI_INST, \
50   IpatchSLIInstClass))
51 
52 /* Index constants for category strings array */
53 enum
54 {
55     IPATCH_SLI_INST_CAT_80S = 0,
56     IPATCH_SLI_INST_CAT_A_SYNTH,
57     IPATCH_SLI_INST_CAT_ACID,
58     IPATCH_SLI_INST_CAT_ATTACK,
59     IPATCH_SLI_INST_CAT_BASS,
60     IPATCH_SLI_INST_CAT_BELL,
61     IPATCH_SLI_INST_CAT_BIG_BEAT,
62     IPATCH_SLI_INST_CAT_BLOCK,
63     IPATCH_SLI_INST_CAT_BONGO,
64     IPATCH_SLI_INST_CAT_BRASS,
65     IPATCH_SLI_INST_CAT_CHIME,
66     IPATCH_SLI_INST_CAT_CHINA,
67     IPATCH_SLI_INST_CAT_CLAP,
68     IPATCH_SLI_INST_CAT_CLAVE,
69     IPATCH_SLI_INST_CAT_CONGA,
70     IPATCH_SLI_INST_CAT_CRASH,
71     IPATCH_SLI_INST_CAT_CUICA,
72     IPATCH_SLI_INST_CAT_CYMBAL,
73     IPATCH_SLI_INST_CAT_D_SYNTH,
74     IPATCH_SLI_INST_CAT_DISCO,
75     IPATCH_SLI_INST_CAT_DRUM_LOOP,
76     IPATCH_SLI_INST_CAT_EFFECTS,
77     IPATCH_SLI_INST_CAT_ELECTRO,
78     IPATCH_SLI_INST_CAT_ETHNIC,
79     IPATCH_SLI_INST_CAT_EXT_IN,
80     IPATCH_SLI_INST_CAT_FB_LOOP,
81     IPATCH_SLI_INST_CAT_FX_LOOP,
82     IPATCH_SLI_INST_CAT_FUNK,
83     IPATCH_SLI_INST_CAT_GONG,
84     IPATCH_SLI_INST_CAT_GUIRO,
85     IPATCH_SLI_INST_CAT_HIHAT,
86     IPATCH_SLI_INST_CAT_HIPHOP,
87     IPATCH_SLI_INST_CAT_HOUSE,
88     IPATCH_SLI_INST_CAT_HUMAN,
89     IPATCH_SLI_INST_CAT_INDUSTRY,
90     IPATCH_SLI_INST_CAT_JAZZ,
91     IPATCH_SLI_INST_CAT_KICK,
92     IPATCH_SLI_INST_CAT_LEAD,
93     IPATCH_SLI_INST_CAT_MARCH,
94     IPATCH_SLI_INST_CAT_MARIMBA,
95     IPATCH_SLI_INST_CAT_MULTI,
96     IPATCH_SLI_INST_CAT_NATURAL,
97     IPATCH_SLI_INST_CAT_OLDIE,
98     IPATCH_SLI_INST_CAT_ORGAN,
99     IPATCH_SLI_INST_CAT_OTHER,
100     IPATCH_SLI_INST_CAT_PAD,
101     IPATCH_SLI_INST_CAT_PERC_LOOP,
102     IPATCH_SLI_INST_CAT_PERCUSSION,
103     IPATCH_SLI_INST_CAT_PERCUSSIVE,
104     IPATCH_SLI_INST_CAT_PIANO,
105     IPATCH_SLI_INST_CAT_PLUG,
106     IPATCH_SLI_INST_CAT_POP,
107     IPATCH_SLI_INST_CAT_RELEASE,
108     IPATCH_SLI_INST_CAT_RIDE,
109     IPATCH_SLI_INST_CAT_ROCK,
110     IPATCH_SLI_INST_CAT_SCRATCH,
111     IPATCH_SLI_INST_CAT_SEQUENCER,
112     IPATCH_SLI_INST_CAT_SHAKER,
113     IPATCH_SLI_INST_CAT_SNARE,
114     IPATCH_SLI_INST_CAT_SPLASH,
115     IPATCH_SLI_INST_CAT_STRING,
116     IPATCH_SLI_INST_CAT_SYNTH_BASS,
117     IPATCH_SLI_INST_CAT_TR_ALIKE,
118     IPATCH_SLI_INST_CAT_TECHNO,
119     IPATCH_SLI_INST_CAT_TEXTURE,
120     IPATCH_SLI_INST_CAT_TIMBALE,
121     IPATCH_SLI_INST_CAT_TOM,
122     IPATCH_SLI_INST_CAT_TONAL_LOOP,
123     IPATCH_SLI_INST_CAT_TRIANGLE,
124     IPATCH_SLI_INST_CAT_VOICE,
125     IPATCH_SLI_INST_CAT_WHISTLE,
126     IPATCH_SLI_INST_CAT_WIND,
127     IPATCH_SLI_INST_CAT_WORLD
128 };
129 
130 struct _IpatchSLIInstCatMapEntry
131 {
132     char code;                        /* cat code */
133     guint name_idx;                   /* cat string index */
134     const IpatchSLIInstCatMapEntry *submap; /* poniter to subcat map array */
135 };
136 
137 /* Defined in IpatchSLIInst_CatMaps.c */
138 extern const char *ipatch_sli_inst_cat_strings[];
139 /* getter fonction that returns pointer on ipatch_sli_inst_cat_strings table */
140 extern const gchar **ipatch_sli_inst_get_cat_strings(void);
141 extern const IpatchSLIInstCatMapEntry ipatch_sli_inst_cat_map[];
142 /* getter fonction that returns pointer on ipatch_sli_inst_cat_map table */
143 extern const IpatchSLIInstCatMapEntry * ipatch_sli_inst_get_cat_map(void);
144 
145 /* SoundFont instrument item */
146 struct _IpatchSLIInst
147 {
148     IpatchContainer parent_instance;
149 
150     char *name;			/* name of inst */
151     GSList *zones;		/* list of inst zones */
152     guint sound_id;		/* instrument identifier */
153     guint category;		/* category code for grouping */
154 };
155 
156 struct _IpatchSLIInstClass
157 {
158     IpatchContainerClass parent_class;
159 };
160 
161 GType ipatch_sli_inst_get_type(void);
162 IpatchSLIInst *ipatch_sli_inst_new(void);
163 
164 #define ipatch_sli_inst_zones_count(inst) \
165     ipatch_container_count (IPATCH_CONTAINER (inst), \
166                             IPATCH_TYPE_SLI_ZONE)
167 #define ipatch_sli_inst_get_zones(inst) \
168     ipatch_container_get_children (IPATCH_CONTAINER (inst), \
169 				   IPATCH_TYPE_SLI_ZONE)
170 
171 IpatchSLIInst *ipatch_sli_inst_first(IpatchIter *iter);
172 IpatchSLIInst *ipatch_sli_inst_next(IpatchIter *iter);
173 
174 void ipatch_sli_inst_new_zone(IpatchSLIInst *inst, IpatchSLISample *sample);
175 
176 void ipatch_sli_inst_set_name(IpatchSLIInst *inst, const char *name);
177 char *ipatch_sli_inst_get_name(IpatchSLIInst *inst);
178 
179 char *ipatch_sli_inst_get_category_as_path(IpatchSLIInst *inst);
180 #endif
181