changeset 52:d3995d2b5e08

* Fix from Craig Sapp for incorrect mixdown code
author cannam
date Mon, 12 Mar 2007 11:00:11 +0000
parents 2403ae53b8a5
children 74822738965b
files host/vamp-simple-host.cpp
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/host/vamp-simple-host.cpp	Fri Mar 02 12:26:53 2007 +0000
+++ b/host/vamp-simple-host.cpp	Mon Mar 12 11:00:11 2007 +0000
@@ -322,15 +322,22 @@
             }
         }
 
-        for (int c = 0; c < sfinfo.channels; ++c) {
-            int tc = c;
-            if (mix) tc = 0;
-            for (int j = 0; j < blockSize && j < count; ++j) {
-                plugbuf[tc][j] += filebuf[j * channels + c];
+        for (int j = 0; j < blockSize && j < count; ++j) {
+            int tc = 0;
+            for (int c = 0; c < sfinfo.channels; ++c) {
+                tc = c;
+                if (mix) tc = 0;
+                plugbuf[tc][j] += filebuf[j * sfinfo.channels + c];
             }
+            if (mix) {
+                plugbuf[0][j] /= sfinfo.channels;
+            }
+        }
 
-            if (plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain) {
-                transformInput(plugbuf[tc], blockSize);
+        if (plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain) {
+            for (int c = 0; c < sfinfo.channels; ++c) {
+                transformInput(plugbuf[c], blockSize);
+                if (mix) break;
             }
         }