Merged with trunk R1705.
[ardour.git] / libs / ardour / panner.cc
index ee8e100e4aa3931fbe95a7fcfde4e3a1acc387f7..e12857da93d643daad3bda85c46a3d753e79a183 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #define __STDC_FORMAT_MACROS 1
@@ -36,6 +35,7 @@
 #include <pbd/error.h>
 #include <pbd/failed_constructor.h>
 #include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
 
 #include <ardour/session.h>
 #include <ardour/panner.h>
@@ -544,9 +544,10 @@ EqualPowerStereoPanner::set_state (const XMLNode& node)
 
        for (XMLNodeConstIterator iter = node.children().begin(); iter != node.children().end(); ++iter) {
 
-               if ((*iter)->name() == X_("panner")) {
-
-                       _control.set_state (**iter);
+               if ((*iter)->name() == X_("controllable")) {
+                       if ((prop = (*iter)->property("name")) != 0 && prop->value() == "panner") {
+                               _control.set_state (**iter);
+                       }
 
                } else if ((*iter)->name() == X_("Automation")) {
 
@@ -665,10 +666,7 @@ Multi2dPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_co
                        }
                        
                        pan = left * gain_coeff;
-                       
-                       for (; n < nframes; ++n) {
-                               dst[n] += src[n] * pan;
-                       }
+                       Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
                        
                } else {
 
@@ -678,20 +676,10 @@ Multi2dPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_co
                        if ((pan *= gain_coeff) != 1.0f) {
                                
                                if (pan != 0.0f) {
-                                       
-                                       for (nframes_t n = 0; n < nframes; ++n) {
-                                               dst[n] += src[n] * pan;
-                                       }      
-                                       
+                                       Session::mix_buffers_with_gain(dst,src,nframes,pan);
                                } 
-
-                               
                        } else {
-                               
-                               for (nframes_t n = 0; n < nframes; ++n) {
-                                       dst[n] += src[n];
-                               }      
-
+                                       Session::mix_buffers_no_gain(dst,src,nframes);
                        }
 #endif
 #ifdef CAN_INTERP
@@ -1068,8 +1056,7 @@ Panner::state (bool full)
        char buf[32];
 
        root->add_property (X_("linked"), (_linked ? "yes" : "no"));
-       snprintf (buf, sizeof (buf), "%d", _link_direction);
-       root->add_property (X_("link_direction"), buf);
+       root->add_property (X_("link_direction"), enum_2_string (_link_direction));
        root->add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
 
        /* add each output */
@@ -1113,8 +1100,8 @@ Panner::set_state (const XMLNode& node)
        }
 
        if ((prop = node.property (X_("link_direction"))) != 0) {
-               sscanf (prop->value().c_str(), "%d", &i);
-               set_link_direction ((LinkDirection) (i));
+               LinkDirection ld; /* here to provide type information */
+               set_link_direction (LinkDirection (string_2_enum (prop->value(), ld)));
        }
 
        nlist = node.children();