libardour added.
[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     $Id$
19 */
20
21 #ifndef __ardour_vst_plugin_h__
22 #define __ardour_vst_plugin_h__
23
24 #include <list>
25 #include <map>
26 #include <set>
27 #include <vector>
28 #include <string>
29 #include <dlfcn.h>
30
31 #include <midi++/controllable.h>
32 #include <sigc++/signal.h>
33
34 #include <jack/types.h>
35 #include <ardour/stateful.h>
36 #include <ardour/plugin_state.h>
37 #include <ardour/plugin.h>
38 #include <ardour/vst_plugin.h>
39
40 using std::string;
41 using std::vector;
42 using std::list;
43 using std::map;
44
45 struct _FSTHandle;
46 struct _FST;
47 typedef struct _FSTHandle FSTHandle;
48 typedef struct _FST FST;
49 class AEffect;
50
51 namespace ARDOUR {
52 class AudioEngine;
53 class Session;
54
55 class VSTPlugin : public ARDOUR::Plugin
56 {
57   public:
58         VSTPlugin (ARDOUR::AudioEngine&, ARDOUR::Session&, FSTHandle* handle);
59         VSTPlugin (const VSTPlugin &);
60         ~VSTPlugin ();
61
62         /* Plugin interface */
63         
64         uint32_t unique_id() const;
65         const char * label() const;
66         const char * name() const;
67         const char * maker() const;
68         uint32_t parameter_count() const;
69         float default_value (uint32_t port);
70         jack_nframes_t latency() const;
71         void set_parameter (uint32_t port, float val);
72         float get_parameter (uint32_t port) const;
73         int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
74         std::set<uint32_t> automatable() const;
75         uint32_t nth_parameter (uint32_t port, bool& ok) const;
76         void activate ();
77         void deactivate ();
78         void set_block_size (jack_nframes_t nframes);
79         int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, jack_nframes_t nframes, jack_nframes_t offset);
80         void store_state (ARDOUR::PluginState&);
81         void restore_state (ARDOUR::PluginState&);
82         string describe_parameter (uint32_t);
83         string state_node_name() const { return "vst"; }
84         void print_parameter (uint32_t, char*, uint32_t len) const;
85
86         bool parameter_is_audio(uint32_t i) const { return false; }
87         bool parameter_is_control(uint32_t i) const { return true; }
88         bool parameter_is_input(uint32_t i) const { return true; }
89         bool parameter_is_output(uint32_t i) const { return false; }
90
91         bool load_preset (const string preset_label );
92         bool save_preset(string name);
93
94         bool has_editor () const;
95
96         XMLNode& get_state();
97         int set_state(const XMLNode& node);
98
99         AEffect* plugin() const { return _plugin; }
100         FST* fst() const { return _fst; }
101
102
103   private:
104         FSTHandle* handle;
105         FST*       _fst;
106         AEffect*   _plugin;
107         bool        been_resumed;
108 };
109
110 }
111
112 #endif /* __ardour_vst_plugin_h__ */