Ardour  8.12
ladspa_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2007 Sampo Savolainen <v2@iki.fi>
5  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_ladspa_plugin_h__
24 #define __ardour_ladspa_plugin_h__
25 
26 #include <set>
27 #include <vector>
28 #include <string>
29 
30 #include <glibmm/module.h>
31 
32 #include "pbd/stateful.h"
33 
34 #include "ardour/ladspa.h"
35 #include "ardour/plugin.h"
36 
37 namespace ARDOUR {
38 class AudioEngine;
39 class Session;
40 
42 {
43  public:
44  LadspaPlugin (std::string module_path, ARDOUR::AudioEngine&, ARDOUR::Session&, uint32_t index, samplecnt_t sample_rate);
47 
48  /* Plugin interface */
49 
50  std::string unique_id() const;
51  const char* label() const { return _descriptor->Label; }
52  const char* name() const { return _descriptor->Name; }
53  const char* maker() const { return _descriptor->Maker; }
54  uint32_t parameter_count() const { return _descriptor->PortCount; }
55  float default_value (uint32_t port) { return _default_value (port); }
56  void set_parameter (uint32_t port, float val, sampleoffset_t);
57  float get_parameter (uint32_t port) const;
58  int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
59  uint32_t nth_parameter (uint32_t port, bool& ok) const;
60 
61  std::set<Evoral::Parameter> automatable() const;
62 
63  void activate () {
64  if (!_was_activated && _descriptor->activate)
65  _descriptor->activate (_handle);
66 
67  _was_activated = true;
68  }
69 
70  void deactivate () {
71  if (_was_activated && _descriptor->deactivate)
72  _descriptor->deactivate (_handle);
73 
74  _was_activated = false;
75  }
76 
77  void cleanup () {
78  activate();
79  deactivate();
80 
81  if (_descriptor->cleanup)
82  _descriptor->cleanup (_handle);
83  }
84 
85  int set_block_size (pframes_t /*nframes*/) { return 0; }
86 
88  samplepos_t start, samplepos_t end, double speed,
89  ChanMapping const& in, ChanMapping const& out,
90  pframes_t nframes, samplecnt_t offset);
91 
93  std::string state_node_name() const { return "ladspa"; }
94 
95  bool parameter_is_audio(uint32_t) const;
96  bool parameter_is_control(uint32_t) const;
97  bool parameter_is_input(uint32_t) const;
98  bool parameter_is_output(uint32_t) const;
99  bool parameter_is_toggled(uint32_t) const;
100 
101  std::shared_ptr<ScalePoints>
102  get_scale_points(uint32_t port_index) const;
103 
104  int set_state (const XMLNode&, int version);
105 
107 
108  bool has_editor() const { return false; }
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; }
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 
137  void find_presets ();
138 
139  void init (std::string module_path, uint32_t index, samplecnt_t rate);
140  void run_in_place (pframes_t nsamples);
142  int set_state_2X (const XMLNode&, int version);
143  std::string do_save_preset (std::string name);
144  void do_remove_preset (std::string name);
145  std::string preset_source () const;
147  void add_state (XMLNode *) const;
148 };
149 
151  public:
154 
155  bool is_instrument () const { return false; } /* ladspa's are never instruments */
156 #ifdef MIXBUS
157  /* for mixbus, relegate ladspa's to the Utils folder. */
158  bool is_effect () const { return false; }
159  bool is_utility () const { return true; }
160 #endif
161 
163  std::vector<Plugin::PresetRecord> get_presets (bool user_only) const;
164 };
165 
166 typedef std::shared_ptr<LadspaPluginInfo> LadspaPluginInfoPtr;
167 
168 } // namespace ARDOUR
169 
170 #endif /* __ardour_ladspa_plugin_h__ */
std::vector< Plugin::PresetRecord > get_presets(bool user_only) const
PluginPtr load(Session &session)
uint32_t parameter_count() const
Definition: ladspa_plugin.h:54
std::string _module_path
int set_block_size(pframes_t)
Definition: ladspa_plugin.h:85
bool load_preset(PresetRecord)
int connect_and_run(BufferSet &bufs, samplepos_t start, samplepos_t end, double speed, ChanMapping const &in, ChanMapping const &out, pframes_t nframes, samplecnt_t offset)
std::string state_node_name() const
Definition: ladspa_plugin.h:93
uint32_t index() const
int get_parameter_descriptor(uint32_t which, ParameterDescriptor &) const
LADSPA_Properties properties() const
void do_remove_preset(std::string name)
bool parameter_is_toggled(uint32_t) const
const LADSPA_Descriptor * _descriptor
LadspaPlugin(std::string module_path, ARDOUR::AudioEngine &, ARDOUR::Session &, uint32_t index, samplecnt_t sample_rate)
LADSPA_Handle _handle
void run_adding(uint32_t nsamples)
int set_state(const XMLNode &, int version)
const char * copyright() const
std::string preset_source() const
std::set< Evoral::Parameter > automatable() const
LADSPA_Data * _latency_control_port
void init(std::string module_path, uint32_t index, samplecnt_t rate)
float default_value(uint32_t port)
Definition: ladspa_plugin.h:55
float get_parameter(uint32_t port) const
std::string unique_id() const
samplecnt_t plugin_latency() const
void add_state(XMLNode *) const
void connect_port(uint32_t port, float *ptr)
void set_gain(float gain)
bool has_editor() const
void set_parameter(uint32_t port, float val, sampleoffset_t)
float _default_value(uint32_t port) const
LADSPA_Data * _shadow_data
std::string describe_parameter(Evoral::Parameter)
std::string do_save_preset(std::string name)
const char * name() const
Definition: ladspa_plugin.h:52
samplecnt_t _sample_rate
std::shared_ptr< ScalePoints > get_scale_points(uint32_t port_index) const
Glib::Module * _module
bool parameter_is_audio(uint32_t) const
LADSPA_PortDescriptor port_descriptor(uint32_t i) const
uint32_t nth_parameter(uint32_t port, bool &ok) const
void run_in_place(pframes_t nsamples)
bool parameter_is_output(uint32_t) const
const char * maker() const
Definition: ladspa_plugin.h:53
const char * label() const
Definition: ladspa_plugin.h:51
int set_state_2X(const XMLNode &, int version)
const LADSPA_PortRangeHint * port_range_hints() const
const char *const * port_names() const
bool parameter_is_control(uint32_t) const
bool parameter_is_input(uint32_t) const
LadspaPlugin(const LadspaPlugin &)
LADSPA_Data * _control_data
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
int LADSPA_Properties
Definition: ladspa.h:95
int LADSPA_PortDescriptor
Definition: ladspa.h:154
float LADSPA_Data
Definition: ladspa.h:84
void * LADSPA_Handle
Definition: ladspa.h:366
#define LIBARDOUR_API
void session(lua_State *L)
PBD::PropertyDescriptor< gain_t > gain
PBD::PropertyDescriptor< timepos_t > start
std::shared_ptr< LadspaPluginInfo > LadspaPluginInfoPtr
uint32_t pframes_t
std::shared_ptr< Plugin > PluginPtr
Definition: plugin.h:63
Temporal::samplecnt_t samplecnt_t
Temporal::sampleoffset_t sampleoffset_t
Temporal::samplepos_t samplepos_t
DebugBits AudioEngine
Definition: session.h:1413