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_VBANK_REGION_H__
21 #define __IPATCH_VBANK_REGION_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 #include <libinstpatch/IpatchItem.h>
26 #include <libinstpatch/IpatchRange.h>
27 
28 /* forward type declarations */
29 
30 typedef struct _IpatchVBankRegion IpatchVBankRegion;
31 typedef struct _IpatchVBankRegionClass IpatchVBankRegionClass;
32 
33 #define IPATCH_TYPE_VBANK_REGION   (ipatch_vbank_region_get_type ())
34 #define IPATCH_VBANK_REGION(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPATCH_TYPE_VBANK_REGION, \
36   IpatchVBankRegion))
37 #define IPATCH_VBANK_REGION_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_CAST ((klass), IPATCH_TYPE_VBANK_REGION, \
39   IpatchVBankRegionClass))
40 #define IPATCH_IS_VBANK_REGION(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPATCH_TYPE_VBANK_REGION))
42 #define IPATCH_IS_VBANK_REGION_CLASS(klass) \
43   (G_TYPE_CHECK_CLASS_TYPE ((klass), IPATCH_TYPE_VBANK_REGION))
44 #define IPATCH_VBANK_REGION_GET_CLASS(obj) \
45   (G_TYPE_INSTANCE_GET_CLASS ((obj), IPATCH_TYPE_VBANK_REGION, \
46   IpatchVBankRegionClass))
47 
48 /* Virtual bank region */
49 struct _IpatchVBankRegion
50 {
51     IpatchItem parent_instance;
52 
53     /*< private >*/
54     IpatchItem *item; 	/* Referenced item or NULL (if unresolved) */
55     char **id_props;	/* prop/val pairs which ID item or NULL (if resolved) */
56     guint file_index;	/* Index of file in IpatchVBank parent (if unresolved) */
57 
58     IpatchRange note_range;	/* MIDI note range of this region */
59     guint8 note_range_mode;	/* #IpatchVBankRegionNoteRangeMode */
60     gint8 root_note;		/* MIDI root note value */
61     guint8 root_note_mode;	/* #IpatchVBankRegionRootNoteMode */
62 };
63 
64 struct _IpatchVBankRegionClass
65 {
66     IpatchItemClass parent_class;
67 };
68 
69 /**
70  * IpatchVBankNoteRangeMode:
71  * @IPATCH_VBANK_REGION_NOTE_RANGE_MODE_INTERSECT: Note range is applied as an
72  *   intersection with existing voice note ranges (only those notes shared by
73  *   both ranges will become the final range, a logic AND operation).
74  * @IPATCH_VBANK_REGION_NOTE_RANGE_MODE_ASSIGN: Note range of all voices is
75  *   overridden by new range.
76  *
77  * Determines mode in which a virtual bank region's note range is applied to the
78  * affected synthesis voices.
79  */
80 typedef enum
81 {
82     IPATCH_VBANK_REGION_NOTE_RANGE_MODE_INTERSECT	= 0,
83     IPATCH_VBANK_REGION_NOTE_RANGE_MODE_OVERRIDE	= 1
84 } IpatchVBankRegionNoteRangeMode;
85 
86 /**
87  * IpatchVBankRootNoteMode:
88  * @IPATCH_VBANK_REGION_ROOT_NOTE_MODE_OFFSET: Offset the root note parameters of
89  *   affected synthesis voices by a given signed integer amount.
90  * @IPATCH_VBANK_REGION_ROOT_NOTE_MODE_OVERRIDE: Override root note parameters of
91  *   affected synthesis voices.
92  */
93 typedef enum
94 {
95     IPATCH_VBANK_REGION_ROOT_NOTE_MODE_OFFSET	= 0,
96     IPATCH_VBANK_REGION_ROOT_NOTE_MODE_OVERRIDE	= 1
97 } IpatchVBankRegionRootNoteMode;
98 
99 GType ipatch_vbank_region_get_type(void);
100 IpatchVBankRegion *ipatch_vbank_region_new(void);
101 
102 IpatchVBankRegion *ipatch_vbank_region_first(IpatchIter *iter);
103 IpatchVBankRegion *ipatch_vbank_region_next(IpatchIter *iter);
104 
105 void ipatch_vbank_region_set_id_props(IpatchVBankRegion *region,
106                                       char **id_props);
107 char **ipatch_vbank_region_get_id_props(IpatchVBankRegion *region,
108                                         guint *n_elements);
109 void ipatch_vbank_region_set_item(IpatchVBankRegion *region, IpatchItem *item);
110 IpatchItem *ipatch_vbank_region_get_item(IpatchVBankRegion *region);
111 
112 #endif
113 
114