non-crashing (but also non-functional) integration of VBAP with panner "architecture"
[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 <pbd/signals.h>
26
27 #include "ardour/panner.h"
28
29 namespace ARDOUR {
30
31 class VBAPSpeakers;
32
33 class VBAPanner : public StreamPanner { 
34   public:
35         VBAPanner (Panner& parent, Evoral::Parameter param, VBAPSpeakers& s);
36         ~VBAPanner ();
37
38         void do_distribute (AudioBuffer&, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes);
39         void do_distribute_automated (AudioBuffer& src, BufferSet& obufs,
40                                       nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers);
41
42         void set_azimuth_elevation (double azimuth, double elevation);
43
44         XMLNode& state (bool full_state);
45         XMLNode& get_state ();
46         int set_state (const XMLNode&, int version);
47
48         /* there never was any old-school automation */
49
50         int load (std::istream&, std::string path, uint32_t&) { return 0; }
51
52   private:
53         double _azimuth;   /* direction for the signal source */
54         double _elevation; /* elevation of the signal source */
55         bool   _dirty;
56         double gains[3];
57         double desired_gains[3];
58         int    outputs[3];
59         int    desired_outputs[3];
60
61         PBD::ScopedConnection speaker_connection;
62
63         VBAPSpeakers& _speakers;
64         
65         void compute_gains (double g[3], int ls[3], int azi, int ele);
66
67         void update ();
68         void mark_dirty ();
69 };
70
71 } /* namespace */
72
73 #endif /* __libardour_vbap_h__ */