mirror of https://github.com/probonopd/MiniDexed
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.9 KiB
85 lines
1.9 KiB
2 years ago
|
#include <gtest/gtest.h>
|
||
|
|
||
|
#include <fstream>
|
||
|
|
||
|
#include "test_fx_helper.h"
|
||
|
#include "../fx_components.h"
|
||
|
|
||
|
TEST(CppPerformance, LFOPerformance_ComplexLFO_InterpolatedSineOscillator)
|
||
|
{
|
||
|
constexpr size_t NB = 10000000;
|
||
|
float32_t freq = 0.1f;
|
||
|
|
||
|
LFO lfo1(SAMPLING_FREQUENCY, 0.0f, 10.0f);
|
||
|
InterpolatedSineOscillator lfo2(SAMPLING_FREQUENCY, 0.0f, 10.0f);
|
||
|
|
||
|
lfo1.setFrequency(freq);
|
||
|
LAP_TIME("lfo1");
|
||
|
for(size_t i = 0; i < NB; ++i)
|
||
|
{
|
||
|
lfo1.process();
|
||
|
}
|
||
|
auto d1 = LAP_TIME("lfo1");
|
||
|
|
||
|
lfo2.setFrequency(freq);
|
||
|
LAP_TIME("lfo2");
|
||
|
for(size_t i = 0; i < NB; ++i)
|
||
|
{
|
||
|
lfo2.process();
|
||
|
}
|
||
|
auto d2 = LAP_TIME("lfo2");
|
||
|
|
||
|
EXPECT_GE(d1, d2);
|
||
|
}
|
||
|
|
||
|
TEST(CppPerformance, LFOPerformance_ComplexLFO_FastLFO)
|
||
|
{
|
||
|
constexpr size_t NB = 10000000;
|
||
|
float32_t freq = 0.1f;
|
||
|
|
||
|
ComplexLFO lfo1(SAMPLING_FREQUENCY, 0.0f, 10.0f, Constants::MPI_2);
|
||
|
FastLFO lfo2(SAMPLING_FREQUENCY, 0.0f, 10.0f);
|
||
|
|
||
|
lfo1.setFrequency(freq);
|
||
|
LAP_TIME("lfo1");
|
||
|
for(size_t i = 0; i < NB; ++i)
|
||
|
{
|
||
|
lfo1.process();
|
||
|
}
|
||
|
auto d1 = LAP_TIME("lfo1");
|
||
|
|
||
|
lfo2.setFrequency(freq);
|
||
|
LAP_TIME("lfo2");
|
||
|
for(size_t i = 0; i < NB; ++i)
|
||
|
{
|
||
|
lfo2.process();
|
||
|
}
|
||
|
auto d2 = LAP_TIME("lfo2");
|
||
|
|
||
|
EXPECT_GE(d1, d2);
|
||
|
}
|
||
|
|
||
|
TEST_F(FxComponentFixture, FastLFOTuning)
|
||
|
{
|
||
|
float32_t freq = 10.0f;
|
||
|
|
||
|
size_t NB = static_cast<size_t>(1.0f * SAMPLING_FREQUENCY);
|
||
|
|
||
|
FastLFO lfo1(SAMPLING_FREQUENCY, 10.0f, 440.0f);
|
||
|
lfo1.setFrequency(freq);
|
||
|
|
||
|
ComplexLFO lfo2(SAMPLING_FREQUENCY, 10.0f, 440.0f);
|
||
|
lfo2.setFrequency(freq);
|
||
|
|
||
|
std::ofstream out(this->getResultFile("FastLFO-data.csv"));
|
||
|
out << "index;FastLFO;ComplexLFO" << std::endl;
|
||
|
for(size_t i = 0; i < NB; ++i)
|
||
|
{
|
||
|
out
|
||
|
<< i << ";"
|
||
|
<< lfo1.process() << ";"
|
||
|
<< lfo2.process() << std::endl;
|
||
|
}
|
||
|
out.close();
|
||
|
}
|