Ardour  9.0-pre0-350-gf17a656217
processor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #pragma once
23 
24 #include <vector>
25 #include <string>
26 #include <exception>
27 
29 
30 #include "ardour/ardour.h"
31 #include "ardour/buffer_set.h"
32 #include "ardour/latent.h"
33 #include "ardour/session_object.h"
35 #include "ardour/types.h"
36 #include "ardour/automatable.h"
37 
38 class XMLNode;
41 
42 namespace ARDOUR {
43 
44 class Location;
45 class Session;
46 
47 class LIBARDOUR_API ProcessorException: public std::exception
48 {
49 public:
50  explicit ProcessorException (const std::string msg) : _message(msg) {}
51  virtual ~ProcessorException () throw() {}
52 
53  virtual const char* what() const throw() { return _message.c_str(); }
54 
55 private:
56  std::string _message;
57 };
58 
60 class LIBARDOUR_API Processor : public SessionObject, public Automatable, public Latent
61 {
62  public:
63  static const std::string state_node_name;
64 
65  Processor(Session&, const std::string& name, Temporal::TimeDomainProvider const &);
66  Processor (const Processor& other);
67 
68  virtual ~Processor();
69 
70  virtual std::string display_name() const { return SessionObject::name(); }
71 
72  virtual bool display_to_user() const { return _display_to_user; }
73  virtual void set_display_to_user (bool);
74 
75  bool active () const { return _pending_active; }
76  virtual bool enabled () const { return _pending_active; }
77  virtual bool bypassable () const { return true; }
78 
79  virtual bool does_routing() const { return false; }
80 
81  bool get_next_ab_is_active () const { return _next_ab_is_active; }
82  void set_next_ab_is_active (bool yn) { _next_ab_is_active = yn; }
83 
84  virtual samplecnt_t signal_latency() const { return 0; }
85 
86  virtual void set_input_latency (samplecnt_t cnt) { _input_latency = cnt; }
87  samplecnt_t input_latency () const { return _input_latency; }
88 
89  virtual void set_output_latency (samplecnt_t cnt) { _output_latency = cnt; }
90  samplecnt_t output_latency () const { return _output_latency; }
91 
92  virtual void set_capture_offset (samplecnt_t cnt) { _capture_offset = cnt; }
93  samplecnt_t capture_offset () const { return _capture_offset; }
94 
95  virtual void set_playback_offset (samplecnt_t cnt) { _playback_offset = cnt; }
96  samplecnt_t playback_offset () const { return _playback_offset; }
97 
98  virtual int set_block_size (pframes_t /*nframes*/) { return 0; }
99  virtual bool requires_fixed_sized_buffers() const { return false; }
100 
111  virtual void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool result_required) {}
112  virtual void silence (samplecnt_t nframes, samplepos_t start_sample) { automation_run (start_sample, nframes); }
113 
114  virtual void activate () { _pending_active = true; ActiveChanged(); }
115  virtual void deactivate () { _pending_active = false; ActiveChanged(); }
116  virtual void flush() {}
117 
118  virtual void enable (bool yn) { if (yn) { activate (); } else { deactivate (); } }
119 
120  virtual bool configure_io (ChanCount in, ChanCount out);
121 
122  /* Derived classes should override these, or processor appears as an in-place pass-through */
123 
124  virtual bool can_support_io_configuration (const ChanCount& in, ChanCount& out) = 0;
125  virtual ChanCount input_streams () const { return _configured_input; }
126  virtual ChanCount output_streams() const { return _configured_output; }
127 
129  virtual void realtime_locate (bool) {}
130 
131  virtual void set_loop (Location *loc) { _loop_location = loc; }
132 
133  /* most processors won't care about this, but plugins that
134  receive MIDI or similar data from an input source that
135  may suddenly go "quiet" because of monitoring changes
136  need to know about it.
137  */
138  virtual void monitoring_changed() {}
139 
140  /* note: derived classes should implement state(), NOT get_state(), to allow
141  us to merge C++ inheritance and XML lack-of-inheritance reasonably
142  smoothly.
143  */
144 
145  XMLNode& get_state () const;
146  int set_state (const XMLNode&, int version);
147 
148  virtual void set_pre_fader (bool);
149  virtual bool get_pre_fader () const { return _pre_fader; }
150 
154 
155  /* cross-thread signals.
156  * This allows control-surfaces to show/hide a plugin GUI.
157  */
161 
162  ProcessorWindowProxy * window_proxy () const { return _window_proxy; }
163  void set_window_proxy (ProcessorWindowProxy* wp) { _window_proxy = wp; }
164 
165  PluginPinWindowProxy * pinmgr_proxy () const { return _pinmgr_proxy; }
166  void set_pingmgr_proxy (PluginPinWindowProxy* wp) { _pinmgr_proxy = wp ; }
167 
168  virtual void set_owner (SessionObject*);
170 
171 protected:
172  virtual XMLNode& state () const;
173  virtual int set_state_2X (const XMLNode&, int version);
174 
175  bool check_active () { return (_active = _pending_active); }
177 
179  bool _active;
185  bool _pre_fader;
186  void* _ui_pointer;
190  // relative to route
193  // absolute alignment to session i/o
197 };
198 
199 } // namespace ARDOUR
200 
ProcessorException(const std::string msg)
Definition: processor.h:50
virtual ~ProcessorException()
Definition: processor.h:51
virtual const char * what() const
Definition: processor.h:53
bool _pre_fader
true if this processor is currently placed before the Amp, otherwise false
Definition: processor.h:185
ChanCount _configured_input
Definition: processor.h:182
bool active() const
ardour hard bypass
Definition: processor.h:75
PBD::Signal< void()> ShowUI
Definition: processor.h:159
Processor(const Processor &other)
samplecnt_t _output_latency
Definition: processor.h:192
samplecnt_t _input_latency
Definition: processor.h:191
virtual bool bypassable() const
enable is not automated or locked
Definition: processor.h:77
Processor(Session &, const std::string &name, Temporal::TimeDomainProvider const &)
ProcessorWindowProxy * window_proxy() const
Definition: processor.h:162
virtual bool requires_fixed_sized_buffers() const
Definition: processor.h:99
virtual void set_capture_offset(samplecnt_t cnt)
Definition: processor.h:92
void set_window_proxy(ProcessorWindowProxy *wp)
Definition: processor.h:163
bool map_loop_range(samplepos_t &start, samplepos_t &end) const
Location * _loop_location
Definition: processor.h:196
virtual void set_input_latency(samplecnt_t cnt)
Definition: processor.h:86
bool check_active()
Definition: processor.h:175
virtual void set_owner(SessionObject *)
void set_pingmgr_proxy(PluginPinWindowProxy *wp)
Definition: processor.h:166
samplecnt_t _capture_offset
Definition: processor.h:194
virtual ChanCount input_streams() const
Definition: processor.h:125
virtual void set_pre_fader(bool)
bool get_next_ab_is_active() const
Definition: processor.h:81
PBD::Signal< void()> HideUI
Definition: processor.h:160
virtual bool display_to_user() const
Definition: processor.h:72
virtual void activate()
Definition: processor.h:114
samplecnt_t capture_offset() const
Definition: processor.h:93
samplecnt_t _playback_offset
Definition: processor.h:195
virtual int set_block_size(pframes_t)
Definition: processor.h:98
ProcessorWindowProxy * _window_proxy
Definition: processor.h:187
virtual void set_display_to_user(bool)
virtual bool enabled() const
processor enabled/bypass
Definition: processor.h:76
SessionObject * owner() const
PBD::Signal< void()> BypassableChanged
Definition: processor.h:152
virtual bool can_support_io_configuration(const ChanCount &in, ChanCount &out)=0
virtual void deactivate()
Definition: processor.h:115
virtual void realtime_locate(bool)
Definition: processor.h:129
virtual void set_playback_offset(samplecnt_t cnt)
Definition: processor.h:95
PluginPinWindowProxy * _pinmgr_proxy
Definition: processor.h:188
virtual int set_state_2X(const XMLNode &, int version)
SessionObject * _owner
Definition: processor.h:189
bool _next_ab_is_active
Definition: processor.h:180
virtual void run(BufferSet &bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool result_required)
Definition: processor.h:111
virtual bool configure_io(ChanCount in, ChanCount out)
virtual void silence(samplecnt_t nframes, samplepos_t start_sample)
Definition: processor.h:112
XMLNode & get_state() const
samplecnt_t playback_offset() const
Definition: processor.h:96
virtual void set_output_latency(samplecnt_t cnt)
Definition: processor.h:89
samplecnt_t output_latency() const
Definition: processor.h:90
virtual bool get_pre_fader() const
Definition: processor.h:149
virtual ~Processor()
virtual samplecnt_t signal_latency() const
Definition: processor.h:84
void * _ui_pointer
Definition: processor.h:186
void set_next_ab_is_active(bool yn)
Definition: processor.h:82
virtual void realtime_handle_transport_stopped()
Definition: processor.h:128
PBD::Signal< void(ChanCount, ChanCount)> ConfigurationChanged
Definition: processor.h:153
int set_state(const XMLNode &, int version)
virtual ChanCount output_streams() const
Definition: processor.h:126
virtual bool does_routing() const
Definition: processor.h:79
PBD::Signal< void()> ActiveChanged
Definition: processor.h:151
virtual XMLNode & state() const
virtual void enable(bool yn)
Definition: processor.h:118
virtual void flush()
Definition: processor.h:116
PBD::Signal< void()> ToggleUI
Definition: processor.h:158
virtual void monitoring_changed()
Definition: processor.h:138
virtual std::string display_name() const
Definition: processor.h:70
ChanCount _configured_output
Definition: processor.h:183
virtual void set_loop(Location *loc)
Definition: processor.h:131
PluginPinWindowProxy * pinmgr_proxy() const
Definition: processor.h:165
samplecnt_t input_latency() const
Definition: processor.h:87
static const std::string state_node_name
Definition: processor.h:63
std::string name() const
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
PBD::PropertyDescriptor< timepos_t > start
uint32_t pframes_t
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t