Permalink
Fetching contributors…
Cannot retrieve contributors at this time
162 lines (127 sloc) 5 KB
/**
* \ file BesselFilter.cpp
*/
#include <iostream>
#include <ATK/EQ/BesselFilter.h>
#include <ATK/EQ/IIRFilter.h>
#include <ATK/Mock/FFTCheckerFilter.h>
#include <ATK/Mock/SimpleSinusGeneratorFilter.h>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#define PROCESSSIZE (1024*64)
BOOST_AUTO_TEST_CASE( IIRFilter_BesselLowPassCoefficients_1k_test )
{
ATK::SimpleSinusGeneratorFilter<double> generator;
generator.set_output_sampling_rate(1024*64);
generator.set_amplitude(1);
generator.set_frequency(1000);
ATK::IIRFilter<ATK::BesselLowPassCoefficients<double> > filter;
filter.set_input_sampling_rate(1024*64);
filter.set_output_sampling_rate(1024*64);
filter.set_cut_frequency(100);
filter.set_order(3);
ATK::FFTCheckerFilter<double> checker;
checker.set_input_sampling_rate(1024*64);
std::vector<std::pair<int, double> > frequency_checks;
frequency_checks.push_back(std::make_pair(100, 0));
frequency_checks.push_back(std::make_pair(1000, 0.03150874916131525));
frequency_checks.push_back(std::make_pair(10000, 0));
checker.set_checks(frequency_checks);
checker.set_input_port(0, &filter, 0);
filter.set_input_port(0, &generator, 0);
filter.process(1024*64);
checker.process(PROCESSSIZE);
}
BOOST_AUTO_TEST_CASE( IIRTDF2Filter_BesselLowPassCoefficients_1k_test )
{
ATK::SimpleSinusGeneratorFilter<double> generator;
generator.set_output_sampling_rate(1024*64);
generator.set_amplitude(1);
generator.set_frequency(1000);
ATK::IIRTDF2Filter<ATK::BesselLowPassCoefficients<double> > filter;
filter.set_input_sampling_rate(1024*64);
filter.set_output_sampling_rate(1024*64);
filter.set_cut_frequency(100);
filter.set_order(3);
ATK::FFTCheckerFilter<double> checker;
checker.set_input_sampling_rate(1024*64);
std::vector<std::pair<int, double> > frequency_checks;
frequency_checks.push_back(std::make_pair(100, 0));
frequency_checks.push_back(std::make_pair(1000, 0.03150874916131525));
frequency_checks.push_back(std::make_pair(10000, 0));
checker.set_checks(frequency_checks);
checker.set_input_port(0, &filter, 0);
filter.set_input_port(0, &generator, 0);
filter.process(1024*64);
checker.process(PROCESSSIZE);
}
BOOST_AUTO_TEST_CASE( IIRFilter_BesselLowPassCoefficients_100_test )
{
ATK::SimpleSinusGeneratorFilter<double> generator;
generator.set_output_sampling_rate(1024*64);
generator.set_amplitude(1);
generator.set_frequency(100);
ATK::IIRFilter<ATK::BesselLowPassCoefficients<double> > filter;
filter.set_input_sampling_rate(1024*64);
filter.set_output_sampling_rate(1024*64);
filter.set_cut_frequency(100);
filter.set_order(3);
ATK::FFTCheckerFilter<double> checker;
checker.set_input_sampling_rate(1024*64);
std::vector<std::pair<int, double> > frequency_checks;
frequency_checks.push_back(std::make_pair(10, 0));
frequency_checks.push_back(std::make_pair(100, 0.6984126292895364));
frequency_checks.push_back(std::make_pair(1000, 0));
checker.set_checks(frequency_checks);
checker.set_input_port(0, &filter, 0);
filter.set_input_port(0, &generator, 0);
filter.process(1024*64);
checker.process(PROCESSSIZE);
}
BOOST_AUTO_TEST_CASE( IIRFilter_BesselLowPassCoefficients_2k_test )
{
ATK::SimpleSinusGeneratorFilter<double> generator;
generator.set_output_sampling_rate(1024*64);
generator.set_amplitude(1);
generator.set_frequency(2000);
ATK::IIRFilter<ATK::BesselLowPassCoefficients<double> > filter;
filter.set_input_sampling_rate(1024*64);
filter.set_output_sampling_rate(1024*64);
filter.set_cut_frequency(100);
filter.set_order(3);
ATK::FFTCheckerFilter<double> checker;
checker.set_input_sampling_rate(1024*64);
std::vector<std::pair<int, double> > frequency_checks;
frequency_checks.push_back(std::make_pair(100, 0));
frequency_checks.push_back(std::make_pair(1000, 0));
frequency_checks.push_back(std::make_pair(2000, 0.01112234417159909));
checker.set_checks(frequency_checks);
checker.set_input_port(0, &filter, 0);
filter.set_input_port(0, &generator, 0);
filter.process(1024*64);
checker.process(PROCESSSIZE);
}
BOOST_AUTO_TEST_CASE( IIRFilter_BesselLowPassCoefficients_200_test )
{
ATK::SimpleSinusGeneratorFilter<double> generator;
generator.set_output_sampling_rate(1024*64);
generator.set_amplitude(1);
generator.set_frequency(200);
ATK::IIRFilter<ATK::BesselLowPassCoefficients<double> > filter;
filter.set_input_sampling_rate(1024*64);
filter.set_output_sampling_rate(1024*64);
filter.set_cut_frequency(100);
filter.set_order(3);
ATK::FFTCheckerFilter<double> checker;
checker.set_input_sampling_rate(1024*64);
std::vector<std::pair<int, double> > frequency_checks;
frequency_checks.push_back(std::make_pair(100, 0));
frequency_checks.push_back(std::make_pair(200, 0.3285828399406346));
frequency_checks.push_back(std::make_pair(1000, 0));
checker.set_checks(frequency_checks);
checker.set_input_port(0, &filter, 0);
filter.set_input_port(0, &generator, 0);
filter.process(1024*64);
checker.process(PROCESSSIZE);
}