the big Route structure refactor. !!!! THIS WILL ***NOT LOAD*** PRIOR 3.0 or 2.X...
[ardour.git] / libs / ardour / ardour / processor.h
1 /*
2     Copyright (C) 2000 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_processor_h__
21 #define __ardour_processor_h__
22
23 #include <vector>
24 #include <string>
25 #include <exception>
26
27 #include "pbd/statefuldestructible.h" 
28
29 #include <sigc++/signal.h>
30
31 #include "ardour/ardour.h"
32 #include "ardour/automatable_controls.h"
33 #include "ardour/buffer_set.h"
34 #include "ardour/latent.h"
35 #include "ardour/session_object.h"
36 #include "ardour/types.h"
37
38 class XMLNode;
39
40 namespace ARDOUR {
41
42 class Session;
43 class Route;
44
45 /* A mixer strip element - plugin, send, meter, etc.
46  */
47 class Processor : public SessionObject, public AutomatableControls, public Latent
48 {
49   public:
50         static const std::string state_node_name;
51
52         Processor(Session&, const std::string& name);
53         
54         virtual ~Processor() { }
55         
56         virtual bool visible() const { return true; }
57         
58         bool active () const { return _active; }
59
60         /* we keep loose tabs on the "placement" of a Processor. Ultimately,
61            they are all executed as a single list, but there are some
62            semantics that require knowing whether a Processor is before
63            or after the fader, or panner etc. See Route::reorder_processors()
64            to see where this gets set.
65         */
66
67         Placement placement() const { return _placement; }
68         void set_placement (Placement p) { _placement = p; }
69         
70         bool get_next_ab_is_active () const { return _next_ab_is_active; }
71         void set_next_ab_is_active (bool yn) { _next_ab_is_active = yn; }
72         
73         virtual nframes_t signal_latency() const { return 0; }
74         
75         virtual void transport_stopped (sframes_t frame) {}
76         
77         virtual void set_block_size (nframes_t nframes) {}
78
79         virtual void run_in_place (BufferSet& bufs,
80                                    sframes_t start_frame, sframes_t end_frame,
81                                    nframes_t nframes) { assert(is_in_place()); }
82         
83         virtual void run_out_of_place (BufferSet& input, BufferSet& output,
84                                        sframes_t start_frame, sframes_t end_frame,
85                                        nframes_t nframes) { assert(is_out_of_place()); }
86         
87         virtual void silence (nframes_t nframes) {}
88         
89         void activate ()   { _active = true; ActiveChanged(); }
90         void deactivate () { _active = false; ActiveChanged(); }
91         
92         virtual bool configure_io (ChanCount in, ChanCount out);
93
94         /* Derived classes should override these, or processor appears as an in-place pass-through */
95
96         /** In-place processors implement run_in_place and modify thee input buffer parameter */
97         virtual bool is_in_place () const { return true; }
98
99         /* Out-Of-Place processors implement run_out_of_place, don't modify the input parameter
100          * and write to their output parameter */
101         virtual bool is_out_of_place () const { return false; }
102
103         virtual bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const = 0;
104         virtual ChanCount input_streams () const { return _configured_input; }
105         virtual ChanCount output_streams() const { return _configured_output; }
106
107         /* note: derived classes should implement state(), NOT get_state(), to allow
108            us to merge C++ inheritance and XML lack-of-inheritance reasonably
109            smoothly.
110          */
111
112         virtual XMLNode& state (bool full);
113         XMLNode& get_state (void);
114         int set_state (const XMLNode&);
115         
116         void *get_gui () const { return _gui; }
117         void  set_gui (void *p) { _gui = p; }
118
119         static sigc::signal<void,Processor*> ProcessorCreated;
120
121         sigc::signal<void>                     ActiveChanged;
122         sigc::signal<void,ChanCount,ChanCount> ConfigurationChanged;
123
124 protected:
125         int       _pending_active;
126         bool      _active;
127         bool      _next_ab_is_active;
128         bool      _configured;
129         ChanCount _configured_input;
130         ChanCount _configured_output;
131         void*     _gui;  /* generic, we don't know or care what this is */
132         Placement _placement;
133 };
134
135 } // namespace ARDOUR
136
137 #endif /* __ardour_processor_h__ */