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_PORT_H__ 21 #define __AGS_PORT_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ladspa.h> 27 28 #include <ags/libags.h> 29 30 G_BEGIN_DECLS 31 32 #define AGS_TYPE_PORT (ags_port_get_type()) 33 #define AGS_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_PORT, AgsPort)) 34 #define AGS_PORT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_PORT, AgsPortClass)) 35 #define AGS_IS_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_PORT)) 36 #define AGS_IS_PORT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_PORT)) 37 #define AGS_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_PORT, AgsPortClass)) 38 39 #define AGS_PORT_GET_OBJ_MUTEX(obj) (&(((AgsPort *) obj)->obj_mutex)) 40 41 typedef struct _AgsPort AgsPort; 42 typedef struct _AgsPortClass AgsPortClass; 43 44 /** 45 * AgsPortFlags: 46 * @AGS_PORT_ADDED_TO_REGISTRY: add to registry 47 * @AGS_PORT_CONNECTED: indicates the port was connected by calling #AgsConnectable::connect() 48 * @AGS_PORT_CONVERT_ALWAYS: convert always 49 * @AGS_PORT_USE_LADSPA_FLOAT: use ladspa float 50 * @AGS_PORT_IS_OUTPUT: is output 51 * @AGS_PORT_INFINITE_RANGE: infinite range 52 * 53 * Enum values to control the behavior or indicate internal state of #AgsPort by 54 * enable/disable as flags. 55 */ 56 typedef enum{ 57 AGS_PORT_ADDED_TO_REGISTRY = 1, 58 AGS_PORT_CONNECTED = 1 << 1, 59 AGS_PORT_CONVERT_ALWAYS = 1 << 2, 60 AGS_PORT_USE_LADSPA_FLOAT = 1 << 3, 61 AGS_PORT_IS_OUTPUT = 1 << 4, 62 AGS_PORT_INFINITE_RANGE = 1 << 5, 63 }AgsPortFlags; 64 65 struct _AgsPort 66 { 67 GObject gobject; 68 69 guint flags; 70 71 GRecMutex obj_mutex; 72 73 AgsUUID *uuid; 74 75 gchar *plugin_name; 76 gchar *specifier; 77 78 gchar *control_port; 79 80 gboolean port_value_is_pointer; 81 GType port_value_type; 82 83 guint port_value_size; 84 guint port_value_length; 85 86 GObject *plugin_port; 87 AgsConversion *conversion; 88 89 GList *automation; 90 91 union _AgsPortValue{ 92 gboolean ags_port_boolean; 93 gint64 ags_port_int; 94 guint64 ags_port_uint; 95 gfloat ags_port_float; 96 LADSPA_Data ags_port_ladspa; 97 gdouble ags_port_double; 98 AgsComplex ags_port_complex; 99 gchar *ags_port_string; 100 gboolean *ags_port_boolean_ptr; 101 gint64 *ags_port_int_ptr; 102 guint64 *ags_port_uint_ptr; 103 gfloat *ags_port_float_ptr; 104 gdouble *ags_port_double_ptr; 105 AgsComplex *ags_port_complex_ptr; 106 gpointer ags_port_pointer; 107 GObject *ags_port_object; 108 }port_value; 109 }; 110 111 struct _AgsPortClass 112 { 113 GObjectClass gobject; 114 115 void (*safe_read)(AgsPort *port, GValue *value); 116 void (*safe_write)(AgsPort *port, GValue *value); 117 118 void (*safe_get_property)(AgsPort *port, gchar *property_name, GValue *value); 119 void (*safe_set_property)(AgsPort *port, gchar *property_name, GValue *value); 120 }; 121 122 GType ags_port_get_type(); 123 124 gboolean ags_port_test_flags(AgsPort *port, guint flags); 125 void ags_port_set_flags(AgsPort *port, guint flags); 126 void ags_port_unset_flags(AgsPort *port, guint flags); 127 128 void ags_port_safe_read(AgsPort *port, GValue *value); 129 void ags_port_safe_read_raw(AgsPort *port, GValue *value); 130 void ags_port_safe_write(AgsPort *port, GValue *value); 131 void ags_port_safe_write_raw(AgsPort *port, GValue *value); 132 133 void ags_port_safe_get_property(AgsPort *port, gchar *property_name, GValue *value); 134 void ags_port_safe_set_property(AgsPort *port, gchar *property_name, GValue *value); 135 136 GList* ags_port_find_specifier(GList *port, gchar *specifier); 137 138 void ags_port_add_automation(AgsPort *port, 139 GObject *automation); 140 void ags_port_remove_automation(AgsPort *port, 141 GObject *automation); 142 143 AgsPort* ags_port_new(); 144 145 G_END_DECLS 146 147 #endif /*__AGS_PORT_H__*/ 148