13
0
livetrax/libs/audiographer/tests/normalizer_test.cc
Sakari Bergen dde0848a98 Re-integrate export-optimization branch.
Export now happens directly to file (unless normalizing is required), and can be easily optimized even further.
The Session process connection is still broken during export (as it was before this commit also).


git-svn-id: svn://localhost/ardour2/branches/3.0@6401 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-12-27 14:46:23 +00:00

61 lines
1.3 KiB
C++

#include "utils.h"
#include "audiographer/normalizer.h"
#include "audiographer/peak_reader.h"
using namespace AudioGrapher;
class NormalizerTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE (NormalizerTest);
CPPUNIT_TEST (testConstAmplify);
CPPUNIT_TEST_SUITE_END ();
public:
void setUp()
{
frames = 1024;
}
void tearDown()
{
delete [] random_data;
}
void testConstAmplify()
{
float target = 0.0;
random_data = TestUtils::init_random_data(frames, 0.5);
normalizer.reset (new Normalizer(target));
peak_reader.reset (new PeakReader());
sink.reset (new VectorSink<float>());
ProcessContext<float> const c (random_data, frames, 1);
peak_reader->process (c);
float peak = peak_reader->get_peak();
normalizer->alloc_buffer (frames);
normalizer->set_peak (peak);
normalizer->add_output (sink);
normalizer->process (c);
peak_reader->reset();
ConstProcessContext<float> normalized (sink->get_array(), frames, 1);
peak_reader->process (normalized);
peak = peak_reader->get_peak();
CPPUNIT_ASSERT (-FLT_EPSILON <= (peak - 1.0) && (peak - 1.0) <= 0.0);
}
private:
boost::shared_ptr<Normalizer> normalizer;
boost::shared_ptr<PeakReader> peak_reader;
boost::shared_ptr<VectorSink<float> > sink;
float * random_data;
nframes_t frames;
};
CPPUNIT_TEST_SUITE_REGISTRATION (NormalizerTest);