2011-01-17 12:51:44 -05:00
|
|
|
#include <cmath>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "pbd/cartesian.h"
|
2011-04-22 23:34:42 -04:00
|
|
|
#include "pbd/compose.h"
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
#include "ardour/amp.h"
|
2011-01-17 12:51:44 -05:00
|
|
|
#include "ardour/audio_buffer.h"
|
|
|
|
#include "ardour/buffer_set.h"
|
|
|
|
#include "ardour/pan_controllable.h"
|
2011-02-19 12:42:38 -05:00
|
|
|
#include "ardour/pannable.h"
|
|
|
|
#include "ardour/speakers.h"
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-01-26 20:31:03 -05:00
|
|
|
#include "vbap.h"
|
|
|
|
#include "vbap_speakers.h"
|
|
|
|
|
2011-04-22 23:34:42 -04:00
|
|
|
#include "i18n.h"
|
|
|
|
|
2011-01-17 12:51:44 -05:00
|
|
|
using namespace PBD;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
static PanPluginDescriptor _descriptor = {
|
|
|
|
"VBAP 2D panner",
|
2011-01-26 20:31:03 -05:00
|
|
|
-1, -1,
|
2011-01-17 12:51:44 -05:00
|
|
|
VBAPanner::factory
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" { PanPluginDescriptor* panner_descriptor () { return &_descriptor; } }
|
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
VBAPanner::Signal::Signal (Session& session, VBAPanner& p, uint32_t n, uint32_t n_speakers)
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
2011-02-19 12:42:38 -05:00
|
|
|
resize_gains (n_speakers);
|
|
|
|
|
2011-01-17 12:51:44 -05:00
|
|
|
desired_gains[0] = desired_gains[1] = desired_gains[2] = 0;
|
|
|
|
outputs[0] = outputs[1] = outputs[2] = -1;
|
|
|
|
desired_outputs[0] = desired_outputs[1] = desired_outputs[2] = -1;
|
2011-02-19 12:42:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VBAPanner::Signal::Signal::resize_gains (uint32_t n)
|
|
|
|
{
|
|
|
|
gains.assign (n, 0.0);
|
|
|
|
}
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-02-17 11:43:55 -05:00
|
|
|
VBAPanner::VBAPanner (boost::shared_ptr<Pannable> p, boost::shared_ptr<Speakers> s)
|
2011-01-17 12:51:44 -05:00
|
|
|
: Panner (p)
|
2011-02-17 11:43:55 -05:00
|
|
|
, _speakers (new VBAPSpeakers (s))
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
2011-01-26 20:31:03 -05:00
|
|
|
_pannable->pan_azimuth_control->Changed.connect_same_thread (*this, boost::bind (&VBAPanner::update, this));
|
|
|
|
_pannable->pan_width_control->Changed.connect_same_thread (*this, boost::bind (&VBAPanner::update, this));
|
|
|
|
|
|
|
|
update ();
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VBAPanner::~VBAPanner ()
|
2011-01-26 20:31:03 -05:00
|
|
|
{
|
|
|
|
clear_signals ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VBAPanner::clear_signals ()
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
|
|
|
for (vector<Signal*>::iterator i = _signals.begin(); i != _signals.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
2011-01-26 20:31:03 -05:00
|
|
|
_signals.clear ();
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-26 20:31:03 -05:00
|
|
|
VBAPanner::configure_io (ChanCount in, ChanCount /* ignored - we use Speakers */)
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
|
|
|
uint32_t n = in.n_audio();
|
|
|
|
|
2011-01-26 20:31:03 -05:00
|
|
|
clear_signals ();
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < n; ++i) {
|
2011-02-19 12:42:38 -05:00
|
|
|
Signal* s = new Signal (_pannable->session(), *this, i, _speakers->n_speakers());
|
|
|
|
_signals.push_back (s);
|
|
|
|
|
2011-01-26 20:31:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
update ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VBAPanner::update ()
|
|
|
|
{
|
2011-02-22 13:57:26 -05:00
|
|
|
/* recompute signal directions based on panner azimuth and, if relevant, width (diffusion) parameters)
|
2011-01-26 20:31:03 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* panner azimuth control is [0 .. 1.0] which we interpret as [0 .. 360] degrees
|
|
|
|
*/
|
|
|
|
double center = _pannable->pan_azimuth_control->get_value() * 360.0;
|
|
|
|
|
2011-02-22 13:57:26 -05:00
|
|
|
if (_signals.size() > 1) {
|
2011-01-26 20:31:03 -05:00
|
|
|
|
2011-02-22 13:57:26 -05:00
|
|
|
/* panner width control is [-1.0 .. 1.0]; we ignore sign, and map to [0 .. 360] degrees
|
|
|
|
so that a width of 1 corresponds to a signal equally present from all directions,
|
2011-02-24 22:20:47 -05:00
|
|
|
and a width of zero corresponds to a point source from the "center" (above) point
|
|
|
|
on the perimeter of the speaker array.
|
2011-02-22 13:57:26 -05:00
|
|
|
*/
|
2011-01-26 20:31:03 -05:00
|
|
|
|
2011-02-22 13:57:26 -05:00
|
|
|
double w = fabs (_pannable->pan_width_control->get_value()) * 360.0;
|
|
|
|
|
2011-03-01 16:53:54 -05:00
|
|
|
double min_dir = center - (w/2.0);
|
2011-02-23 23:28:48 -05:00
|
|
|
if (min_dir < 0) {
|
|
|
|
min_dir = 360.0 + min_dir; // its already negative
|
|
|
|
}
|
2011-02-22 13:57:26 -05:00
|
|
|
min_dir = max (min (min_dir, 360.0), 0.0);
|
|
|
|
|
2011-03-01 16:53:54 -05:00
|
|
|
double max_dir = center + (w/2.0);
|
2011-02-23 23:28:48 -05:00
|
|
|
if (max_dir > 360.0) {
|
|
|
|
max_dir = max_dir - 360.0;
|
|
|
|
}
|
2011-02-22 13:57:26 -05:00
|
|
|
max_dir = max (min (max_dir, 360.0), 0.0);
|
|
|
|
|
2011-02-23 23:28:48 -05:00
|
|
|
if (max_dir < min_dir) {
|
|
|
|
swap (max_dir, min_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
double degree_step_per_signal = (max_dir - min_dir) / (_signals.size() - 1);
|
2011-02-22 13:57:26 -05:00
|
|
|
double signal_direction = min_dir;
|
2011-02-23 23:28:48 -05:00
|
|
|
|
2011-02-24 22:20:47 -05:00
|
|
|
if (w >= 0.0) {
|
2011-03-01 16:53:54 -05:00
|
|
|
|
|
|
|
/* positive width - normal order of signal spread */
|
|
|
|
|
2011-02-24 22:20:47 -05:00
|
|
|
for (vector<Signal*>::iterator s = _signals.begin(); s != _signals.end(); ++s) {
|
2011-02-22 13:57:26 -05:00
|
|
|
|
2011-02-24 22:20:47 -05:00
|
|
|
Signal* signal = *s;
|
|
|
|
|
|
|
|
signal->direction = AngularVector (signal_direction, 0.0);
|
|
|
|
compute_gains (signal->desired_gains, signal->desired_outputs, signal->direction.azi, signal->direction.ele);
|
|
|
|
signal_direction += degree_step_per_signal;
|
|
|
|
}
|
|
|
|
} else {
|
2011-03-01 16:53:54 -05:00
|
|
|
|
|
|
|
/* inverted width - reverse order of signal spread */
|
|
|
|
|
2011-02-24 22:20:47 -05:00
|
|
|
for (vector<Signal*>::reverse_iterator s = _signals.rbegin(); s != _signals.rend(); ++s) {
|
2011-02-22 13:57:26 -05:00
|
|
|
|
2011-02-24 22:20:47 -05:00
|
|
|
Signal* signal = *s;
|
|
|
|
|
|
|
|
signal->direction = AngularVector (signal_direction, 0.0);
|
|
|
|
compute_gains (signal->desired_gains, signal->desired_outputs, signal->direction.azi, signal->direction.ele);
|
|
|
|
signal_direction += degree_step_per_signal;
|
|
|
|
}
|
2011-02-22 13:57:26 -05:00
|
|
|
}
|
2011-01-26 20:31:03 -05:00
|
|
|
|
2011-02-22 13:57:26 -05:00
|
|
|
} else if (_signals.size() == 1) {
|
2011-01-26 20:31:03 -05:00
|
|
|
|
2011-02-22 13:57:26 -05:00
|
|
|
/* width has no role to play if there is only 1 signal: VBAP does not do "diffusion" of a single channel */
|
2011-01-26 20:31:03 -05:00
|
|
|
|
2011-02-22 13:57:26 -05:00
|
|
|
Signal* s = _signals.front();
|
|
|
|
s->direction = AngularVector (center, 0);
|
|
|
|
compute_gains (s->desired_gains, s->desired_outputs, s->direction.azi, s->direction.ele);
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VBAPanner::compute_gains (double gains[3], int speaker_ids[3], int azi, int ele)
|
|
|
|
{
|
|
|
|
/* calculates gain factors using loudspeaker setup and given direction */
|
|
|
|
double cartdir[3];
|
|
|
|
double power;
|
|
|
|
int i,j,k;
|
|
|
|
double small_g;
|
|
|
|
double big_sm_g, gtmp[3];
|
|
|
|
|
2011-02-24 13:55:33 -05:00
|
|
|
spherical_to_cartesian (azi, ele, 1.0, cartdir[0], cartdir[1], cartdir[2]);
|
2011-01-17 12:51:44 -05:00
|
|
|
big_sm_g = -100000.0;
|
|
|
|
|
|
|
|
gains[0] = gains[1] = gains[2] = 0;
|
|
|
|
speaker_ids[0] = speaker_ids[1] = speaker_ids[2] = 0;
|
|
|
|
|
2011-02-17 11:43:55 -05:00
|
|
|
for (i = 0; i < _speakers->n_tuples(); i++) {
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
small_g = 10000000.0;
|
|
|
|
|
2011-02-17 11:43:55 -05:00
|
|
|
for (j = 0; j < _speakers->dimension(); j++) {
|
2011-01-17 12:51:44 -05:00
|
|
|
|
|
|
|
gtmp[j] = 0.0;
|
|
|
|
|
2011-02-17 11:43:55 -05:00
|
|
|
for (k = 0; k < _speakers->dimension(); k++) {
|
|
|
|
gtmp[j] += cartdir[k] * _speakers->matrix(i)[j*_speakers->dimension()+k];
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gtmp[j] < small_g) {
|
|
|
|
small_g = gtmp[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (small_g > big_sm_g) {
|
|
|
|
|
|
|
|
big_sm_g = small_g;
|
|
|
|
|
|
|
|
gains[0] = gtmp[0];
|
|
|
|
gains[1] = gtmp[1];
|
|
|
|
|
2011-02-17 11:43:55 -05:00
|
|
|
speaker_ids[0] = _speakers->speaker_for_tuple (i, 0);
|
|
|
|
speaker_ids[1] = _speakers->speaker_for_tuple (i, 1);
|
2011-02-17 18:41:45 -05:00
|
|
|
|
2011-02-17 11:43:55 -05:00
|
|
|
if (_speakers->dimension() == 3) {
|
2011-01-17 12:51:44 -05:00
|
|
|
gains[2] = gtmp[2];
|
2011-02-17 11:43:55 -05:00
|
|
|
speaker_ids[2] = _speakers->speaker_for_tuple (i, 2);
|
2011-01-17 12:51:44 -05:00
|
|
|
} else {
|
|
|
|
gains[2] = 0.0;
|
|
|
|
speaker_ids[2] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
power = sqrt (gains[0]*gains[0] + gains[1]*gains[1] + gains[2]*gains[2]);
|
|
|
|
|
|
|
|
if (power > 0) {
|
|
|
|
gains[0] /= power;
|
|
|
|
gains[1] /= power;
|
|
|
|
gains[2] /= power;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-26 20:31:03 -05:00
|
|
|
VBAPanner::distribute (BufferSet& inbufs, BufferSet& obufs, gain_t gain_coefficient, pframes_t nframes)
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
|
|
|
uint32_t n;
|
|
|
|
vector<Signal*>::iterator s;
|
|
|
|
|
|
|
|
assert (inbufs.count().n_audio() == _signals.size());
|
|
|
|
|
|
|
|
for (s = _signals.begin(), n = 0; s != _signals.end(); ++s, ++n) {
|
|
|
|
|
|
|
|
Signal* signal (*s);
|
|
|
|
|
2011-01-26 20:31:03 -05:00
|
|
|
distribute_one (inbufs.get_audio (n), obufs, gain_coefficient, nframes, n);
|
|
|
|
|
|
|
|
memcpy (signal->outputs, signal->desired_outputs, sizeof (signal->outputs));
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-26 20:31:03 -05:00
|
|
|
VBAPanner::distribute_one (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coefficient, pframes_t nframes, uint32_t which)
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
|
|
|
Sample* const src = srcbuf.data();
|
|
|
|
Signal* signal (_signals[which]);
|
|
|
|
|
|
|
|
/* VBAP may distribute the signal across up to 3 speakers depending on
|
|
|
|
the configuration of the speakers.
|
2011-02-19 12:42:38 -05:00
|
|
|
|
|
|
|
But the set of speakers in use "this time" may be different from
|
|
|
|
the set of speakers "the last time". So we have up to 6 speakers
|
|
|
|
involved, and we have to interpolate so that those no longer
|
|
|
|
in use are rapidly faded to silence and those newly in use
|
|
|
|
are rapidly faded to their correct level. This prevents clicks
|
|
|
|
as we change the set of speakers used to put the signal in
|
|
|
|
a given position.
|
|
|
|
|
|
|
|
However, the speakers are represented by output buffers, and other
|
|
|
|
speakers may write to the same buffers, so we cannot use
|
|
|
|
anything here that will simply assign new (sample) values
|
|
|
|
to the output buffers - everything must be done via mixing
|
|
|
|
functions and not assignment/copying.
|
2011-01-17 12:51:44 -05:00
|
|
|
*/
|
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
vector<double>::size_type sz = signal->gains.size();
|
|
|
|
|
|
|
|
assert (sz == obufs.count().n_audio());
|
|
|
|
|
|
|
|
int8_t outputs[sz]; // on the stack, no malloc
|
|
|
|
|
|
|
|
/* set initial state of each output "record"
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (uint32_t o = 0; o < sz; ++o) {
|
|
|
|
outputs[o] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for all outputs used this time and last time,
|
|
|
|
change the output record to show what has
|
|
|
|
happened.
|
|
|
|
*/
|
|
|
|
|
2011-02-21 21:38:29 -05:00
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
for (int o = 0; o < 3; ++o) {
|
|
|
|
if (signal->outputs[o] != -1) {
|
|
|
|
/* used last time */
|
|
|
|
outputs[signal->outputs[o]] |= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signal->desired_outputs[o] != -1) {
|
|
|
|
/* used this time */
|
|
|
|
outputs[signal->desired_outputs[o]] |= 1<<1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* at this point, we can test a speaker's status:
|
|
|
|
|
|
|
|
(outputs[o] & 1) <= in use before
|
|
|
|
(outputs[o] & 2) <= in use this time
|
|
|
|
(outputs[o] & 3) == 3 <= in use both times
|
|
|
|
outputs[o] == 0 <= not in use either time
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-01-17 12:51:44 -05:00
|
|
|
for (int o = 0; o < 3; ++o) {
|
2011-02-19 12:42:38 -05:00
|
|
|
pan_t pan;
|
|
|
|
int output = signal->desired_outputs[o];
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
if (output == -1) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
pan = gain_coefficient * signal->desired_gains[o];
|
2011-02-21 21:38:29 -05:00
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
if (pan == 0.0 && signal->gains[output] == 0.0) {
|
|
|
|
|
|
|
|
/* nothing deing delivered to this output */
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-02-21 21:38:29 -05:00
|
|
|
signal->gains[output] = 0.0;
|
2011-02-19 12:42:38 -05:00
|
|
|
|
|
|
|
} else if (fabs (pan - signal->gains[output]) > 0.00001) {
|
|
|
|
|
|
|
|
/* signal to this output but the gain coefficient has changed, so
|
|
|
|
interpolate between them.
|
|
|
|
*/
|
2011-01-17 12:51:44 -05:00
|
|
|
|
2011-02-19 12:42:38 -05:00
|
|
|
AudioBuffer& buf (obufs.get_audio (output));
|
|
|
|
buf.accumulate_with_ramped_gain_from (srcbuf.data(), nframes, signal->gains[output], pan, 0);
|
|
|
|
signal->gains[output] = pan;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* signal to this output, same gain as before so just copy with gain
|
|
|
|
*/
|
|
|
|
|
|
|
|
mix_buffers_with_gain (obufs.get_audio (output).data(),src,nframes,pan);
|
|
|
|
signal->gains[output] = pan;
|
|
|
|
}
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
2011-02-19 12:42:38 -05:00
|
|
|
|
|
|
|
/* clean up the outputs that were used last time but not this time
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (uint32_t o = 0; o < sz; ++o) {
|
|
|
|
if (outputs[o] == 1) {
|
|
|
|
/* take signal and deliver with a rapid fade out
|
|
|
|
*/
|
|
|
|
AudioBuffer& buf (obufs.get_audio (o));
|
|
|
|
buf.accumulate_with_ramped_gain_from (srcbuf.data(), nframes, signal->gains[o], 0.0, 0);
|
|
|
|
signal->gains[o] = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* note that the output buffers were all silenced at some point
|
|
|
|
so anything we didn't write to with this signal (or any others)
|
|
|
|
is just as it should be.
|
|
|
|
*/
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-26 20:31:03 -05:00
|
|
|
VBAPanner::distribute_one_automated (AudioBuffer& src, BufferSet& obufs,
|
|
|
|
framepos_t start, framepos_t end, pframes_t nframes, pan_t** buffers, uint32_t which)
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode&
|
|
|
|
VBAPanner::get_state ()
|
|
|
|
{
|
|
|
|
XMLNode& node (Panner::get_state());
|
|
|
|
node.add_property (X_("type"), _descriptor.name);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
Panner*
|
2011-02-17 11:43:55 -05:00
|
|
|
VBAPanner::factory (boost::shared_ptr<Pannable> p, boost::shared_ptr<Speakers> s)
|
2011-01-17 12:51:44 -05:00
|
|
|
{
|
|
|
|
return new VBAPanner (p, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChanCount
|
|
|
|
VBAPanner::in() const
|
|
|
|
{
|
|
|
|
return ChanCount (DataType::AUDIO, _signals.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
ChanCount
|
|
|
|
VBAPanner::out() const
|
|
|
|
{
|
2011-02-17 11:43:55 -05:00
|
|
|
return ChanCount (DataType::AUDIO, _speakers->n_speakers());
|
2011-01-17 12:51:44 -05:00
|
|
|
}
|
2011-01-26 20:31:03 -05:00
|
|
|
|
|
|
|
std::set<Evoral::Parameter>
|
|
|
|
VBAPanner::what_can_be_automated() const
|
|
|
|
{
|
|
|
|
set<Evoral::Parameter> s;
|
|
|
|
s.insert (Evoral::Parameter (PanAzimuthAutomation));
|
2011-02-22 13:57:26 -05:00
|
|
|
if (_signals.size() > 1) {
|
|
|
|
s.insert (Evoral::Parameter (PanWidthAutomation));
|
|
|
|
}
|
2011-01-26 20:31:03 -05:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
VBAPanner::describe_parameter (Evoral::Parameter p)
|
|
|
|
{
|
|
|
|
switch (p.type()) {
|
|
|
|
case PanAzimuthAutomation:
|
|
|
|
return _("Direction");
|
|
|
|
case PanWidthAutomation:
|
|
|
|
return _("Diffusion");
|
|
|
|
default:
|
|
|
|
return _pannable->describe_parameter (p);
|
|
|
|
}
|
|
|
|
}
|
2011-01-27 13:48:33 -05:00
|
|
|
|
|
|
|
string
|
|
|
|
VBAPanner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
|
|
|
|
{
|
|
|
|
/* DO NOT USE LocaleGuard HERE */
|
|
|
|
double val = ac->get_value();
|
|
|
|
|
|
|
|
switch (ac->parameter().type()) {
|
|
|
|
case PanAzimuthAutomation: /* direction */
|
2011-02-22 13:57:26 -05:00
|
|
|
return string_compose (_("%1"), int (rint (val * 360.0)));
|
2011-01-27 13:48:33 -05:00
|
|
|
|
|
|
|
case PanWidthAutomation: /* diffusion */
|
|
|
|
return string_compose (_("%1%%"), (int) floor (100.0 * fabs(val)));
|
|
|
|
|
|
|
|
default:
|
|
|
|
return _pannable->value_as_string (ac);
|
|
|
|
}
|
|
|
|
}
|
2011-02-17 13:54:13 -05:00
|
|
|
|
|
|
|
AngularVector
|
|
|
|
VBAPanner::signal_position (uint32_t n) const
|
|
|
|
{
|
|
|
|
if (n < _signals.size()) {
|
|
|
|
return _signals[n]->direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AngularVector();
|
|
|
|
}
|
2011-02-17 14:47:53 -05:00
|
|
|
|
|
|
|
boost::shared_ptr<Speakers>
|
|
|
|
VBAPanner::get_speakers () const
|
|
|
|
{
|
|
|
|
return _speakers->parent();
|
|
|
|
}
|
2011-02-17 15:15:26 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
VBAPanner::set_position (double p)
|
|
|
|
{
|
2011-02-22 16:55:25 -05:00
|
|
|
if (p < 0.0) {
|
|
|
|
p = 1.0 + p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p > 1.0) {
|
|
|
|
p = fmod (p, 1.0);
|
|
|
|
}
|
|
|
|
|
2011-02-17 15:15:26 -05:00
|
|
|
_pannable->pan_azimuth_control->set_value (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-02-22 16:55:25 -05:00
|
|
|
VBAPanner::set_width (double w)
|
2011-02-17 15:15:26 -05:00
|
|
|
{
|
2011-02-22 16:55:25 -05:00
|
|
|
_pannable->pan_width_control->set_value (min (1.0, max (-1.0, w)));
|
2011-02-17 15:15:26 -05:00
|
|
|
}
|