Gruesome-in-the-extreme VST hacks to attempt to allow presets to
[ardour.git] / libs / fst / fst.h
1 #ifndef __fst_fst_h__
2 #define __fst_fst_h__
3
4 #include <setjmp.h>
5 #include <signal.h>
6 #include <pthread.h>
7
8 /**
9  * Display FST error message.
10  *
11  * Set via fst_set_error_function(), otherwise a FST-provided
12  * default will print @a msg (plus a newline) to stderr.
13  *
14  * @param msg error message text (no newline at end).
15  */
16 extern void (*fst_error_callback)(const char *msg);
17
18 /**
19  * Set the @ref fst_error_callback for error message display.
20  *
21  * The FST library provides two built-in callbacks for this purpose:
22  * default_fst_error_callback() and silent_fst_error_callback().
23  */
24 void fst_set_error_function (void (*func)(const char *));
25
26 void  fst_error (const char *fmt, ...);
27
28 #define VESTIGE_HEADER
29
30 #ifdef VESTIGE_HEADER
31 #include <vestige/aeffectx.h>
32 #endif
33
34 typedef struct _FST FST;
35 typedef struct _FSTHandle FSTHandle;
36 typedef struct _FSTInfo FSTInfo;
37 typedef struct _FSTKey FSTKey;
38
39 struct _FSTInfo 
40 {
41     char *name;
42     char *creator;
43     int UniqueID;
44     char *Category;
45     
46     int numInputs;
47     int numOutputs;
48     int numParams;
49
50     int wantMidi;
51     int wantEvents;
52     int hasEditor;
53     int canProcessReplacing; // what do we need this for ?
54
55     // i think we should save the parameter Info Stuff soon.
56     // struct VstParameterInfo *infos;
57     char **ParamNames;
58     char **ParamLabels;
59 };
60
61 typedef struct AEffect * (*main_entry_t)(audioMasterCallback);
62
63 struct _FSTHandle
64 {
65     void*    dll;
66     char*    name;
67     char*    nameptr; /* ptr returned from strdup() etc. */
68     //struct AEffect* (*main_entry)(audioMasterCallback);
69     main_entry_t main_entry;
70
71     int plugincnt;
72 };
73
74 struct _FSTKey
75 {
76         /** virtual-key code, or 0 if this _FSTKey is a `character' key */
77         int special;
78         /** `character' key, or 0 if this _FSTKey is a virtual-key */
79         int character;
80 };
81
82 struct _FST 
83 {
84     struct AEffect*    plugin;
85     void*       window; /* win32 HWND */
86     int         xid; /* X11 XWindow */
87     FSTHandle*  handle;
88     int         width;
89     int         height;
90     int         wantIdle;
91     int         destroy;
92     int         vst_version;
93     int         has_editor;
94
95     int         program_set_without_editor;
96     int         want_program;
97     int         want_chunk;
98     unsigned char *wanted_chunk;
99     int         wanted_chunk_size;
100     int         current_program;
101     float      *want_params;
102     float      *set_params;
103         
104     FSTKey      pending_keys[16];
105     int         n_pending_keys;
106
107     int         dispatcher_wantcall;
108     int         dispatcher_opcode;
109     int         dispatcher_index;
110     int         dispatcher_val;
111     void *      dispatcher_ptr;
112     float       dispatcher_opt;
113     int         dispatcher_retval;
114
115     struct _FST* next;
116     pthread_mutex_t lock;
117     pthread_cond_t  window_status_change;
118     pthread_cond_t  plugin_dispatcher_called;
119     int             been_activated;
120 };
121
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125
126 extern int        fst_init (void* possible_hmodule);
127 extern void       fst_exit ();
128
129 extern FSTHandle* fst_load (const char*);
130 extern int        fst_unload (FSTHandle*);
131
132 extern FST*       fst_instantiate (FSTHandle*, audioMasterCallback amc, void* userptr);
133 extern void       fst_close (FST*);
134
135 extern int fst_create_editor (FST* fst);
136 extern int  fst_run_editor (FST*);
137 extern void  fst_destroy_editor (FST*);
138 extern int  fst_get_XID (FST*);
139 extern void fst_move_window_into_view (FST*);
140
141 extern FSTInfo *fst_get_info (char *dllpathname);
142 extern void fst_free_info (FSTInfo *info);
143 extern void fst_event_loop_remove_plugin (FST* fst);
144 extern int fst_call_dispatcher(FST *fst, int opcode, int index, int val, void *ptr, float opt );
145
146 /**
147  * Load a plugin state from a file.
148  */
149 extern int fst_load_state (FST * fst, char * filename);
150
151 /**
152  * Save a plugin state to a file.
153  */
154 extern int fst_save_state (FST * fst, char * filename);
155
156 extern int wine_pthread_create (pthread_t* thread_id, const pthread_attr_t* attr, void *(*function)(void*), void* arg);
157
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif /* __fst_fst_h__ */