Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
24 
25 #include <set>
26 #include <vector>
27 #include <string>
28 
29 #include <glibmm/module.h>
30 
31 #include "pbd/stateful.h"
32 
33 #include "ardour/ladspa.h"
34 #include "ardour/plugin.h"
35 
36 namespace ARDOUR {
37 class AudioEngine;
38 class Session;
39 
41 {
42  public:
43  LadspaPlugin (std::string module_path, ARDOUR::AudioEngine&, ARDOUR::Session&, uint32_t index, samplecnt_t sample_rate);
46 
47  /* Plugin interface */
48 
49  std::string unique_id() const;
50  const char* label() const { return _descriptor->Label; }
51  const char* name() const { return _descriptor->Name; }
52  const char* maker() const { return _descriptor->Maker; }
53  uint32_t parameter_count() const { return _descriptor->PortCount; }
54  float default_value (uint32_t port) { return _default_value (port); }
55  void set_parameter (uint32_t port, float val, sampleoffset_t);
56  float get_parameter (uint32_t port) const;
57  int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
58  uint32_t nth_parameter (uint32_t port, bool& ok) const;
59 
60  std::set<Evoral::Parameter> automatable() const;
61 
62  void activate () {
63  if (!_was_activated && _descriptor->activate)
64  _descriptor->activate (_handle);
65 
66  _was_activated = true;
67  }
68 
69  void deactivate () {
70  if (_was_activated && _descriptor->deactivate)
71  _descriptor->deactivate (_handle);
72 
73  _was_activated = false;
74  }
75 
76  void cleanup () {
77  activate();
78  deactivate();
79 
80  if (_descriptor->cleanup)
81  _descriptor->cleanup (_handle);
82  }
83 
84  int set_block_size (pframes_t /*nframes*/) { return 0; }
85 
87  samplepos_t start, samplepos_t end, double speed,
88  ChanMapping const& in, ChanMapping const& out,
89  pframes_t nframes, samplecnt_t offset);
90 
92  std::string state_node_name() const { return "ladspa"; }
93 
94  bool parameter_is_audio(uint32_t) const;
95  bool parameter_is_control(uint32_t) const;
96  bool parameter_is_input(uint32_t) const;
97  bool parameter_is_output(uint32_t) const;
98  bool parameter_is_toggled(uint32_t) const;
99 
100  std::shared_ptr<ScalePoints>
101  get_scale_points(uint32_t port_index) const;
102 
103  int set_state (const XMLNode&, int version);
104 
106 
107  bool has_editor() const { return false; }
108 
109  /* LADSPA extras */
110 
111  LADSPA_Properties properties() const { return _descriptor->Properties; }
112  uint32_t index() const { return _index; }
113  const char * copyright() const { return _descriptor->Copyright; }
115  const LADSPA_PortRangeHint* port_range_hints() const { return _descriptor->PortRangeHints; }
116  const char * const * port_names() const { return _descriptor->PortNames; }
117 
118  void set_gain (float gain) { _descriptor->set_run_adding_gain (_handle, gain); }
119  void run_adding (uint32_t nsamples) { _descriptor->run_adding (_handle, nsamples); }
120  void connect_port (uint32_t port, float *ptr) { _descriptor->connect_port (_handle, port, ptr); }
121 
122  private:
123  float _default_value (uint32_t port) const;
124  std::string _module_path;
125  Glib::Module* _module;
132  uint32_t _index;
134 
136  void find_presets ();
137 
138  void init (std::string module_path, uint32_t index, samplecnt_t rate);
139  void run_in_place (pframes_t nsamples);
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_source () const;
146  void add_state (XMLNode *) const;
147 };
148 
150  public:
153 
154  bool is_instrument () const { return false; } /* ladspa's are never instruments */
155 #ifdef MIXBUS
156  /* for mixbus, relegate ladspa's to the Utils folder. */
157  bool is_effect () const { return false; }
158  bool is_utility () const { return true; }
159 #endif
160 
162  std::vector<Plugin::PresetRecord> get_presets (bool user_only) const;
163 };
164 
165 typedef std::shared_ptr<LadspaPluginInfo> LadspaPluginInfoPtr;
166 
167 } // namespace ARDOUR
168 
std::vector< Plugin::PresetRecord > get_presets(bool user_only) const
PluginPtr load(Session &session)
uint32_t parameter_count() const
Definition: ladspa_plugin.h:53
std::string _module_path
int set_block_size(pframes_t)
Definition: ladspa_plugin.h:84
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:92
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:54
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:51
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:52
const char * label() const
Definition: ladspa_plugin.h:50
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:62
Temporal::samplecnt_t samplecnt_t
Temporal::sampleoffset_t sampleoffset_t
Temporal::samplepos_t samplepos_t
DebugBits AudioEngine
Definition: session.h:1349