Reorganizing tests

pull/409/head
abscisys 2 years ago
parent 4709fc3f81
commit 20419bb077
  1. 152
      src/test/test_fxLevelTuning.cpp
  2. 71
      src/test/test_fx_plate_reverb.cpp
  3. 51
      src/test/test_fx_rack.cpp

@ -15,20 +15,11 @@ TEST(LevelTuning, Tube)
fx.reset(); fx.reset();
fx.setOverdrive(0.75f); fx.setOverdrive(0.75f);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -37,11 +28,9 @@ TEST(LevelTuning, Tube)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);
@ -57,20 +46,11 @@ TEST(LevelTuning, Chorus)
fx.setRate(0.4f); fx.setRate(0.4f);
fx.setDepth(0.5f); fx.setDepth(0.5f);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -79,11 +59,9 @@ TEST(LevelTuning, Chorus)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);
@ -101,20 +79,11 @@ TEST(LevelTuning, Flanger)
fx.setDepth(0.75f); fx.setDepth(0.75f);
fx.setFeedback(0.5f); fx.setFeedback(0.5f);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -123,11 +92,9 @@ TEST(LevelTuning, Flanger)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);
@ -144,20 +111,11 @@ TEST(LevelTuning, Orbitone)
fx.setRate(0.4f); fx.setRate(0.4f);
fx.setDepth(0.5f); fx.setDepth(0.5f);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -166,11 +124,9 @@ TEST(LevelTuning, Orbitone)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);
@ -189,20 +145,11 @@ TEST(LevelTuning, Phaser)
fx.setFeedback(0.5f); fx.setFeedback(0.5f);
fx.setNbStages(12); fx.setNbStages(12);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -211,11 +158,9 @@ TEST(LevelTuning, Phaser)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);
@ -235,20 +180,11 @@ TEST(LevelTuning, Delay)
fx.setFlutterRate(0.0f); fx.setFlutterRate(0.0f);
fx.setFlutterAmount(0.0f); fx.setFlutterAmount(0.0f);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -257,11 +193,9 @@ TEST(LevelTuning, Delay)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);
@ -283,20 +217,11 @@ TEST(LevelTuning, PlateReverb)
fx.diffusion(0.65f); fx.diffusion(0.65f);
fx.level(1.0f); fx.level(1.0f);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -305,11 +230,9 @@ TEST(LevelTuning, PlateReverb)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);
@ -327,20 +250,11 @@ TEST(LevelTuning, ShimmerReverb)
fx.setDiffusion(0.75f); fx.setDiffusion(0.75f);
fx.setLP(0.8f); fx.setLP(0.8f);
size_t size; PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t sumIn = 0.0f; float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f; float32_t sumOut = 0.0f;
size_t nb_errors = 0; size_t nb_errors = 0;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
for(size_t i = 0; i < size; ++i)
{
float32_t inL = inSamples[0][i];
float32_t inR = inSamples[1][i];
float32_t outL;
float32_t outR;
sumIn += inL * inL; sumIn += inL * inL;
fx.processSample(inL, inR, outL, outR); fx.processSample(inL, inR, outL, outR);
@ -349,11 +263,9 @@ TEST(LevelTuning, ShimmerReverb)
nb_errors += std::abs(outL) > 1.0f ? 1 : 0; nb_errors += std::abs(outL) > 1.0f ? 1 : 0;
nb_errors += std::abs(outR) > 1.0f ? 1 : 0; nb_errors += std::abs(outR) > 1.0f ? 1 : 0;
} );
delete[] inSamples[0]; CLEANUP_AUDIO_TEST(inSamples, outSamples);
delete[] inSamples[1];
delete[] inSamples;
float32_t ratio = std::sqrt(sumOut / sumIn); float32_t ratio = std::sqrt(sumOut / sumIn);

