Merge branch 'master' into windows
[ardour.git] / libs / panners / vbap / vbap.cc
index 59f8cddb62353c3395450bea4172b6e2c9c83541..6d7496729c87abf938b07e0b5dacb4b9c94f9be7 100644 (file)
@@ -1,3 +1,22 @@
+/*
+    Copyright (C) 2012 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
 #include <cmath>
 #include <cstdlib>
 #include <cstdio>
@@ -6,6 +25,10 @@
 #include <iostream>
 #include <string>
 
+#ifdef COMPILER_MSVC
+#include <malloc.h>
+#endif
+
 #include "pbd/cartesian.h"
 #include "pbd/compose.h"
 
@@ -31,7 +54,7 @@ static PanPluginDescriptor _descriptor = {
         VBAPanner::factory
 };
 
-extern "C" { PanPluginDescriptor* panner_descriptor () { return &_descriptor; } }
+extern "C" ARDOURPANNER_API PanPluginDescriptor* panner_descriptor () { return &_descriptor; }
 
 VBAPanner::Signal::Signal (Session&, VBAPanner&, uint32_t, uint32_t n_speakers)
 {
@@ -43,7 +66,7 @@ VBAPanner::Signal::Signal (Session&, VBAPanner&, uint32_t, uint32_t n_speakers)
 }
 
 void
-VBAPanner::Signal::Signal::resize_gains (uint32_t n)
+VBAPanner::Signal::resize_gains (uint32_t n)
 {
         gains.assign (n, 0.0);
 }        
@@ -271,7 +294,7 @@ VBAPanner::distribute_one (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_co
 
         assert (sz == obufs.count().n_audio());
 
-        int8_t outputs[sz]; // on the stack, no malloc
+        int8_t *outputs = (int8_t*)alloca(sz); // on the stack, no malloc
         
         /* set initial state of each output "record"
          */
@@ -300,10 +323,10 @@ VBAPanner::distribute_one (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_co
 
         /* at this point, we can test a speaker's status:
 
-           (outputs[o] & 1)      <= in use before
-           (outputs[o] & 2)      <= in use this time
-           (outputs[o] & 3) == 3 <= in use both times
-            outputs[o] == 0      <= not in use either time
+           (*outputs[o] & 1)      <= in use before
+           (*outputs[o] & 2)      <= in use this time
+           (*outputs[o] & 3) == 3 <= in use both times
+            *outputs[o] == 0      <= not in use either time
            
         */
 
@@ -473,3 +496,12 @@ VBAPanner::set_width (double w)
 {
         _pannable->pan_width_control->set_value (min (1.0, max (-1.0, w)));
 }
+
+void
+VBAPanner::reset ()
+{
+       set_position (0);
+       set_width (1);
+
+       update ();
+}