179 if (!
read (chans, 2, readerStartSample, numSamples,
true))
191 convertFixedToFloat (dests, 2, numSamples);
196 if (numTargetChannels <= 64)
199 return readChannels (*
this, chans, buffer, startSample, numSamples,
203 HeapBlock<int*> chans (numTargetChannels + 1);
205 return readChannels (*
this, chans, buffer, startSample, numSamples,
212 jassert (channelsToRead > 0 && channelsToRead <= (
int)
numChannels);
216 for (
int i = 0; i < channelsToRead; ++i)
222 auto bufferSize = (int) jmin (numSamples, (int64) 4096);
226 auto intBuffer =
reinterpret_cast<int* const*
> (floatBuffer);
227 bool isFirstBlock =
true;
229 while (numSamples > 0)
231 auto numToDo = (int) jmin (numSamples, (int64) bufferSize);
233 if (!
read (intBuffer, channelsToRead, startSampleInFile, numToDo,
false))
236 for (
int i = 0; i < channelsToRead; ++i)
242 r = FloatVectorOperations::findMinAndMax (floatBuffer[i], numToDo);
248 r =
Range<float> ((
float) intRange.getStart() / (
float) std::numeric_limits<int>::max(),
249 (
float) intRange.getEnd() / (
float) std::numeric_limits<int>::max());
252 results[i] = isFirstBlock ? r : results[i].
getUnionWith (r);
255 isFirstBlock =
false;
256 numSamples -= numToDo;
257 startSampleInFile += numToDo;
262 float& lowestLeft,
float& highestLeft,
263 float& lowestRight,
float& highestRight)
270 levels[1] = levels[0];
278 highestLeft = levels[0].
getEnd();
280 highestRight = levels[1].
getEnd();
284 int64 numSamplesToSearch,
285 double magnitudeRangeMinimum,
286 double magnitudeRangeMaximum,
287 int minimumConsecutiveSamples)
289 if (numSamplesToSearch == 0)
292 const int bufferSize = 4096;
295 int* tempBuffer[3] = { tempSpace.
get(),
296 tempSpace.
get() + bufferSize,
300 int64 firstMatchPos = -1;
302 jassert (magnitudeRangeMaximum > magnitudeRangeMinimum);
304 auto doubleMin = jlimit (0.0, (
double) std::numeric_limits<int>::max(), magnitudeRangeMinimum * std::numeric_limits<int>::max());
305 auto doubleMax = jlimit (doubleMin, (
double) std::numeric_limits<int>::max(), magnitudeRangeMaximum * std::numeric_limits<int>::max());
306 auto intMagnitudeRangeMinimum = roundToInt (doubleMin);
307 auto intMagnitudeRangeMaximum = roundToInt (doubleMax);
309 while (numSamplesToSearch != 0)
311 auto numThisTime = (int) jmin (std::abs (numSamplesToSearch), (int64) bufferSize);
312 int64 bufferStart = startSample;
314 if (numSamplesToSearch < 0)
315 bufferStart -= numThisTime;
320 read (tempBuffer, 2, bufferStart, numThisTime,
false);
321 auto num = numThisTime;
325 if (numSamplesToSearch < 0)
328 bool matches =
false;
329 auto index = (int) (startSample - bufferStart);
333 const float sample1 = std::abs (((
float*) tempBuffer[0]) [index]);
335 if (sample1 >= magnitudeRangeMinimum
336 && sample1 <= magnitudeRangeMaximum)
342 const float sample2 = std::abs (((
float*) tempBuffer[1]) [index]);
344 matches = (sample2 >= magnitudeRangeMinimum
345 && sample2 <= magnitudeRangeMaximum);
350 const int sample1 = std::abs (tempBuffer[0] [index]);
352 if (sample1 >= intMagnitudeRangeMinimum
353 && sample1 <= intMagnitudeRangeMaximum)
359 const int sample2 = std::abs (tempBuffer[1][index]);
361 matches = (sample2 >= intMagnitudeRangeMinimum
362 && sample2 <= intMagnitudeRangeMaximum);
368 if (firstMatchPos < 0)
369 firstMatchPos = startSample;
371 if (++consecutive >= minimumConsecutiveSamples)
376 return firstMatchPos;
385 if (numSamplesToSearch > 0)
389 if (numSamplesToSearch > 0)
390 numSamplesToSearch -= numThisTime;
392 numSamplesToSearch += numThisTime;