merge from 2.0-ongoing @ 3581
[ardour.git] / libs / ardour / panner.cc
index 3912faf9e77cec115c8433cba42d05f4a55bad20..2163ba5cc0a4554a8cdcede85af0fad45db3c6b6 100644 (file)
@@ -69,7 +69,7 @@ static double direct_pan_to_control (pan_t val) {
        return val;
 }
 
-StreamPanner::StreamPanner (Panner& p, ParamID param)
+StreamPanner::StreamPanner (Panner& p, Parameter param)
        : parent (p)
        , _control (new PanControllable(p.session(), X_("panner"), *this, param))
 {
@@ -191,7 +191,7 @@ StreamPanner::add_state (XMLNode& node)
 
 /*---------------------------------------------------------------------- */
 
-BaseStereoPanner::BaseStereoPanner (Panner& p, ParamID param)
+BaseStereoPanner::BaseStereoPanner (Panner& p, Parameter param)
        : StreamPanner (p, param)
 {
 }
@@ -269,7 +269,7 @@ BaseStereoPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain
                
                pan = left * gain_coeff;
 
-               mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
+               mix_buffers_with_gain (dst+n,src+n,nframes-n,pan);
                
        } else {
                
@@ -348,7 +348,7 @@ BaseStereoPanner::distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain
 
 /*---------------------------------------------------------------------- */
 
-EqualPowerStereoPanner::EqualPowerStereoPanner (Panner& p, ParamID param)
+EqualPowerStereoPanner::EqualPowerStereoPanner (Panner& p, Parameter param)
        : BaseStereoPanner (p, param)
 {
        update ();
@@ -463,7 +463,7 @@ EqualPowerStereoPanner::distribute_automated (AudioBuffer& srcbuf, BufferSet& ob
 }
 
 StreamPanner*
-EqualPowerStereoPanner::factory (Panner& parent, ParamID param)
+EqualPowerStereoPanner::factory (Panner& parent, Parameter param)
 {
        return new EqualPowerStereoPanner (parent, param);
 }
@@ -532,7 +532,7 @@ EqualPowerStereoPanner::set_state (const XMLNode& node)
 
 /*----------------------------------------------------------------------*/
 
-Multi2dPanner::Multi2dPanner (Panner& p, ParamID param)
+Multi2dPanner::Multi2dPanner (Panner& p, Parameter param)
        : StreamPanner (p, param)
 {
        update ();
@@ -650,7 +650,7 @@ Multi2dPanner::distribute_automated (AudioBuffer& src, BufferSet& obufs,
 }
 
 StreamPanner*
-Multi2dPanner::factory (Panner& p, ParamID param)
+Multi2dPanner::factory (Panner& p, Parameter param)
 {
        return new Multi2dPanner (p, param);
 }
@@ -800,7 +800,7 @@ Panner::reset (uint32_t nouts, uint32_t npans)
                outputs.push_back (Output (1.0, 0));
 
                for (n = 0; n < npans; ++n) {
-                       push_back (new EqualPowerStereoPanner (*this, ParamID(PanAutomation, n)));
+                       push_back (new EqualPowerStereoPanner (*this, Parameter(PanAutomation, n)));
                }
                break;
 
@@ -810,7 +810,7 @@ Panner::reset (uint32_t nouts, uint32_t npans)
                outputs.push_back (Output  (1.0, 1.0));
 
                for (n = 0; n < npans; ++n) {
-                       push_back (new Multi2dPanner (*this, ParamID(PanAutomation, n)));
+                       push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n)));
                }
 
                break; 
@@ -822,7 +822,7 @@ Panner::reset (uint32_t nouts, uint32_t npans)
                outputs.push_back (Output  (0, 1.0));
 
                for (n = 0; n < npans; ++n) {
-                       push_back (new Multi2dPanner (*this, ParamID(PanAutomation, n)));
+                       push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n)));
                }
 
                break;  
@@ -835,7 +835,7 @@ Panner::reset (uint32_t nouts, uint32_t npans)
                outputs.push_back (Output  (0.5, 0.75));
 
                for (n = 0; n < npans; ++n) {
-                       push_back (new Multi2dPanner (*this, ParamID(PanAutomation, n)));
+                       push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n)));
                }
 
                break;
@@ -847,7 +847,7 @@ Panner::reset (uint32_t nouts, uint32_t npans)
                }
 
                for (n = 0; n < npans; ++n) {
-                       push_back (new Multi2dPanner (*this, ParamID(PanAutomation, n)));
+                       push_back (new Multi2dPanner (*this, Parameter(PanAutomation, n)));
                }
 
                break;
@@ -981,7 +981,7 @@ Panner::clear_automation ()
 struct PanPlugins {
     string name;
     uint32_t nouts;
-    StreamPanner* (*factory)(Panner&, ParamID);
+    StreamPanner* (*factory)(Panner&, Parameter);
 };
 
 PanPlugins pan_plugins[] = {
@@ -1083,7 +1083,7 @@ Panner::set_state (const XMLNode& node)
                                                   assumption, but its still an assumption.
                                                */
                                                
-                                               sp = pan_plugins[i].factory (*this, ParamID(PanAutomation, 0));
+                                               sp = pan_plugins[i].factory (*this, Parameter(PanAutomation, 0));
                                                
                                                if (sp->set_state (**niter) == 0) {
                                                        push_back (sp);
@@ -1115,8 +1115,7 @@ Panner::set_state (const XMLNode& node)
 
                /* automation path is relative */
                
-               automation_path = _session.automation_dir();
-               automation_path += prop->value ();
+               automation_path = Glib::build_filename(_session.automation_dir(), prop->value ());
        } 
 
        return 0;
@@ -1311,10 +1310,12 @@ Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes
                        dst.read_from(inbufs.get_audio(0), nframes, offset);
                        
                        // accumulate starting with the second
-                       BufferSet::audio_iterator i = inbufs.audio_begin();
-                       for (++i; i != inbufs.audio_end(); ++i) {
-                               dst.accumulate_from(*i, nframes, offset);
-                       }
+            if (inbufs.count().n_audio() > 0) {
+                BufferSet::audio_iterator i = inbufs.audio_begin();
+                for (++i; i != inbufs.audio_end(); ++i) {
+                    dst.accumulate_from(*i, nframes, offset);
+                }
+            }
 
                } else {
 
@@ -1324,10 +1325,12 @@ Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes
                        dst.read_from(inbufs.get_audio(0), nframes, offset);
                        
                        // accumulate (with gain) starting with the second
-                       BufferSet::audio_iterator i = inbufs.audio_begin();
-                       for (++i; i != inbufs.audio_end(); ++i) {
-                               dst.accumulate_with_gain_from(*i, nframes, offset, gain_coeff);
-                       }
+            if (inbufs.count().n_audio() > 0) {
+                       BufferSet::audio_iterator i = inbufs.audio_begin();
+                           for (++i; i != inbufs.audio_end(); ++i) {
+                               dst.accumulate_with_gain_from(*i, nframes, offset, gain_coeff);
+                       }
+            }
 
                }
 
@@ -1412,11 +1415,8 @@ Panner::distribute (BufferSet& inbufs, BufferSet& outbufs, nframes_t start_frame
 void
 Panner::set_name (string str)
 {
-       automation_path = _session.automation_dir();
-       automation_path += _session.snap_name();
-       automation_path += "-pan-";
-       automation_path += legalize_for_path (str);
-       automation_path += ".automation";
+       automation_path = Glib::build_filename(_session.automation_dir(), 
+               _session.snap_name() + "-pan-" + legalize_for_path (str) + ".automation");
 }
 
 int