comparison data/fileio/CSVFileReader.cpp @ 1490:9ab8e5ec4731 import-audio-data

Correct channel indexing
author Chris Cannam
date Thu, 28 Jun 2018 15:52:30 +0100
parents 8d4f09552ba4
children 1dc64d3d323c
comparison
equal deleted inserted replaced
1489:8d4f09552ba4 1490:9ab8e5ec4731
416 int channels = modelW->getChannelCount(); 416 int channels = modelW->getChannelCount();
417 417
418 float **samples = 418 float **samples =
419 breakfastquay::allocate_and_zero_channels<float> 419 breakfastquay::allocate_and_zero_channels<float>
420 (channels, 1); 420 (channels, 1);
421 421
422 for (int i = 0; i < list.size() && i < channels; ++i) { 422 int channel = 0;
423 423
424 if (m_format.getColumnPurpose(i) != CSVFormat::ColumnValue) { 424 for (int i = 0; i < list.size() && channel < channels; ++i) {
425
426 if (m_format.getColumnPurpose(i) !=
427 CSVFormat::ColumnValue) {
425 continue; 428 continue;
426 } 429 }
427 430
428 bool ok = false; 431 bool ok = false;
429 float value = list[i].toFloat(&ok); 432 float value = list[i].toFloat(&ok);
430 433
431 samples[i][0] = value; 434 samples[channel][0] = value;
435
436 ++channel;
432 } 437 }
433 438
434 bool ok = modelW->addSamples(samples, 1); 439 bool ok = modelW->addSamples(samples, 1);
435 440
436 breakfastquay::deallocate_channels(samples, channels); 441 breakfastquay::deallocate_channels(samples, channels);