mirror of https://github.com/probonopd/MiniDexed
parent
0cec94f491
commit
55feb0f794
@ -1,55 +1,216 @@ |
||||
#include "../mixing_console_constants.h" |
||||
#include <gtest/gtest.h> |
||||
#include <cmath> |
||||
#include <iostream> |
||||
|
||||
#include "test_fx_helper.h" |
||||
#include "../mixing_console.hpp" |
||||
|
||||
#include <iostream> |
||||
TEST(BetaTest, WavefileSamplesBoundariesTest) |
||||
{ |
||||
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(); |
||||
|
||||
using namespace std; |
||||
size_t size; |
||||
float32_t** samples = readWaveFile(AUDIO_SOURCE_FILE, size); |
||||
|
||||
typedef MixingConsole<8> Mixer; |
||||
size_t nb_errors = 0; |
||||
for(size_t i = 0; i < size; ++i) |
||||
{ |
||||
nb_errors += fullInspector(full_test_name + ".rawWaveSampleTest", samples[0][i], -1.0f, 1.0f, true); |
||||
nb_errors += fullInspector(full_test_name + ".rawWaveSampleTest", samples[1][i], -1.0f, 1.0f, true); |
||||
} |
||||
EXPECT_EQ(0, nb_errors) << full_test_name << ".rawWaveSampleTest"; |
||||
|
||||
int main() |
||||
delete[] samples[0]; |
||||
delete[] samples[1]; |
||||
delete[] samples; |
||||
} |
||||
|
||||
typedef MixingConsole<1> Mixer; |
||||
|
||||
TEST(BetaTest, MixingConsoleShortBuffer) |
||||
{ |
||||
Mixer* mixer = new Mixer(44100.0f, 4); |
||||
// DUMP2(mixer, cout, "Post creation");
|
||||
static const float32_t SINPI_4 = std::sqrt(2.0f) / 2.0f; |
||||
|
||||
mixer->reset(); |
||||
DUMP2(mixer, cout, "Post creation"); |
||||
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 size_t size = 10; |
||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); |
||||
|
||||
mixer->setChannelLevel(0, 1.0f); |
||||
// DUMP2(mixer, cout, "Post setChannelLevel");
|
||||
mixer->setPan(0, 0.5f); |
||||
|
||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); |
||||
|
||||
float32_t inSamples[size]; |
||||
for(size_t s = 0; s < size; ++s) inSamples[s] = getRandomValue(); |
||||
float32_t outSamples[2][size]; |
||||
memset(outSamples[0], 0, size * sizeof(float32_t)); |
||||
memset(outSamples[1], 0, size * sizeof(float32_t)); |
||||
|
||||
mixer->setInputSampleBuffer(0, inSamples); |
||||
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||
|
||||
mixer->process(outSamples[0], outSamples[1]); |
||||
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||
for(size_t s = 0; s < size; ++s) |
||||
{ |
||||
EXPECT_EQ(outSamples[0][s], outSamples[1][s]); |
||||
EXPECT_EQ(outSamples[0][s], inSamples[s] * SINPI_4); |
||||
} |
||||
|
||||
delete mixer; |
||||
} |
||||
|
||||
TEST(BetaTest, MixingConsoleShimmerShortBuffer) |
||||
{ |
||||
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 size_t size = 10; |
||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); |
||||
|
||||
mixer->setChannelLevel(0, 1.0f); |
||||
mixer->setPan(0, 0.5f); |
||||
// DUMP2(mixer, cout, "Post setPan");
|
||||
|
||||
float32_t samples[] = {0.0f, 0.0f, 0.0f, 0.0f}; |
||||
mixer->setInputSampleBuffer(0, samples); |
||||
// DUMP2(mixer, cout, "Post setInputSampleBuffer");
|
||||
mixer->getShimmerReverb()->setInputGain(0.35f); |
||||
mixer->getShimmerReverb()->setTime(0.69f); |
||||
mixer->getShimmerReverb()->setDiffusion(0.7f); |
||||
mixer->getShimmerReverb()->setLP(0.8f); |
||||
|
||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.4f); |
||||
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f); |
||||
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 0.6f); |
||||
|
||||
float32_t inSamples[size]; |
||||
for(size_t s = 0; s < size; ++s) inSamples[s] = getRandomValue(); |
||||
float32_t outSamples[2][size]; |
||||
memset(outSamples[0], 0, size * sizeof(float32_t)); |
||||
memset(outSamples[1], 0, size * sizeof(float32_t)); |
||||
|
||||
mixer->setInputSampleBuffer(0, inSamples); |
||||
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||
// FAST_DUMP(mixer, std::cerr, full_test_name + ".setInputSampleBuffer");
|
||||
|
||||
mixer->process(outSamples[0], outSamples[1]); |
||||
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||
// FAST_DUMP(mixer, std::cerr, full_test_name + ".process");
|
||||
|
||||
delete mixer; |
||||
} |
||||
|
||||
TEST(BetaTest, MixingConsoleDrySamplesBoundariesTest) |
||||
{ |
||||
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(); |
||||
|
||||
size_t size; |
||||
float32_t** inSamples =readWaveFile(AUDIO_SOURCE_FILE, size); |
||||
|
||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); |
||||
mixer->reset(); |
||||
FULL_INSPECT2(mixer, true, "Mixer.reset"); |
||||
|
||||
mixer->setChannelLevel(0, 1.0f); |
||||
mixer->setPan(0, 0.5f); |
||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); |
||||
// DUMP2(mixer, cout, "Post setSendLevel - full dry");
|
||||
|
||||
float32_t outL[4]; |
||||
float32_t outR[4]; |
||||
mixer->process(outL, outR); |
||||
DUMP2(mixer, cout, "Post process"); |
||||
cout.precision(5); |
||||
cout << std::fixed; |
||||
cout << "+ outL: " << outL[0] << " - " << outL[1] << endl; |
||||
cout << "+ outR: " << outR[0] << " - " << outR[1] << endl; |
||||
mixer->setInputSampleBuffer(0, inSamples[0]); |
||||
|
||||
float32_t** outSamples = new float32_t*[2]; |
||||
outSamples[0] = new float32_t[size]; |
||||
outSamples[1] = new float32_t[size]; |
||||
memset(outSamples[0], 0, size * sizeof(float32_t)); |
||||
memset(outSamples[1], 0, size * sizeof(float32_t)); |
||||
|
||||
mixer->process(outSamples[0], outSamples[1]); |
||||
|
||||
size_t nb_errors = 0; |
||||
for(size_t i = 0; i < size; ++i) |
||||
{ |
||||
nb_errors += fullInspector(full_test_name + ".outputSampleTest", inSamples[0][i], -1.0f, 1.0f, true); |
||||
nb_errors += fullInspector(full_test_name + ".outputSampleTest", inSamples[1][i], -1.0f, 1.0f, true); |
||||
} |
||||
EXPECT_EQ(0, nb_errors) << full_test_name << ".outputSampleTest"; |
||||
|
||||
delete[] inSamples[0]; |
||||
delete[] inSamples[1]; |
||||
delete[] inSamples; |
||||
|
||||
delete[] outSamples[0]; |
||||
delete[] outSamples[1]; |
||||
delete[] outSamples; |
||||
|
||||
delete mixer; |
||||
} |
||||
|
||||
TEST(BetaTest, MixingConsoleShimmerSamplesBoundariesTest) |
||||
{ |
||||
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(); |
||||
|
||||
size_t size; |
||||
float32_t** inSamples =readWaveFile(AUDIO_SOURCE_FILE, size); |
||||
|
||||
float32_t** outSamples = new float32_t*[2]; |
||||
outSamples[0] = new float32_t[size]; |
||||
outSamples[1] = new float32_t[size]; |
||||
memset(outSamples[0], 0, size * sizeof(float32_t)); |
||||
memset(outSamples[1], 0, size * sizeof(float32_t)); |
||||
|
||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); |
||||
mixer->reset(); |
||||
mixer->setChannelLevel(0, 1.0f); |
||||
mixer->setPan(0, 0.5f); |
||||
|
||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.4f); |
||||
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f); |
||||
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 0.6f); |
||||
|
||||
mixer->getShimmerReverb()->setMute(false); |
||||
mixer->getShimmerReverb()->setInputGain(0.35); |
||||
mixer->getShimmerReverb()->setTime(0.65); |
||||
mixer->getShimmerReverb()->setDiffusion(0.8); |
||||
mixer->getShimmerReverb()->setLP(0.7f); |
||||
|
||||
mixer->setSendLevel(0, MixerOutput::FX_Tube, 1.0f); |
||||
mixer->setSendLevel(0, MixerOutput::FX_Delay, 1.0f); |
||||
mixer->setSendLevel(0, MixerOutput::FX_PlateReverb, 1.0f); |
||||
mixer->setInputSampleBuffer(0, inSamples[0]); |
||||
mixer->process(outSamples[0], outSamples[1]); |
||||
FAST_DUMP(mixer, std::cerr, full_test_name); |
||||
//EXPECT_EQ(0, FULL_INSPECT2(mixer, true, full_test_name + "Mixer.process")) << full_test_name << "Mixer.process";
|
||||
saveWaveFile(getResultFile(full_test_name + ".wav", true), outSamples[0], outSamples[1], size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); |
||||
|
||||
mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::FX_Orbitone, 1.0f); |
||||
mixer->setReturnLevel(MixerOutput::FX_Orbitone, MixerOutput::MainOutput, 0.5f); |
||||
mixer->setReturnLevel(MixerOutput::FX_Orbitone, MixerOutput::FX_PlateReverb, 1.0f); |
||||
mixer->setReturnLevel(MixerOutput::FX_Delay, MixerOutput::MainOutput, 0.5f); |
||||
mixer->setReturnLevel(MixerOutput::FX_PlateReverb, MixerOutput::MainOutput, 0.5f); |
||||
// DUMP2(mixer, cout, "Post setSendLevel & setReturnLevel");
|
||||
size_t nb_errors = 0; |
||||
for(size_t i = 0; i < size; ++i) |
||||
{ |
||||
nb_errors += fullInspector(full_test_name + ".outputSampleTest", inSamples[0][i], -1.0f, 1.0f, true); |
||||
nb_errors += fullInspector(full_test_name + ".outputSampleTest", inSamples[1][i], -1.0f, 1.0f, true); |
||||
} |
||||
EXPECT_EQ(0, nb_errors) << full_test_name << ".outputSampleTest"; |
||||
|
||||
delete[] inSamples[0]; |
||||
delete[] inSamples[1]; |
||||
delete[] inSamples; |
||||
|
||||
delete[] outSamples[0]; |
||||
delete[] outSamples[1]; |
||||
delete[] outSamples; |
||||
|
||||
delete mixer; |
||||
} |
||||
|
||||
return 0; |
||||
int main(int argc, char **argv) |
||||
{ |
||||
::testing::InitGoogleTest(&argc, argv); |
||||
return RUN_ALL_TESTS(); |
||||
} |
@ -0,0 +1,182 @@ |
||||
#include <gtest/gtest.h> |
||||
|
||||
#include "test_fx_helper.h" |
||||
#include "../fx_shimmer_reverb.h" |
||||
|
||||
TEST(FXShimmerReverb, TransientSilence) |
||||
{ |
||||
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 size_t size = static_cast<size_t>(SAMPLING_FREQUENCY); |
||||
float32_t* inSamples = new float32_t[size]; |
||||
memset(inSamples, 0, size * sizeof(float32_t)); |
||||
|
||||
float32_t* outSamplesL = new float32_t[size]; |
||||
float32_t* outSamplesR = new float32_t[size]; |
||||
memset(outSamplesL, 0, size * sizeof(float32_t)); |
||||
memset(outSamplesR, 0, size * sizeof(float32_t)); |
||||
|
||||
ShimmerReverb* shimmer = new ShimmerReverb(SAMPLING_FREQUENCY); |
||||
|
||||
shimmer->setInputGain(0.55f); |
||||
shimmer->setTime(0.75f); |
||||
shimmer->setDiffusion(0.8f); |
||||
shimmer->setLP(0.7f); |
||||
|
||||
shimmer->reset(); |
||||
for(size_t i = 0; i < size; ++i) |
||||
{ |
||||
shimmer->processSample( |
||||
inSamples[i],
|
||||
inSamples[i],
|
||||
outSamplesL[i],
|
||||
outSamplesR[i] |
||||
); |
||||
} |
||||
|
||||
saveWaveFile(getResultFile(full_test_name + ".wav", true), outSamplesL, outSamplesR, size, SAMPLING_FREQUENCY, 16); |
||||
|
||||
delete shimmer; |
||||
|
||||
delete[] inSamples; |
||||
|
||||
delete[] outSamplesL; |
||||
delete[] outSamplesR; |
||||
} |
||||
|
||||
TEST(FXShimmerReverb, TransientSilenceWithDirac) |
||||
{ |
||||
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 size_t size = 4 * static_cast<size_t>(SAMPLING_FREQUENCY); |
||||
float32_t* inSamples = new float32_t[size]; |
||||
memset(inSamples, 0, size * sizeof(float32_t)); |
||||
inSamples[0] = 1.0f; |
||||
|
||||
float32_t* outSamplesL = new float32_t[size]; |
||||
float32_t* outSamplesR = new float32_t[size]; |
||||
memset(outSamplesL, 0, size * sizeof(float32_t)); |
||||
memset(outSamplesR, 0, size * sizeof(float32_t)); |
||||
|
||||
ShimmerReverb* shimmer = new ShimmerReverb(SAMPLING_FREQUENCY); |
||||
|
||||
shimmer->setInputGain(0.55f); |
||||
shimmer->setTime(0.75f); |
||||
shimmer->setDiffusion(0.8f); |
||||
shimmer->setLP(0.7f); |
||||
|
||||
shimmer->reset(); |
||||
for(size_t i = 0; i < size; ++i) |
||||
{ |
||||
shimmer->processSample( |
||||
inSamples[i],
|
||||
inSamples[i],
|
||||
outSamplesL[i],
|
||||
outSamplesR[i] |
||||
); |
||||
} |
||||
|
||||
saveWaveFile(getResultFile(full_test_name + ".wav", true), outSamplesL, outSamplesR, size, SAMPLING_FREQUENCY, 16); |
||||
|
||||
delete shimmer; |
||||
|
||||
delete[] inSamples; |
||||
|
||||
delete[] outSamplesL; |
||||
delete[] outSamplesR; |
||||
} |
||||
|
||||
TEST(FXShimmerReverb, TransientNoise) |
||||
{ |
||||
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 size_t size = static_cast<size_t>(SAMPLING_FREQUENCY); |
||||
float32_t* inSamples = new float32_t[size]; |
||||
for(size_t i = 0; i < size; ++i) inSamples[i] = getRandomValue(); |
||||
|
||||
float32_t* outSamplesL = new float32_t[size]; |
||||
float32_t* outSamplesR = new float32_t[size]; |
||||
memset(outSamplesL, 0, size * sizeof(float32_t)); |
||||
memset(outSamplesR, 0, size * sizeof(float32_t)); |
||||
|
||||
ShimmerReverb* shimmer = new ShimmerReverb(SAMPLING_FREQUENCY); |
||||
|
||||
shimmer->setInputGain(0.55f); |
||||
shimmer->setTime(0.75f); |
||||
shimmer->setDiffusion(0.8f); |
||||
shimmer->setLP(0.7f); |
||||
|
||||
shimmer->reset(); |
||||
for(size_t i = 0; i < size; ++i) |
||||
{ |
||||
shimmer->processSample( |
||||
inSamples[i],
|
||||
inSamples[i],
|
||||
outSamplesL[i],
|
||||
outSamplesR[i] |
||||
); |
||||
} |
||||
|
||||
saveWaveFile(getResultFile(full_test_name + ".wav", true), outSamplesL, outSamplesR, size, SAMPLING_FREQUENCY, 16); |
||||
|
||||
delete shimmer; |
||||
|
||||
delete[] inSamples; |
||||
|
||||
delete[] outSamplesL; |
||||
delete[] outSamplesR; |
||||
} |
||||
|
||||
TEST(FXShimmerReverb, TransientMusic) |
||||
{ |
||||
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(); |
||||
|
||||
size_t size; |
||||
float32_t** inSamples = readWaveFile(AUDIO_SOURCE_FILE, size); |
||||
|
||||
float32_t* outSamplesL = new float32_t[size]; |
||||
float32_t* outSamplesR = new float32_t[size]; |
||||
memset(outSamplesL, 0, size * sizeof(float32_t)); |
||||
memset(outSamplesR, 0, size * sizeof(float32_t)); |
||||
|
||||
ShimmerReverb* shimmer = new ShimmerReverb(SAMPLING_FREQUENCY); |
||||
|
||||
shimmer->setInputGain(0.55f); |
||||
shimmer->setTime(0.75f); |
||||
shimmer->setDiffusion(0.8f); |
||||
shimmer->setLP(0.7f); |
||||
|
||||
shimmer->reset(); |
||||
for(size_t i = 0; i < size; ++i) |
||||
{ |
||||
shimmer->processSample( |
||||
inSamples[0][i],
|
||||
inSamples[1][i],
|
||||
outSamplesL[i],
|
||||
outSamplesR[i] |
||||
); |
||||
} |
||||
|
||||
saveWaveFile(getResultFile(full_test_name + ".wav", true), outSamplesL, outSamplesR, size, SAMPLING_FREQUENCY, 16); |
||||
|
||||
delete shimmer; |
||||
|
||||
delete[] inSamples[0]; |
||||
delete[] inSamples[1]; |
||||
delete[] inSamples; |
||||
|
||||
delete[] outSamplesL; |
||||
delete[] outSamplesR; |
||||
} |
Loading…
Reference in new issue