1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2019 Joël Krähemann
3  *
4  * This file is part of GSequencer.
5  *
6  * GSequencer is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSequencer is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSequencer.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __AGS_SFZ_FILE_H__
21 #define __AGS_SFZ_FILE_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <ags/libags.h>
27 
28 #include <stdio.h>
29 
30 G_BEGIN_DECLS
31 
32 #define AGS_TYPE_SFZ_FILE                (ags_sfz_file_get_type())
33 #define AGS_SFZ_FILE(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_SFZ_FILE, AgsSFZFile))
34 #define AGS_SFZ_FILE_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_SFZ_FILE, AgsSFZFileClass))
35 #define AGS_IS_SFZ_FILE(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_SFZ_FILE))
36 #define AGS_IS_SFZ_FILE_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_SFZ_FILE))
37 #define AGS_SFZ_FILE_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_SFZ_FILE, AgsSFZFileClass))
38 
39 #define AGS_SFZ_FILE_GET_OBJ_MUTEX(obj) (&(((AgsSFZFile *) obj)->obj_mutex))
40 
41 #define AGS_SFZ_FILE_DEFAULT_CHANNELS (2)
42 #define AGS_SFZ_FILE_LOOP_MAX (4294967296)
43 
44 #define AGS_SFZ_FILE_READ "r"
45 #define AGS_SFZ_FILE_WRITE "w"
46 
47 typedef struct _AgsSFZFile AgsSFZFile;
48 typedef struct _AgsSFZFileClass AgsSFZFileClass;
49 
50 /**
51  * AgsSFZFileFlags:
52  * @AGS_SFZ_FILE_ADDED_TO_REGISTRY: the sfz_file was added to registry, see #AgsConnectable::add_to_registry()
53  * @AGS_SFZ_FILE_CONNECTED: indicates the sfz_file was connected by calling #AgsConnectable::connect()
54  *
55  * Enum values to control the behavior or indicate internal state of #AgsSFZFile by
56  * enable/disable as flags.
57  */
58 typedef enum{
59   AGS_SFZ_FILE_ADDED_TO_REGISTRY    = 1,
60   AGS_SFZ_FILE_CONNECTED            = 1 <<  1,
61 }AgsSFZFileFlags;
62 
63 /**
64  * AgsSFZLevel:
65  * @AGS_SFZ_LEVEL_FILENAME: filename
66  * @AGS_SFZ_LEVEL_SAMPLE: sample
67  *
68  * Enum values to describe the different levels of a SFZ file.
69  */
70 typedef enum{
71   AGS_SFZ_LEVEL_FILENAME = 0,
72   AGS_SFZ_LEVEL_SAMPLE   = 1,
73 }AgsSFZLevel;
74 
75 struct _AgsSFZFile
76 {
77   GObject gobject;
78 
79   guint flags;
80 
81   GRecMutex obj_mutex;
82 
83   AgsUUID *uuid;
84 
85   GObject *soundcard;
86 
87   char *filename;
88   char *mode;
89 
90   FILE *file;
91 
92   guint nesting_level;
93 
94   gchar *level_id;
95   guint level_index;
96 
97   GObject *reader;
98   GObject *writer;
99 
100   GList *group;
101   GList *region;
102   GList *sample;
103 
104   guint *index_selected;
105   gchar **name_selected;
106 
107   gpointer current_sample;
108 
109   GList *audio_signal;
110 };
111 
112 struct _AgsSFZFileClass
113 {
114   GObjectClass gobject;
115 };
116 
117 GType ags_sfz_file_get_type();
118 
119 gboolean ags_sfz_file_test_flags(AgsSFZFile *sfz_file, guint flags);
120 void ags_sfz_file_set_flags(AgsSFZFile *sfz_file, guint flags);
121 void ags_sfz_file_unset_flags(AgsSFZFile *sfz_file, guint flags);
122 
123 gboolean ags_sfz_file_select_sample(AgsSFZFile *sfz_file,
124 				    guint sample_index);
125 
126 void ags_sfz_file_get_range(AgsSFZFile *sfz_file,
127 			    glong *hikey, glong *lokey);
128 
129 gboolean ags_sfz_file_check_suffix(gchar *filename);
130 
131 void ags_sfz_file_parse(AgsSFZFile *sfz_file);
132 
133 AgsSFZFile* ags_sfz_file_new();
134 
135 G_END_DECLS
136 
137 #endif /*__AGS_SFZ_FILE_H__*/
138