| @@ -1280,6 +1280,31 @@ private: | |||||
| JUCE_LEAK_DETECTOR (AudioBuffer) | JUCE_LEAK_DETECTOR (AudioBuffer) | ||||
| }; | }; | ||||
| //============================================================================== | |||||
| template <typename Type> | |||||
| bool operator== (const AudioBuffer<Type>& a, const AudioBuffer<Type>& b) | |||||
| { | |||||
| if (a.getNumChannels() != b.getNumChannels()) | |||||
| return false; | |||||
| for (auto c = 0; c < a.getNumChannels(); ++c) | |||||
| { | |||||
| const auto begin = [c] (auto& x) { return x.getReadPointer (c); }; | |||||
| const auto end = [c] (auto& x) { return x.getReadPointer (c) + x.getNumSamples(); }; | |||||
| if (! std::equal (begin (a), end (a), begin (b), end (b))) | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| template <typename Type> | |||||
| bool operator!= (const AudioBuffer<Type>& a, const AudioBuffer<Type>& b) | |||||
| { | |||||
| return ! (a == b); | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| A multi-channel buffer of 32-bit floating point audio samples. | A multi-channel buffer of 32-bit floating point audio samples. | ||||
| @@ -108,26 +108,6 @@ void MemoryAudioSource::setLooping (bool shouldLoop) | |||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_UNIT_TESTS | #if JUCE_UNIT_TESTS | ||||
| static bool operator== (const AudioBuffer<float>& a, const AudioBuffer<float>& b) | |||||
| { | |||||
| if (a.getNumChannels() != b.getNumChannels()) | |||||
| return false; | |||||
| for (int channel = 0; channel < a.getNumChannels(); ++channel) | |||||
| { | |||||
| auto* aPtr = a.getReadPointer (channel); | |||||
| auto* bPtr = b.getReadPointer (channel); | |||||
| if (std::vector<float> (aPtr, aPtr + a.getNumSamples()) | |||||
| != std::vector<float> (bPtr, bPtr + b.getNumSamples())) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| struct MemoryAudioSourceTests : public UnitTest | struct MemoryAudioSourceTests : public UnitTest | ||||
| { | { | ||||
| MemoryAudioSourceTests() : UnitTest ("MemoryAudioSource", UnitTestCategories::audio) {} | MemoryAudioSourceTests() : UnitTest ("MemoryAudioSource", UnitTestCategories::audio) {} | ||||
| @@ -176,26 +176,6 @@ bool BufferingAudioReader::readNextBufferChunk() | |||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_UNIT_TESTS | #if JUCE_UNIT_TESTS | ||||
| static bool operator== (const AudioBuffer<float>& a, const AudioBuffer<float>& b) | |||||
| { | |||||
| if (a.getNumChannels() != b.getNumChannels() || a.getNumSamples() != b.getNumSamples()) | |||||
| return false; | |||||
| for (int channel = 0; channel < a.getNumChannels(); ++channel) | |||||
| { | |||||
| auto* aPtr = a.getReadPointer (channel); | |||||
| auto* bPtr = b.getReadPointer (channel); | |||||
| if (std::vector<float> (aPtr, aPtr + a.getNumSamples()) | |||||
| != std::vector<float> (bPtr, bPtr + b.getNumSamples())) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| static bool isSilent (const AudioBuffer<float>& b) | static bool isSilent (const AudioBuffer<float>& b) | ||||
| { | { | ||||
| for (int channel = 0; channel < b.getNumChannels(); ++channel) | for (int channel = 0; channel < b.getNumChannels(); ++channel) | ||||