a) fix problems with multichannel tape tracks
[ardour.git] / libs / ardour / panner.cc
index 63bcd7f30245559196721c5fc44967c38b9a5ef5..6b0013cada2d5b1697c664b45946351af85cb3ef 100644 (file)
@@ -41,6 +41,9 @@
 
 #include "i18n.h"
 
+#include <pbd/mathfix.h>
+
+
 using namespace std;
 using namespace ARDOUR;
 
@@ -106,7 +109,8 @@ StreamPanner::MIDIControl::send_feedback (pan_t value)
                if (get_control_info (ch, ev, additional)) {
                        data.controller_number = additional;
                        data.value = val;
-
+                       last_written = val;
+                       
                        sp.get_parent().session().send_midi_message (get_port(), ev, ch, data);
                }
 
@@ -609,7 +613,8 @@ EqualPowerStereoPanner::distribute_automated (Sample* src, Sample** obufs,
 
        /* store effective pan position. do this even if we are muted */
 
-       effective_x = buffers[0][nframes-1];
+       if (nframes > 0) 
+               effective_x = buffers[0][nframes-1];
 
        if (_muted) {
                return;
@@ -778,8 +783,12 @@ Multi2dPanner::update ()
                }
                f += dsq[i] * dsq[i];
        }
-       fr = 1.0f / sqrtf(f);
-       
+#ifdef __APPLE__
+       // terrible hack to support OSX < 10.3.9 builds
+       fr = (float) (1.0 / sqrt((double)f));
+#else
+       fr = 1.0 / sqrtf(f);
+#endif 
        for (i = 0; i < nouts; ++i) {
                parent.outputs[i].desired_pan = 1.0f - (dsq[i] * fr);
        }