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_ZONE_H__
23 #define __IPATCH_SLI_ZONE_H__
24 
25 #include <stdarg.h>
26 #include <glib.h>
27 #include <glib-object.h>
28 #include <libinstpatch/IpatchItem.h>
29 #include <libinstpatch/IpatchSF2Gen.h>
30 #include <libinstpatch/IpatchSLISample.h>
31 
32 /* forward type declarations */
33 
34 typedef struct _IpatchSLIZone IpatchSLIZone;
35 typedef struct _IpatchSLIZoneClass IpatchSLIZoneClass;
36 
37 #define IPATCH_TYPE_SLI_ZONE   (ipatch_sli_zone_get_type ())
38 #define IPATCH_SLI_ZONE(obj) \
39   (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPATCH_TYPE_SLI_ZONE, \
40   IpatchSLIZone))
41 #define IPATCH_SLI_ZONE_CLASS(klass) \
42   (G_TYPE_CHECK_CLASS_CAST ((klass), IPATCH_TYPE_SLI_ZONE, \
43   IpatchSLIZoneClass))
44 #define IPATCH_IS_SLI_ZONE(obj) \
45   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPATCH_TYPE_SLI_ZONE))
46 #define IPATCH_IS_SLI_ZONE_CLASS(klass) \
47   (G_TYPE_CHECK_CLASS_TYPE ((klass), IPATCH_TYPE_SLI_ZONE))
48 #define IPATCH_SLI_ZONE_GET_CLASS(obj) \
49   (G_TYPE_INSTANCE_GET_CLASS ((obj), IPATCH_TYPE_SLI_ZONE, \
50   IpatchSLIZoneClass))
51 
52 /* SoundFont zone item */
53 struct _IpatchSLIZone
54 {
55     IpatchItem parent_instance;
56 
57     /*< private >*/
58 
59     IpatchSLISample *sample;	/* referenced sample */
60     IpatchSF2GenArray genarray;	/* generator array */
61     int flags;                    /* misc flags */
62 };
63 
64 struct _IpatchSLIZoneClass
65 {
66     IpatchItemClass parent_class;
67 };
68 
69 /**
70  * IPATCH_SLI_ZONE_UNUSED_FLAG_SHIFT: (skip)
71  */
72 /* reserve 2 flags */
73 #define IPATCH_SLI_ZONE_UNUSED_FLAG_SHIFT  (IPATCH_ITEM_UNUSED_FLAG_SHIFT + 2)
74 
75 /* a macro for getting or setting a generator value directly, normally
76    ipatch_sli_zone_(get/set)_gen should be used instead, zone is not locked
77    and no flags are set (should only be used on zones with exclusive access) */
78 #define IPATCH_SLI_ZONE_GEN_AMT(zone, genid) \
79   ((IpatchSLIZone *)zone)->genarray.values[genid]
80 
81 /* macros for manipulating zone generator set flags directly, should not
82    normally be used except in the case of exclusive access, not locked, etc */
83 #define IPATCH_SLI_ZONE_GEN_TEST_FLAG(zone, genid) \
84   IPATCH_SLI_GEN_ARRAY_TEST_FLAG (&((IpatchSLIZone *)(zone))->genarray, genid)
85 #define IPATCH_SLI_ZONE_GEN_SET_FLAG(zone, genid) \
86   IPATCH_SLI_GEN_ARRAY_SET_FLAG (&((IpatchSLIZone *)(zone))->genarray, genid)
87 #define IPATCH_SLI_ZONE_GEN_CLEAR_FLAG(zone, genid) \
88   IPATCH_SLI_GEN_ARRAY_CLEAR_FLAG (&((IpatchSLIZone *)(zone))->genarray, genid)
89 
90 GType ipatch_sli_zone_get_type(void);
91 IpatchSLIZone *ipatch_sli_zone_new(void);
92 
93 IpatchSLIZone *ipatch_sli_zone_first(IpatchIter *iter);
94 IpatchSLIZone *ipatch_sli_zone_next(IpatchIter *iter);
95 
96 void ipatch_sli_zone_set_sample(IpatchSLIZone *zone, IpatchSLISample *sample);
97 IpatchSLISample *ipatch_sli_zone_get_sample(IpatchSLIZone *zone);
98 IpatchSLISample *ipatch_sli_zone_peek_sample(IpatchSLIZone *zone);
99 #endif
100