2 Copyright (C) 2004 Paul Davis
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.
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.
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.
33 #include <pbd/error.h>
34 #include <pbd/failed_constructor.h>
35 #include <pbd/xml++.h>
37 #include <ardour/session.h>
38 #include <ardour/panner.h>
39 #include <ardour/utils.h>
41 #include <ardour/mix.h>
45 #include <pbd/mathfix.h>
48 using namespace ARDOUR;
51 float Panner::current_automation_version_number = 1.0;
53 string EqualPowerStereoPanner::name = "Equal Power Stereo";
54 string Multi2dPanner::name = "Multiple (2D)";
56 /* this is a default mapper of control values to a pan position
57 others can be imagined.
60 static pan_t direct_control_to_pan (double fract) {
64 static double direct_pan_to_control (pan_t val) {
68 StreamPanner::StreamPanner (Panner& p)
70 _control (X_("panner"), *this)
79 StreamPanner::~StreamPanner ()
84 StreamPanner::PanControllable::set_value (float val)
86 panner.set_position (direct_control_to_pan (val));
90 StreamPanner::PanControllable::get_value (void) const
93 panner.get_effective_position (xpos);
94 return direct_pan_to_control (xpos);
98 StreamPanner::PanControllable::can_send_feedback () const
100 AutoState astate = panner.get_parent().automation_state ();
102 if ((astate == Play) || (astate == Touch && !panner.get_parent().touching())) {
110 StreamPanner::set_muted (bool yn)
119 StreamPanner::set_position (float xpos, bool link_call)
121 if (!link_call && parent.linked()) {
122 parent.set_position (xpos, *this);
134 StreamPanner::set_position (float xpos, float ypos, bool link_call)
136 if (!link_call && parent.linked()) {
137 parent.set_position (xpos, ypos, *this);
140 if (x != xpos || y != ypos) {
150 StreamPanner::set_position (float xpos, float ypos, float zpos, bool link_call)
152 if (!link_call && parent.linked()) {
153 parent.set_position (xpos, ypos, zpos, *this);
156 if (x != xpos || y != ypos || z != zpos) {
166 StreamPanner::set_state (const XMLNode& node)
168 const XMLProperty* prop;
169 XMLNodeConstIterator iter;
171 if ((prop = node.property (X_("muted")))) {
172 set_muted (prop->value() == "yes");
179 StreamPanner::add_state (XMLNode& node)
181 node.add_property (X_("muted"), (muted() ? "yes" : "no"));
184 /*---------------------------------------------------------------------- */
186 BaseStereoPanner::BaseStereoPanner (Panner& p)
187 : StreamPanner (p), _automation (0.0, 1.0, 0.5)
191 BaseStereoPanner::~BaseStereoPanner ()
196 BaseStereoPanner::snapshot (nframes_t now)
198 if (_automation.automation_state() == Write || _automation.automation_state() == Touch) {
199 _automation.rt_add (now, x);
204 BaseStereoPanner::transport_stopped (nframes_t frame)
206 _automation.reposition_for_rt_add (frame);
208 if (_automation.automation_state() != Off) {
209 set_position (_automation.eval (frame));
214 BaseStereoPanner::set_automation_style (AutoStyle style)
216 _automation.set_automation_style (style);
220 BaseStereoPanner::set_automation_state (AutoState state)
222 if (state != _automation.automation_state()) {
224 _automation.set_automation_state (state);
227 set_position (_automation.eval (parent.session().transport_frame()));
233 BaseStereoPanner::save (ostream& out) const
235 LocaleGuard lg (X_("POSIX"));
237 /* force a single format for numeric data to ease session interchange
238 across national boundaries.
241 out << "begin" << endl;
243 for (AutomationList::const_iterator i = _automation.const_begin(); i != _automation.const_end(); ++i) {
244 out << '\t' << (nframes_t) floor ((*i)->when) << ' ' << (*i)->value << endl;
246 error << string_compose (_("error writing pan automation file (%s)"), strerror (errno)) << endmsg;
250 out << "end" << endl;
256 BaseStereoPanner::load (istream& in, string path, uint32_t& linecnt)
259 LocaleGuard lg (X_("POSIX"));
261 _automation.clear ();
263 while (in.getline (line, sizeof (line), '\n')) {
269 if (strcmp (line, "end") == 0) {
273 if (sscanf (line, "%" PRIu32 " %lf", &when, &value) != 2) {
274 warning << string_compose(_("badly formatted pan automation event record at line %1 of %2 (ignored) [%3]"), linecnt, path, line) << endmsg;
278 _automation.add (when, value, true);
281 /* now that we are done loading */
283 _automation.StateChanged (Change (0));
289 BaseStereoPanner::distribute (Sample* src, Sample** obufs, gain_t gain_coeff, nframes_t nframes)
303 if (fabsf ((delta = (left - desired_left))) > 0.002) { // about 1 degree of arc
305 /* interpolate over 64 frames or nframes, whichever is smaller */
307 nframes_t limit = min ((nframes_t)64, nframes);
310 delta = -(delta / (float) (limit));
312 for (n = 0; n < limit; n++) {
313 left_interp = left_interp + delta;
314 left = left_interp + 0.9 * (left - left_interp);
315 dst[n] += src[n] * left * gain_coeff;
318 pan = left * gain_coeff;
320 Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
327 if ((pan = (left * gain_coeff)) != 1.0f) {
331 Session::mix_buffers_with_gain(dst,src,nframes,pan);
333 /* mark that we wrote into the buffer */
341 Session::mix_buffers_no_gain(dst,src,nframes);
343 /* mark that we wrote into the buffer */
353 if (fabsf ((delta = (right - desired_right))) > 0.002) { // about 1 degree of arc
355 /* interpolate over 64 frames or nframes, whichever is smaller */
357 nframes_t limit = min ((nframes_t)64, nframes);
360 delta = -(delta / (float) (limit));
362 for (n = 0; n < limit; n++) {
363 right_interp = right_interp + delta;
364 right = right_interp + 0.9 * (right - right_interp);
365 dst[n] += src[n] * right * gain_coeff;
368 pan = right * gain_coeff;
370 Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
372 /* XXX it would be nice to mark the buffer as written to */
376 right = desired_right;
377 right_interp = right;
379 if ((pan = (right * gain_coeff)) != 1.0f) {
383 Session::mix_buffers_with_gain(dst,src,nframes,pan);
385 /* XXX it would be nice to mark the buffer as written to */
390 Session::mix_buffers_no_gain(dst,src,nframes);
392 /* XXX it would be nice to mark the buffer as written to */
397 /*---------------------------------------------------------------------- */
399 EqualPowerStereoPanner::EqualPowerStereoPanner (Panner& p)
400 : BaseStereoPanner (p)
405 right = desired_right;
407 right_interp = right;
410 EqualPowerStereoPanner::~EqualPowerStereoPanner ()
415 EqualPowerStereoPanner::update ()
417 /* it would be very nice to split this out into a virtual function
418 that can be accessed from BaseStereoPanner and used in distribute_automated().
420 but the place where its used in distribute_automated() is a tight inner loop,
421 and making "nframes" virtual function calls to compute values is an absurd
425 /* x == 0 => hard left
430 float panL = 1 - panR;
432 const float pan_law_attenuation = -3.0f;
433 const float scale = 2.0f - 4.0f * powf (10.0f,pan_law_attenuation/20.0f);
435 desired_left = panL * (scale * panL + 1.0f - scale);
436 desired_right = panR * (scale * panR + 1.0f - scale);
442 EqualPowerStereoPanner::distribute_automated (Sample* src, Sample** obufs,
443 nframes_t start, nframes_t end, nframes_t nframes,
449 /* fetch positional data */
451 if (!_automation.rt_safe_get_vector (start, end, buffers[0], nframes)) {
454 distribute (src, obufs, 1.0, nframes);
459 /* store effective pan position. do this even if we are muted */
462 effective_x = buffers[0][nframes-1];
468 /* apply pan law to convert positional data into pan coefficients for
472 const float pan_law_attenuation = -3.0f;
473 const float scale = 2.0f - 4.0f * powf (10.0f,pan_law_attenuation/20.0f);
475 for (nframes_t n = 0; n < nframes; ++n) {
477 float panR = buffers[0][n];
478 float panL = 1 - panR;
480 buffers[0][n] = panL * (scale * panL + 1.0f - scale);
481 buffers[1][n] = panR * (scale * panR + 1.0f - scale);
489 for (nframes_t n = 0; n < nframes; ++n) {
490 dst[n] += src[n] * pbuf[n];
493 /* XXX it would be nice to mark the buffer as written to */
500 for (nframes_t n = 0; n < nframes; ++n) {
501 dst[n] += src[n] * pbuf[n];
504 /* XXX it would be nice to mark the buffer as written to */
508 EqualPowerStereoPanner::factory (Panner& parent)
510 return new EqualPowerStereoPanner (parent);
514 EqualPowerStereoPanner::get_state (void)
520 EqualPowerStereoPanner::state (bool full_state)
522 XMLNode* root = new XMLNode ("StreamPanner");
524 LocaleGuard lg (X_("POSIX"));
526 snprintf (buf, sizeof (buf), "%.12g", x);
527 root->add_property (X_("x"), buf);
528 root->add_property (X_("type"), EqualPowerStereoPanner::name);
530 snprintf (buf, sizeof (buf), "0x%x", _automation.automation_state());
532 /* never store automation states other than off in a template */
533 snprintf (buf, sizeof (buf), "0x%x", ARDOUR::Off);
535 root->add_property (X_("automation-state"), buf);
536 snprintf (buf, sizeof (buf), "0x%x", _automation.automation_style());
537 root->add_property (X_("automation-style"), buf);
539 StreamPanner::add_state (*root);
540 root->add_child_nocopy (_control.get_state ());
546 EqualPowerStereoPanner::set_state (const XMLNode& node)
548 const XMLProperty* prop;
551 LocaleGuard lg (X_("POSIX"));
553 if ((prop = node.property (X_("x")))) {
554 pos = atof (prop->value().c_str());
555 set_position (pos, true);
558 if ((prop = node.property (X_("automation-state")))) {
559 sscanf (prop->value().c_str(), "0x%x", &x);
560 _automation.set_automation_state ((AutoState) x);
563 set_position (_automation.eval (parent.session().transport_frame()));
567 if ((prop = node.property (X_("automation-style")))) {
568 sscanf (prop->value().c_str(), "0x%x", &x);
569 _automation.set_automation_style ((AutoStyle) x);
572 StreamPanner::set_state (node);
574 for (XMLNodeConstIterator iter = node.children().begin(); iter != node.children().end(); ++iter) {
575 if ((*iter)->name() == X_("panner")) {
576 _control.set_state (**iter);
577 parent.session().add_controllable (&_control);
584 /*----------------------------------------------------------------------*/
586 Multi2dPanner::Multi2dPanner (Panner& p)
587 : StreamPanner (p), _automation (0.0, 1.0, 0.5) // XXX useless
592 Multi2dPanner::~Multi2dPanner ()
597 Multi2dPanner::snapshot (nframes_t now)
603 Multi2dPanner::transport_stopped (nframes_t frame)
609 Multi2dPanner::set_automation_style (AutoStyle style)
615 Multi2dPanner::set_automation_state (AutoState state)
621 Multi2dPanner::update ()
623 static const float BIAS = FLT_MIN;
625 uint32_t nouts = parent.outputs.size();
632 for (i = 0; i < nouts; i++) {
633 dsq[i] = ((x - parent.outputs[i].x) * (x - parent.outputs[i].x) + (y - parent.outputs[i].y) * (y - parent.outputs[i].y) + BIAS);
637 f += dsq[i] * dsq[i];
640 // terrible hack to support OSX < 10.3.9 builds
641 fr = (float) (1.0 / sqrt((double)f));
645 for (i = 0; i < nouts; ++i) {
646 parent.outputs[i].desired_pan = 1.0f - (dsq[i] * fr);
653 Multi2dPanner::distribute (Sample* src, Sample** obufs, gain_t gain_coeff, nframes_t nframes)
657 vector<Panner::Output>::iterator o;
665 for (n = 0, o = parent.outputs.begin(); o != parent.outputs.end(); ++o, ++n) {
670 if (fabsf ((delta = (left_interp - desired_left))) > 0.002) { // about 1 degree of arc
672 /* interpolate over 64 frames or nframes, whichever is smaller */
674 nframes_t limit = min ((nframes_t)64, nframes);
677 delta = -(delta / (float) (limit));
679 for (n = 0; n < limit; n++) {
680 left_interp = left_interp + delta;
681 left = left_interp + 0.9 * (left - left_interp);
682 dst[n] += src[n] * left * gain_coeff;
685 pan = left * gain_coeff;
687 for (; n < nframes; ++n) {
688 dst[n] += src[n] * pan;
694 pan = (*o).desired_pan;
696 if ((pan *= gain_coeff) != 1.0f) {
700 for (nframes_t n = 0; n < nframes; ++n) {
701 dst[n] += src[n] * pan;
709 for (nframes_t n = 0; n < nframes; ++n) {
724 Multi2dPanner::distribute_automated (Sample* src, Sample** obufs,
725 nframes_t start, nframes_t end, nframes_t nframes,
738 Multi2dPanner::factory (Panner& p)
740 return new Multi2dPanner (p);
744 Multi2dPanner::load (istream& in, string path, uint32_t& linecnt)
750 Multi2dPanner::save (ostream& out) const
756 Multi2dPanner::get_state (void)
762 Multi2dPanner::state (bool full_state)
764 XMLNode* root = new XMLNode ("StreamPanner");
766 LocaleGuard lg (X_("POSIX"));
768 snprintf (buf, sizeof (buf), "%.12g", x);
769 root->add_property (X_("x"), buf);
770 snprintf (buf, sizeof (buf), "%.12g", y);
771 root->add_property (X_("y"), buf);
772 root->add_property (X_("type"), Multi2dPanner::name);
778 Multi2dPanner::set_state (const XMLNode& node)
780 const XMLProperty* prop;
782 LocaleGuard lg (X_("POSIX"));
787 if ((prop = node.property (X_("x")))) {
788 newx = atof (prop->value().c_str());
791 if ((prop = node.property (X_("y")))) {
792 newy = atof (prop->value().c_str());
795 if (x < 0 || y < 0) {
796 error << _("badly-formed positional data for Multi2dPanner - ignored")
801 set_position (newx, newy);
805 /*---------------------------------------------------------------------- */
807 Panner::Panner (string name, Session& s)
812 _link_direction = SameDirection;
821 Panner::set_linked (bool yn)
825 _session.set_dirty ();
826 LinkStateChanged (); /* EMIT SIGNAL */
831 Panner::set_link_direction (LinkDirection ld)
833 if (ld != _link_direction) {
834 _link_direction = ld;
835 _session.set_dirty ();
836 LinkStateChanged (); /* EMIT SIGNAL */
841 Panner::set_name (string str)
843 automation_path = _session.automation_dir();
844 automation_path += _session.snap_name();
845 automation_path += "-pan-";
846 automation_path += legalize_for_path (str);
847 automation_path += ".automation";
852 Panner::set_bypassed (bool yn)
854 if (yn != _bypassed) {
862 Panner::reset (uint32_t nouts, uint32_t npans)
865 bool changed = false;
868 if (nouts < 2 || (nouts == outputs.size() && npans == size())) {
891 fatal << _("programming error:")
892 << X_("Panner::reset() called with a single output")
899 outputs.push_back (Output (0, 0));
900 outputs.push_back (Output (1.0, 0));
902 for (n = 0; n < npans; ++n) {
903 push_back (new EqualPowerStereoPanner (*this));
908 outputs.push_back (Output (0.5, 0));
909 outputs.push_back (Output (0, 1.0));
910 outputs.push_back (Output (1.0, 1.0));
912 for (n = 0; n < npans; ++n) {
913 push_back (new Multi2dPanner (*this));
919 outputs.push_back (Output (0, 0));
920 outputs.push_back (Output (1.0, 0));
921 outputs.push_back (Output (1.0, 1.0));
922 outputs.push_back (Output (0, 1.0));
924 for (n = 0; n < npans; ++n) {
925 push_back (new Multi2dPanner (*this));
930 case 5: //square+offcenter center
931 outputs.push_back (Output (0, 0));
932 outputs.push_back (Output (1.0, 0));
933 outputs.push_back (Output (1.0, 1.0));
934 outputs.push_back (Output (0, 1.0));
935 outputs.push_back (Output (0.5, 0.75));
937 for (n = 0; n < npans; ++n) {
938 push_back (new Multi2dPanner (*this));
944 /* XXX horrible placement. FIXME */
945 for (n = 0; n < nouts; ++n) {
946 outputs.push_back (Output (0.1 * n, 0.1 * n));
949 for (n = 0; n < npans; ++n) {
950 push_back (new Multi2dPanner (*this));
956 for (iterator x = begin(); x != end(); ++x) {
960 /* force hard left/right panning in a common case: 2in/2out
963 if (npans == 2 && outputs.size() == 2) {
965 /* Do this only if we changed configuration, or our configuration
966 appears to be the default set up (center).
972 front()->get_position (left);
973 back()->get_position (right);
975 if (changed || ((left == 0.5) && (right == 0.5))) {
977 front()->set_position (0.0);
978 front()->automation().reset_default (0.0);
980 back()->set_position (1.0);
981 back()->automation().reset_default (1.0);
988 Changed (); /* EMIT SIGNAL */
995 Panner::remove (uint32_t which)
997 vector<StreamPanner*>::iterator i;
998 for (i = begin(); i != end() && which; ++i, --which);
1009 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1013 vector<StreamPanner*>::clear ();
1017 Panner::set_automation_style (AutoStyle style)
1019 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1020 (*i)->set_automation_style (style);
1022 _session.set_dirty ();
1026 Panner::set_automation_state (AutoState state)
1028 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1029 (*i)->set_automation_state (state);
1031 _session.set_dirty ();
1035 Panner::automation_state () const
1038 return front()->automation().automation_state ();
1045 Panner::automation_style () const
1048 return front()->automation().automation_style ();
1055 Panner::transport_stopped (nframes_t frame)
1057 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1058 (*i)->transport_stopped (frame);
1063 Panner::snapshot (nframes_t now)
1065 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1066 (*i)->snapshot (now);
1071 Panner::clear_automation ()
1073 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1074 (*i)->automation().clear ();
1076 _session.set_dirty ();
1080 Panner::save () const
1082 ofstream out (automation_path.c_str());
1085 error << string_compose (_("cannot open pan automation file \"%1\" for saving (%2)"), automation_path, strerror (errno))
1090 out << X_("version ") << current_automation_version_number << endl;
1092 for (vector<StreamPanner*>::const_iterator i = begin(); i != end(); ++i) {
1093 if ((*i)->save (out)) {
1105 uint32_t linecnt = 0;
1108 LocaleGuard lg (X_("POSIX"));
1110 if (automation_path.length() == 0) {
1114 if (access (automation_path.c_str(), F_OK)) {
1118 ifstream in (automation_path.c_str());
1121 error << string_compose (_("cannot open pan automation file %1 (%2)"),
1122 automation_path, strerror (errno))
1129 while (in.getline (line, sizeof(line), '\n')) {
1131 if (++linecnt == 1) {
1132 if (memcmp (line, X_("version"), 7) == 0) {
1133 if (sscanf (line, "version %f", &version) != 1) {
1134 error << string_compose(_("badly formed version number in pan automation event file \"%1\""), automation_path) << endmsg;
1138 error << string_compose(_("no version information in pan automation event file \"%1\" (first line = %2)"),
1139 automation_path, line) << endmsg;
1143 if (version != current_automation_version_number) {
1144 error << string_compose(_("mismatched pan automation event file version (%1)"), version) << endmsg;
1151 if (strlen (line) == 0 || line[0] == '#') {
1155 if (strcmp (line, "begin") == 0) {
1158 error << string_compose (_("too many panner states found in pan automation file %1"),
1164 if ((*sp)->load (in, automation_path, linecnt)) {
1178 StreamPanner* (*factory)(Panner&);
1181 PanPlugins pan_plugins[] = {
1182 { EqualPowerStereoPanner::name, 2, EqualPowerStereoPanner::factory },
1183 { Multi2dPanner::name, 3, Multi2dPanner::factory },
1184 { string (""), 0, 0 }
1188 Panner::get_state (void)
1190 return state (true);
1194 Panner::state (bool full)
1196 XMLNode* root = new XMLNode (X_("Panner"));
1199 for (iterator p = begin(); p != end(); ++p) {
1200 root->add_child_nocopy ((*p)->state (full));
1203 root->add_property (X_("linked"), (_linked ? "yes" : "no"));
1204 snprintf (buf, sizeof (buf), "%d", _link_direction);
1205 root->add_property (X_("link_direction"), buf);
1206 root->add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
1208 /* add each output */
1210 for (vector<Panner::Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) {
1211 XMLNode* onode = new XMLNode (X_("Output"));
1212 snprintf (buf, sizeof (buf), "%.12g", (*o).x);
1213 onode->add_property (X_("x"), buf);
1214 snprintf (buf, sizeof (buf), "%.12g", (*o).y);
1215 onode->add_property (X_("y"), buf);
1216 root->add_child_nocopy (*onode);
1221 root->add_property (X_("automation"), Glib::path_get_basename (automation_path));
1229 Panner::set_state (const XMLNode& node)
1232 XMLNodeConstIterator niter;
1233 const XMLProperty *prop;
1236 LocaleGuard lg (X_("POSIX"));
1241 if ((prop = node.property (X_("linked"))) != 0) {
1242 set_linked (prop->value() == "yes");
1246 if ((prop = node.property (X_("bypassed"))) != 0) {
1247 set_bypassed (prop->value() == "yes");
1250 if ((prop = node.property (X_("link_direction"))) != 0) {
1251 sscanf (prop->value().c_str(), "%d", &i);
1252 set_link_direction ((LinkDirection) (i));
1255 nlist = node.children();
1257 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1258 if ((*niter)->name() == X_("Output")) {
1262 prop = (*niter)->property (X_("x"));
1263 sscanf (prop->value().c_str(), "%g", &x);
1265 prop = (*niter)->property (X_("y"));
1266 sscanf (prop->value().c_str(), "%g", &y);
1268 outputs.push_back (Output (x, y));
1272 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1274 if ((*niter)->name() == X_("StreamPanner")) {
1276 if ((prop = (*niter)->property (X_("type")))) {
1278 for (i = 0; pan_plugins[i].factory; ++i) {
1279 if (prop->value() == pan_plugins[i].name) {
1282 /* note that we assume that all the stream panners
1283 are of the same type. pretty good
1284 assumption, but its still an assumption.
1287 sp = pan_plugins[i].factory (*this);
1289 if (sp->set_state (**niter) == 0) {
1298 if (!pan_plugins[i].factory) {
1299 error << string_compose (_("Unknown panner plugin \"%1\" found in pan state - ignored"),
1305 error << _("panner plugin node has no type information!")
1313 /* don't try to load automation if it wasn't marked as existing */
1315 if ((prop = node.property (X_("automation")))) {
1317 /* automation path is relative */
1319 automation_path = _session.automation_dir();
1320 automation_path += prop->value ();
1329 Panner::touching () const
1331 for (vector<StreamPanner*>::const_iterator i = begin(); i != end(); ++i) {
1332 if ((*i)->automation().touching ()) {
1341 Panner::set_position (float xpos, StreamPanner& orig)
1347 orig.get_position (xnow);
1348 xdelta = xpos - xnow;
1350 if (_link_direction == SameDirection) {
1352 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1354 (*i)->set_position (xpos, true);
1356 (*i)->get_position (xnow);
1357 xnew = min (1.0f, xnow + xdelta);
1358 xnew = max (0.0f, xnew);
1359 (*i)->set_position (xnew, true);
1365 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1367 (*i)->set_position (xpos, true);
1369 (*i)->get_position (xnow);
1370 xnew = min (1.0f, xnow - xdelta);
1371 xnew = max (0.0f, xnew);
1372 (*i)->set_position (xnew, true);
1379 Panner::set_position (float xpos, float ypos, StreamPanner& orig)
1382 float xdelta, ydelta;
1385 orig.get_position (xnow, ynow);
1386 xdelta = xpos - xnow;
1387 ydelta = ypos - ynow;
1389 if (_link_direction == SameDirection) {
1391 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1393 (*i)->set_position (xpos, ypos, true);
1395 (*i)->get_position (xnow, ynow);
1397 xnew = min (1.0f, xnow + xdelta);
1398 xnew = max (0.0f, xnew);
1400 ynew = min (1.0f, ynow + ydelta);
1401 ynew = max (0.0f, ynew);
1403 (*i)->set_position (xnew, ynew, true);
1409 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1411 (*i)->set_position (xpos, ypos, true);
1413 (*i)->get_position (xnow, ynow);
1415 xnew = min (1.0f, xnow - xdelta);
1416 xnew = max (0.0f, xnew);
1418 ynew = min (1.0f, ynow - ydelta);
1419 ynew = max (0.0f, ynew);
1421 (*i)->set_position (xnew, ynew, true);
1428 Panner::set_position (float xpos, float ypos, float zpos, StreamPanner& orig)
1430 float xnow, ynow, znow;
1431 float xdelta, ydelta, zdelta;
1432 float xnew, ynew, znew;
1434 orig.get_position (xnow, ynow, znow);
1435 xdelta = xpos - xnow;
1436 ydelta = ypos - ynow;
1437 zdelta = zpos - znow;
1439 if (_link_direction == SameDirection) {
1441 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1443 (*i)->set_position (xpos, ypos, zpos, true);
1445 (*i)->get_position (xnow, ynow, znow);
1447 xnew = min (1.0f, xnow + xdelta);
1448 xnew = max (0.0f, xnew);
1450 ynew = min (1.0f, ynow + ydelta);
1451 ynew = max (0.0f, ynew);
1453 znew = min (1.0f, znow + zdelta);
1454 znew = max (0.0f, znew);
1456 (*i)->set_position (xnew, ynew, znew, true);
1462 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1464 (*i)->set_position (xpos, ypos, true);
1466 (*i)->get_position (xnow, ynow, znow);
1468 xnew = min (1.0f, xnow - xdelta);
1469 xnew = max (0.0f, xnew);
1471 ynew = min (1.0f, ynow - ydelta);
1472 ynew = max (0.0f, ynew);
1474 znew = min (1.0f, znow + zdelta);
1475 znew = max (0.0f, znew);
1477 (*i)->set_position (xnew, ynew, znew, true);