# HG changeset patch # User Chris Cannam # Date 1434367187 -3600 # Node ID 49c89950b06debd4fdb0285d5b447b3c4bf07385 # Parent ea30a8c4cb93d8f57373466832dba95dec9ce7e1 Rework audio file reader API to prefer using std containers diff -r ea30a8c4cb93 -r 49c89950b06d audioio/AudioGenerator.cpp --- a/audioio/AudioGenerator.cpp Fri Jun 12 14:51:46 2015 +0100 +++ b/audioio/AudioGenerator.cpp Mon Jun 15 12:19:47 2015 +0100 @@ -439,17 +439,20 @@ sv_frame_t got = 0; if (startFrame >= fadeIn/2) { - got = dtvm->getMultiChannelData(0, modelChannels - 1, - startFrame - fadeIn/2, - frames + fadeOut/2 + fadeIn/2, - m_channelBuffer); + + auto data = dtvm->getMultiChannelData(0, modelChannels - 1, + startFrame - fadeIn/2, + frames + fadeOut/2 + fadeIn/2); + + for (int c = 0; c < modelChannels; ++c) { + copy(data[c].begin(), data[c].end(), m_channelBuffer[c]); + } + + got = data.size(); + } else { sv_frame_t missing = fadeIn/2 - startFrame; - for (int c = 0; c < modelChannels; ++c) { - m_channelBuffer[c] += missing; - } - if (missing > 0) { cerr << "note: channelBufSiz = " << m_channelBufSiz << ", frames + fadeOut/2 = " << frames + fadeOut/2 @@ -457,16 +460,14 @@ << ", missing = " << missing << endl; } - got = dtvm->getMultiChannelData(0, modelChannels - 1, - startFrame, - frames + fadeOut/2, - m_channelBuffer); - + auto data = dtvm->getMultiChannelData(0, modelChannels - 1, + startFrame, + frames + fadeOut/2); for (int c = 0; c < modelChannels; ++c) { - m_channelBuffer[c] -= missing; + copy(data[c].begin(), data[c].end(), m_channelBuffer[c] + missing); } - got += missing; + got = data.size() + missing; } for (int c = 0; c < m_targetChannelCount; ++c) {