summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/redirect.h
blob: e60438f3ba69e7f16fb201f9d852c98075cab2ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
    Copyright (C) 2001 Paul Davis 

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    $Id$
*/

#ifndef __ardour_redirect_h__
#define __ardour_redirect_h__

#include <string>
#include <vector>
#include <set>
#include <map>
#include <boost/shared_ptr.hpp>
#include <sigc++/signal.h>

#include <glibmm/thread.h>

#include <pbd/undo.h>

#include <ardour/ardour.h>
#include <ardour/io.h>
#include <ardour/automation_event.h>

using std::map;
using std::set;
using std::string;
using std::vector;

class XMLNode;

namespace ARDOUR {

class Session;

class Redirect : public IO
{
  public:
	static const string state_node_name;

	Redirect (Session&, const string& name, Placement,
		  int input_min = -1, int input_max = -1, int output_min = -1, int output_max = -1);
	Redirect (const Redirect&);
	virtual ~Redirect ();

	static boost::shared_ptr<Redirect> clone (boost::shared_ptr<const Redirect>);

	bool active () const { return _active; }
	void set_active (bool yn, void *src);

	virtual uint32_t output_streams() const { return n_outputs(); }
	virtual uint32_t input_streams () const { return n_inputs(); }
	virtual uint32_t natural_output_streams() const { return n_outputs(); }
	virtual uint32_t natural_input_streams () const { return n_inputs(); }

	uint32_t sort_key() const { return _sort_key; }
	void set_sort_key (uint32_t key);

	Placement placement() const { return _placement; }
	void set_placement (Placement, void *src);

	virtual void run (vector<Sample *>& ibufs, uint32_t nbufs, nframes_t nframes, nframes_t offset) = 0;
	virtual void activate () = 0;
	virtual void deactivate () = 0;
	virtual nframes_t latency() { return 0; }

	virtual void set_block_size (nframes_t nframes) {}

	sigc::signal<void,Redirect*,void*> active_changed;
	sigc::signal<void,Redirect*,void*> placement_changed;
	sigc::signal<void,Redirect*,bool>  AutomationPlaybackChanged;
	sigc::signal<void,Redirect*,uint32_t> AutomationChanged;

	static sigc::signal<void,Redirect*> RedirectCreated;
	
	XMLNode& state (bool full);
	XMLNode& get_state (void);
	int set_state (const XMLNode&);

	void *get_gui () const { return _gui; }
	void  set_gui (void *p) { _gui = p; }

	virtual string describe_parameter (uint32_t which);
	virtual float default_parameter_value (uint32_t which) {
		return 1.0f;
	}

	int load_automation (string path);
	int save_automation (string path);

	void what_has_automation (set<uint32_t>&) const;
	void what_has_visible_automation (set<uint32_t>&) const;
	const set<uint32_t>& what_can_be_automated () const { return can_automate_list; }

	void mark_automation_visible (uint32_t, bool);
	
	AutomationList& automation_list (uint32_t);
	bool find_next_event (nframes_t, nframes_t, ControlEvent&) const;

	virtual void transport_stopped (nframes_t frame) {};
	
  protected:
	void set_placement (const string&, void *src);

	/* children may use this stuff as they see fit */

	map<uint32_t,AutomationList*> parameter_automation;
	set<uint32_t> visible_parameter_automation;

	mutable Glib::Mutex _automation_lock;

	void can_automate (uint32_t);
	set<uint32_t> can_automate_list;

	virtual void automation_list_creation_callback (uint32_t, AutomationList&) {}

  private:
	bool _active;
	Placement _placement;
	uint32_t _sort_key;
	void* _gui;  /* generic, we don't know or care what this is */
};

} // namespace ARDOUR

#endif /* __ardour_redirect_h__ */