@ -6,65 +6,34 @@
TEST(FXPlateReverb, Migration) TEST(FXPlateReverb, Migration)
{ {
const testing::TestInfo* test_info = testing::UnitTest::GetInstance()->current_test_info(); AudioEffectPlateReverb reverb(SAMPLING_FREQUENCY);
std::string full_test_name = test_info->test_case_name(); reverb.set_bypass(false);
full_test_name += "."; reverb.size(0.7f);
full_test_name += test_info->name(); reverb.hidamp(0.5f);
reverb.lodamp(0.5f);
const unsigned nbRepeats = 4; reverb.lowpass(0.3f);
reverb.diffusion(0.65f);
AudioEffectPlateReverb* reverb = new AudioEffectPlateReverb(SAMPLING_FREQUENCY); reverb.level(1.0f);
reverb->set_bypass(false);
reverb->size(0.7f); PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
reverb->hidamp(0.5f); for(size_t i = 0; i < size; ++i)
reverb->lodamp(0.5f);
reverb->lowpass(0.3f);
reverb->diffusion(0.65f);
reverb->level(1.0f);
size_t size;
float32_t** samples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t* sampleOutL = new float32_t[size * nbRepeats];
float32_t* sampleOutR = new float32_t[size * nbRepeats];
memset(sampleOutL, 0, size * nbRepeats * sizeof(float32_t));
memset(sampleOutR, 0, size * nbRepeats * sizeof(float32_t));
unsigned index = 0;
for(unsigned i = 0; i < nbRepeats; ++i)
{
for(unsigned j = 0; j < size; ++j)
{ {
reverb->processSample(samples[0][j], samples[1][j], sampleOutL[index], sampleOutR[index]); reverb.processSample(inSamples[0][i], inSamples[1][i], outSamples[0][i], outSamples[1][i]);
++index;
}
} }
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-new.wav", true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); saveWaveFile(getResultFile(full_test_name + ".PlateReverb-new.wav", true), outSamples[0], outSamples[1], size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
unsigned indexOut = 0;
for (unsigned i = 0; i < nbRepeats; ++i)
{
unsigned len = size;
unsigned indexIn = 0;
size_t index = 0;
size_t len = size;
while(len > 0) while(len > 0)
{ {
unsigned grainSize = (len < 1024 ? len : 1024); size_t grainSize = (len < 1024 ? len : 1024);
reverb->doReverb(samples[0] + indexIn, samples[1] + indexIn, sampleOutL + indexOut, sampleOutR + indexOut, grainSize); reverb.doReverb(inSamples[0] + index, inSamples[1] + index, outSamples[0] + index, outSamples[1] + index, grainSize);
indexIn += grainSize; index += grainSize;
indexOut += grainSize;
len -= grainSize; len -= grainSize;
} }
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-legacy.wav", true), outSamples[0], outSamples[1], size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
} CLEANUP_AUDIO_TEST(inSamples, outSamples);
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-legacy.wav", true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
delete[] sampleOutL;
delete[] sampleOutR;
delete[] samples[0];
delete[] samples[1];
delete[] samples;
delete reverb;
} }

@ -56,57 +56,32 @@ void setupRack(FXRack* rack, int scenario)
TEST_P(FXScenarioTest, FXRackResetAllScenarios) TEST_P(FXScenarioTest, FXRackResetAllScenarios)
{ {
FXRack *rack = new FXRack(SAMPLING_FREQUENCY); FXRack rack(SAMPLING_FREQUENCY);
int fxSwitch = this->GetParam(); int fxSwitch = this->GetParam();
rack->setEnable(true); rack.setEnable(true);
setupRack(rack, fxSwitch); setupRack(&rack, fxSwitch);
rack->reset(); rack.reset();
delete rack;
} }
TEST_P(FXScenarioTest, ScenarioProcessing) TEST_P(FXScenarioTest, ScenarioProcessing)
{ {
const testing::TestInfo* test_info = testing::UnitTest::GetInstance()->current_test_info();
std::string full_test_name = test_info->test_case_name();
full_test_name += ".";
full_test_name += test_info->name();
const unsigned nbRepeats = 1;
size_t size;
float32_t** samples = readWaveFile(AUDIO_SOURCE_FILE, size);
float32_t* sampleOutL = new float32_t[size * nbRepeats];
float32_t* sampleOutR = new float32_t[size * nbRepeats];
memset(sampleOutL, 0, size * nbRepeats * sizeof(float32_t));
memset(sampleOutR, 0, size * nbRepeats * sizeof(float32_t));
FXRack *rack = new FXRack(SAMPLING_FREQUENCY);
int fxSwitch = this->GetParam(); int fxSwitch = this->GetParam();
rack->setEnable(true);
setupRack(rack, fxSwitch);
rack->reset();
string name = getScenarioName(fxSwitch); string name = getScenarioName(fxSwitch);
for(unsigned i = 0; i < nbRepeats; ++i) FXRack rack(SAMPLING_FREQUENCY);
{ rack.setEnable(true);
rack->process(samples[0], samples[1], sampleOutL + i * size, sampleOutR + i * size, size); setupRack(&rack, fxSwitch);
} rack.reset();
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
rack.process(inSamples[0], inSamples[1], outSamples[0], outSamples[1], size);
stringstream ss; stringstream ss;
ss << full_test_name << "-fx-rack" << name << ".wav"; ss << full_test_name << "-fx-rack" << name << ".wav";
saveWaveFile(getResultFile(ss.str(), true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); saveWaveFile(getResultFile(ss.str(), true), outSamples[0], outSamples[1], size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
delete[] samples[0];
delete[] samples[1];
delete[] samples;
delete[] sampleOutL;
delete[] sampleOutR;
delete rack; CLEANUP_AUDIO_TEST(inSamples, outSamples);
} }
INSTANTIATE_TEST_SUITE_P(FXRack, FXScenarioTest, testing::Range(0, 1 << (FXSwitch::FX__ShimmerReverb + 1))); INSTANTIATE_TEST_SUITE_P(FXRack, FXScenarioTest, testing::Range(0, 1 << (FXSwitch::FX__ShimmerReverb + 1)));

Loading…
Cancel
Save