419930c574a38b83a6998955e0df7d4e121bcd6c
[ardour.git] / libs / ardour / ardour / vbap.h
1 /*
2     Copyright (C) 2010 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 #ifndef __libardour_vbap_h__
20 #define __libardour_vbap_h__
21
22 #include <string>
23 #include <map>
24
25 #include "ardour/panner.h"
26 #include "ardour/vbap_speakers.h"
27
28 namespace ARDOUR {
29
30 class Speakers;
31
32 class VBAPanner : public StreamPanner { 
33 public:
34         VBAPanner (Panner& parent, Evoral::Parameter param, Speakers& s);
35         ~VBAPanner ();
36
37         static StreamPanner* factory (Panner& parent, Evoral::Parameter param, Speakers& s);
38         static std::string name;
39
40         void do_distribute (AudioBuffer&, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes);
41         void do_distribute_automated (AudioBuffer& src, BufferSet& obufs,
42                                       framepos_t start, framepos_t end, pframes_t nframes, pan_t** buffers);
43
44         void set_azimuth_elevation (double azimuth, double elevation);
45
46         XMLNode& state (bool full_state);
47         XMLNode& get_state ();
48         int set_state (const XMLNode&, int version);
49
50         /* there never was any old-school automation */
51
52         int load (std::istream&, std::string path, uint32_t&) { return 0; }
53
54 private:
55         bool   _dirty;
56         double gains[3];
57         double desired_gains[3];
58         int    outputs[3];
59         int    desired_outputs[3];
60
61         VBAPSpeakers& _speakers;
62         
63         void compute_gains (double g[3], int ls[3], int azi, int ele);
64
65         void update ();
66 };
67
68 } /* namespace */
69
70 #endif /* __libardour_vbap_h__ */