2011-01-17 12:51:44 -05:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2011-2015 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
#ifndef __libardour_vbap_speakers_h__
|
|
|
|
#define __libardour_vbap_speakers_h__
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <boost/utility.hpp>
|
|
|
|
|
|
|
|
#include <pbd/signals.h>
|
|
|
|
|
|
|
|
#include "ardour/panner.h"
|
|
|
|
#include "ardour/speakers.h"
|
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
namespace ARDOUR
|
|
|
|
{
|
2011-01-17 12:51:44 -05:00
|
|
|
class Speakers;
|
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
class VBAPSpeakers : public boost::noncopyable
|
|
|
|
{
|
2011-01-17 12:51:44 -05:00
|
|
|
public:
|
2023-02-16 18:33:28 -05:00
|
|
|
VBAPSpeakers (std::shared_ptr<Speakers>);
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-02-17 14:47:53 -05:00
|
|
|
typedef std::vector<double> dvector;
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
const dvector matrix (int tuple) const
|
|
|
|
{
|
|
|
|
return _matrices[tuple];
|
|
|
|
}
|
|
|
|
|
|
|
|
int speaker_for_tuple (int tuple, int which) const
|
|
|
|
{
|
|
|
|
return _speaker_tuples[tuple][which];
|
|
|
|
}
|
|
|
|
|
|
|
|
int n_tuples () const
|
|
|
|
{
|
|
|
|
return _matrices.size ();
|
|
|
|
}
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
int dimension () const
|
|
|
|
{
|
|
|
|
return _dimension;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t n_speakers () const
|
|
|
|
{
|
|
|
|
return _speakers.size ();
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Speakers> parent () const
|
2020-03-23 11:46:03 -04:00
|
|
|
{
|
|
|
|
return _parent;
|
|
|
|
}
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
~VBAPSpeakers ();
|
|
|
|
|
|
|
|
private:
|
2020-03-23 11:46:03 -04:00
|
|
|
static const double MIN_VOL_P_SIDE_LGTH;
|
|
|
|
int _dimension;
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Speakers> _parent;
|
2020-03-23 11:46:03 -04:00
|
|
|
std::vector<Speaker> _speakers;
|
|
|
|
PBD::ScopedConnection speaker_connection;
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
struct azimuth_sorter {
|
2020-03-23 11:46:03 -04:00
|
|
|
bool operator() (const Speaker& s1, const Speaker& s2)
|
|
|
|
{
|
|
|
|
return s1.angles ().azi < s2.angles ().azi;
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct twoDmatrix : public dvector {
|
2020-03-23 11:46:03 -04:00
|
|
|
twoDmatrix () : dvector (4, 0.0) { }
|
2011-01-17 12:51:44 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct threeDmatrix : public dvector {
|
2020-03-23 11:46:03 -04:00
|
|
|
threeDmatrix () : dvector (9, 0.0) { }
|
2011-01-17 12:51:44 -05:00
|
|
|
};
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2011-01-17 12:51:44 -05:00
|
|
|
struct tmatrix : public dvector {
|
2020-03-23 11:46:03 -04:00
|
|
|
tmatrix () : dvector (3, 0.0) { }
|
2011-01-17 12:51:44 -05:00
|
|
|
};
|
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
std::vector<dvector> _matrices; /* holds matrices for a given speaker combinations */
|
|
|
|
std::vector<tmatrix> _speaker_tuples; /* holds speakers IDs for a given combination */
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
/* A struct for all loudspeakers */
|
|
|
|
struct ls_triplet_chain {
|
2020-03-23 11:46:03 -04:00
|
|
|
int ls_nos[3];
|
|
|
|
float inv_mx[9];
|
|
|
|
struct ls_triplet_chain* next;
|
2011-01-17 12:51:44 -05:00
|
|
|
};
|
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
static double vec_angle (PBD::CartesianVector v1, PBD::CartesianVector v2);
|
|
|
|
static double vec_length (PBD::CartesianVector v1);
|
|
|
|
static double vec_prod (PBD::CartesianVector v1, PBD::CartesianVector v2);
|
|
|
|
static double vol_p_side_lgth (int i, int j, int k, const std::vector<Speaker>&);
|
|
|
|
static void cross_prod (PBD::CartesianVector v1, PBD::CartesianVector v2, PBD::CartesianVector* res);
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
void update ();
|
|
|
|
int any_ls_inside_triplet (int a, int b, int c);
|
2020-03-23 11:46:03 -04:00
|
|
|
void add_ldsp_triplet (int i, int j, int k, struct ls_triplet_chain** ls_triplets);
|
|
|
|
int lines_intersect (int i, int j, int k, int l);
|
|
|
|
void calculate_3x3_matrixes (struct ls_triplet_chain* ls_triplets);
|
|
|
|
void choose_speaker_triplets (struct ls_triplet_chain** ls_triplets);
|
2011-01-17 12:51:44 -05:00
|
|
|
void choose_speaker_pairs ();
|
|
|
|
void sort_2D_lss (int* sorted_lss);
|
2020-03-23 11:46:03 -04:00
|
|
|
int calc_2D_inv_tmatrix (double azi1, double azi2, double* inv_mat);
|
2011-01-17 12:51:44 -05:00
|
|
|
};
|
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
} // namespace ARDOUR
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
#endif /* __libardour_vbap_speakers_h__ */
|