1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2020 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_PRESET_H__
21 #define __AGS_PRESET_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <ags/libags.h>
27 
28 G_BEGIN_DECLS
29 
30 #define AGS_TYPE_PRESET                (ags_preset_get_type())
31 #define AGS_PRESET(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_PRESET, AgsPreset))
32 #define AGS_PRESET_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_PRESET, AgsPresetClass))
33 #define AGS_IS_PRESET(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_PRESET))
34 #define AGS_IS_PRESET_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_PRESET))
35 #define AGS_PRESET_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_PRESET, AgsPresetClass))
36 
37 #define AGS_PRESET_GET_OBJ_MUTEX(obj) (&(((AgsPreset *) obj)->obj_mutex))
38 
39 typedef struct _AgsPreset AgsPreset;
40 typedef struct _AgsPresetClass AgsPresetClass;
41 
42 /**
43  * AgsPresetFlags:
44  * @AGS_PRESET_ADDED_TO_REGISTRY: the preset was added to registry, see #AgsConnectable::add_to_registry()
45  * @AGS_PRESET_CONNECTED: indicates the playback was connected by calling #AgsConnectable::connect()
46  *
47  * Enum values to control the behavior or indicate internal state of #AgsPreset by
48  * enable/disable as flags.
49  */
50 typedef enum{
51   AGS_PRESET_ADDED_TO_REGISTRY  = 1,
52   AGS_PRESET_CONNECTED          = 1 <<  1,
53 }AgsPresetFlags;
54 
55 #define AGS_PRESET_ERROR (ags_preset_error_quark())
56 
57 typedef enum{
58   AGS_PRESET_ERROR_NO_SUCH_PARAMETER,
59 }AgsPresetError;
60 
61 struct _AgsPreset
62 {
63   GObject gobject;
64 
65   guint flags;
66 
67   GRecMutex obj_mutex;
68 
69   GObject *audio;
70 
71   gchar *scope;
72   gchar *preset_name;
73 
74   guint audio_channel_start;
75   guint audio_channel_end;
76 
77   guint pad_start;
78   guint pad_end;
79 
80   guint x_start;
81   guint x_end;
82 
83   guint n_params;
84   gchar **parameter_name;
85   GValue *value;
86 };
87 
88 struct _AgsPresetClass
89 {
90   GObjectClass gobject;
91 };
92 
93 GType ags_preset_get_type();
94 
95 GQuark ags_preset_error_quark();
96 
97 GRecMutex* ags_preset_get_obj_mutex(AgsPreset *preset);
98 
99 gboolean ags_preset_test_flags(AgsPreset *preset, guint flags);
100 void ags_preset_set_flags(AgsPreset *preset, guint flags);
101 void ags_preset_unset_flags(AgsPreset *preset, guint flags);
102 
103 GObject* ags_preset_get_audio(AgsPreset *preset);
104 void ags_preset_set_audio(AgsPreset *preset,
105 			  GObject *audio);
106 
107 gchar* ags_preset_get_scope(AgsPreset *preset);
108 void ags_preset_set_scope(AgsPreset *preset,
109 			  gchar *scope);
110 
111 gchar* ags_preset_get_preset_name(AgsPreset *preset);
112 void ags_preset_set_preset_name(AgsPreset *preset,
113 				gchar *preset_name);
114 
115 guint ags_preset_get_audio_channel_start(AgsPreset *preset);
116 void ags_preset_set_audio_channel_start(AgsPreset *preset,
117 					guint audio_channel_start);
118 
119 guint ags_preset_get_audio_channel_end(AgsPreset *preset);
120 void ags_preset_set_audio_channel_end(AgsPreset *preset,
121 				      guint audio_channel_end);
122 
123 guint ags_preset_get_pad_start(AgsPreset *preset);
124 void ags_preset_set_pad_start(AgsPreset *preset,
125 			      guint pad_start);
126 
127 guint ags_preset_get_pad_end(AgsPreset *preset);
128 void ags_preset_set_pad_end(AgsPreset *preset,
129 			    guint pad_end);
130 
131 guint ags_preset_get_x_start(AgsPreset *preset);
132 void ags_preset_set_x_start(AgsPreset *preset,
133 			    guint x_start);
134 
135 guint ags_preset_get_x_end(AgsPreset *preset);
136 void ags_preset_set_x_end(AgsPreset *preset,
137 			  guint x_end);
138 
139 GList* ags_preset_find_scope(GList *preset,
140 			     gchar *scope);
141 GList* ags_preset_find_name(GList *preset,
142 			    gchar *preset_name);
143 
144 gboolean ags_preset_add_parameter(AgsPreset *preset,
145 				  gchar *param_name, GValue *value);
146 void ags_preset_remove_parameter(AgsPreset *preset,
147 				 guint nth);
148 
149 void ags_preset_get_parameter(AgsPreset *preset,
150 			      gchar *param_name, GValue *value,
151 			      GError **error);
152 
153 AgsPreset* ags_preset_new();
154 
155 G_END_DECLS
156 
157 #endif /*__AGS_PRESET_H__*/
158