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