consolidate VSTState functions
[ardour.git] / libs / ardour / ardour / vst_types.h
1 /*
2     Copyright (C) 2010 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_vst_types_h__
21 #define __ardour_vst_types_h__
22
23 #include <pthread.h>
24 #include "ardour/libardour_visibility.h"
25 #include "ardour/vestige/aeffectx.h"
26
27 struct LIBARDOUR_API _VSTKey
28 {
29         /** virtual-key code, or 0 if this _VSTFXKey is a `character' key */
30         int special;
31         /** `character' key, or 0 if this _VSTFXKey is a virtual-key */
32         int character;
33 };
34
35 typedef struct _VSTKey VSTKey;
36
37 struct LIBARDOUR_API _VSTInfo
38 {
39         char  *name;
40         char  *creator;
41         int    UniqueID;
42         char  *Category;
43
44         int    numInputs;
45         int    numOutputs;
46         int    numParams;
47
48         int    wantMidi;
49         int    wantEvents;
50         int    hasEditor;
51         int    isInstrument; // still unused
52         int    canProcessReplacing;
53
54         char** ParamNames;
55         char** ParamLabels;
56 };
57
58 typedef struct _VSTInfo VSTInfo;
59
60 typedef AEffect * (* main_entry_t) (audioMasterCallback);
61
62 struct LIBARDOUR_API _VSTHandle
63 {
64         void*        dll;
65         char*        name;
66         char*        path;
67
68         main_entry_t main_entry;
69
70         int          plugincnt;
71 #ifdef MACVST_SUPPORT
72         int32_t      res_file_id;
73 #endif
74 };
75
76 typedef struct _VSTHandle VSTHandle;
77
78 struct LIBARDOUR_API _VSTState
79 {
80         AEffect* plugin;
81
82         /* Linux */
83         int         linux_window;            ///< The plugin's parent X11 XWindow
84         int         linux_plugin_ui_window;  ///< The ID of the plugin UI window created by the plugin
85
86         /* Windows */
87         void*       windows_window;
88
89         int         xid;               ///< X11 XWindow
90
91         int         want_resize;       ///< Set to signal the plugin resized its UI
92         void*       extra_data;        ///< Pointer to any extra data
93
94         void * event_callback_thisptr;
95         void  (* eventProc) (void * event);
96
97         VSTHandle*  handle;
98
99         int width;
100         int height;
101         int wantIdle;
102
103         int voffset;
104         int hoffset;
105         int gui_shown;
106         int destroy;
107         int vst_version;
108         int has_editor;
109
110         int         program_set_without_editor;
111
112         int         want_program;
113         int         want_chunk;
114         int         n_pending_keys;
115         unsigned char * wanted_chunk;
116         int         wanted_chunk_size;
117         float *     want_params;
118         float *     set_params;
119
120         VSTKey      pending_keys[16];
121
122         int         dispatcher_wantcall;
123         int         dispatcher_opcode;
124         int         dispatcher_index;
125         int         dispatcher_val;
126         void *      dispatcher_ptr;
127         float       dispatcher_opt;
128         int         dispatcher_retval;
129
130         struct _VSTState * next;
131         pthread_mutex_t    lock;
132         pthread_mutex_t    state_lock;
133         pthread_cond_t     window_status_change;
134         pthread_cond_t     plugin_dispatcher_called;
135         pthread_cond_t     window_created;
136         int                been_activated;
137 };
138
139 typedef struct _VSTState VSTState;
140
141 #ifdef __cplusplus
142 extern "C" {
143 #endif
144 LIBARDOUR_API extern void vststate_init (VSTState* state);
145 LIBARDOUR_API extern void vststate_maybe_set_program (VSTState* state);
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif