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  */
21 #ifndef __IPATCH_BASE_H__
22 #define __IPATCH_BASE_H__
23 
24 #include <stdarg.h>
25 #include <glib.h>
26 #include <glib-object.h>
27 
28 /* forward type declarations */
29 
30 typedef struct _IpatchBase IpatchBase;
31 typedef struct _IpatchBaseClass IpatchBaseClass;
32 
33 #include <libinstpatch/IpatchFile.h>
34 #include <libinstpatch/IpatchContainer.h>
35 #include <libinstpatch/IpatchSF2Preset.h>
36 #include <libinstpatch/IpatchSF2Inst.h>
37 #include <libinstpatch/IpatchSF2Sample.h>
38 
39 #define IPATCH_TYPE_BASE   (ipatch_base_get_type ())
40 #define IPATCH_BASE(obj) \
41   (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPATCH_TYPE_BASE, IpatchBase))
42 #define IPATCH_BASE_CLASS(klass) \
43   (G_TYPE_CHECK_CLASS_CAST ((klass), IPATCH_TYPE_BASE, IpatchBaseClass))
44 #define IPATCH_IS_BASE(obj) \
45   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPATCH_TYPE_BASE))
46 #define IPATCH_IS_BASE_CLASS(klass) \
47   (G_TYPE_CHECK_CLASS_TYPE ((klass), IPATCH_TYPE_BASE))
48 #define IPATCH_BASE_GET_CLASS(obj) \
49   (G_TYPE_INSTANCE_GET_CLASS ((obj), IPATCH_TYPE_BASE, IpatchBaseClass))
50 
51 /**
52  * IpatchBaseFlags:
53  * @IPATCH_BASE_CHANGED: Does the base object have any unsaved changes?
54  * @IPATCH_BASE_SAVED: Has the base object ever been saved?
55  */
56 typedef enum
57 {
58     IPATCH_BASE_CHANGED = 1 << IPATCH_ITEM_UNUSED_FLAG_SHIFT,
59     IPATCH_BASE_SAVED   = 1 << (IPATCH_ITEM_UNUSED_FLAG_SHIFT + 1)
60 } IpatchBaseFlags;
61 
62 /* we reserve a couple flags for backwards compatible expansion */
63 /**
64  * IPATCH_BASE_UNUSED_FLAG_SHIFT: (skip)
65  */
66 #define IPATCH_BASE_UNUSED_FLAG_SHIFT (IPATCH_ITEM_UNUSED_FLAG_SHIFT + 4)
67 
68 /* patch base object */
69 struct _IpatchBase
70 {
71     IpatchContainer parent_instance; /* derived from IpatchContainer */
72 
73     /*< private >*/
74 
75     IpatchFile *file;		/* file object associated with this patch */
76 };
77 
78 /* SoundFont class */
79 struct _IpatchBaseClass
80 {
81     IpatchContainerClass parent_class;
82 
83     /* methods */
84     void (*find_unused_locale)(IpatchBase *base, int *bank, int *program,
85                                const IpatchItem *exclude, gboolean percussion);
86     IpatchItem *(*find_item_by_locale)(IpatchBase *base, int bank, int program);
87 };
88 
89 /**
90  * IPATCH_BASE_DEFAULT_NAME: (skip)
91  */
92 #define IPATCH_BASE_DEFAULT_NAME "Untitled"
93 
94 GType ipatch_base_get_type(void);
95 char *ipatch_base_type_get_mime_type(GType base_type);
96 void ipatch_base_set_file(IpatchBase *base, IpatchFile *file);
97 IpatchFile *ipatch_base_get_file(IpatchBase *base);
98 void ipatch_base_set_file_name(IpatchBase *base, const char *file_name);
99 char *ipatch_base_get_file_name(IpatchBase *base);
100 
101 void ipatch_base_find_unused_midi_locale(IpatchBase *base,
102         int *bank, int *program,
103         const IpatchItem *exclude,
104         gboolean percussion);
105 IpatchItem *ipatch_base_find_item_by_midi_locale(IpatchBase *base, int bank,
106         int program);
107 
108 gboolean ipatch_base_save(IpatchBase *base, GError **err);
109 gboolean ipatch_base_save_to_filename(IpatchBase *base, const char *filename, GError **err);
110 gboolean ipatch_base_save_a_copy(IpatchBase *base, const char *filename, GError **err);
111 gboolean ipatch_base_close(IpatchBase *base, GError **err);
112 gboolean ipatch_close_base_list(IpatchList *list, GError **err);
113 
114 #endif
115 
116