0d64e38ffc6fe493418d675d35cbbc65dae819a6
[ardour.git] / libs / ardour / ardour / audio_unit.h
1 /*
2     Copyright (C) 2006 Paul Davis 
3         Written by Taybin Rutkin
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __ardour_audio_unit_h__
22 #define __ardour_audio_unit_h__
23
24 #include <list>
25
26 #include <ardour/plugin.h>
27
28 #include <boost/shared_ptr.hpp>
29
30 struct ComponentDescription;
31
32 namespace ARDOUR {
33
34 class CAAudioUnit;
35
36 class AUPlugin : public ARDOUR::Plugin
37 {
38   public:
39         AUPlugin (AudioEngine& engine, Session& session) : Plugin(engine, session) {};
40         virtual ~AUPlugin () {};
41         
42         uint32_t unique_id () const;
43         const char * label () const;
44         const char * name () const { return _info->name.c_str(); }
45         const char * maker () const;
46         uint32_t parameter_count () const;
47         float default_value (uint32_t port);
48         jack_nframes_t latency () const;
49         void set_parameter (uint32_t which, float val);
50         float get_parameter (uint32_t which) const;
51     
52         int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
53         uint32_t nth_parameter (uint32_t which, bool& ok) const;
54         void activate ();
55         void deactivate ();
56         void set_block_size (jack_nframes_t nframes);
57     
58         int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, jack_nframes_t nframes, jack_nframes_t offset);
59         std::set<uint32_t> automatable() const;
60         void store_state (ARDOUR::PluginState&);
61         void restore_state (ARDOUR::PluginState&);
62         string describe_parameter (uint32_t);
63         string state_node_name () const;
64         void print_parameter (uint32_t, char*, uint32_t len) const;
65     
66         bool parameter_is_audio (uint32_t) const;
67         bool parameter_is_control (uint32_t) const;
68         bool parameter_is_input (uint32_t) const;
69         bool parameter_is_output (uint32_t) const;
70     
71         bool save_preset (string name);
72         bool load_preset (const string preset_label);
73         std::vector<std::string> get_presets ();
74     
75         bool has_editor () const;
76         
77   private:
78     boost::shared_ptr<CAAudioUnit> unit;
79 };
80
81 class AUPluginInfo : public PluginInfo {
82   public:
83         typedef boost::shared_ptr<ComponentDescription> CompDescPtr;
84         
85         AUPluginInfo () { };
86         ~AUPluginInfo () { };
87
88         CompDescPtr desc;
89
90         static PluginInfoList discover ();
91         PluginPtr load (Session& session);
92
93   private:
94         static std::string get_name (ComponentDescription&);
95 };
96
97 typedef boost::shared_ptr<AUPluginInfo> AUPluginInfoPtr;
98
99 } // namespace ARDOUR
100
101 #endif // __ardour_audio_unit_h__