various fixes to MidiRegionView selection handling, key handling, drawing of ghost...
[ardour2.git] / libs / panners / vbap / vbap.h
blob752a0c9be664d3fd1733a21aef67e98980d77414
1 /*
2 Copyright (C) 2010 Paul Davis
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.
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.
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.
19 #ifndef __libardour_vbap_h__
20 #define __libardour_vbap_h__
22 #include <string>
23 #include <map>
25 #include "pbd/cartesian.h"
27 #include "ardour/panner.h"
28 #include "ardour/panner_shell.h"
30 #include "vbap_speakers.h"
32 namespace ARDOUR {
34 class Speakers;
35 class Pannable;
37 class VBAPanner : public Panner
39 public:
40 VBAPanner (boost::shared_ptr<Pannable>, boost::shared_ptr<Speakers>);
41 ~VBAPanner ();
43 void configure_io (ChanCount in, ChanCount /* ignored - we use Speakers */);
44 ChanCount in() const;
45 ChanCount out() const;
47 void set_position (double);
48 void set_width (double);
50 std::set<Evoral::Parameter> what_can_be_automated() const;
52 static Panner* factory (boost::shared_ptr<Pannable>, boost::shared_ptr<Speakers>);
54 void distribute (BufferSet& ibufs, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes);
56 void set_azimuth_elevation (double azimuth, double elevation);
58 std::string describe_parameter (Evoral::Parameter);
59 std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
61 XMLNode& get_state ();
63 PBD::AngularVector signal_position (uint32_t n) const;
64 boost::shared_ptr<Speakers> get_speakers() const;
66 private:
67 struct Signal {
68 PBD::AngularVector direction;
69 std::vector<double> gains; /* most recently used gain for all speakers */
71 int outputs[3]; /* most recent set of outputs used (2 or 3, depending on dimension) */
72 int desired_outputs[3]; /* outputs to use the next time we distribute */
73 double desired_gains[3]; /* target gains for desired_outputs */
75 Signal (Session&, VBAPanner&, uint32_t which, uint32_t n_speakers);
76 void resize_gains (uint32_t n_speakers);
79 std::vector<Signal*> _signals;
80 boost::shared_ptr<VBAPSpeakers> _speakers;
82 void compute_gains (double g[3], int ls[3], int azi, int ele);
83 void update ();
84 void clear_signals ();
86 void distribute_one (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which);
87 void distribute_one_automated (AudioBuffer& src, BufferSet& obufs,
88 framepos_t start, framepos_t end, pframes_t nframes,
89 pan_t** buffers, uint32_t which);
92 } /* namespace */
94 #endif /* __libardour_vbap_h__ */