changeset 1490:9ab8e5ec4731 import-audio-data

Correct channel indexing
author Chris Cannam
date Thu, 28 Jun 2018 15:52:30 +0100
parents 8d4f09552ba4
children 1dc64d3d323c
files data/fileio/CSVFileReader.cpp
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/CSVFileReader.cpp	Thu Jun 28 15:44:31 2018 +0100
+++ b/data/fileio/CSVFileReader.cpp	Thu Jun 28 15:52:30 2018 +0100
@@ -418,17 +418,22 @@
                 float **samples =
                     breakfastquay::allocate_and_zero_channels<float>
                     (channels, 1);
+
+                int channel = 0;
                 
-                for (int i = 0; i < list.size() && i < channels; ++i) {
+                for (int i = 0; i < list.size() && channel < channels; ++i) {
 
-                    if (m_format.getColumnPurpose(i) != CSVFormat::ColumnValue) {
+                    if (m_format.getColumnPurpose(i) !=
+                        CSVFormat::ColumnValue) {
                         continue;
                     }
 
                     bool ok = false;
                     float value = list[i].toFloat(&ok);
                     
-                    samples[i][0] = value;
+                    samples[channel][0] = value;
+
+                    ++channel;
                 }
 
                 bool ok = modelW->addSamples(samples, 1);