redesign VCA control over gain (and theoretically other scalar controls)
[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 <pbd/signals.h>
24 #include "ardour/plugin.h"
25
26 struct _AEffect;
27 typedef struct _AEffect AEffect;
28 struct _VSTHandle;
29 typedef struct _VSTHandle VSTHandle;
30 struct _VSTState;
31 typedef struct _VSTState VSTState;
32
33 #include "ardour/vestige/aeffectx.h"
34
35 namespace ARDOUR {
36
37 class PluginInsert;
38
39 /** Parent class for VST plugins of both Windows and Linux varieties */
40 class LIBARDOUR_API VSTPlugin : public Plugin
41 {
42 public:
43         VSTPlugin (AudioEngine &, Session &, VSTHandle *);
44         VSTPlugin (const VSTPlugin& other);
45         virtual ~VSTPlugin ();
46
47         void activate ();
48         void deactivate ();
49
50         int set_block_size (pframes_t);
51         bool inplace_broken() const { return true; }
52         float default_value (uint32_t port);
53         float get_parameter (uint32_t port) const;
54         uint32_t nth_parameter (uint32_t port, bool& ok) const;
55         void set_parameter (uint32_t port, float val);
56         void set_parameter_automated (uint32_t port, float val);
57         bool load_preset (PresetRecord);
58         int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
59         std::string describe_parameter (Evoral::Parameter);
60         framecnt_t signal_latency() const;
61         std::set<Evoral::Parameter> automatable() const;
62
63         PBD::Signal0<void> LoadPresetProgram;
64
65         bool parameter_is_audio (uint32_t) const { return false; }
66         bool parameter_is_control (uint32_t) const { return true; }
67         bool parameter_is_input (uint32_t) const { return true; }
68         bool parameter_is_output (uint32_t) const { return false; }
69
70         int connect_and_run (BufferSet&,
71                         framepos_t start, framepos_t end, double speed,
72                         ChanMapping in, ChanMapping out,
73                         pframes_t nframes, framecnt_t offset
74                         );
75
76         std::string unique_id () const;
77         const char * label () const;
78         const char * name () const;
79         const char * maker () const;
80         uint32_t parameter_count () const;
81         void print_parameter (uint32_t, char*, uint32_t len) const;
82
83         bool has_editor () const;
84
85         AEffect * plugin () const { return _plugin; }
86         VSTState * state () const { return _state; }
87         MidiBuffer * midi_buffer () const { return _midi_out_buf; }
88
89         int set_state (XMLNode const &, int);
90
91         int first_user_preset_index () const;
92
93         void set_insert (PluginInsert* pi, uint32_t num) { _pi = pi; _num = num; }
94         PluginInsert* plugin_insert () const { return _pi; }
95         uint32_t plugin_number () const { return _num; }
96         VstTimeInfo* timeinfo () { return &_timeInfo; }
97         framepos_t transport_frame () const { return _transport_frame; }
98         float transport_speed () const { return _transport_speed; }
99
100
101 protected:
102         void set_plugin (AEffect *);
103         gchar* get_chunk (bool) const;
104         int set_chunk (gchar const *, bool);
105         void add_state (XMLNode *) const;
106         bool load_user_preset (PresetRecord);
107         bool load_plugin_preset (PresetRecord);
108         std::string do_save_preset (std::string name);
109         void do_remove_preset (std::string name);
110         XMLTree * presets_tree () const;
111         std::string presets_file () const;
112         void find_presets ();
113
114         VSTHandle* _handle;
115         VSTState*  _state;
116         AEffect*   _plugin;
117         PluginInsert* _pi;
118         uint32_t      _num;
119
120         MidiBuffer* _midi_out_buf;
121         VstTimeInfo _timeInfo;
122
123         framepos_t _transport_frame;
124         float      _transport_speed;
125         mutable std::map <uint32_t, float> _parameter_defaults;
126 };
127
128 }
129
130 #endif