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_LV2_BRIDGE_H__
21 #define __AGS_LV2_BRIDGE_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <gtk/gtk.h>
27 
28 #include <ags/libags.h>
29 #include <ags/libags-audio.h>
30 
31 #include <ags/libags-gui.h>
32 
33 #include <ags/X/ags_machine.h>
34 
35 #include <lv2.h>
36 #include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
37 
38 G_BEGIN_DECLS
39 
40 #define AGS_TYPE_LV2_BRIDGE                (ags_lv2_bridge_get_type())
41 #define AGS_LV2_BRIDGE(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_LV2_BRIDGE, AgsLv2Bridge))
42 #define AGS_LV2_BRIDGE_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_LV2_BRIDGE, AgsLv2BridgeClass))
43 #define AGS_IS_LV2_BRIDGE(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_LV2_BRIDGE))
44 #define AGS_IS_LV2_BRIDGE_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_LV2_BRIDGE))
45 #define AGS_LV2_BRIDGE_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_LV2_BRIDGE, AgsLv2BridgeClass))
46 
47 #define AGS_LV2_BRIDGE_DEFAULT_VERSION "0.4.3"
48 #define AGS_LV2_BRIDGE_DEFAULT_BUILD_ID "CEST 13-05-2015 13:40"
49 
50 typedef struct _AgsLv2Bridge AgsLv2Bridge;
51 typedef struct _AgsLv2BridgeClass AgsLv2BridgeClass;
52 
53 typedef enum{
54   AGS_LV2_BRIDGE_DISPLAY_INPUT    = 1,
55   AGS_LV2_BRIDGE_BULK_OUTPUT      = 1 <<  1,
56   AGS_LV2_BRIDGE_DISPLAY_OUTPUT   = 1 <<  2,
57   AGS_LV2_BRIDGE_BULK_INPUT       = 1 <<  3,
58   AGS_LV2_BRIDGE_NO_UPDATE        = 1 <<  4,
59 }AgsLv2BridgeFlags;
60 
61 struct _AgsLv2Bridge
62 {
63   AgsMachine machine;
64 
65   guint flags;
66 
67   gchar *name;
68 
69   gchar *version;
70   gchar *build_id;
71 
72   gchar *xml_type;
73 
74   guint mapped_output_pad;
75   guint mapped_input_pad;
76 
77   AgsRecallContainer *lv2_play_container;
78   AgsRecallContainer *lv2_recall_container;
79 
80   AgsRecallContainer *envelope_play_container;
81   AgsRecallContainer *envelope_recall_container;
82 
83   AgsRecallContainer *buffer_play_container;
84   AgsRecallContainer *buffer_recall_container;
85 
86   gchar *filename;
87   gchar *effect;
88   gchar *uri;
89   guint uri_index;
90 
91   gboolean has_midi;
92 
93   AgsLv2Plugin *lv2_plugin;
94 
95   LV2_Descriptor *lv2_descriptor;
96   LV2_Handle *lv2_handle;
97   float *port_value;
98 
99   gboolean has_gui;
100   gchar *gui_filename;
101   gchar *gui_uri;
102 
103   AgsLv2uiPlugin *lv2ui_plugin;
104 
105   LV2UI_Descriptor *ui_descriptor;
106   LV2_Feature **ui_feature;
107   LV2UI_Handle *ui_handle;
108 
109   GtkBox *vbox;
110 
111   GtkComboBox *program;
112   GtkComboBox *preset;
113 
114   GtkMenu *lv2_menu;
115 
116   GtkWidget *lv2_gui;
117   GtkWidget *ui_widget;
118 
119   GtkWidget *lv2_window;
120 };
121 
122 struct _AgsLv2BridgeClass
123 {
124   AgsMachineClass machine;
125 };
126 
127 GType ags_lv2_bridge_get_type(void);
128 
129 void ags_lv2_bridge_input_map_recall(AgsLv2Bridge *lv2_bridge,
130 				     guint audio_channel_start,
131 				     guint input_pad_start);
132 void ags_lv2_bridge_output_map_recall(AgsLv2Bridge *lv2_bridge,
133 				      guint audio_channel_start,
134 				      guint output_pad_start);
135 
136 void ags_lv2_bridge_load_program(AgsLv2Bridge *lv2_bridge);
137 void ags_lv2_bridge_load_preset(AgsLv2Bridge *lv2_bridge);
138 void ags_lv2_bridge_load_midi(AgsLv2Bridge *lv2_bridge);
139 void ags_lv2_bridge_load_gui(AgsLv2Bridge *lv2_bridge);
140 void ags_lv2_bridge_load(AgsLv2Bridge *lv2_bridge);
141 
142 gboolean ags_lv2_bridge_lv2ui_idle_timeout(GtkWidget *widget);
143 
144 AgsLv2Bridge* ags_lv2_bridge_new(GObject *soundcard,
145 				 gchar *filename,
146 				 gchar *effect);
147 
148 G_END_DECLS
149 
150 #endif /*__AGS_LV2_BRIDGE_H__*/
151