Fix a problem where VST automation data wasn't getting written (if the adjustments...
[ardour.git] / libs / ardour / ardour / vst_plugin.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_plugin_h__
21 #define __ardour_vst_plugin_h__
22
23 #include "ardour/plugin.h"
24
25 struct _AEffect;
26 typedef struct _AEffect AEffect;
27 struct _VSTHandle;
28 typedef struct _VSTHandle VSTHandle;
29 struct _VSTState;
30 typedef struct _VSTState VSTState;
31
32 namespace ARDOUR {
33
34 /** Parent class for VST plugins of both Windows and Linux varieties */
35 class LIBARDOUR_API VSTPlugin : public Plugin
36 {
37 public:
38         VSTPlugin (AudioEngine &, Session &, VSTHandle *);
39         virtual ~VSTPlugin ();
40
41         void activate ();
42         void deactivate ();
43
44         int set_block_size (pframes_t);
45         float default_value (uint32_t port);
46         float get_parameter (uint32_t port) const;
47         uint32_t nth_parameter (uint32_t port, bool& ok) const;
48         void set_parameter (uint32_t port, float val);
49         void set_parameter_automated (uint32_t port, float val);
50         bool load_preset (PresetRecord);
51         int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
52         std::string describe_parameter (Evoral::Parameter);
53         framecnt_t signal_latency() const;
54         std::set<Evoral::Parameter> automatable() const;
55
56         bool parameter_is_audio (uint32_t) const { return false; }
57         bool parameter_is_control (uint32_t) const { return true; }
58         bool parameter_is_input (uint32_t) const { return true; }
59         bool parameter_is_output (uint32_t) const { return false; }
60
61         int connect_and_run (
62                 BufferSet&, ChanMapping in, ChanMapping out,
63                 pframes_t nframes, framecnt_t offset
64                 );
65
66         std::string unique_id () const;
67         const char * label () const;
68         const char * name () const;
69         const char * maker () const;
70         uint32_t parameter_count () const;
71         void print_parameter (uint32_t, char*, uint32_t len) const;
72
73         bool has_editor () const;
74
75         AEffect * plugin () const { return _plugin; }
76         VSTState * state () const { return _state; }
77         MidiBuffer * midi_buffer () const { return _midi_out_buf; }
78
79         int set_state (XMLNode const &, int);
80
81         int first_user_preset_index () const;
82
83 protected:
84         void set_plugin (AEffect *);
85         gchar* get_chunk (bool) const;
86         int set_chunk (gchar const *, bool);
87         void add_state (XMLNode *) const;
88         bool load_user_preset (PresetRecord);
89         bool load_plugin_preset (PresetRecord);
90         std::string do_save_preset (std::string name);
91         void do_remove_preset (std::string name);
92         XMLTree * presets_tree () const;
93         std::string presets_file () const;
94         void find_presets ();
95
96         VSTHandle* _handle;
97         VSTState*  _state;
98         AEffect*   _plugin;
99
100         MidiBuffer* _midi_out_buf;
101 };
102
103 }
104
105 #endif