1 /* GSequencer - Advanced GTK Sequencer 2 * Copyright (C) 2005-2021 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_RECALL_H__ 21 #define __AGS_RECALL_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ags/libags.h> 27 28 #include <ags/audio/ags_sound_enums.h> 29 #include <ags/audio/ags_port.h> 30 #include <ags/audio/ags_recall_id.h> 31 #include <ags/audio/ags_recall_dependency.h> 32 33 G_BEGIN_DECLS 34 35 #define AGS_TYPE_RECALL (ags_recall_get_type()) 36 #define AGS_TYPE_RECALL_FLAGS (ags_recall_flags_get_type()) 37 #define AGS_TYPE_RECALL_NOTIFY_DEPENDENCY_MODE (ags_recall_notify_dependency_mode_get_type()) 38 #define AGS_RECALL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_RECALL, AgsRecall)) 39 #define AGS_RECALL_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_RECALL, AgsRecallClass)) 40 #define AGS_IS_RECALL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_RECALL)) 41 #define AGS_IS_RECALL_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_RECALL)) 42 #define AGS_RECALL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_RECALL, AgsRecallClass)) 43 44 #define AGS_RECALL_HANDLER(handler) ((AgsRecallHandler *)(handler)) 45 46 #define AGS_RECALL_GET_OBJ_MUTEX(obj) (&(((AgsRecall *) obj)->obj_mutex)) 47 48 #define AGS_RECALL_DEFAULT_VERSION "2.0.0" 49 #define AGS_RECALL_DEFAULT_BUILD_ID "Tue Feb 6 14:27:35 UTC 2018" 50 51 typedef struct _AgsRecall AgsRecall; 52 typedef struct _AgsRecallClass AgsRecallClass; 53 typedef struct _AgsRecallHandler AgsRecallHandler; 54 55 /** 56 * AgsRecallFlags: 57 * @AGS_RECALL_ADDED_TO_REGISTRY: the recall was added to registry, see #AgsConnectable::add_to_registry() 58 * @AGS_RECALL_CONNECTED: indicates the port was connected by calling #AgsConnectable::connect() 59 * @AGS_RECALL_TEMPLATE: is template 60 * @AGS_RECALL_DEFAULT_TEMPLATE: is default template 61 * @AGS_RECALL_HAS_OUTPUT_PORT: has output port 62 * @AGS_RECALL_BYPASS: don't apply effect processing 63 * @AGS_RECALL_INITIAL_RUN: initial run, first attack to audio data 64 * 65 * Enum values to control the behavior or indicate internal state of #AgsRecall by 66 * enable/disable as flags. 67 */ 68 typedef enum{ 69 AGS_RECALL_ADDED_TO_REGISTRY = 1, 70 AGS_RECALL_CONNECTED = 1 << 1, 71 AGS_RECALL_TEMPLATE = 1 << 2, 72 AGS_RECALL_DEFAULT_TEMPLATE = 1 << 3, 73 AGS_RECALL_HAS_OUTPUT_PORT = 1 << 4, 74 AGS_RECALL_BYPASS = 1 << 5, 75 AGS_RECALL_INITIAL_RUN = 1 << 6, 76 }AgsRecallFlags; 77 78 /** 79 * AgsRecallNotifyDependencyMode: 80 * @AGS_RECALL_NOTIFY_RUN: notify dependency as calling run 81 * @AGS_RECALL_NOTIFY_AUDIO: notify dependency audio 82 * @AGS_RECALL_NOTIFY_AUDIO_RUN: notifiy dependency audio run 83 * @AGS_RECALL_NOTIFY_CHANNEL: notifiy dependency channel 84 * @AGS_RECALL_NOTIFY_CHANNEL_RUN: notifiy dependency channel run 85 * @AGS_RECALL_NOTIFY_RECALL: notifiy dependency recall 86 * 87 * Modes to notify of dependencies. 88 */ 89 typedef enum{ 90 AGS_RECALL_NOTIFY_RUN, 91 AGS_RECALL_NOTIFY_AUDIO, 92 AGS_RECALL_NOTIFY_AUDIO_RUN, 93 AGS_RECALL_NOTIFY_CHANNEL, 94 AGS_RECALL_NOTIFY_CHANNEL_RUN, 95 AGS_RECALL_NOTIFY_RECALL, 96 }AgsRecallNotifyDependencyMode; 97 98 struct _AgsRecall 99 { 100 GObject gobject; 101 102 guint flags; 103 guint ability_flags; 104 guint behaviour_flags; 105 gint sound_scope; 106 guint staging_flags; 107 guint state_flags; 108 109 // gboolean rt_safe; note replace by globals 110 111 GRecMutex obj_mutex; 112 113 AgsUUID *uuid; 114 115 gchar *version; 116 gchar *build_id; 117 118 gchar *name; 119 120 gchar *filename; 121 gchar *effect; 122 guint effect_index; 123 124 gchar *xml_type; 125 126 GObject *recall_container; 127 128 GObject *output_soundcard; 129 gint output_soundcard_channel; 130 131 GObject *input_soundcard; 132 gint input_soundcard_channel; 133 134 guint samplerate; 135 guint buffer_size; 136 guint format; 137 138 guint pad; 139 guint audio_channel; 140 141 guint line; 142 143 GList *port; 144 GList *automation_port; 145 146 AgsRecallID *recall_id; 147 148 GList *recall_dependency; 149 GList *recall_handler; 150 151 AgsRecall *parent; 152 153 GType child_type; 154 155 guint n_child_params; 156 gchar **child_parameter_name; 157 GValue *child_value; 158 159 GList *children; 160 }; 161 162 struct _AgsRecallClass 163 { 164 GObjectClass gobject; 165 166 void (*resolve_dependency)(AgsRecall *recall); 167 void (*check_rt_data)(AgsRecall *recall); 168 169 void (*run_init_pre)(AgsRecall *recall); 170 void (*run_init_inter)(AgsRecall *recall); 171 void (*run_init_post)(AgsRecall *recall); 172 173 void (*feed_input_queue)(AgsRecall *recall); 174 void (*automate)(AgsRecall *recall); 175 176 void (*run_pre)(AgsRecall *recall); 177 void (*run_inter)(AgsRecall *recall); 178 void (*run_post)(AgsRecall *recall); 179 180 void (*do_feedback)(AgsRecall *recall); 181 void (*feed_output_queue)(AgsRecall *recall); 182 183 void (*stop_persistent)(AgsRecall *recall); 184 void (*cancel)(AgsRecall *recall); 185 void (*done)(AgsRecall *recall); 186 187 AgsRecall* (*duplicate)(AgsRecall *recall, 188 AgsRecallID *recall_id, 189 guint *n_params, gchar **parameter_name, GValue *value); 190 191 void (*notify_dependency)(AgsRecall *recall, guint dependency, gboolean increase); 192 193 void (*child_added)(AgsRecall *recall, AgsRecall *child); 194 }; 195 196 /** 197 * AgsRecallHandler: 198 * @signal_name: the signal to listen 199 * @callback: the callback to use 200 * @data: user data to pass 201 * 202 * A #AgsRecallHandler-struct acts as a callback definition 203 */ 204 struct _AgsRecallHandler 205 { 206 const gchar *signal_name; 207 GCallback callback; 208 GObject *data; 209 }; 210 211 GType ags_recall_get_type(); 212 213 GType ags_recall_flags_get_type(); 214 GType ags_recall_notify_dependency_mode_get_type(); 215 216 void ags_recall_global_set_omit_event(gboolean omit_event); 217 218 gboolean ags_recall_global_get_children_lock_free(); 219 gboolean ags_recall_global_get_omit_event(); 220 gboolean ags_recall_global_get_performance_mode(); 221 gboolean ags_recall_global_get_rt_safe(); 222 223 GRecMutex* ags_recall_get_obj_mutex(AgsRecall *recall); 224 225 gboolean ags_recall_test_flags(AgsRecall *recall, guint flags); 226 void ags_recall_set_flags(AgsRecall *recall, guint flags); 227 void ags_recall_unset_flags(AgsRecall *recall, guint flags); 228 229 /* ability flags */ 230 gboolean ags_recall_test_ability_flags(AgsRecall *recall, guint ability_flags); 231 void ags_recall_set_ability_flags(AgsRecall *recall, guint ability_flags); 232 void ags_recall_unset_ability_flags(AgsRecall *recall, guint ability_flags); 233 234 gboolean ags_recall_check_ability_flags(AgsRecall *recall, guint ability_flags); 235 gboolean ags_recall_match_ability_flags_to_scope(AgsRecall *recall, gint sound_scope); 236 237 /* behaviour flags */ 238 gboolean ags_recall_test_behaviour_flags(AgsRecall *recall, guint behaviour_flags); 239 void ags_recall_set_behaviour_flags(AgsRecall *recall, guint behaviour_flags); 240 void ags_recall_unset_behaviour_flags(AgsRecall *recall, guint behaviour_flags); 241 242 gboolean ags_recall_check_behaviour_flags(AgsRecall *recall, guint behaviour_flags); 243 244 /* scope */ 245 void ags_recall_set_sound_scope(AgsRecall *recall, gint sound_scope); 246 gint ags_recall_get_sound_scope(AgsRecall *recall); 247 248 gboolean ags_recall_check_sound_scope(AgsRecall *recall, gint sound_scope); 249 250 /* staging flags */ 251 gboolean ags_recall_test_staging_flags(AgsRecall *recall, guint staging_flags); 252 void ags_recall_set_staging_flags(AgsRecall *recall, guint staging_flags); 253 void ags_recall_unset_staging_flags(AgsRecall *recall, guint staging_flags); 254 255 gboolean ags_recall_check_staging_flags(AgsRecall *recall, guint staging_flags); 256 257 /* state flags */ 258 gboolean ags_recall_test_state_flags(AgsRecall *recall, guint state_flags); 259 void ags_recall_set_state_flags(AgsRecall *recall, guint state_flags); 260 void ags_recall_unset_state_flags(AgsRecall *recall, guint state_flags); 261 262 gboolean ags_recall_check_state_flags(AgsRecall *recall, guint state_flags); 263 264 /* fields */ 265 gchar* ags_recall_get_filename(AgsRecall *recall); 266 void ags_recall_set_filename(AgsRecall *recall, 267 gchar *filename); 268 269 gchar* ags_recall_get_effect(AgsRecall *recall); 270 void ags_recall_set_effect(AgsRecall *recall, 271 gchar *effect); 272 273 guint ags_recall_get_effect_index(AgsRecall *recall); 274 void ags_recall_set_effect_index(AgsRecall *recall, 275 guint effect_index); 276 277 GObject* ags_recall_get_recall_container(AgsRecall *recall); 278 void ags_recall_set_recall_container(AgsRecall *recall, 279 GObject *recall_container); 280 281 /* children */ 282 AgsRecallID* ags_recall_get_recall_id(AgsRecall *recall); 283 void ags_recall_set_recall_id(AgsRecall *recall, 284 AgsRecallID *recall_id); 285 286 GList* ags_recall_get_recall_dependency(AgsRecall *recall); 287 void ags_recall_set_recall_dependency(AgsRecall *recall, 288 GList *recall_dependency); 289 290 void ags_recall_add_recall_dependency(AgsRecall *recall, 291 AgsRecallDependency *recall_dependency); 292 void ags_recall_remove_recall_dependency(AgsRecall *recall, 293 AgsRecallDependency *recall_dependency); 294 295 GList* ags_recall_get_port(AgsRecall *recall); 296 void ags_recall_set_port(AgsRecall *recall, GList *port); 297 298 void ags_recall_add_port(AgsRecall *recall, 299 AgsPort *port); 300 void ags_recall_remove_port(AgsRecall *recall, 301 AgsPort *port); 302 303 GList* ags_recall_get_children(AgsRecall *recall); 304 void ags_recall_set_children(AgsRecall *recall, 305 GList *children); 306 307 void ags_recall_add_child(AgsRecall *recall, AgsRecall *child); 308 void ags_recall_remove_child(AgsRecall *recall, AgsRecall *child); 309 310 void ags_recall_handler_free(AgsRecallHandler *recall_handler); 311 AgsRecallHandler* ags_recall_handler_alloc(const gchar *signal_name, 312 GCallback callback, 313 GObject *data); 314 315 void ags_recall_add_recall_handler(AgsRecall *recall, 316 AgsRecallHandler *recall_handler); 317 void ags_recall_remove_recall_handler(AgsRecall *recall, 318 AgsRecallHandler *recall_handler); 319 320 /* soundcard */ 321 GObject* ags_recall_get_output_soundcard(AgsRecall *recall); 322 void ags_recall_set_output_soundcard(AgsRecall *recall, GObject *output_soundcard); 323 324 GObject* ags_recall_get_input_soundcard(AgsRecall *recall); 325 void ags_recall_set_input_soundcard(AgsRecall *recall, GObject *input_soundcard); 326 327 /* presets */ 328 guint ags_recall_get_samplerate(AgsRecall *recall); 329 void ags_recall_set_samplerate(AgsRecall *recall, guint samplerate); 330 331 guint ags_recall_get_buffer_size(AgsRecall *recall); 332 void ags_recall_set_buffer_size(AgsRecall *recall, guint buffer_size); 333 334 guint ags_recall_get_format(AgsRecall *recall); 335 void ags_recall_set_format(AgsRecall *recall, guint format); 336 337 /* events */ 338 void ags_recall_resolve_dependency(AgsRecall *recall); 339 void ags_recall_check_rt_data(AgsRecall *recall); 340 341 void ags_recall_run_init_pre(AgsRecall *recall); 342 void ags_recall_run_init_inter(AgsRecall *recall); 343 void ags_recall_run_init_post(AgsRecall *recall); 344 345 void ags_recall_feed_input_queue(AgsRecall *recall); 346 void ags_recall_automate(AgsRecall *recall); 347 348 void ags_recall_run_pre(AgsRecall *recall); 349 void ags_recall_run_inter(AgsRecall *recall); 350 void ags_recall_run_post(AgsRecall *recall); 351 352 void ags_recall_do_feedback(AgsRecall *recall); 353 void ags_recall_feed_output_queue(AgsRecall *recall); 354 355 void ags_recall_stop_persistent(AgsRecall *recall); 356 void ags_recall_cancel(AgsRecall *recall); 357 void ags_recall_done(AgsRecall *recall); 358 359 AgsRecall* ags_recall_duplicate(AgsRecall *recall, 360 AgsRecallID *recall_id, 361 guint *n_params, gchar **parameter_name, GValue *value); 362 363 void ags_recall_notify_dependency(AgsRecall *recall, guint dependency, gboolean increase); 364 void ags_recall_child_added(AgsRecall *recall, AgsRecall *child); 365 366 /* query */ 367 gboolean ags_recall_is_done(GList *recall, GObject *recycling_context); 368 369 GList* ags_recall_get_by_effect(GList *recall, gchar *filename, gchar *effect); 370 GList* ags_recall_find_recall_id_with_effect(GList *recall, AgsRecallID *recall_id, gchar *filename, gchar *effect); 371 372 GList* ags_recall_find_type(GList *recall, GType type); 373 GList* ags_recall_find_template(GList *recall); 374 GList* ags_recall_template_find_type(GList *recall, GType type); 375 GList* ags_recall_template_find_all_type(GList *recall, ...); 376 GList* ags_recall_find_type_with_recycling_context(GList *recall, GType type, GObject *recycling_context); 377 GList* ags_recall_find_recycling_context(GList *recall, GObject *recycling_context); 378 GList* ags_recall_find_provider(GList *recall, GObject *provider); 379 GList* ags_recall_template_find_provider(GList *recall, GObject *provider); 380 GList* ags_recall_find_provider_with_recycling_context(GList *recall, GObject *provider, GObject *recycling_context); 381 382 /* control */ 383 void ags_recall_lock_port(AgsRecall *recall); 384 void ags_recall_unlock_port(AgsRecall *recall); 385 386 /* instantiate */ 387 AgsRecall* ags_recall_new(); 388 389 G_END_DECLS 390 391 #endif /*__AGS_RECALL_H__*/ 392