comparison data/fileio/AudioFileReader.cpp @ 1096:4d9816ba0ebe simple-fft-model

Rework audio file reader API to prefer using std containers
author Chris Cannam
date Mon, 15 Jun 2015 12:19:47 +0100
parents 843f67be0ed9
children 54af1e21705c
comparison
equal deleted inserted replaced
1095:b66734b5f806 1096:4d9816ba0ebe
15 15
16 #include "AudioFileReader.h" 16 #include "AudioFileReader.h"
17 17
18 using std::vector; 18 using std::vector;
19 19
20 vector<SampleBlock> 20 vector<vector<float>>
21 AudioFileReader::getDeInterleavedFrames(sv_frame_t start, sv_frame_t count) const 21 AudioFileReader::getDeInterleavedFrames(sv_frame_t start, sv_frame_t count) const
22 { 22 {
23 SampleBlock interleaved = getInterleavedFrames(start, count); 23 vector<float> interleaved = getInterleavedFrames(start, count);
24 24
25 int channels = getChannelCount(); 25 int channels = getChannelCount();
26 if (channels == 1) return { interleaved };
27
26 sv_frame_t rc = interleaved.size() / channels; 28 sv_frame_t rc = interleaved.size() / channels;
27 29
28 vector<SampleBlock> frames(channels, SampleBlock(rc, 0.f)); 30 vector<vector<float>> frames(channels, vector<float>(rc, 0.f));
29 31
30 for (int c = 0; c < channels; ++c) { 32 for (int c = 0; c < channels; ++c) {
31 for (sv_frame_t i = 0; i < rc; ++i) { 33 for (sv_frame_t i = 0; i < rc; ++i) {
32 frames[c][i] = interleaved[i * channels + c]; 34 frames[c][i] = interleaved[i * channels + c];
33 } 35 }