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) {
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);
546 root->add_child_nocopy (_control.get_state ());
552 EqualPowerStereoPanner::set_state (const XMLNode& node)
554 const XMLProperty* prop;
557 LocaleGuard lg (X_("POSIX"));
559 if ((prop = node.property (X_("x")))) {
560 pos = atof (prop->value().c_str());
561 set_position (pos, true);
564 if ((prop = node.property (X_("automation-state")))) {
565 sscanf (prop->value().c_str(), "0x%x", &x);
566 _automation.set_automation_state ((AutoState) x);
569 set_position (_automation.eval (parent.session().transport_frame()));
573 if ((prop = node.property (X_("automation-style")))) {
574 sscanf (prop->value().c_str(), "0x%x", &x);
575 _automation.set_automation_style ((AutoStyle) x);
578 StreamPanner::set_state (node);
580 for (XMLNodeConstIterator iter = node.children().begin(); iter != node.children().end(); ++iter) {
581 if ((*iter)->name() == X_("panner")) {
582 _control.set_state (**iter);
583 parent.session().add_controllable (&_control);
590 /*----------------------------------------------------------------------*/
592 Multi2dPanner::Multi2dPanner (Panner& p)
593 : StreamPanner (p), _automation (0.0, 1.0, 0.5) // XXX useless
598 Multi2dPanner::~Multi2dPanner ()
603 Multi2dPanner::snapshot (nframes_t now)
609 Multi2dPanner::transport_stopped (nframes_t frame)
615 Multi2dPanner::set_automation_style (AutoStyle style)
621 Multi2dPanner::set_automation_state (AutoState state)
627 Multi2dPanner::update ()
629 static const float BIAS = FLT_MIN;
631 uint32_t nouts = parent.outputs.size();
638 for (i = 0; i < nouts; i++) {
639 dsq[i] = ((x - parent.outputs[i].x) * (x - parent.outputs[i].x) + (y - parent.outputs[i].y) * (y - parent.outputs[i].y) + BIAS);
643 f += dsq[i] * dsq[i];
646 // terrible hack to support OSX < 10.3.9 builds
647 fr = (float) (1.0 / sqrt((double)f));
651 for (i = 0; i < nouts; ++i) {
652 parent.outputs[i].desired_pan = 1.0f - (dsq[i] * fr);
659 Multi2dPanner::distribute (Sample* src, Sample** obufs, gain_t gain_coeff, nframes_t nframes)
663 vector<Panner::Output>::iterator o;
671 for (n = 0, o = parent.outputs.begin(); o != parent.outputs.end(); ++o, ++n) {
676 if (fabsf ((delta = (left_interp - desired_left))) > 0.002) { // about 1 degree of arc
678 /* interpolate over 64 frames or nframes, whichever is smaller */
680 nframes_t limit = min ((nframes_t)64, nframes);
683 delta = -(delta / (float) (limit));
685 for (n = 0; n < limit; n++) {
686 left_interp = left_interp + delta;
687 left = left_interp + 0.9 * (left - left_interp);
688 dst[n] += src[n] * left * gain_coeff;
691 pan = left * gain_coeff;
693 for (; n < nframes; ++n) {
694 dst[n] += src[n] * pan;
700 pan = (*o).desired_pan;
702 if ((pan *= gain_coeff) != 1.0f) {
706 for (nframes_t n = 0; n < nframes; ++n) {
707 dst[n] += src[n] * pan;
715 for (nframes_t n = 0; n < nframes; ++n) {
730 Multi2dPanner::distribute_automated (Sample* src, Sample** obufs,
731 nframes_t start, nframes_t end, nframes_t nframes,
744 Multi2dPanner::factory (Panner& p)
746 return new Multi2dPanner (p);
750 Multi2dPanner::load (istream& in, string path, uint32_t& linecnt)
756 Multi2dPanner::save (ostream& out) const
762 Multi2dPanner::get_state (void)
768 Multi2dPanner::state (bool full_state)
770 XMLNode* root = new XMLNode ("StreamPanner");
772 LocaleGuard lg (X_("POSIX"));
774 snprintf (buf, sizeof (buf), "%.12g", x);
775 root->add_property (X_("x"), buf);
776 snprintf (buf, sizeof (buf), "%.12g", y);
777 root->add_property (X_("y"), buf);
778 root->add_property (X_("type"), Multi2dPanner::name);
784 Multi2dPanner::set_state (const XMLNode& node)
786 const XMLProperty* prop;
788 LocaleGuard lg (X_("POSIX"));
793 if ((prop = node.property (X_("x")))) {
794 newx = atof (prop->value().c_str());
797 if ((prop = node.property (X_("y")))) {
798 newy = atof (prop->value().c_str());
801 if (x < 0 || y < 0) {
802 error << _("badly-formed positional data for Multi2dPanner - ignored")
807 set_position (newx, newy);
811 /*---------------------------------------------------------------------- */
813 Panner::Panner (string name, Session& s)
818 _link_direction = SameDirection;
827 Panner::set_linked (bool yn)
831 _session.set_dirty ();
832 LinkStateChanged (); /* EMIT SIGNAL */
837 Panner::set_link_direction (LinkDirection ld)
839 if (ld != _link_direction) {
840 _link_direction = ld;
841 _session.set_dirty ();
842 LinkStateChanged (); /* EMIT SIGNAL */
847 Panner::set_name (string str)
849 automation_path = _session.automation_dir();
850 automation_path += _session.snap_name();
851 automation_path += "-pan-";
852 automation_path += legalize_for_path (str);
853 automation_path += ".automation";
858 Panner::set_bypassed (bool yn)
860 if (yn != _bypassed) {
868 Panner::reset (uint32_t nouts, uint32_t npans)
871 bool changed = false;
874 if (nouts < 2 || (nouts == outputs.size() && npans == size())) {
897 fatal << _("programming error:")
898 << X_("Panner::reset() called with a single output")
905 outputs.push_back (Output (0, 0));
906 outputs.push_back (Output (1.0, 0));
908 for (n = 0; n < npans; ++n) {
909 push_back (new EqualPowerStereoPanner (*this));
914 outputs.push_back (Output (0.5, 0));
915 outputs.push_back (Output (0, 1.0));
916 outputs.push_back (Output (1.0, 1.0));
918 for (n = 0; n < npans; ++n) {
919 push_back (new Multi2dPanner (*this));
925 outputs.push_back (Output (0, 0));
926 outputs.push_back (Output (1.0, 0));
927 outputs.push_back (Output (1.0, 1.0));
928 outputs.push_back (Output (0, 1.0));
930 for (n = 0; n < npans; ++n) {
931 push_back (new Multi2dPanner (*this));
936 case 5: //square+offcenter center
937 outputs.push_back (Output (0, 0));
938 outputs.push_back (Output (1.0, 0));
939 outputs.push_back (Output (1.0, 1.0));
940 outputs.push_back (Output (0, 1.0));
941 outputs.push_back (Output (0.5, 0.75));
943 for (n = 0; n < npans; ++n) {
944 push_back (new Multi2dPanner (*this));
950 /* XXX horrible placement. FIXME */
951 for (n = 0; n < nouts; ++n) {
952 outputs.push_back (Output (0.1 * n, 0.1 * n));
955 for (n = 0; n < npans; ++n) {
956 push_back (new Multi2dPanner (*this));
962 for (iterator x = begin(); x != end(); ++x) {
966 /* force hard left/right panning in a common case: 2in/2out
969 if (npans == 2 && outputs.size() == 2) {
971 /* Do this only if we changed configuration, or our configuration
972 appears to be the default set up (center).
978 front()->get_position (left);
979 back()->get_position (right);
981 if (changed || ((left == 0.5) && (right == 0.5))) {
983 front()->set_position (0.0);
984 front()->automation().reset_default (0.0);
986 back()->set_position (1.0);
987 back()->automation().reset_default (1.0);
994 Changed (); /* EMIT SIGNAL */
1001 Panner::remove (uint32_t which)
1003 vector<StreamPanner*>::iterator i;
1004 for (i = begin(); i != end() && which; ++i, --which);
1015 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1019 vector<StreamPanner*>::clear ();
1023 Panner::set_automation_style (AutoStyle style)
1025 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1026 (*i)->set_automation_style (style);
1028 _session.set_dirty ();
1032 Panner::set_automation_state (AutoState state)
1034 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1035 (*i)->set_automation_state (state);
1037 _session.set_dirty ();
1041 Panner::automation_state () const
1044 return front()->automation().automation_state ();
1051 Panner::automation_style () const
1054 return front()->automation().automation_style ();
1061 Panner::transport_stopped (nframes_t frame)
1063 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1064 (*i)->transport_stopped (frame);
1069 Panner::snapshot (nframes_t now)
1071 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1072 (*i)->snapshot (now);
1077 Panner::clear_automation ()
1079 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1080 (*i)->automation().clear ();
1082 _session.set_dirty ();
1086 Panner::save () const
1088 ofstream out (automation_path.c_str());
1091 error << string_compose (_("cannot open pan automation file \"%1\" for saving (%2)"), automation_path, strerror (errno))
1096 out << X_("version ") << current_automation_version_number << endl;
1098 for (vector<StreamPanner*>::const_iterator i = begin(); i != end(); ++i) {
1099 if ((*i)->save (out)) {
1111 uint32_t linecnt = 0;
1114 LocaleGuard lg (X_("POSIX"));
1116 if (automation_path.length() == 0) {
1120 if (access (automation_path.c_str(), F_OK)) {
1124 ifstream in (automation_path.c_str());
1127 error << string_compose (_("cannot open pan automation file %1 (%2)"),
1128 automation_path, strerror (errno))
1135 while (in.getline (line, sizeof(line), '\n')) {
1137 if (++linecnt == 1) {
1138 if (memcmp (line, X_("version"), 7) == 0) {
1139 if (sscanf (line, "version %f", &version) != 1) {
1140 error << string_compose(_("badly formed version number in pan automation event file \"%1\""), automation_path) << endmsg;
1144 error << string_compose(_("no version information in pan automation event file \"%1\" (first line = %2)"),
1145 automation_path, line) << endmsg;
1149 if (version != current_automation_version_number) {
1150 error << string_compose(_("mismatched pan automation event file version (%1)"), version) << endmsg;
1157 if (strlen (line) == 0 || line[0] == '#') {
1161 if (strcmp (line, "begin") == 0) {
1164 error << string_compose (_("too many panner states found in pan automation file %1"),
1170 if ((*sp)->load (in, automation_path, linecnt)) {
1184 StreamPanner* (*factory)(Panner&);
1187 PanPlugins pan_plugins[] = {
1188 { EqualPowerStereoPanner::name, 2, EqualPowerStereoPanner::factory },
1189 { Multi2dPanner::name, 3, Multi2dPanner::factory },
1190 { string (""), 0, 0 }
1194 Panner::get_state (void)
1196 return state (true);
1200 Panner::state (bool full)
1202 XMLNode* root = new XMLNode (X_("Panner"));
1205 for (iterator p = begin(); p != end(); ++p) {
1206 root->add_child_nocopy ((*p)->state (full));
1209 root->add_property (X_("linked"), (_linked ? "yes" : "no"));
1210 snprintf (buf, sizeof (buf), "%d", _link_direction);
1211 root->add_property (X_("link_direction"), buf);
1212 root->add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
1214 /* add each output */
1216 for (vector<Panner::Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) {
1217 XMLNode* onode = new XMLNode (X_("Output"));
1218 snprintf (buf, sizeof (buf), "%.12g", (*o).x);
1219 onode->add_property (X_("x"), buf);
1220 snprintf (buf, sizeof (buf), "%.12g", (*o).y);
1221 onode->add_property (X_("y"), buf);
1222 root->add_child_nocopy (*onode);
1227 root->add_property (X_("automation"), Glib::path_get_basename (automation_path));
1235 Panner::set_state (const XMLNode& node)
1238 XMLNodeConstIterator niter;
1239 const XMLProperty *prop;
1242 LocaleGuard lg (X_("POSIX"));
1247 if ((prop = node.property (X_("linked"))) != 0) {
1248 set_linked (prop->value() == "yes");
1252 if ((prop = node.property (X_("bypassed"))) != 0) {
1253 set_bypassed (prop->value() == "yes");
1256 if ((prop = node.property (X_("link_direction"))) != 0) {
1257 sscanf (prop->value().c_str(), "%d", &i);
1258 set_link_direction ((LinkDirection) (i));
1261 nlist = node.children();
1263 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1264 if ((*niter)->name() == X_("Output")) {
1268 prop = (*niter)->property (X_("x"));
1269 sscanf (prop->value().c_str(), "%g", &x);
1271 prop = (*niter)->property (X_("y"));
1272 sscanf (prop->value().c_str(), "%g", &y);
1274 outputs.push_back (Output (x, y));
1278 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1280 if ((*niter)->name() == X_("StreamPanner")) {
1282 if ((prop = (*niter)->property (X_("type")))) {
1284 for (i = 0; pan_plugins[i].factory; ++i) {
1285 if (prop->value() == pan_plugins[i].name) {
1288 /* note that we assume that all the stream panners
1289 are of the same type. pretty good
1290 assumption, but its still an assumption.
1293 sp = pan_plugins[i].factory (*this);
1295 if (sp->set_state (**niter) == 0) {
1304 if (!pan_plugins[i].factory) {
1305 error << string_compose (_("Unknown panner plugin \"%1\" found in pan state - ignored"),
1311 error << _("panner plugin node has no type information!")
1319 /* don't try to load automation if it wasn't marked as existing */
1321 if ((prop = node.property (X_("automation")))) {
1323 /* automation path is relative */
1325 automation_path = _session.automation_dir();
1326 automation_path += prop->value ();
1335 Panner::touching () const
1337 for (vector<StreamPanner*>::const_iterator i = begin(); i != end(); ++i) {
1338 if ((*i)->automation().touching ()) {
1347 Panner::set_position (float xpos, StreamPanner& orig)
1353 orig.get_position (xnow);
1354 xdelta = xpos - xnow;
1356 if (_link_direction == SameDirection) {
1358 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1360 (*i)->set_position (xpos, true);
1362 (*i)->get_position (xnow);
1363 xnew = min (1.0f, xnow + xdelta);
1364 xnew = max (0.0f, xnew);
1365 (*i)->set_position (xnew, true);
1371 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1373 (*i)->set_position (xpos, true);
1375 (*i)->get_position (xnow);
1376 xnew = min (1.0f, xnow - xdelta);
1377 xnew = max (0.0f, xnew);
1378 (*i)->set_position (xnew, true);
1385 Panner::set_position (float xpos, float ypos, StreamPanner& orig)
1388 float xdelta, ydelta;
1391 orig.get_position (xnow, ynow);
1392 xdelta = xpos - xnow;
1393 ydelta = ypos - ynow;
1395 if (_link_direction == SameDirection) {
1397 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1399 (*i)->set_position (xpos, ypos, true);
1401 (*i)->get_position (xnow, ynow);
1403 xnew = min (1.0f, xnow + xdelta);
1404 xnew = max (0.0f, xnew);
1406 ynew = min (1.0f, ynow + ydelta);
1407 ynew = max (0.0f, ynew);
1409 (*i)->set_position (xnew, ynew, true);
1415 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1417 (*i)->set_position (xpos, ypos, true);
1419 (*i)->get_position (xnow, ynow);
1421 xnew = min (1.0f, xnow - xdelta);
1422 xnew = max (0.0f, xnew);
1424 ynew = min (1.0f, ynow - ydelta);
1425 ynew = max (0.0f, ynew);
1427 (*i)->set_position (xnew, ynew, true);
1434 Panner::set_position (float xpos, float ypos, float zpos, StreamPanner& orig)
1436 float xnow, ynow, znow;
1437 float xdelta, ydelta, zdelta;
1438 float xnew, ynew, znew;
1440 orig.get_position (xnow, ynow, znow);
1441 xdelta = xpos - xnow;
1442 ydelta = ypos - ynow;
1443 zdelta = zpos - znow;
1445 if (_link_direction == SameDirection) {
1447 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1449 (*i)->set_position (xpos, ypos, zpos, true);
1451 (*i)->get_position (xnow, ynow, znow);
1453 xnew = min (1.0f, xnow + xdelta);
1454 xnew = max (0.0f, xnew);
1456 ynew = min (1.0f, ynow + ydelta);
1457 ynew = max (0.0f, ynew);
1459 znew = min (1.0f, znow + zdelta);
1460 znew = max (0.0f, znew);
1462 (*i)->set_position (xnew, ynew, znew, true);
1468 for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
1470 (*i)->set_position (xpos, ypos, true);
1472 (*i)->get_position (xnow, ynow, znow);
1474 xnew = min (1.0f, xnow - xdelta);
1475 xnew = max (0.0f, xnew);
1477 ynew = min (1.0f, ynow - ydelta);
1478 ynew = max (0.0f, ynew);
1480 znew = min (1.0f, znow + zdelta);
1481 znew = max (0.0f, znew);
1483 (*i)->set_position (xnew, ynew, znew, true);