allow user tweaking of everything that might have inherent latency; add GUI for track...
[ardour.git] / libs / ardour / ardour / vst_plugin.h
1 /*
2     Copyright (C) 2004 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 <list>
24 #include <map>
25 #include <set>
26 #include <vector>
27 #include <string>
28 #include <dlfcn.h>
29
30 #include <sigc++/signal.h>
31 #include <pbd/stateful.h> 
32 #include <jack/types.h>
33 #include <ardour/plugin.h>
34
35 using std::string;
36 using std::vector;
37 using std::list;
38 using std::map;
39
40 struct _FSTHandle;
41 struct _FST;
42 typedef struct _FSTHandle FSTHandle;
43 typedef struct _FST FST;
44 class AEffect;
45
46 namespace ARDOUR {
47 class AudioEngine;
48 class Session;
49
50 class VSTPlugin : public ARDOUR::Plugin
51 {
52   public:
53         VSTPlugin (ARDOUR::AudioEngine&, ARDOUR::Session&, FSTHandle* handle);
54         VSTPlugin (const VSTPlugin &);
55         ~VSTPlugin ();
56
57         /* Plugin interface */
58         
59         uint32_t unique_id() const;
60         const char * label() const;
61         const char * name() const;
62         const char * maker() const;
63         uint32_t parameter_count() const;
64         float default_value (uint32_t port);
65         nframes_t signal_latency() const;
66         void set_parameter (uint32_t port, float val);
67         float get_parameter (uint32_t port) const;
68         int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
69         std::set<uint32_t> automatable() const;
70         uint32_t nth_parameter (uint32_t port, bool& ok) const;
71         void activate ();
72         void deactivate ();
73         void set_block_size (nframes_t nframes);
74         int connect_and_run (BufferSet&, uint32_t& in, uint32_t& out, nframes_t nframes, nframes_t offset);
75         void store_state (ARDOUR::PluginState&);
76         void restore_state (ARDOUR::PluginState&);
77         string describe_parameter (uint32_t);
78         string state_node_name() const { return "vst"; }
79         void print_parameter (uint32_t, char*, uint32_t len) const;
80
81         bool parameter_is_audio(uint32_t i) const { return false; }
82         bool parameter_is_control(uint32_t i) const { return true; }
83         bool parameter_is_input(uint32_t i) const { return true; }
84         bool parameter_is_output(uint32_t i) const { return false; }
85
86         bool load_preset (const string preset_label );
87         bool save_preset(string name);
88
89         bool has_editor () const;
90
91         XMLNode& get_state();
92         int set_state(const XMLNode& node);
93
94         AEffect* plugin() const { return _plugin; }
95         FST* fst() const { return _fst; }
96
97
98   private:
99         FSTHandle* handle;
100         FST*       _fst;
101         AEffect*   _plugin;
102         bool        been_resumed;
103 };
104
105 class VSTPluginInfo : public PluginInfo
106 {
107   public:
108         VSTPluginInfo () {}
109         ~VSTPluginInfo () {}
110         
111         PluginPtr load (Session& session);
112 };
113
114 typedef boost::shared_ptr<VSTPluginInfo> VSTPluginInfoPtr;
115
116 } // namespace ARDOUR
117
118 #endif /* __ardour_vst_plugin_h__ */