Browse Source

Fixes for negativeAwareModulo() and audio thumbnail.

tags/2021-05-28
jules 12 years ago
parent
commit
1e7ea748ca
2 changed files with 9 additions and 8 deletions
  1. +8
    -7
      modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp
  2. +1
    -1
      modules/juce_core/maths/juce_MathsFunctions.h

+ 8
- 7
modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp View File

@@ -376,10 +376,9 @@ public:
const double rate, const int numChans, const int sampsPerThumbSample, const double rate, const int numChans, const int sampsPerThumbSample,
LevelDataSource* levelData, const OwnedArray<ThumbData>& chans) LevelDataSource* levelData, const OwnedArray<ThumbData>& chans)
{ {
refillCache (area.getWidth(), startTime, endTime, rate,
numChans, sampsPerThumbSample, levelData, chans);
if (isPositiveAndBelow (channelNum, numChannelsCached))
if (refillCache (area.getWidth(), startTime, endTime, rate,
numChans, sampsPerThumbSample, levelData, chans)
&& isPositiveAndBelow (channelNum, numChannelsCached))
{ {
const Rectangle<int> clip (g.getClipBounds().getIntersection (area.withWidth (jmin (numSamplesCached, area.getWidth())))); const Rectangle<int> clip (g.getClipBounds().getIntersection (area.withWidth (jmin (numSamplesCached, area.getWidth()))));
@@ -412,7 +411,7 @@ private:
int numChannelsCached, numSamplesCached; int numChannelsCached, numSamplesCached;
bool cacheNeedsRefilling; bool cacheNeedsRefilling;
void refillCache (const int numSamples, double startTime, const double endTime,
bool refillCache (const int numSamples, double startTime, const double endTime,
const double rate, const int numChans, const int sampsPerThumbSample, const double rate, const int numChans, const int sampsPerThumbSample,
LevelDataSource* levelData, const OwnedArray<ThumbData>& chans) LevelDataSource* levelData, const OwnedArray<ThumbData>& chans)
{ {
@@ -421,7 +420,7 @@ private:
if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0) if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0)
{ {
invalidate(); invalidate();
return;
return false;
} }
if (numSamples == numSamplesCached if (numSamples == numSamplesCached
@@ -430,7 +429,7 @@ private:
&& timePerPixel == cachedTimePerPixel && timePerPixel == cachedTimePerPixel
&& ! cacheNeedsRefilling) && ! cacheNeedsRefilling)
{ {
return;
return ! cacheNeedsRefilling;
} }
numSamplesCached = numSamples; numSamplesCached = numSamples;
@@ -497,6 +496,8 @@ private:
} }
} }
} }
return true;
} }
MinMaxValue* getData (const int channelNum, const int cacheIndex) noexcept MinMaxValue* getData (const int channelNum, const int cacheIndex) noexcept


+ 1
- 1
modules/juce_core/maths/juce_MathsFunctions.h View File

@@ -441,7 +441,7 @@ inline int nextPowerOfTwo (int n) noexcept
The divisor must be greater than zero. The divisor must be greater than zero.
*/ */
template <typename IntegerType> template <typename IntegerType>
int negativeAwareModulo (IntegerType dividend, const IntegerType divisor) noexcept
IntegerType negativeAwareModulo (IntegerType dividend, const IntegerType divisor) noexcept
{ {
jassert (divisor > 0); jassert (divisor > 0);
dividend %= divisor; dividend %= divisor;


Loading…
Cancel
Save