ardour
ladspa_plugin.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000-2006 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_ladspa_plugin_h__
21 #define __ardour_ladspa_plugin_h__
22 
23 #include <set>
24 #include <vector>
25 #include <string>
26 
27 #include <glibmm/module.h>
28 
29 #include "pbd/stateful.h"
30 
31 #include "ardour/ladspa.h"
32 #include "ardour/plugin.h"
33 
34 namespace ARDOUR {
35 class AudioEngine;
36 class Session;
37 
39 {
40  public:
41  LadspaPlugin (std::string module_path, ARDOUR::AudioEngine&, ARDOUR::Session&, uint32_t index, framecnt_t sample_rate);
42  LadspaPlugin (const LadspaPlugin &);
43  ~LadspaPlugin ();
44 
45  /* Plugin interface */
46 
47  std::string unique_id() const;
48  const char* label() const { return _descriptor->Label; }
49  const char* name() const { return _descriptor->Name; }
50  const char* maker() const { return _descriptor->Maker; }
51  uint32_t parameter_count() const { return _descriptor->PortCount; }
52  float default_value (uint32_t port) { return _default_value (port); }
53  framecnt_t signal_latency() const;
54  void set_parameter (uint32_t port, float val);
55  float get_parameter (uint32_t port) const;
56  int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
57  uint32_t nth_parameter (uint32_t port, bool& ok) const;
58 
59  std::set<Evoral::Parameter> automatable() const;
60 
61  void activate () {
62  if (!_was_activated && _descriptor->activate)
63  _descriptor->activate (_handle);
64 
65  _was_activated = true;
66  }
67 
68  void deactivate () {
69  if (_was_activated && _descriptor->deactivate)
70  _descriptor->deactivate (_handle);
71 
72  _was_activated = false;
73  }
74 
75  void cleanup () {
76  activate();
77  deactivate();
78 
79  if (_descriptor->cleanup)
80  _descriptor->cleanup (_handle);
81  }
82 
83  int set_block_size (pframes_t /*nframes*/) { return 0; }
84 
85  int connect_and_run (BufferSet& bufs,
86  ChanMapping in, ChanMapping out,
87  pframes_t nframes, framecnt_t offset);
88 
89  std::string describe_parameter (Evoral::Parameter);
90  std::string state_node_name() const { return "ladspa"; }
91  void print_parameter (uint32_t, char*, uint32_t len) const;
92 
93  bool parameter_is_audio(uint32_t) const;
94  bool parameter_is_control(uint32_t) const;
95  bool parameter_is_input(uint32_t) const;
96  bool parameter_is_output(uint32_t) const;
97  bool parameter_is_toggled(uint32_t) const;
98 
100  get_scale_points(uint32_t port_index) const;
101 
102  int set_state (const XMLNode&, int version);
103 
104  bool load_preset (PresetRecord);
105 
106  bool has_editor() const { return false; }
107 
108  int require_output_streams (uint32_t);
109 
110  /* LADSPA extras */
111 
112  LADSPA_Properties properties() const { return _descriptor->Properties; }
113  uint32_t index() const { return _index; }
114  const char * copyright() const { return _descriptor->Copyright; }
115  LADSPA_PortDescriptor port_descriptor(uint32_t i) const;
116  const LADSPA_PortRangeHint* port_range_hints() const { return _descriptor->PortRangeHints; }
117  const char * const * port_names() const { return _descriptor->PortNames; }
118 
119  void set_gain (float gain) { _descriptor->set_run_adding_gain (_handle, gain); }
120  void run_adding (uint32_t nsamples) { _descriptor->run_adding (_handle, nsamples); }
121  void connect_port (uint32_t port, float *ptr) { _descriptor->connect_port (_handle, port, ptr); }
122 
123  private:
124  float _default_value (uint32_t port) const;
125  std::string _module_path;
126  Glib::Module* _module;
133  uint32_t _index;
135 
136  void find_presets ();
137 
138  void init (std::string module_path, uint32_t index, framecnt_t rate);
139  void run_in_place (pframes_t nsamples);
140  void latency_compute_run ();
141  int set_state_2X (const XMLNode&, int version);
142  std::string do_save_preset (std::string name);
143  void do_remove_preset (std::string name);
144  std::string preset_envvar () const;
145  std::string preset_source (std::string) const;
146  bool write_preset_file (std::string);
147  void add_state (XMLNode *) const;
148 };
149 
151  public:
152  LadspaPluginInfo ();
154 
155  PluginPtr load (Session& session);
156 };
157 
159 
160 } // namespace ARDOUR
161 
162 #endif /* __ardour_ladspa_plugin_h__ */
bool has_editor() const
LADSPA_Properties properties() const
void * LADSPA_Handle
Definition: ladspa.h:366
const LADSPA_Descriptor * _descriptor
int LADSPA_PortDescriptor
Definition: ladspa.h:154
uint32_t pframes_t
Definition: types.h:61
const char * name() const
Definition: ladspa_plugin.h:49
LIBARDOUR_API PBD::PropertyDescriptor< bool > gain
Definition: route_group.cc:44
const char *const * port_names() const
std::string state_node_name() const
Definition: ladspa_plugin.h:90
const char * maker() const
Definition: ladspa_plugin.h:50
void set_gain(float gain)
uint32_t index() const
Glib::Module * _module
LADSPA_Data * _control_data
std::string _module_path
boost::shared_ptr< LadspaPluginInfo > LadspaPluginInfoPtr
int64_t framecnt_t
Definition: types.h:76
void run_adding(uint32_t nsamples)
int LADSPA_Properties
Definition: ladspa.h:95
float LADSPA_Data
Definition: ladspa.h:84
uint32_t parameter_count() const
Definition: ladspa_plugin.h:51
Definition: amp.h:29
const char * label() const
Definition: ladspa_plugin.h:48
void connect_port(uint32_t port, float *ptr)
#define LIBARDOUR_API
const char * name
const LADSPA_PortRangeHint * port_range_hints() const
LADSPA_Handle _handle
Definition: xml++.h:95
LADSPA_Data * _latency_control_port
LIBARDOUR_API uint64_t AudioEngine
Definition: session.h:982
LIBARDOUR_API bool init(bool with_vst, bool try_optimization, const char *localedir)
Definition: globals.cc:376
float default_value(uint32_t port)
Definition: ladspa_plugin.h:52
const char * copyright() const
LADSPA_Data * _shadow_data
int set_block_size(pframes_t)
Definition: ladspa_plugin.h:83