20 const std::shared_ptr<const WideSampleSequence> &pSequence)
28 const auto nChannels = pSequence->NChannels();
29 for (
size_t ii : {0, 1}) {
31 for (
size_t iChannel = 0; iChannel < nChannels; ++iChannel)
43std::pair<const float *, const float *>
49 assert(nChannels <= 2);
53 const auto end = start + len;
96 const auto start0 =
mpSequence->GetBlockStart(start);
98 const auto len0 =
mpSequence->GetBestBlockSize(start0);
103 return {
nullptr,
nullptr };
124 const auto start1 =
mpSequence->GetBlockStart(end0);
125 if (start1 == end0) {
126 const auto len1 =
mpSequence->GetBestBlockSize(start1);
130 return {
nullptr,
nullptr };
140 auto remaining = len;
141 const auto resizeOverlapBuffers = [&]{
142 for (
size_t iChannel = 0; iChannel < nChannels; ++iChannel) {
146 overlaps[iChannel] =
reinterpret_cast<float*
>(overlapBuffer.ptr());
149 const auto assignBuffers = [&]{
151 for (; iChannel < nChannels; ++iChannel)
152 buffers[iChannel] =
reinterpret_cast<samplePtr>(overlaps[iChannel]);
153 for (; iChannel < 2; ++iChannel)
154 buffers[iChannel] =
nullptr;
166 resizeOverlapBuffers();
168 auto sinitLen = initLen.as_size_t();
169 if (!
mpSequence->GetFloats(0, nChannels, overlaps,
170 start, sinitLen,
fillZero, mayThrow))
171 return {
nullptr,
nullptr };
172 assert(sinitLen <= remaining);
173 remaining -= sinitLen;
175 for (
size_t iChannel = 0; iChannel < nChannels; ++iChannel)
177 reinterpret_cast<samplePtr>(overlaps[iChannel] + sinitLen);
181 for (
int ii = 0; ii < mNValidBuffers && remaining > 0; ++ii) {
190 if (initLen <= 0 && leni == len) {
200 resizeOverlapBuffers();
204 const size_t size =
sizeof(float) * leni.as_size_t();
206 for (
size_t iChannel = 0; iChannel < nChannels; ++iChannel)
207 memcpy(buffers[iChannel],
208 mBuffers[ii].areas[iChannel].get() + starti.as_size_t(),
210 assert(leni <= remaining);
211 remaining -= leni.as_size_t();
213 for (
size_t iChannel = 0; iChannel < nChannels; ++iChannel)
214 buffers[iChannel] +=
size;
222 resizeOverlapBuffers();
225 reinterpret_cast<float**
>(buffers),
226 start, remaining,
fillZero, mayThrow))
227 return {
nullptr,
nullptr };
230 return { overlaps[0], overlaps[1] };
234 return {
nullptr,
nullptr };
void reinit(Integral count)
GrowableSampleBuffer & Resize(size_t count, sampleFormat format)
std::pair< const float *, const float * > GetFloatsWide(size_t nChannels, sampleCount start, size_t len, bool mayThrow)
Retrieve samples as floats from the track or from the memory cache.
const std::shared_ptr< const WideSampleSequence > & GetSequence() const
GrowableSampleBuffer mOverlapBuffers[2]
void SetSequence(const std::shared_ptr< const WideSampleSequence > &pSequence)
std::shared_ptr< const WideSampleSequence > mpSequence
Positions or offsets within audio files need a wide type.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
std::pair< const float *, const float * > GetResults(size_t nChannels, size_t offset) const