Start using libappleutility
[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 <stdint.h>
25
26 #include <list>
27 #include <set>
28 #include <string>
29 #include <vector>
30
31 #include <ardour/plugin.h>
32
33 #include <boost/shared_ptr.hpp>
34
35 class CAComponent;
36 class CAAudioUnit;
37 class CAComponentDescription;
38
39 namespace ARDOUR {
40
41 class AudioEngine;
42 class Session;
43
44 class AUPlugin : public ARDOUR::Plugin
45 {
46   public:
47         AUPlugin (AudioEngine& engine, Session& session, CAComponent* comp);
48         virtual ~AUPlugin ();
49         
50         uint32_t unique_id () const;
51         const char * label () const;
52         const char * name () const { return _info->name.c_str(); }
53         const char * maker () const;
54         uint32_t parameter_count () const;
55         float default_value (uint32_t port);
56         jack_nframes_t latency () const;
57         void set_parameter (uint32_t which, float val);
58         float get_parameter (uint32_t which) const;
59     
60         int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
61         uint32_t nth_parameter (uint32_t which, bool& ok) const;
62         void activate ();
63         void deactivate ();
64         void set_block_size (jack_nframes_t nframes);
65     
66         int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, jack_nframes_t nframes, jack_nframes_t offset);
67         std::set<uint32_t> automatable() const;
68         void store_state (ARDOUR::PluginState&);
69         void restore_state (ARDOUR::PluginState&);
70         string describe_parameter (uint32_t);
71         string state_node_name () const { return "audiounit"; }
72         void print_parameter (uint32_t, char*, uint32_t len) const;
73     
74         bool parameter_is_audio (uint32_t) const;
75         bool parameter_is_control (uint32_t) const;
76         bool parameter_is_input (uint32_t) const;
77         bool parameter_is_output (uint32_t) const;
78     
79         XMLNode& get_state();
80         int set_state(const XMLNode& node);
81         
82         bool save_preset (string name);
83         bool load_preset (const string preset_label);
84         std::vector<std::string> get_presets ();
85     
86         bool has_editor () const;
87         
88   private:
89         CAComponent* comp;
90     CAAudioUnit* unit;
91 };
92
93 class AUPluginInfo : public PluginInfo {
94   public:       
95         AUPluginInfo () { };
96         ~AUPluginInfo ();
97
98         CAComponentDescription* desc;
99
100         static PluginInfoList discover ();
101         PluginPtr load (Session& session);
102
103   private:
104         static std::string get_name (CAComponentDescription&);
105 };
106
107 typedef boost::shared_ptr<AUPluginInfo> AUPluginInfoPtr;
108
109 } // namespace ARDOUR
110
111 #endif // __ardour_audio_unit_h__