From 3346b33a1ac96e51a61e038800fac45e18cd3b30 Mon Sep 17 00:00:00 2001 From: nwolek Date: Tue, 19 Apr 2016 14:19:51 -0400 Subject: [PATCH] SampleBuffer: passes basic test filling the sample values. see issue #89 --- include/Jamoma.h | 1 + include/objects/JamomaSampleBuffer.h | 20 ++++++++++++++++++++ test/SampleBuffer/SampleBuffer.cpp | 12 +++++++----- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/include/Jamoma.h b/include/Jamoma.h index c838f17..2cf1cf5 100644 --- a/include/Jamoma.h +++ b/include/Jamoma.h @@ -148,6 +148,7 @@ constexpr inline uint32_t Hash(const char *const str, const uint32_t seed = 0xAE #include "JamomaLimiter.h" #include "JamomaLowpassOnePole.h" #include "JamomaLowpassFourPole.h" +#include "JamomaSampleBuffer.h" #include "JamomaSync.h" #include "JamomaWhiteNoise.h" #include "JamomaUnitImpulse.h" diff --git a/include/objects/JamomaSampleBuffer.h b/include/objects/JamomaSampleBuffer.h index 7dee0ec..77a2db8 100644 --- a/include/objects/JamomaSampleBuffer.h +++ b/include/objects/JamomaSampleBuffer.h @@ -23,7 +23,27 @@ namespace Jamoma { */ class SampleBuffer : public SampleBundle { public: + static constexpr Classname classname = { "samplebuffer" }; + static constexpr auto tags = { "audio", "sample" }; + + /** Create a SampleBuffer of a specific size. + @param channelCount The number of channels for which to allocate memory. + @param frameCount The number of samples per channel for which to allocate memory. + */ + SampleBuffer(int channelCount, int frameCount) : SampleBundle(channelCount,frameCount) + { + } + + /** Default constructor creates a bundle containing a single sample. */ + SampleBuffer() + : SampleBuffer(1,1) + {} + + + SampleBuffer(const SampleBuffer&) = default; // inheriting the default copy constructor + private: + }; diff --git a/test/SampleBuffer/SampleBuffer.cpp b/test/SampleBuffer/SampleBuffer.cpp index 0ce4be5..2266257 100644 --- a/test/SampleBuffer/SampleBuffer.cpp +++ b/test/SampleBuffer/SampleBuffer.cpp @@ -21,14 +21,15 @@ namespace Jamoma { SampleBufferTest(Jamoma::UnitTest* test) : mTest(test) { - //testBasic(); + testBasic(); } - /* + void testBasic() { - Jamoma::SampleBuffer my_samples(1, 4); + Jamoma::SampleBuffer my_samples(1, 4); + my_samples.fill(1.0); int badSampleCount = 0; @@ -38,14 +39,15 @@ namespace Jamoma { for (int i = 0; i < my_samples.frameCount(); i++) { temp = my_samples[0][i]; - if (mTest->compare(temp, tempExpected) ) { + if ( ! mTest->compare(temp, tempExpected) ) { badSampleCount++; } } mTest->TEST_ASSERT("filled with ones", badSampleCount == 0); + } - */ + };