initial check in of VBAP implementation (not coupled to any existing ardour objects...
[ardour.git] / libs / ardour / panner.cc
index b6decc281f807a4999c7a529664825a90f1ffb27..8ce12caf6994d909ec679bdd230c679763e6e375 100644 (file)
@@ -17,7 +17,6 @@
 
 */
 
-#define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
 
 #include <cmath>
@@ -29,6 +28,7 @@
 #include <locale.h>
 #include <unistd.h>
 #include <float.h>
+#include <iomanip>
 
 #include <glibmm.h>
 
@@ -100,13 +100,13 @@ StreamPanner::set_mono (bool yn)
 }
 
 void
-Panner::PanControllable::set_value (float val)
+Panner::PanControllable::set_value (double val)
 {
        panner.streampanner (parameter().id()).set_position (direct_control_to_pan (val));
        AutomationControl::set_value(val);
 }
 
-float
+double
 Panner::PanControllable::get_value (void) const
 {
        return AutomationControl::get_value();
@@ -182,7 +182,7 @@ StreamPanner::set_state (const XMLNode& node, int /*version*/)
        if ((prop = node.property (X_("mono")))) {
                set_mono (string_is_affirmative (prop->value()));
        }
-       
+
        return 0;
 }
 
@@ -767,7 +767,7 @@ Multi2dPanner::set_state (const XMLNode& node, int /*version*/)
 
 Panner::Panner (string name, Session& s)
        : SessionObject (s, name)
-       , AutomatableControls (s)
+       , Automatable (s)
 {
        //set_name_old_auto (name);
        set_name (name);
@@ -1152,6 +1152,7 @@ Panner::state (bool full)
                node->add_child_nocopy ((*i)->state (full));
        }
 
+       node->add_child_nocopy (get_automation_xml_state ());
 
        return *node;
 }
@@ -1258,6 +1259,12 @@ Panner::set_state (const XMLNode& node, int version)
                automation_path = Glib::build_filename(_session.automation_dir(), prop->value ());
        }
 
+       for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
+               if ((*niter)->name() == X_("Automation")) {
+                       set_automation_xml_state (**niter, Evoral::Parameter (PanAutomation));
+               }
+       }
+       
        return 0;
 }
 
@@ -1488,7 +1495,7 @@ Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes
 }
 
 void
-Panner::run (BufferSet& inbufs, BufferSet& outbufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
+Panner::run (BufferSet& inbufs, BufferSet& outbufs, framepos_t start_frame, framepos_t end_frame, nframes_t nframes)
 {
        if (outbufs.count().n_audio() == 0) {
                // Failing to deliver audio we were asked to deliver is a bug
@@ -1640,3 +1647,25 @@ Panner::set_mono (bool yn)
                (*i)->set_mono (yn);
        }
 }
+
+string
+Panner::value_as_string (double v)
+{
+       if (Panner::equivalent (v, 0.5)) {
+               return _("C");
+       } else if (equivalent (v, 0)) {
+               return _("L");
+       } else if (equivalent (v, 1)) {
+               return _("R");
+       } else if (v < 0.5) {
+               stringstream s;
+               s << fixed << setprecision (0) << _("L") << ((0.5 - v) * 200) << "%";
+               return s.str();
+       } else {
+               stringstream s;
+               s << fixed << setprecision (0) << _("R") << ((v -0.5) * 200) << "%";
+               return s.str ();
+       }
+
+       return "";
+}