Change the feedback alert to a flashing button; works
[ardour.git] / libs / ardour / ardour / vstfx.h
1 #ifndef __vstfx_h__
2 #define __vstfx_h__
3
4 #include <setjmp.h>
5 #include <signal.h>
6 #include <pthread.h>
7 #include <stdio.h>
8
9 /******************************************************************************************/
10 /*VSTFX - an engine to manage native linux VST plugins - derived from FST for Windows VSTs*/
11 /******************************************************************************************/
12  
13 extern void (*vstfx_error_callback)(const char *msg);
14
15 void vstfx_set_error_function (void (*func)(const char *));
16
17 void  vstfx_error (const char *fmt, ...);
18
19 /*We will use the vestige headers*/
20
21 #define VESTIGE_HEADER
22
23 #include <ardour/vestige/aeffectx.h>
24
25 typedef struct _VSTFX VSTFX;
26 typedef struct _VSTFXHandle VSTFXHandle;
27 typedef struct _VSTFXInfo VSTFXInfo;
28 typedef struct _VSTFXKey VSTFXKey;
29
30
31 /*Struct to contain the info about a plugin*/
32
33 struct _VSTFXInfo 
34 {
35     char *name;
36     char *creator;
37     int UniqueID;
38     char *Category;
39     
40     int numInputs;
41     int numOutputs;
42     int numParams;
43
44     int wantMidi;
45     int wantEvents;
46     int hasEditor;
47     int canProcessReplacing;
48
49     /* i think we should save the parameter Info Stuff soon. */
50     // struct VstParameterInfo *infos;
51     char **ParamNames;
52     char **ParamLabels;
53 };
54
55 /*The AEffect which contains the info about a plugin instance*/
56
57 typedef struct AEffect * (*main_entry_t)(audioMasterCallback);
58
59 /*A handle used to identify a plugin to vstfx*/
60
61 struct _VSTFXHandle
62 {
63     void*    dll;
64     char*    name;
65     char*    nameptr; /* ptr returned from strdup() etc. */
66         
67     main_entry_t main_entry;
68
69     int plugincnt;
70 };
71
72 /*No key forwarding enabled in vstfx at the moment - maybe
73   not required*/
74
75 struct _VSTFXKey
76 {
77     /** virtual-key code, or 0 if this _VSTFXKey is a `character' key */
78     int special;
79     /** `character' key, or 0 if this _VSTFXKey is a virtual-key */
80     int character;
81 };
82
83
84
85 /*Structure used to describe the instance of VSTFX responsible for
86   a particular plugin instance.  These are connected together in a 
87   linked list*/
88
89 struct _VSTFX 
90 {
91     struct AEffect*    plugin;
92     int         window;            /* The plugin's parent X11 XWindow */
93     int         plugin_ui_window;  /*The ID of the plugin UI window created by the plugin*/
94     int         xid;               /* X11 XWindow */
95         
96     int         want_resize;       /*Set to signal the plugin resized its UI*/
97     void*       extra_data;        /*Pointer to any extra data*/
98         
99     void* event_callback_thisptr;
100     void (*eventProc) (void* event);
101         
102     VSTFXHandle*  handle;
103         
104     int         width;
105     int         height;
106     int         wantIdle;
107     int         destroy;
108     int         vst_version;
109     int         has_editor;
110         
111     int         program_set_without_editor;
112
113     int         want_program;
114     int         want_chunk;
115     int         n_pending_keys;
116     unsigned char* wanted_chunk;
117     int         wanted_chunk_size;
118     int         current_program;
119     float       *want_params;
120     float       *set_params;
121         
122     VSTFXKey    pending_keys[16];
123
124     int         dispatcher_wantcall;
125     int         dispatcher_opcode;
126     int         dispatcher_index;
127     int         dispatcher_val;
128     void *      dispatcher_ptr;
129     float       dispatcher_opt;
130     int         dispatcher_retval;
131
132     struct _VSTFX* next;
133     pthread_mutex_t lock;
134     pthread_cond_t  window_status_change;
135     pthread_cond_t  plugin_dispatcher_called;
136     pthread_cond_t  window_created;
137     int             been_activated;
138 };
139
140 /*API to vstfx*/
141
142 extern int          vstfx_launch_editor(VSTFX* vstfx);
143 extern int          vstfx_init (void* possible_hmodule);
144 extern void         vstfx_exit ();
145 extern VSTFXHandle* vstfx_load (const char*);
146 extern int          vstfx_unload (VSTFXHandle*);
147 extern VSTFX*       vstfx_instantiate (VSTFXHandle*, audioMasterCallback amc, void* userptr);
148 extern void         vstfx_close (VSTFX*);
149
150 extern int          vstfx_create_editor (VSTFX* vstfx);
151 extern int          vstfx_run_editor (VSTFX*);
152 extern void         vstfx_destroy_editor (VSTFX*);
153 extern int          vstfx_get_XID (VSTFX*);
154 extern void         vstfx_move_window_into_view (VSTFX*);
155
156 extern VSTFXInfo*   vstfx_get_info (char *dllpathname);
157 extern void         vstfx_free_info (VSTFXInfo *info);
158 extern void         vstfx_event_loop_remove_plugin (VSTFX* fst);
159 extern int          vstfx_call_dispatcher(VSTFX *vstfx, int opcode, int index, int val, void *ptr, float opt );
160
161 /** Load a plugin state from a file.**/
162
163 extern int vstfx_load_state (VSTFX* vstfx, char * filename);
164
165 /** Save a plugin state to a file.**/
166
167 extern int vstfx_save_state (VSTFX* vstfx, char * filename);
168
169
170 #endif /* __vstfx_h__ */