2011-01-17 12:51:44 -05:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2011-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
*
|
|
|
|
* 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_h__
|
|
|
|
#define __libardour_vbap_h__
|
|
|
|
|
|
|
|
#include <map>
|
2020-03-23 11:46:03 -04:00
|
|
|
#include <string>
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
#include "pbd/cartesian.h"
|
|
|
|
|
|
|
|
#include "ardour/panner.h"
|
|
|
|
#include "ardour/panner_shell.h"
|
2011-01-26 20:31:03 -05:00
|
|
|
|
|
|
|
#include "vbap_speakers.h"
|
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
|
|
|
class Speakers;
|
|
|
|
class Pannable;
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
class VBAPanner : public Panner
|
|
|
|
{
|
2011-01-17 12:51:44 -05:00
|
|
|
public:
|
2011-02-17 11:43:55 -05:00
|
|
|
VBAPanner (boost::shared_ptr<Pannable>, boost::shared_ptr<Speakers>);
|
2011-01-17 12:51:44 -05:00
|
|
|
~VBAPanner ();
|
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
void configure_io (ChanCount in, ChanCount /* ignored - we use Speakers */);
|
|
|
|
ChanCount in () const;
|
|
|
|
ChanCount out () const;
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
void set_position (double);
|
|
|
|
void set_width (double);
|
|
|
|
void set_elevation (double);
|
2011-02-17 15:15:26 -05:00
|
|
|
|
2011-02-17 11:43:55 -05:00
|
|
|
static Panner* factory (boost::shared_ptr<Pannable>, boost::shared_ptr<Speakers>);
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-01-26 20:31:03 -05:00
|
|
|
void distribute (BufferSet& ibufs, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes);
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
void set_azimuth_elevation (double azimuth, double elevation);
|
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
std::string value_as_string (boost::shared_ptr<const AutomationControl>) const;
|
2011-01-26 20:31:03 -05:00
|
|
|
|
2022-04-06 23:56:32 -04:00
|
|
|
XMLNode& get_state () const;
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
PBD::AngularVector signal_position (uint32_t n) const;
|
|
|
|
boost::shared_ptr<Speakers> get_speakers () const;
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-10-22 12:19:27 -04:00
|
|
|
void reset ();
|
|
|
|
|
2011-01-17 12:51:44 -05:00
|
|
|
private:
|
2020-03-23 11:46:03 -04:00
|
|
|
struct Signal {
|
|
|
|
PBD::AngularVector direction;
|
|
|
|
std::vector<double> gains; /* most recently used gain for all speakers */
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
int outputs[3]; /* most recent set of outputs used (2 or 3, depending on dimension) */
|
|
|
|
int desired_outputs[3]; /* outputs to use the next time we distribute */
|
|
|
|
double desired_gains[3]; /* target gains for desired_outputs */
|
2011-02-19 12:42:38 -05:00
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
Signal (VBAPanner&, uint32_t which, uint32_t n_speakers);
|
|
|
|
void resize_gains (uint32_t n_speakers);
|
|
|
|
};
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2020-03-23 11:46:03 -04:00
|
|
|
std::vector<Signal*> _signals;
|
|
|
|
boost::shared_ptr<VBAPSpeakers> _speakers;
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2011-01-17 12:51:44 -05:00
|
|
|
void compute_gains (double g[3], int ls[3], int azi, int ele);
|
2020-03-23 11:46:03 -04:00
|
|
|
void update ();
|
|
|
|
void clear_signals ();
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-01-26 20:31:03 -05:00
|
|
|
void distribute_one (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, pframes_t nframes, uint32_t which);
|
|
|
|
void distribute_one_automated (AudioBuffer& src, BufferSet& obufs,
|
2020-03-23 11:46:03 -04:00
|
|
|
samplepos_t start, samplepos_t end, pframes_t nframes,
|
|
|
|
pan_t** buffers, uint32_t which);
|
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_h__ */
|