1 /*
2  * Copyright (C) 2011-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2013-2014 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __ardour_panner_shell_h__
22 #define __ardour_panner_shell_h__
23 
24 #include <cmath>
25 #include <cassert>
26 #include <vector>
27 #include <string>
28 #include <iostream>
29 
30 #include <boost/noncopyable.hpp>
31 
32 #include "pbd/cartesian.h"
33 
34 #include "ardour/libardour_visibility.h"
35 #include "ardour/types.h"
36 #include "ardour/session_object.h"
37 
38 namespace ARDOUR {
39 
40 class Session;
41 class Route;
42 class Panner;
43 class BufferSet;
44 class AudioBuffer;
45 class Speakers;
46 class Pannable;
47 
48 /** Class to manage panning by instantiating and controlling
49  *  an appropriate Panner object for a given in/out configuration.
50  */
51 class LIBARDOUR_API PannerShell : public SessionObject
52 {
53 public:
54 	PannerShell (std::string name, Session&, boost::shared_ptr<Pannable>, bool is_send = false);
55 	virtual ~PannerShell ();
56 
57 	std::string describe_parameter (Evoral::Parameter param);
58 
can_support_io_configuration(const ChanCount &,ChanCount &)59 	bool can_support_io_configuration (const ChanCount& /*in*/, ChanCount& /*out*/) { return true; };
60 	void configure_io (ChanCount in, ChanCount out);
61 
62 	/// The fundamental Panner function
63 	void run (BufferSet& src, BufferSet& dest, samplepos_t start_sample, samplepos_t end_samples, pframes_t nframes);
64 
65 	XMLNode& get_state ();
66 	int      set_state (const XMLNode&, int version);
67 
68 	PBD::Signal0<void> PannableChanged; /* Pannable changed -- l*/
69 	PBD::Signal0<void> Changed; /* panner and/or outputs count and/or bypass state changed */
70 
panner()71 	boost::shared_ptr<Panner> panner() const { return _panner; }
pannable()72 	boost::shared_ptr<Pannable> pannable() const { return _panlinked ? _pannable_route : _pannable_internal; }
unlinked_pannable()73 	boost::shared_ptr<Pannable> unlinked_pannable () const { return _pannable_internal; }
74 
75 	bool bypassed () const;
76 	void set_bypassed (bool);
77 
is_send()78 	bool is_send () const { return (_is_send); }
is_linked_to_route()79 	bool is_linked_to_route () const { return (_is_send && _panlinked); }
80 	/* this function takes the process lock: */
81 	void set_linked_to_route (bool);
82 
current_panner_uri()83 	std::string current_panner_uri() const { return _current_panner_uri; }
user_selected_panner_uri()84 	std::string user_selected_panner_uri() const { return _user_selected_panner_uri; }
panner_gui_uri()85 	std::string panner_gui_uri() const { return _panner_gui_uri; }
86 
87 	/* this function takes the process lock: */
88 	bool select_panner_by_uri (std::string const uri);
89 
90   private:
91 	void distribute_no_automation (BufferSet& src, BufferSet& dest, pframes_t nframes, gain_t gain_coeff);
92 	bool set_user_selected_panner_uri (std::string const uri);
93 
94 	boost::shared_ptr<Panner> _panner;
95 
96 	boost::shared_ptr<Pannable> _pannable_internal;
97 	boost::shared_ptr<Pannable> _pannable_route;
98 	bool _is_send;
99 	bool _panlinked;
100 	bool _bypassed;
101 
102 	std::string _current_panner_uri;
103 	std::string _user_selected_panner_uri;
104 	std::string _panner_gui_uri;
105 	bool _force_reselect;
106 };
107 
108 } // namespace ARDOUR
109 
110 #endif /* __ardour_panner_shell_h__ */
111