mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 16:24:57 +01:00
Minor tidy-ups to MTDM code; add test.
git-svn-id: svn://localhost/ardour2/branches/3.0@12527 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
98f44aa20c
commit
162d672769
6 changed files with 55 additions and 11 deletions
|
|
@ -27,11 +27,11 @@ public:
|
|||
MTDM ();
|
||||
|
||||
int process (size_t len, float *inp, float *out);
|
||||
int resolve (void);
|
||||
void invert (void) { _inv ^= 1; }
|
||||
int inv (void) { return _inv; }
|
||||
double del (void) { return _del; }
|
||||
double err (void) { return _err; }
|
||||
int resolve ();
|
||||
void invert () { _inv ^= 1; }
|
||||
int inv () { return _inv; }
|
||||
double del () { return _del; }
|
||||
double err () { return _err; }
|
||||
|
||||
private:
|
||||
class Freq {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "ardour/mtdm.h"
|
||||
|
||||
MTDM::MTDM (void)
|
||||
MTDM::MTDM ()
|
||||
: _cnt (0)
|
||||
, _inv (0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,10 +62,7 @@ PortInsert::~PortInsert ()
|
|||
void
|
||||
PortInsert::start_latency_detection ()
|
||||
{
|
||||
if (_mtdm != 0) {
|
||||
delete _mtdm;
|
||||
}
|
||||
|
||||
delete _mtdm;
|
||||
_mtdm = new MTDM;
|
||||
_latency_flush_frames = false;
|
||||
_latency_detect = true;
|
||||
|
|
@ -118,7 +115,7 @@ PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
|
|||
Sample* out = outbuf.data();
|
||||
|
||||
_mtdm->process (nframes, in, out);
|
||||
|
||||
|
||||
outbuf.set_is_silent (false);
|
||||
}
|
||||
|
||||
|
|
|
|||
29
libs/ardour/test/mtdm_test.cc
Normal file
29
libs/ardour/test/mtdm_test.cc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include "ardour/mtdm.h"
|
||||
#include "mtdm_test.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (MTDMTest);
|
||||
|
||||
using namespace std;
|
||||
|
||||
void
|
||||
MTDMTest::basicTest ()
|
||||
{
|
||||
float in[256];
|
||||
float out[256];
|
||||
|
||||
memset (in, 0, 256 * sizeof (float));
|
||||
MTDM* mtdm = new MTDM;
|
||||
mtdm->process (256, in, out);
|
||||
memcpy (in, out, 256 * sizeof (float));
|
||||
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
mtdm->process (256, in, out);
|
||||
memcpy (in, out, 256 * sizeof (float));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL (0, mtdm->resolve ());
|
||||
CPPUNIT_ASSERT (mtdm->err() < 1);
|
||||
CPPUNIT_ASSERT_EQUAL (256.0, rint (mtdm->del()));
|
||||
}
|
||||
}
|
||||
17
libs/ardour/test/mtdm_test.h
Normal file
17
libs/ardour/test/mtdm_test.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <sigc++/sigc++.h>
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class MTDMTest : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (MTDMTest);
|
||||
CPPUNIT_TEST (basicTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
void setUp () {}
|
||||
void tearDown () {}
|
||||
|
||||
void basicTest ();
|
||||
};
|
||||
|
||||
|
|
@ -437,6 +437,7 @@ def build(bld):
|
|||
test/playlist_layering_test.cc
|
||||
test/playlist_read_test.cc
|
||||
test/control_surfaces_test.cc
|
||||
test/mtdm_test.cc
|
||||
test/testrunner.cc
|
||||
'''.split()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue