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.setOverdrive(0.75f);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);
@ -57,20 +46,11 @@ TEST(LevelTuning, Chorus)
fx.setRate(0.4f);
fx.setDepth(0.5f);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);
@ -101,20 +79,11 @@ TEST(LevelTuning, Flanger)
fx.setDepth(0.75f);
fx.setFeedback(0.5f);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);
@ -144,20 +111,11 @@ TEST(LevelTuning, Orbitone)
fx.setRate(0.4f);
fx.setDepth(0.5f);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);
@ -189,20 +145,11 @@ TEST(LevelTuning, Phaser)
fx.setFeedback(0.5f);
fx.setNbStages(12);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);
@ -235,20 +180,11 @@ TEST(LevelTuning, Delay)
fx.setFlutterRate(0.0f);
fx.setFlutterAmount(0.0f);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);
@ -283,20 +217,11 @@ TEST(LevelTuning, PlateReverb)
fx.diffusion(0.65f);
fx.level(1.0f);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);
@ -327,20 +250,11 @@ TEST(LevelTuning, ShimmerReverb)
fx.setDiffusion(0.75f);
fx.setLP(0.8f);
size_t size;
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
float32_t sumIn = 0.0f;
float32_t sumOut = 0.0f;
size_t nb_errors = 0;
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;
AUDIO_LOOP(inSamples, outSamples, size, inL, inR, outL, outR,
sumIn += inL * inL;
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(outR) > 1.0f ? 1 : 0;
}
);
delete[] inSamples[0];
delete[] inSamples[1];
delete[] inSamples;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
float32_t ratio = std::sqrt(sumOut / sumIn);

@ -6,65 +6,34 @@
TEST(FXPlateReverb, Migration)
{
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 = 4;
AudioEffectPlateReverb* reverb = new AudioEffectPlateReverb(SAMPLING_FREQUENCY);
reverb->set_bypass(false);
reverb->size(0.7f);
reverb->hidamp(0.5f);
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)
AudioEffectPlateReverb reverb(SAMPLING_FREQUENCY);
reverb.set_bypass(false);
reverb.size(0.7f);
reverb.hidamp(0.5f);
reverb.lodamp(0.5f);
reverb.lowpass(0.3f);
reverb.diffusion(0.65f);
reverb.level(1.0f);
PREPARE_AUDIO_TEST(size, inSamples, outSamples, full_test_name);
for(size_t i = 0; i < size; ++i)
{
reverb->processSample(samples[0][j], samples[1][j], sampleOutL[index], sampleOutR[index]);
++index;
}
reverb.processSample(inSamples[0][i], inSamples[1][i], outSamples[0][i], outSamples[1][i]);
}
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-new.wav", true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
unsigned indexOut = 0;
for (unsigned i = 0; i < nbRepeats; ++i)
{
unsigned len = size;
unsigned indexIn = 0;
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-new.wav", true), outSamples[0], outSamples[1], size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
size_t index = 0;
size_t len = size;
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;
indexOut += grainSize;
index += grainSize;
len -= grainSize;
}
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-legacy.wav", true), outSamples[0], outSamples[1], size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
}
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;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
}

@ -56,57 +56,32 @@ void setupRack(FXRack* rack, int scenario)
TEST_P(FXScenarioTest, FXRackResetAllScenarios)
{
FXRack *rack = new FXRack(SAMPLING_FREQUENCY);
FXRack rack(SAMPLING_FREQUENCY);
int fxSwitch = this->GetParam();
rack->setEnable(true);
setupRack(rack, fxSwitch);
rack->reset();
delete rack;
rack.setEnable(true);
setupRack(&rack, fxSwitch);
rack.reset();
}
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();
rack->setEnable(true);
setupRack(rack, fxSwitch);
rack->reset();
string name = getScenarioName(fxSwitch);
for(unsigned i = 0; i < nbRepeats; ++i)
{
rack->process(samples[0], samples[1], sampleOutL + i * size, sampleOutR + i * size, size);
}
FXRack rack(SAMPLING_FREQUENCY);
rack.setEnable(true);
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;
ss << full_test_name << "-fx-rack" << name << ".wav";
saveWaveFile(getResultFile(ss.str(), true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
delete[] samples[0];
delete[] samples[1];
delete[] samples;
delete[] sampleOutL;
delete[] sampleOutR;
saveWaveFile(getResultFile(ss.str(), true), outSamples[0], outSamples[1], size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
delete rack;
CLEANUP_AUDIO_TEST(inSamples, outSamples);
}
INSTANTIATE_TEST_SUITE_P(FXRack, FXScenarioTest, testing::Range(0, 1 << (FXSwitch::FX__ShimmerReverb + 1)));

Loading…
Cancel
Save