annotate test/TestYin.cpp @ 164:a7d9c6142f8f tip

Added tag v1.2 for changeset 4a97f7638ffd
author Chris Cannam
date Thu, 06 Feb 2020 15:02:47 +0000
parents 99bac62ee2da
children
rev   line source
matthiasm@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
matthiasm@0 2
matthiasm@0 3 #include "Yin.h"
matthiasm@0 4
matthiasm@0 5 #define BOOST_TEST_DYN_LINK
matthiasm@0 6 #define BOOST_TEST_MAIN
matthiasm@0 7
matthiasm@0 8 #include <boost/test/unit_test.hpp>
matthiasm@0 9
matthiasm@0 10 BOOST_AUTO_TEST_SUITE(TestYin)
matthiasm@0 11
matthiasm@0 12 BOOST_AUTO_TEST_CASE(implicitYinOutput)
matthiasm@0 13 {
matthiasm@0 14 // this test is just to make sure a YinOutput initialises
matthiasm@0 15 // -- the actual reason for me to write this is to have written
matthiasm@0 16 // a test, so let's plough on...
matthiasm@0 17 Yin::YinOutput out;
matthiasm@0 18
matthiasm@0 19 BOOST_CHECK_EQUAL(out.f0, 0);
matthiasm@0 20 BOOST_CHECK_EQUAL(out.periodicity, 0);
matthiasm@0 21 BOOST_CHECK_EQUAL(out.rms, 0);
matthiasm@0 22 }
matthiasm@0 23
matthiasm@0 24 BOOST_AUTO_TEST_CASE(sine128)
matthiasm@0 25 {
matthiasm@0 26
matthiasm@0 27 // a very short frame (8) with maximum frequency (128),
matthiasm@0 28 // assuming a sampling rate of 256 1/sec.
matthiasm@0 29 // Yin should get it approximately right...
matthiasm@0 30 // but because of post-processing we want to be tolerant
matthiasm@0 31
matthiasm@0 32 double in[] = { 1, -1, 1, -1, 1, -1, 1, -1 };
matthiasm@0 33 Yin y(8, 256);
matthiasm@0 34 Yin::YinOutput yo = y.process(in);
matthiasm@0 35
matthiasm@0 36 BOOST_CHECK(yo.f0 > 114);
matthiasm@0 37 BOOST_CHECK(yo.f0 < 142);
matthiasm@0 38 }
matthiasm@0 39
matthiasm@0 40 BOOST_AUTO_TEST_SUITE_END()
matthiasm@0 41