I am working with Qt C++, am trying to use QVector to store data from a file of 4 interleaved channels, and use it afterwords. I tried something like that but still not sure how to store every channel data in a different vector(column),
QVector<QVector<float_t> > buffer(4);
for(int i = 0; i < 10000 < i++){
QByteArray tmp = file.read(3); // 24 bits for each channel
float x = my_converison_that_works(tmp);
buffer.append(x);
}
I am looking for an optimized way for this task, any help!
If you want to have each channel in a speperate
QVectorthen just append each channel to a differentQVector:Your code appends a single
floatto the buffer. That wont work. You do not want to append tobufferbut tobuffer[0],buffer[1],..., (channelin above code).For "the optimal" you should reserve space in the vectors before appending to them. Alternatively use a container with fixed size, when you know the size at compile time.