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_PLUGIN_PORT_H__
21 #define __AGS_PLUGIN_PORT_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_PLUGIN_PORT                (ags_plugin_port_get_type())
31 #define AGS_PLUGIN_PORT(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_PLUGIN_PORT, AgsPluginPort))
32 #define AGS_PLUGIN_PORT_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_PLUGIN_PORT, AgsPluginPortClass))
33 #define AGS_IS_PLUGIN_PORT(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_PLUGIN_PORT))
34 #define AGS_IS_PLUGIN_PORT_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_PLUGIN_PORT))
35 #define AGS_PLUGIN_PORT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), AGS_TYPE_PLUGIN_PORT, AgsPluginPortClass))
36 
37 #define AGS_PLUGIN_PORT_GET_OBJ_MUTEX(obj) (&(((AgsPluginPort *) obj)->obj_mutex))
38 
39 typedef struct _AgsPluginPort AgsPluginPort;
40 typedef struct _AgsPluginPortClass AgsPluginPortClass;
41 
42 /**
43  * AgsPluginPortFlags:
44  * @AGS_PLUGIN_PORT_ATOM: atom port
45  * @AGS_PLUGIN_PORT_AUDIO: audio port
46  * @AGS_PLUGIN_PORT_CONTROL: control port
47  * @AGS_PLUGIN_PORT_MIDI: MIDI port
48  * @AGS_PLUGIN_PORT_EVENT: event port
49  * @AGS_PLUGIN_PORT_OUTPUT: is output
50  * @AGS_PLUGIN_PORT_INPUT: is input
51  * @AGS_PLUGIN_PORT_TOGGLED: toggle control
52  * @AGS_PLUGIN_PORT_ENUMERATION: enumerated
53  * @AGS_PLUGIN_PORT_LOGARITHMIC: logarithmic
54  * @AGS_PLUGIN_PORT_INTEGER: integer
55  * @AGS_PLUGIN_PORT_SAMPLERATE: samplerate
56  * @AGS_PLUGIN_PORT_BOUNDED_BELOW: bounded below
57  * @AGS_PLUGIN_PORT_BOUNDED_ABOVE: bounded above
58  * @AGS_PLUGIN_PORT_UI_NOTIFICATION: ui notification
59  *
60  * Common port attributes.
61  */
62 typedef enum{
63   AGS_PLUGIN_PORT_ATOM            = 1,
64   AGS_PLUGIN_PORT_AUDIO           = 1 <<  1,
65   AGS_PLUGIN_PORT_CONTROL         = 1 <<  2,
66   AGS_PLUGIN_PORT_MIDI            = 1 <<  3,
67   AGS_PLUGIN_PORT_EVENT           = 1 <<  4,
68   AGS_PLUGIN_PORT_OUTPUT          = 1 <<  5,
69   AGS_PLUGIN_PORT_INPUT           = 1 <<  6,
70   AGS_PLUGIN_PORT_TOGGLED         = 1 <<  7,
71   AGS_PLUGIN_PORT_ENUMERATION     = 1 <<  8,
72   AGS_PLUGIN_PORT_LOGARITHMIC     = 1 <<  9,
73   AGS_PLUGIN_PORT_INTEGER         = 1 << 10,
74   AGS_PLUGIN_PORT_SAMPLERATE      = 1 << 11,
75   AGS_PLUGIN_PORT_BOUNDED_BELOW   = 1 << 12,
76   AGS_PLUGIN_PORT_BOUNDED_ABOVE   = 1 << 13,
77   AGS_PLUGIN_PORT_UI_NOTIFICATION = 1 << 14,
78 }AgsPluginPortFlags;
79 
80 struct _AgsPluginPort
81 {
82   GObject gobject;
83 
84   guint flags;
85 
86   GRecMutex obj_mutex;
87 
88   guint port_index;
89 
90   gchar *port_name;
91   gchar *port_symbol;
92 
93   gint scale_steps;
94   gchar **scale_point;
95   gdouble *scale_value;
96 
97   GValue *lower_value;
98   GValue *upper_value;
99 
100   GValue *default_value;
101 
102   gpointer user_data;
103 };
104 
105 struct _AgsPluginPortClass
106 {
107   GObjectClass gobject;
108 };
109 
110 GType ags_plugin_port_get_type(void);
111 GType ags_plugin_port_flags_get_type();
112 
113 GRecMutex* ags_plugin_port_get_obj_mutex(AgsPluginPort *plugin_port);
114 
115 gboolean ags_plugin_port_test_flags(AgsPluginPort *plugin_port, guint flags);
116 void ags_plugin_port_set_flags(AgsPluginPort *plugin_port, guint flags);
117 void ags_plugin_port_unset_flags(AgsPluginPort *plugin_port, guint flags);
118 
119 guint ags_plugin_port_get_port_index(AgsPluginPort *plugin_port);
120 void ags_plugin_port_set_port_index(AgsPluginPort *plugin_port,
121 				    guint port_index);
122 
123 gchar* ags_plugin_port_get_port_name(AgsPluginPort *plugin_port);
124 void ags_plugin_port_set_port_name(AgsPluginPort *plugin_port,
125 				   gchar *port_name);
126 
127 gchar* ags_plugin_port_get_port_symbol(AgsPluginPort *plugin_port);
128 void ags_plugin_port_set_port_symbol(AgsPluginPort *plugin_port,
129 				     gchar *port_symbol);
130 
131 gint ags_plugin_port_get_scale_steps(AgsPluginPort *plugin_port);
132 void ags_plugin_port_set_scale_steps(AgsPluginPort *plugin_port,
133 				     gint scale_steps);
134 
135 gchar** ags_plugin_port_get_scale_point(AgsPluginPort *plugin_port);
136 void ags_plugin_port_set_scale_point(AgsPluginPort *plugin_port,
137 				     gchar **scale_point);
138 
139 gdouble* ags_plugin_port_get_scale_value(AgsPluginPort *plugin_port);
140 void ags_plugin_port_set_scale_value(AgsPluginPort *plugin_port,
141 				     gdouble *scale_value);
142 
143 GValue* ags_plugin_port_get_lower_value(AgsPluginPort *plugin_port);
144 void ags_plugin_port_set_lower_value(AgsPluginPort *plugin_port,
145 				     GValue *lower_value);
146 
147 GValue* ags_plugin_port_get_upper_value(AgsPluginPort *plugin_port);
148 void ags_plugin_port_set_upper_value(AgsPluginPort *plugin_port,
149 				     GValue *upper_value);
150 
151 GValue* ags_plugin_port_get_default_value(AgsPluginPort *plugin_port);
152 void ags_plugin_port_set_default_value(AgsPluginPort *plugin_port,
153 				       GValue *default_value);
154 
155 GList* ags_plugin_port_find_symbol(GList *plugin_port,
156 				   gchar *port_symbol);
157 GList* ags_plugin_port_find_port_index(GList *plugin_port,
158 				       guint port_index);
159 
160 AgsPluginPort* ags_plugin_port_new();
161 
162 G_END_DECLS
163 
164 #endif /*__AGS_PLUGIN_PORT_H__*/
165