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)
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) {
210 if (_automation.automation_write()) {
211 _automation.save_state (_("automation write pass"));
214 set_position (_automation.eval (frame));
219 BaseStereoPanner::set_automation_style (AutoStyle style)
221 _automation.set_automation_style (style);
225 BaseStereoPanner::set_automation_state (AutoState state)
227 if (state != _automation.automation_state()) {
229 _automation.set_automation_state (state);
232 set_position (_automation.eval (parent.session().transport_frame()));
238 BaseStereoPanner::save (ostream& out) const
240 LocaleGuard lg (X_("POSIX"));
242 /* force a single format for numeric data to ease session interchange
243 across national boundaries.
246 out << "begin" << endl;
248 for (AutomationList::const_iterator i = _automation.const_begin(); i != _automation.const_end(); ++i) {
249 out << '\t' << (nframes_t) floor ((*i)->when) << ' ' << (*i)->value << endl;
251 error << string_compose (_("error writing pan automation file (%s)"), strerror (errno)) << endmsg;
255 out << "end" << endl;
261 BaseStereoPanner::load (istream& in, string path, uint32_t& linecnt)
264 LocaleGuard lg (X_("POSIX"));
266 _automation.clear ();
268 while (in.getline (line, sizeof (line), '\n')) {
274 if (strcmp (line, "end") == 0) {
278 if (sscanf (line, "%" PRIu32 " %lf", &when, &value) != 2) {
279 warning << string_compose(_("badly formatted pan automation event record at line %1 of %2 (ignored) [%3]"), linecnt, path, line) << endmsg;
283 _automation.add (when, value, true);
286 /* now that we are done loading */
288 _automation.save_state (_("loaded from disk"));
289 _automation.StateChanged (Change (0));
295 BaseStereoPanner::distribute (Sample* src, Sample** obufs, gain_t gain_coeff, nframes_t nframes)
309 if (fabsf ((delta = (left - desired_left))) > 0.002) { // about 1 degree of arc
311 /* interpolate over 64 frames or nframes, whichever is smaller */
313 nframes_t limit = min ((nframes_t)64, nframes);
316 delta = -(delta / (float) (limit));
318 for (n = 0; n < limit; n++) {
319 left_interp = left_interp + delta;
320 left = left_interp + 0.9 * (left - left_interp);
321 dst[n] += src[n] * left * gain_coeff;
324 pan = left * gain_coeff;
326 Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
333 if ((pan = (left * gain_coeff)) != 1.0f) {
337 Session::mix_buffers_with_gain(dst,src,nframes,pan);
339 /* mark that we wrote into the buffer */
347 Session::mix_buffers_no_gain(dst,src,nframes);
349 /* mark that we wrote into the buffer */
359 if (fabsf ((delta = (right - desired_right))) > 0.002) { // about 1 degree of arc
361 /* interpolate over 64 frames or nframes, whichever is smaller */
363 nframes_t limit = min ((nframes_t)64, nframes);
366 delta = -(delta / (float) (limit));
368 for (n = 0; n < limit; n++) {
369 right_interp = right_interp + delta;
370 right = right_interp + 0.9 * (right - right_interp);
371 dst[n] += src[n] * right * gain_coeff;
374 pan = right * gain_coeff;
376 Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
378 /* XXX it would be nice to mark the buffer as written to */
382 right = desired_right;
383 right_interp = right;
385 if ((pan = (right * gain_coeff)) != 1.0f) {
389 Session::mix_buffers_with_gain(dst,src,nframes,pan);
391 /* XXX it would be nice to mark the buffer as written to */
396 Session::mix_buffers_no_gain(dst,src,nframes);
398 /* XXX it would be nice to mark the buffer as written to */
403 /*---------------------------------------------------------------------- */
405 EqualPowerStereoPanner::EqualPowerStereoPanner (Panner& p)
406 : BaseStereoPanner (p)
411 right = desired_right;
413 right_interp = right;
416 EqualPowerStereoPanner::~EqualPowerStereoPanner ()
421 EqualPowerStereoPanner::update ()
423 /* it would be very nice to split this out into a virtual function
424 that can be accessed from BaseStereoPanner and used in distribute_automated().
426 but the place where its used in distribute_automated() is a tight inner loop,
427 and making "nframes" virtual function calls to compute values is an absurd
431 /* x == 0 => hard left
436 float panL = 1 - panR;
438 const float pan_law_attenuation = -3.0f;
439 const float scale = 2.0f - 4.0f * powf (10.0f,pan_law_attenuation/20.0f);
441 desired_left = panL * (scale * panL + 1.0f - scale);
442 desired_right = panR * (scale * panR + 1.0f - scale);
448 EqualPowerStereoPanner::distribute_automated (Sample* src, Sample** obufs,
449 nframes_t start, nframes_t end, nframes_t nframes,
455 /* fetch positional data */
457 if (!_automation.rt_safe_get_vector (start, end, buffers[0], nframes)) {
460 distribute (src, obufs, 1.0, nframes);
465 /* store effective pan position. do this even if we are muted */
468 effective_x = buffers[0][nframes-1];
474 /* apply pan law to convert positional data into pan coefficients for
478 const float pan_law_attenuation = -3.0f;
479 const float scale = 2.0f - 4.0f * powf (10.0f,pan_law_attenuation/20.0f);
481 for (nframes_t n = 0; n < nframes; ++n) {
483 float panR = buffers[0][n];
484 float panL = 1 - panR;
486 buffers[0][n] = panL * (scale * panL + 1.0f - scale);
487 buffers[1][n] = panR * (scale * panR + 1.0f - scale);
495 for (nframes_t n = 0; n < nframes; ++n) {
496 dst[n] += src[n] * pbuf[n];
499 /* XXX it would be nice to mark the buffer as written to */
506 for (nframes_t n = 0; n < nframes; ++n) {
507 dst[n] += src[n] * pbuf[n];
510 /* XXX it would be nice to mark the buffer as written to */
514 EqualPowerStereoPanner::factory (Panner& parent)
516 return new EqualPowerStereoPanner (parent);
520 EqualPowerStereoPanner::get_state (void)
526 EqualPowerStereoPanner::state (bool full_state)
528 XMLNode* root = new XMLNode ("StreamPanner");
530 LocaleGuard lg (X_("POSIX"));
532 snprintf (buf, sizeof (buf), "%.12g", x);
533 root->add_property (X_("x"), buf);
534 root->add_property (X_("type"), EqualPowerStereoPanner::name);
536 snprintf (buf, sizeof (buf), "0x%x", _automation.automation_state());
538 /* never store automation states other than off in a template */
539 snprintf (buf, sizeof (buf), "0x%x", ARDOUR::Off);
541 root->add_property (X_("automation-state"), buf);
542 snprintf (buf, sizeof (buf), "0x%x", _automation.automation_style());
543 root->add_property (X_("automation-style"), buf);
545 StreamPanner::add_state (*root);
551 EqualPowerStereoPanner::set_state (const XMLNode& node)
553 const XMLProperty* prop;
556 LocaleGuard lg (X_("POSIX"));
558 if ((prop = node.property (X_("x")))) {
559 pos = atof (prop->value().c_str());
560 set_position (pos, true);
563 if ((prop = node.property (X_("automation-state")))) {
564 sscanf (prop->value().c_str(), "0x%x", &x);
565 _automation.set_automation_state ((AutoState) x);
568 set_position (_automation.eval (parent.session().transport_frame()));
572 if ((prop = node.property (X_("automation-style")))) {
573 sscanf (prop->value().c_str(), "0x%x", &x);
574 _automation.set_automation_style ((AutoStyle) x);
577 StreamPanner::set_state (node);
582 /*----------------------------------------------------------------------*/
584 Multi2dPanner::Multi2dPanner (Panner& p)
585 : StreamPanner (p), _automation (0.0, 1.0, 0.5) // XXX useless
590 Multi2dPanner::~Multi2dPanner ()
595 Multi2dPanner::snapshot (nframes_t now)
601 Multi2dPanner::transport_stopped (nframes_t frame)
607 Multi2dPanner::set_automation_style (AutoStyle style)
613 Multi2dPanner::set_automation_state (AutoState state)
619 Multi2dPanner::update ()
621 static const float BIAS = FLT_MIN;
623 uint32_t nouts = parent.outputs.size();
630 for (i = 0; i < nouts; i++) {
631 dsq[i] = ((x - parent.outputs[i].x) * (x - parent.outputs[i].x) + (y - parent.outputs[i].y) * (y - parent.outputs[i].y) + BIAS);
635 f += dsq[i] * dsq[i];
638 // terrible hack to support OSX < 10.3.9 builds
639 fr = (float) (1.0 / sqrt((double)f));
643 for (i = 0; i < nouts; ++i) {
644 parent.outputs[i].desired_pan = 1.0f - (dsq[i] * fr);
651 Multi2dPanner::distribute (Sample* src, Sample** obufs, gain_t gain_coeff, nframes_t nframes)
655 vector<Panner::Output>::iterator o;
663 for (n = 0, o = parent.outputs.begin(); o != parent.outputs.end(); ++o, ++n) {
668 if (fabsf ((delta = (left_interp - desired_left))) > 0.002) { // about 1 degree of arc
670 /* interpolate over 64 frames or nframes, whichever is smaller */
672 nframes_t limit = min ((nframes_t)64, nframes);
675 delta = -(delta / (float) (limit));
677 for (n = 0; n < limit; n++) {
678 left_interp = left_interp + delta;
679 left = left_interp + 0.9 * (left - left_interp);
680 dst[n] += src[n] * left * gain_coeff;
683 pan = left * gain_coeff;
685 for (; n < nframes; ++n) {
686 dst[n] += src[n] * pan;
692 pan = (*o).desired_pan;
694 if ((pan *= gain_coeff) != 1.0f) {
698 for (nframes_t n = 0; n < nframes; ++n) {
699 dst[n] += src[n] * pan;
707 for (nframes_t n = 0; n < nframes; ++n) {
722 Multi2dPanner::distribute_automated (Sample* src, Sample** obufs,
723 nframes_t start, nframes_t end, nframes_t nframes,
736 Multi2dPanner::factory (Panner& p)
738 return new Multi2dPanner (p);
742 Multi2dPanner::load (istream& in, string path, uint32_t& linecnt)
748 Multi2dPanner::save (ostream& out) const
754 Multi2dPanner::get_state (void)
760 Multi2dPanner::state (bool full_state)
762 XMLNode* root = new XMLNode ("StreamPanner");
764 LocaleGuard lg (X_("POSIX"));
766 snprintf (buf, sizeof (buf), "%.12g", x);
767 root->add_property (X_("x"), buf);
768 snprintf (buf, sizeof (buf), "%.12g", y);
769 root->add_property (X_("y"), buf);
770 root->add_property (X_("type"), Multi2dPanner::name);
776 Multi2dPanner::set_state (const XMLNode& node)
778 const XMLProperty* prop;
780 LocaleGuard lg (X_("POSIX"));
785 if ((prop = node.property (X_("x")))) {
786 newx = atof (prop->value().c_str());
789 if ((prop = node.property (X_("y")))) {
790 newy = atof (prop->value().c_str());
793 if (x < 0 || y < 0) {
794 error << _("badly-formed positional data for Multi2dPanner - ignored")
799 set_position (newx, newy);
803 /*---------------------------------------------------------------------- */
805 Panner::Panner (string name, Session& s)
810 _link_direction = SameDirection;
819 Panner::set_linked (bool yn)
823 _session.set_dirty ();
824 LinkStateChanged (); /* EMIT SIGNAL */
829 Panner::set_link_direction (LinkDirection ld)
831 if (ld != _link_direction) {
832 _link_direction = ld;
833 _session.set_dirty ();
834 LinkStateChanged (); /* EMIT SIGNAL */
839 Panner::set_name (string str)
841 automation_path = _session.automation_dir();
842 automation_path += _session.snap_name();
843 automation_path += "-pan-";
844 automation_path += legalize_for_path (str);
845 automation_path += ".automation";
850 Panner::set_bypassed (bool yn)
852 if (yn != _bypassed) {
860 Panner::reset (uint32_t nouts, uint32_t npans)
863 bool changed = false;
866 if (nouts < 2 || (nouts == outputs.size() && npans == size())) {
889 fatal << _("programming error:")
890 << X_("Panner::reset() called with a single output")
897 outputs.push_back (Output (0, 0));
898 outputs.push_back (Output (1.0, 0));
900 for (n = 0; n < npans; ++n) {
901 push_back (new EqualPowerStereoPanner (*this));
906 outputs.push_back (Output (0.5, 0));
907 outputs.push_back (Output (0, 1.0));
908 outputs.push_back (Output (1.0, 1.0));
910 for (n = 0; n < npans; ++n) {
911 push_back (new Multi2dPanner (*this));
917 outputs.push_back (Output (0, 0));
918 outputs.push_back (Output (1.0, 0));
919 outputs.push_back (Output (1.0, 1.0));
920 outputs.push_back (Output (0, 1.0));
922 for (n = 0; n < npans; ++n) {
923 push_back (new Multi2dPanner (*this));
928 case 5: //square+offcenter center
929 outputs.push_back (Output (0, 0));
930 outputs.push_back (Output (1.0, 0));
931 outputs.push_back (Output (1.0, 1.0));
932 outputs.push_back (Output (0, 1.0));
933 outputs.push_back (Output (0.5, 0.75));
935 for (n = 0; n < npans; ++n) {
936 push_back (new Multi2dPanner (*this));
942 /* XXX horrible placement. FIXME */
943 for (n = 0; n < nouts; ++n) {
944 outputs.push_back (Output (0.1 * n, 0.1 * n));
947 for (n = 0; n < npans; ++n) {
948 push_back (new Multi2dPanner (*this));
954 for (iterator x = begin(); x != end(); ++x) {
958 /* force hard left/right panning in a common case: 2in/2out
961 if (npans == 2 && outputs.size() == 2) {
963 /* Do this only if we changed configuration, or our configuration
964 appears to be the default set up (center).
970 front()->get_position (left);
971 back()->get_position (right);
973 if (changed || ((left == 0.5) && (right == 0.5))) {
975 front()->set_position (0.0);
976 front()->automation().reset_default (0.0);
978 back()->set_position (1.0);
979 back()->automation().reset_default (1.0);
986 Changed (); /* EMIT SIGNAL */
993 Panner::remove (uint32_t which)
995 vector<StreamPanner*>::iterator i;
996 for (i = begin(); i != end() && which; ++i, --which);
1007 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1011 vector<StreamPanner*>::clear ();
1015 Panner::set_automation_style (AutoStyle style)
1017 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1018 (*i)->set_automation_style (style);
1020 _session.set_dirty ();
1024 Panner::set_automation_state (AutoState state)
1026 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1027 (*i)->set_automation_state (state);
1029 _session.set_dirty ();
1033 Panner::automation_state () const
1036 return front()->automation().automation_state ();
1043 Panner::automation_style () const
1046 return front()->automation().automation_style ();
1053 Panner::transport_stopped (nframes_t frame)
1055 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1056 (*i)->transport_stopped (frame);
1061 Panner::snapshot (nframes_t now)
1063 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1064 (*i)->snapshot (now);
1069 Panner::clear_automation ()
1071 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1072 (*i)->automation().clear ();
1074 _session.set_dirty ();
1078 Panner::save () const
1080 ofstream out (automation_path.c_str());
1083 error << string_compose (_("cannot open pan automation file \"%1\" for saving (%2)"), automation_path, strerror (errno))
1088 out << X_("version ") << current_automation_version_number << endl;
1090 for (vector<StreamPanner*>::const_iterator i = begin(); i != end(); ++i) {
1091 if ((*i)->save (out)) {
1103 uint32_t linecnt = 0;
1106 LocaleGuard lg (X_("POSIX"));
1108 if (automation_path.length() == 0) {
1112 if (access (automation_path.c_str(), F_OK)) {
1116 ifstream in (automation_path.c_str());
1119 error << string_compose (_("cannot open pan automation file %1 (%2)"),
1120 automation_path, strerror (errno))
1127 while (in.getline (line, sizeof(line), '\n')) {
1129 if (++linecnt == 1) {
1130 if (memcmp (line, X_("version"), 7) == 0) {
1131 if (sscanf (line, "version %f", &version) != 1) {
1132 error << string_compose(_("badly formed version number in pan automation event file \"%1\""), automation_path) << endmsg;
1136 error << string_compose(_("no version information in pan automation event file \"%1\" (first line = %2)"),
1137 automation_path, line) << endmsg;
1141 if (version != current_automation_version_number) {
1142 error << string_compose(_("mismatched pan automation event file version (%1)"), version) << endmsg;
1149 if (strlen (line) == 0 || line[0] == '#') {
1153 if (strcmp (line, "begin") == 0) {
1156 error << string_compose (_("too many panner states found in pan automation file %1"),
1162 if ((*sp)->load (in, automation_path, linecnt)) {
1176 StreamPanner* (*factory)(Panner&);
1179 PanPlugins pan_plugins[] = {
1180 { EqualPowerStereoPanner::name, 2, EqualPowerStereoPanner::factory },
1181 { Multi2dPanner::name, 3, Multi2dPanner::factory },
1182 { string (""), 0, 0 }
1186 Panner::get_state (void)
1188 return state (true);
1192 Panner::state (bool full)
1194 XMLNode* root = new XMLNode (X_("Panner"));
1197 for (iterator p = begin(); p != end(); ++p) {
1198 root->add_child_nocopy ((*p)->state (full));
1201 root->add_property (X_("linked"), (_linked ? "yes" : "no"));
1202 snprintf (buf, sizeof (buf), "%d", _link_direction);
1203 root->add_property (X_("link_direction"), buf);
1204 root->add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
1206 /* add each output */
1208 for (vector<Panner::Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) {
1209 XMLNode* onode = new XMLNode (X_("Output"));
1210 snprintf (buf, sizeof (buf), "%.12g", (*o).x);
1211 onode->add_property (X_("x"), buf);
1212 snprintf (buf, sizeof (buf), "%.12g", (*o).y);
1213 onode->add_property (X_("y"), buf);
1214 root->add_child_nocopy (*onode);
1219 root->add_property (X_("automation"), Glib::path_get_basename (automation_path));
1227 Panner::set_state (const XMLNode& node)
1230 XMLNodeConstIterator niter;
1231 const XMLProperty *prop;
1234 LocaleGuard lg (X_("POSIX"));
1239 if ((prop = node.property (X_("linked"))) != 0) {
1240 set_linked (prop->value() == "yes");
1244 if ((prop = node.property (X_("bypassed"))) != 0) {
1245 set_bypassed (prop->value() == "yes");
1248 if ((prop = node.property (X_("link_direction"))) != 0) {
1249 sscanf (prop->value().c_str(), "%d", &i);
1250 set_link_direction ((LinkDirection) (i));
1253 nlist = node.children();
1255 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1256 if ((*niter)->name() == X_("Output")) {
1260 prop = (*niter)->property (X_("x"));
1261 sscanf (prop->value().c_str(), "%g", &x);
1263 prop = (*niter)->property (X_("y"));
1264 sscanf (prop->value().c_str(), "%g", &y);
1266 outputs.push_back (Output (x, y));
1270 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1272 if ((*niter)->name() == X_("StreamPanner")) {
1274 if ((prop = (*niter)->property (X_("type")))) {
1276 for (i = 0; pan_plugins[i].factory; ++i) {
1277 if (prop->value() == pan_plugins[i].name) {
1280 /* note that we assume that all the stream panners
1281 are of the same type. pretty good
1282 assumption, but its still an assumption.
1285 sp = pan_plugins[i].factory (*this);
1287 if (sp->set_state (**niter) == 0) {
1296 if (!pan_plugins[i].factory) {
1297 error << string_compose (_("Unknown panner plugin \"%1\" found in pan state - ignored"),
1303 error << _("panner plugin node has no type information!")
1311 /* don't try to load automation if it wasn't marked as existing */
1313 if ((prop = node.property (X_("automation")))) {
1315 /* automation path is relative */
1317 automation_path = _session.automation_dir();
1318 automation_path += prop->value ();
1327 Panner::touching () const
1329 for (vector<StreamPanner*>::const_iterator i = begin(); i != end(); ++i) {
1330 if ((*i)->automation().touching ()) {
1339 Panner::set_position (float xpos, StreamPanner& orig)
1345 orig.get_position (xnow);
1346 xdelta = xpos - xnow;
1348 if (_link_direction == SameDirection) {
1350 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1352 (*i)->set_position (xpos, true);
1354 (*i)->get_position (xnow);
1355 xnew = min (1.0f, xnow + xdelta);
1356 xnew = max (0.0f, xnew);
1357 (*i)->set_position (xnew, true);
1363 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1365 (*i)->set_position (xpos, true);
1367 (*i)->get_position (xnow);
1368 xnew = min (1.0f, xnow - xdelta);
1369 xnew = max (0.0f, xnew);
1370 (*i)->set_position (xnew, true);
1377 Panner::set_position (float xpos, float ypos, StreamPanner& orig)
1380 float xdelta, ydelta;
1383 orig.get_position (xnow, ynow);
1384 xdelta = xpos - xnow;
1385 ydelta = ypos - ynow;
1387 if (_link_direction == SameDirection) {
1389 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1391 (*i)->set_position (xpos, ypos, true);
1393 (*i)->get_position (xnow, ynow);
1395 xnew = min (1.0f, xnow + xdelta);
1396 xnew = max (0.0f, xnew);
1398 ynew = min (1.0f, ynow + ydelta);
1399 ynew = max (0.0f, ynew);
1401 (*i)->set_position (xnew, ynew, true);
1407 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1409 (*i)->set_position (xpos, ypos, true);
1411 (*i)->get_position (xnow, ynow);
1413 xnew = min (1.0f, xnow - xdelta);
1414 xnew = max (0.0f, xnew);
1416 ynew = min (1.0f, ynow - ydelta);
1417 ynew = max (0.0f, ynew);
1419 (*i)->set_position (xnew, ynew, true);
1426 Panner::set_position (float xpos, float ypos, float zpos, StreamPanner& orig)
1428 float xnow, ynow, znow;
1429 float xdelta, ydelta, zdelta;
1430 float xnew, ynew, znew;
1432 orig.get_position (xnow, ynow, znow);
1433 xdelta = xpos - xnow;
1434 ydelta = ypos - ynow;
1435 zdelta = zpos - znow;
1437 if (_link_direction == SameDirection) {
1439 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1441 (*i)->set_position (xpos, ypos, zpos, true);
1443 (*i)->get_position (xnow, ynow, znow);
1445 xnew = min (1.0f, xnow + xdelta);
1446 xnew = max (0.0f, xnew);
1448 ynew = min (1.0f, ynow + ydelta);
1449 ynew = max (0.0f, ynew);
1451 znew = min (1.0f, znow + zdelta);
1452 znew = max (0.0f, znew);
1454 (*i)->set_position (xnew, ynew, znew, true);
1460 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1462 (*i)->set_position (xpos, ypos, true);
1464 (*i)->get_position (xnow, ynow, znow);
1466 xnew = min (1.0f, xnow - xdelta);
1467 xnew = max (0.0f, xnew);
1469 ynew = min (1.0f, ynow - ydelta);
1470 ynew = max (0.0f, ynew);
1472 znew = min (1.0f, znow + zdelta);
1473 znew = max (0.0f, znew);
1475 (*i)->set_position (xnew, ynew, znew, true);