Reading of MIDI CC from MIDI regions (MidiModel). UI still needs work though..
[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/types.h>
32 #include <ardour/ardour.h>
33 #include <ardour/plugin_state.h>
34 #include <ardour/buffer_set.h>
35 #include <ardour/automatable.h>
36 #include <ardour/latent.h>
37
38 class XMLNode;
39
40 namespace ARDOUR {
41
42 class Session;
43
44 /* A mixer strip element - plugin, send, meter, etc.
45  */
46 class Processor : public Automatable, public Latent
47 {
48   public:
49         static const string state_node_name;
50
51         Processor(Session&, const string& name, Placement p); // TODO: remove placement in favour of sort key
52         
53         virtual ~Processor() { }
54         
55         static boost::shared_ptr<Processor> clone (boost::shared_ptr<const Processor>);
56
57         uint32_t sort_key() const { return _sort_key; }
58         void set_sort_key (uint32_t key);
59
60         Placement placement() const { return _placement; }
61         void set_placement (Placement);
62         
63         bool active () const { return _active; }
64         void set_active (bool yn);
65         
66         bool get_next_ab_is_active () const { return _next_ab_is_active; }
67         void set_next_ab_is_active (bool yn) { _next_ab_is_active = yn; }
68         
69         virtual nframes_t signal_latency() const { return 0; }
70         
71         virtual void transport_stopped (nframes_t frame) {}
72         
73         virtual void set_block_size (nframes_t nframes) {}
74
75         virtual void run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) { assert(is_in_place()); }
76         
77         virtual void run_out_of_place (BufferSet& input, BufferSet& output, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) { assert(is_out_of_place()); }
78         
79         virtual void silence (nframes_t nframes, nframes_t offset) {}
80         
81         virtual void activate () { _active = true; ActiveChanged.emit(); }
82         virtual void deactivate () { _active = false; ActiveChanged.emit(); }
83         
84         virtual bool configure_io (ChanCount in, ChanCount out) { _configured_input = in; return (_configured = true); }
85
86         /* Derived classes should override these, or processor appears as an in-place pass-through */
87
88         /** In-place processors implement run_in_place and modify thee input buffer parameter */
89         virtual bool is_in_place () const { return true; }
90
91         /* Out-Of-Place processors implement run_out_of_place, don't modify the input parameter
92          * and write to their output parameter */
93         virtual bool is_out_of_place () const { return false; }
94
95         virtual bool      can_support_input_configuration (ChanCount in) const { return true; }
96         virtual ChanCount output_for_input_configuration (ChanCount in) const { return in; }
97         virtual ChanCount output_streams() const { return _configured_input; }
98         virtual ChanCount input_streams () const { return _configured_input; }
99
100         virtual XMLNode& state (bool full);
101         virtual XMLNode& get_state (void);
102         virtual int set_state (const XMLNode&);
103         
104         void *get_gui () const { return _gui; }
105         void  set_gui (void *p) { _gui = p; }
106
107         static sigc::signal<void,Processor*> ProcessorCreated;
108
109         sigc::signal<void> ActiveChanged;
110         sigc::signal<void> PlacementChanged;
111
112 protected:
113         bool      _active;
114         bool      _next_ab_is_active;
115         bool      _configured;
116         ChanCount _configured_input;
117         Placement _placement;
118         uint32_t  _sort_key;
119         void*     _gui;  /* generic, we don't know or care what this is */
120 };
121
122 } // namespace ARDOUR
123
124 #endif /* __ardour_processor_h__ */