Merge windows+cc branch into cairocanvas branch. Not finished, need to now merge...
[ardour.git] / libs / panners / 1in2out / panner_1in2out.cc
index 7a59aa04cc276bd23bdda87c1c6399ea4bc1ad64..d92120c7aafd94b5b490060fe8af7536afb7e1fe 100644 (file)
@@ -63,11 +63,14 @@ using namespace PBD;
 
 static PanPluginDescriptor _descriptor = {
         "Mono to Stereo Panner",
+        "http://ardour.org/plugin/panner_1in2out",
+        "http://ardour.org/plugin/panner_1in2out#ui",
         1, 2, 
+        10000,
         Panner1in2out::factory
 };
 
-extern "C" { PanPluginDescriptor* panner_descriptor () { return &_descriptor; } }
+extern "C" ARDOURPANNER_API PanPluginDescriptor*  panner_descriptor () { return &_descriptor; }
 
 Panner1in2out::Panner1in2out (boost::shared_ptr<Pannable> p)
        : Panner (p)
@@ -121,6 +124,12 @@ Panner1in2out::clamp_position (double& p)
         return true;
 }
 
+pair<double, double>
+Panner1in2out::position_range () const
+{
+       return make_pair (0, 1);
+}
+
 double 
 Panner1in2out::position () const
 {
@@ -317,32 +326,21 @@ Panner1in2out::distribute_one_automated (AudioBuffer& srcbuf, BufferSet& obufs,
 
 
 Panner*
-Panner1in2out::factory (boost::shared_ptr<Pannable> p, Speakers& /* ignored */)
+Panner1in2out::factory (boost::shared_ptr<Pannable> p, boost::shared_ptr<Speakers> /* ignored */)
 {
        return new Panner1in2out (p);
 }
 
 XMLNode&
-Panner1in2out::get_state (void)
-{
-       return state (true);
-}
-
-XMLNode&
-Panner1in2out::state (bool /*full_state*/)
+Panner1in2out::get_state ()
 {
        XMLNode& root (Panner::get_state ());
+       root.add_property (X_("uri"), _descriptor.panner_uri);
+       /* this is needed to allow new sessions to load with old Ardour: */
        root.add_property (X_("type"), _descriptor.name);
        return root;
 }
 
-int
-Panner1in2out::set_state (const XMLNode& node, int version)
-{
-       LocaleGuard lg (X_("POSIX"));
-       Panner::set_state (node, version);
-       return 0;
-}
 
 std::set<Evoral::Parameter> 
 Panner1in2out::what_can_be_automated() const
@@ -362,3 +360,38 @@ Panner1in2out::describe_parameter (Evoral::Parameter p)
                 return _pannable->describe_parameter (p);
         }
 }
+
+string 
+Panner1in2out::value_as_string (boost::shared_ptr<AutomationControl> ac) const
+{
+        /* DO NOT USE LocaleGuard HERE */
+        double val = ac->get_value();
+
+        switch (ac->parameter().type()) {
+        case PanAzimuthAutomation:
+                /* We show the position of the center of the image relative to the left & right.
+                   This is expressed as a pair of percentage values that ranges from (100,0) 
+                   (hard left) through (50,50) (hard center) to (0,100) (hard right).
+                   
+                   This is pretty wierd, but its the way audio engineers expect it. Just remember that
+                   the center of the USA isn't Kansas, its (50LA, 50NY) and it will all make sense.
+
+                  This is designed to be as narrow as possible. Dedicated
+                  panner GUIs can do their own version of this if they need
+                  something less compact.
+                */
+                
+                return string_compose (_("L%1R%2"), (int) rint (100.0 * (1.0 - val)),
+                                       (int) rint (100.0 * val));
+                
+        default:
+                return _pannable->value_as_string (ac);
+        }
+}
+
+void
+Panner1in2out::reset ()
+{
+       set_position (0.5);
+       update ();
+}