Ardour  8.12
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 #ifndef __ardour_processor_h__
23 #define __ardour_processor_h__
24 
25 #include <vector>
26 #include <string>
27 #include <exception>
28 
30 
31 #include "ardour/ardour.h"
32 #include "ardour/buffer_set.h"
33 #include "ardour/latent.h"
34 #include "ardour/session_object.h"
36 #include "ardour/types.h"
37 #include "ardour/automatable.h"
38 
39 class XMLNode;
42 
43 namespace ARDOUR {
44 
45 class Location;
46 class Session;
47 
48 class LIBARDOUR_API ProcessorException: public std::exception
49 {
50 public:
51  explicit ProcessorException (const std::string msg) : _message(msg) {}
52  virtual ~ProcessorException () throw() {}
53 
54  virtual const char* what() const throw() { return _message.c_str(); }
55 
56 private:
57  std::string _message;
58 };
59 
61 class LIBARDOUR_API Processor : public SessionObject, public Automatable, public Latent
62 {
63  public:
64  static const std::string state_node_name;
65 
66  Processor(Session&, const std::string& name, Temporal::TimeDomainProvider const &);
67  Processor (const Processor& other);
68 
69  virtual ~Processor();
70 
71  virtual std::string display_name() const { return SessionObject::name(); }
72 
73  virtual bool display_to_user() const { return _display_to_user; }
74  virtual void set_display_to_user (bool);
75 
76  bool active () const { return _pending_active; }
77  virtual bool enabled () const { return _pending_active; }
78  virtual bool bypassable () const { return true; }
79 
80  virtual bool does_routing() const { return false; }
81 
82  bool get_next_ab_is_active () const { return _next_ab_is_active; }
83  void set_next_ab_is_active (bool yn) { _next_ab_is_active = yn; }
84 
85  virtual samplecnt_t signal_latency() const { return 0; }
86 
87  virtual void set_input_latency (samplecnt_t cnt) { _input_latency = cnt; }
88  samplecnt_t input_latency () const { return _input_latency; }
89 
90  virtual void set_output_latency (samplecnt_t cnt) { _output_latency = cnt; }
91  samplecnt_t output_latency () const { return _output_latency; }
92 
93  virtual void set_capture_offset (samplecnt_t cnt) { _capture_offset = cnt; }
94  samplecnt_t capture_offset () const { return _capture_offset; }
95 
96  virtual void set_playback_offset (samplecnt_t cnt) { _playback_offset = cnt; }
97  samplecnt_t playback_offset () const { return _playback_offset; }
98 
99  virtual int set_block_size (pframes_t /*nframes*/) { return 0; }
100  virtual bool requires_fixed_sized_buffers() const { return false; }
101 
112  virtual void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool result_required) {}
113  virtual void silence (samplecnt_t nframes, samplepos_t start_sample) { automation_run (start_sample, nframes); }
114 
115  virtual void activate () { _pending_active = true; ActiveChanged(); }
116  virtual void deactivate () { _pending_active = false; ActiveChanged(); }
117  virtual void flush() {}
118 
119  virtual void enable (bool yn) { if (yn) { activate (); } else { deactivate (); } }
120 
121  virtual bool configure_io (ChanCount in, ChanCount out);
122 
123  /* Derived classes should override these, or processor appears as an in-place pass-through */
124 
125  virtual bool can_support_io_configuration (const ChanCount& in, ChanCount& out) = 0;
126  virtual ChanCount input_streams () const { return _configured_input; }
127  virtual ChanCount output_streams() const { return _configured_output; }
128 
130  virtual void realtime_locate (bool) {}
131 
132  virtual void set_loop (Location *loc) { _loop_location = loc; }
133 
134  /* most processors won't care about this, but plugins that
135  receive MIDI or similar data from an input source that
136  may suddenly go "quiet" because of monitoring changes
137  need to know about it.
138  */
139  virtual void monitoring_changed() {}
140 
141  /* note: derived classes should implement state(), NOT get_state(), to allow
142  us to merge C++ inheritance and XML lack-of-inheritance reasonably
143  smoothly.
144  */
145 
146  XMLNode& get_state () const;
147  int set_state (const XMLNode&, int version);
148 
149  virtual void set_pre_fader (bool);
150  virtual bool get_pre_fader () const { return _pre_fader; }
151 
152  PBD::Signal0<void> ActiveChanged;
153  PBD::Signal0<void> BypassableChanged;
154  PBD::Signal2<void,ChanCount,ChanCount> ConfigurationChanged;
155 
156  /* cross-thread signals.
157  * This allows control-surfaces to show/hide a plugin GUI.
158  */
159  PBD::Signal0<void> ToggleUI;
160  PBD::Signal0<void> ShowUI;
161  PBD::Signal0<void> HideUI;
162 
163  ProcessorWindowProxy * window_proxy () const { return _window_proxy; }
164  void set_window_proxy (ProcessorWindowProxy* wp) { _window_proxy = wp; }
165 
166  PluginPinWindowProxy * pinmgr_proxy () const { return _pinmgr_proxy; }
167  void set_pingmgr_proxy (PluginPinWindowProxy* wp) { _pinmgr_proxy = wp ; }
168 
169  virtual void set_owner (SessionObject*);
171 
172 protected:
173  virtual XMLNode& state () const;
174  virtual int set_state_2X (const XMLNode&, int version);
175 
176  bool check_active () { return (_active = _pending_active); }
178 
180  bool _active;
186  bool _pre_fader;
187  void* _ui_pointer;
191  // relative to route
194  // absolute alignment to session i/o
198 };
199 
200 } // namespace ARDOUR
201 
202 #endif /* __ardour_processor_h__ */
ProcessorException(const std::string msg)
Definition: processor.h:51
virtual ~ProcessorException()
Definition: processor.h:52
virtual const char * what() const
Definition: processor.h:54
bool _pre_fader
true if this processor is currently placed before the Amp, otherwise false
Definition: processor.h:186
ChanCount _configured_input
Definition: processor.h:183
PBD::Signal0< void > BypassableChanged
Definition: processor.h:153
bool active() const
ardour hard bypass
Definition: processor.h:76
Processor(const Processor &other)
samplecnt_t _output_latency
Definition: processor.h:193
samplecnt_t _input_latency
Definition: processor.h:192
virtual bool bypassable() const
enable is not automated or locked
Definition: processor.h:78
Processor(Session &, const std::string &name, Temporal::TimeDomainProvider const &)
ProcessorWindowProxy * window_proxy() const
Definition: processor.h:163
virtual bool requires_fixed_sized_buffers() const
Definition: processor.h:100
virtual void set_capture_offset(samplecnt_t cnt)
Definition: processor.h:93
void set_window_proxy(ProcessorWindowProxy *wp)
Definition: processor.h:164
bool map_loop_range(samplepos_t &start, samplepos_t &end) const
Location * _loop_location
Definition: processor.h:197
virtual void set_input_latency(samplecnt_t cnt)
Definition: processor.h:87
PBD::Signal0< void > ActiveChanged
Definition: processor.h:152
bool check_active()
Definition: processor.h:176
virtual void set_owner(SessionObject *)
void set_pingmgr_proxy(PluginPinWindowProxy *wp)
Definition: processor.h:167
samplecnt_t _capture_offset
Definition: processor.h:195
virtual ChanCount input_streams() const
Definition: processor.h:126
virtual void set_pre_fader(bool)
bool get_next_ab_is_active() const
Definition: processor.h:82
PBD::Signal0< void > ShowUI
Definition: processor.h:160
virtual bool display_to_user() const
Definition: processor.h:73
virtual void activate()
Definition: processor.h:115
samplecnt_t capture_offset() const
Definition: processor.h:94
samplecnt_t _playback_offset
Definition: processor.h:196
virtual int set_block_size(pframes_t)
Definition: processor.h:99
ProcessorWindowProxy * _window_proxy
Definition: processor.h:188
virtual void set_display_to_user(bool)
virtual bool enabled() const
processor enabled/bypass
Definition: processor.h:77
SessionObject * owner() const
PBD::Signal0< void > ToggleUI
Definition: processor.h:159
virtual bool can_support_io_configuration(const ChanCount &in, ChanCount &out)=0
virtual void deactivate()
Definition: processor.h:116
virtual void realtime_locate(bool)
Definition: processor.h:130
virtual void set_playback_offset(samplecnt_t cnt)
Definition: processor.h:96
PluginPinWindowProxy * _pinmgr_proxy
Definition: processor.h:189
virtual int set_state_2X(const XMLNode &, int version)
SessionObject * _owner
Definition: processor.h:190
bool _next_ab_is_active
Definition: processor.h:181
virtual void run(BufferSet &bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool result_required)
Definition: processor.h:112
virtual bool configure_io(ChanCount in, ChanCount out)
virtual void silence(samplecnt_t nframes, samplepos_t start_sample)
Definition: processor.h:113
XMLNode & get_state() const
samplecnt_t playback_offset() const
Definition: processor.h:97
virtual void set_output_latency(samplecnt_t cnt)
Definition: processor.h:90
samplecnt_t output_latency() const
Definition: processor.h:91
virtual bool get_pre_fader() const
Definition: processor.h:150
virtual ~Processor()
virtual samplecnt_t signal_latency() const
Definition: processor.h:85
PBD::Signal2< void, ChanCount, ChanCount > ConfigurationChanged
Definition: processor.h:154
PBD::Signal0< void > HideUI
Definition: processor.h:161
void * _ui_pointer
Definition: processor.h:187
void set_next_ab_is_active(bool yn)
Definition: processor.h:83
virtual void realtime_handle_transport_stopped()
Definition: processor.h:129
int set_state(const XMLNode &, int version)
virtual ChanCount output_streams() const
Definition: processor.h:127
virtual bool does_routing() const
Definition: processor.h:80
virtual XMLNode & state() const
virtual void enable(bool yn)
Definition: processor.h:119
virtual void flush()
Definition: processor.h:117
virtual void monitoring_changed()
Definition: processor.h:139
virtual std::string display_name() const
Definition: processor.h:71
ChanCount _configured_output
Definition: processor.h:184
virtual void set_loop(Location *loc)
Definition: processor.h:132
PluginPinWindowProxy * pinmgr_proxy() const
Definition: processor.h:166
samplecnt_t input_latency() const
Definition: processor.h:88
static const std::string state_node_name
Definition: processor.h:64
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