Ardour  8.12
vbap_speakers.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2015 Paul Davis <paul@linuxaudiosystems.com>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __libardour_vbap_speakers_h__
20 #define __libardour_vbap_speakers_h__
21 
22 #include <string>
23 #include <vector>
24 
25 #include <pbd/signals.h>
26 
27 #include "ardour/panner.h"
28 #include "ardour/speakers.h"
29 
30 namespace ARDOUR
31 {
32 class Speakers;
33 
34 class VBAPSpeakers : public boost::noncopyable
35 {
36 public:
37  VBAPSpeakers (std::shared_ptr<Speakers>);
38 
39  typedef std::vector<double> dvector;
40 
41  const dvector matrix (int tuple) const
42  {
43  return _matrices[tuple];
44  }
45 
46  int speaker_for_tuple (int tuple, int which) const
47  {
48  return _speaker_tuples[tuple][which];
49  }
50 
51  int n_tuples () const
52  {
53  return _matrices.size ();
54  }
55 
56  int dimension () const
57  {
58  return _dimension;
59  }
60 
61  uint32_t n_speakers () const
62  {
63  return _speakers.size ();
64  }
65 
66  std::shared_ptr<Speakers> parent () const
67  {
68  return _parent;
69  }
70 
72 
73 private:
74  static const double MIN_VOL_P_SIDE_LGTH;
76  std::shared_ptr<Speakers> _parent;
77  std::vector<Speaker> _speakers;
79 
80  struct azimuth_sorter {
81  bool operator() (const Speaker& s1, const Speaker& s2)
82  {
83  return s1.angles ().azi < s2.angles ().azi;
84  }
85  };
86 
87  struct twoDmatrix : public dvector {
88  twoDmatrix () : dvector (4, 0.0) { }
89  };
90 
91  struct threeDmatrix : public dvector {
92  threeDmatrix () : dvector (9, 0.0) { }
93  };
94 
95  struct tmatrix : public dvector {
96  tmatrix () : dvector (3, 0.0) { }
97  };
98 
99  std::vector<dvector> _matrices; /* holds matrices for a given speaker combinations */
100  std::vector<tmatrix> _speaker_tuples; /* holds speakers IDs for a given combination */
101 
102  /* A struct for all loudspeakers */
104  int ls_nos[3];
105  float inv_mx[9];
107  };
108 
110  static double vec_length (PBD::CartesianVector v1);
112  static double vol_p_side_lgth (int i, int j, int k, const std::vector<Speaker>&);
114 
115  void update ();
116  int any_ls_inside_triplet (int a, int b, int c);
117  void add_ldsp_triplet (int i, int j, int k, struct ls_triplet_chain** ls_triplets);
118  int lines_intersect (int i, int j, int k, int l);
119  void calculate_3x3_matrixes (struct ls_triplet_chain* ls_triplets);
120  void choose_speaker_triplets (struct ls_triplet_chain** ls_triplets);
122  void sort_2D_lss (int* sorted_lss);
123  int calc_2D_inv_tmatrix (double azi1, double azi2, double* inv_mat);
124 };
125 
126 } // namespace ARDOUR
127 
128 #endif /* __libardour_vbap_speakers_h__ */
int dimension() const
Definition: vbap_speakers.h:56
static const double MIN_VOL_P_SIDE_LGTH
Definition: vbap_speakers.h:74
std::vector< tmatrix > _speaker_tuples
int calc_2D_inv_tmatrix(double azi1, double azi2, double *inv_mat)
VBAPSpeakers(std::shared_ptr< Speakers >)
int any_ls_inside_triplet(int a, int b, int c)
std::vector< dvector > _matrices
Definition: vbap_speakers.h:99
void choose_speaker_triplets(struct ls_triplet_chain **ls_triplets)
uint32_t n_speakers() const
Definition: vbap_speakers.h:61
static double vec_prod(PBD::CartesianVector v1, PBD::CartesianVector v2)
static double vec_length(PBD::CartesianVector v1)
int lines_intersect(int i, int j, int k, int l)
void calculate_3x3_matrixes(struct ls_triplet_chain *ls_triplets)
std::shared_ptr< Speakers > _parent
Definition: vbap_speakers.h:76
std::vector< double > dvector
Definition: vbap_speakers.h:39
void add_ldsp_triplet(int i, int j, int k, struct ls_triplet_chain **ls_triplets)
void sort_2D_lss(int *sorted_lss)
static void cross_prod(PBD::CartesianVector v1, PBD::CartesianVector v2, PBD::CartesianVector *res)
static double vec_angle(PBD::CartesianVector v1, PBD::CartesianVector v2)
std::shared_ptr< Speakers > parent() const
Definition: vbap_speakers.h:66
int n_tuples() const
Definition: vbap_speakers.h:51
const dvector matrix(int tuple) const
Definition: vbap_speakers.h:41
int speaker_for_tuple(int tuple, int which) const
Definition: vbap_speakers.h:46
std::vector< Speaker > _speakers
Definition: vbap_speakers.h:77
static double vol_p_side_lgth(int i, int j, int k, const std::vector< Speaker > &)
PBD::ScopedConnection speaker_connection
Definition: vbap_speakers.h:78
static const MIDISequence s2[]
static const MIDISequence s1[]
bool operator()(const Speaker &s1, const Speaker &s2)
Definition: vbap_speakers.h:81
struct ls_triplet_chain * next