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_WRITER_H__
21 #define __IPATCH_SF2_WRITER_H__
22 
23 #include <glib.h>
24 #include <libinstpatch/IpatchSF2File.h>
25 #include <libinstpatch/IpatchRiff.h>
26 #include <libinstpatch/IpatchSF2.h>
27 #include <libinstpatch/IpatchSF2Mod.h>
28 #include <libinstpatch/IpatchSF2Gen.h>
29 #include <libinstpatch/IpatchList.h>
30 
31 typedef struct _IpatchSF2Writer IpatchSF2Writer; /* private structure */
32 typedef struct _IpatchSF2WriterClass IpatchSF2WriterClass;
33 
34 #define IPATCH_TYPE_SF2_WRITER   (ipatch_sf2_writer_get_type ())
35 #define IPATCH_SF2_WRITER(obj) \
36   (G_TYPE_CHECK_INSTANCE_CAST ((obj), IPATCH_TYPE_SF2_WRITER, \
37    IpatchSF2Writer))
38 #define IPATCH_SF2_WRITER_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST ((klass), IPATCH_TYPE_SF2_WRITER, \
40    IpatchSF2WriterClass))
41 #define IPATCH_IS_SF2_WRITER(obj) \
42   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IPATCH_TYPE_SF2_WRITER))
43 #define IPATCH_IS_SF2_WRITER_CLASS(klass) \
44   (G_TYPE_CHECK_CLASS_TYPE ((klass), IPATCH_TYPE_SF2_WRITER))
45 
46 /* SF2 writer object */
47 struct _IpatchSF2Writer
48 {
49     IpatchRiff parent_instance; /* derived from IpatchRiff */
50     IpatchSF2 *orig_sf;		/* original SF2 object */
51     IpatchSF2 *sf;		/* duplicated SF2 object to save */
52     gboolean migrate_samples; /* set to TRUE to migrate samples to new file */
53     GHashTable *inst_hash;	/* instrument => index hash */
54     GHashTable *sample_hash;	/* sample => SampleHashValue hash */
55     IpatchList *store_list;       /* list of stores, only set if ipatch_sf2_writer_create_stores() was called */
56 };
57 
58 /* SF2 writer class */
59 struct _IpatchSF2WriterClass
60 {
61     IpatchRiffClass parent_class;
62 };
63 
64 GType ipatch_sf2_writer_get_type(void);
65 IpatchSF2Writer *ipatch_sf2_writer_new(IpatchFileHandle *handle, IpatchSF2 *sfont);
66 void ipatch_sf2_writer_set_patch(IpatchSF2Writer *writer, IpatchSF2 *sfont);
67 void ipatch_sf2_writer_set_file_handle(IpatchSF2Writer *writer,
68                                        IpatchFileHandle *handle);
69 gboolean ipatch_sf2_writer_save(IpatchSF2Writer *writer, GError **err);
70 IpatchList *ipatch_sf2_writer_create_stores(IpatchSF2Writer *writer);
71 
72 void ipatch_sf2_write_phdr(IpatchFileHandle *handle, const IpatchSF2Phdr *phdr);
73 void ipatch_sf2_write_ihdr(IpatchFileHandle *handle, const IpatchSF2Ihdr *ihdr);
74 void ipatch_sf2_write_shdr(IpatchFileHandle *handle, const IpatchSF2Shdr *shdr);
75 void ipatch_sf2_write_bag(IpatchFileHandle *handle, const IpatchSF2Bag *bag);
76 void ipatch_sf2_write_mod(IpatchFileHandle *handle, const IpatchSF2Mod *mod);
77 void ipatch_sf2_write_gen(IpatchFileHandle *handle, int genid,
78                           const IpatchSF2GenAmount *amount);
79 
80 #endif
81