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 "../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); |
static const float32_t SINPI_4 = std::sqrt(2.0f) / 2.0f; |
||||||
// DUMP2(mixer, cout, "Post creation");
|
|
||||||
|
|
||||||
mixer->reset(); |
const testing::TestInfo* test_info = testing::UnitTest::GetInstance()->current_test_info(); |
||||||
DUMP2(mixer, cout, "Post creation"); |
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->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); |
mixer->setPan(0, 0.5f); |
||||||
// DUMP2(mixer, cout, "Post setPan");
|
|
||||||
|
|
||||||
float32_t samples[] = {0.0f, 0.0f, 0.0f, 0.0f}; |
mixer->getShimmerReverb()->setInputGain(0.35f); |
||||||
mixer->setInputSampleBuffer(0, samples); |
mixer->getShimmerReverb()->setTime(0.69f); |
||||||
// DUMP2(mixer, cout, "Post setInputSampleBuffer");
|
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); |
mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); |
||||||
// DUMP2(mixer, cout, "Post setSendLevel - full dry");
|
|
||||||
|
|
||||||
float32_t outL[4]; |
mixer->setInputSampleBuffer(0, inSamples[0]); |
||||||
float32_t outR[4]; |
|
||||||
mixer->process(outL, outR); |
float32_t** outSamples = new float32_t*[2]; |
||||||
DUMP2(mixer, cout, "Post process"); |
outSamples[0] = new float32_t[size]; |
||||||
cout.precision(5); |
outSamples[1] = new float32_t[size]; |
||||||
cout << std::fixed; |
memset(outSamples[0], 0, size * sizeof(float32_t)); |
||||||
cout << "+ outL: " << outL[0] << " - " << outL[1] << endl; |
memset(outSamples[1], 0, size * sizeof(float32_t)); |
||||||
cout << "+ outR: " << outR[0] << " - " << outR[1] << endl; |
|
||||||
|
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); |
||||||
|
|
||||||
mixer->setSendLevel(0, MixerOutput::FX_Tube, 1.0f); |
float32_t** outSamples = new float32_t*[2]; |
||||||
mixer->setSendLevel(0, MixerOutput::FX_Delay, 1.0f); |
outSamples[0] = new float32_t[size]; |
||||||
mixer->setSendLevel(0, MixerOutput::FX_PlateReverb, 1.0f); |
outSamples[1] = new float32_t[size]; |
||||||
|
memset(outSamples[0], 0, size * sizeof(float32_t)); |
||||||
|
memset(outSamples[1], 0, size * sizeof(float32_t)); |
||||||
|
|
||||||
mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::FX_Orbitone, 1.0f); |
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); |
||||||
mixer->setReturnLevel(MixerOutput::FX_Orbitone, MixerOutput::MainOutput, 0.5f); |
mixer->reset(); |
||||||
mixer->setReturnLevel(MixerOutput::FX_Orbitone, MixerOutput::FX_PlateReverb, 1.0f); |
mixer->setChannelLevel(0, 1.0f); |
||||||
mixer->setReturnLevel(MixerOutput::FX_Delay, MixerOutput::MainOutput, 0.5f); |
mixer->setPan(0, 0.5f); |
||||||
mixer->setReturnLevel(MixerOutput::FX_PlateReverb, MixerOutput::MainOutput, 0.5f); |
|
||||||
// DUMP2(mixer, cout, "Post setSendLevel & setReturnLevel");
|
|
||||||
|
|
||||||
|
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->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); |
||||||
|
|
||||||
|
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; |
delete mixer; |
||||||
|
} |
||||||
|
|
||||||
return 0; |
int main(int argc, char **argv) |
||||||
} |
{ |
||||||
|
::testing::InitGoogleTest(&argc, argv); |
||||||
|
return RUN_ALL_TESTS(); |
||||||
|
} |
||||||
|
@ -1,245 +1,353 @@ |
|||||||
#include <gtest/gtest.h> |
#include <gtest/gtest.h> |
||||||
#include <cmath> |
#include <cmath> |
||||||
|
|
||||||
#include "test_fx_helper.h" |
#include "test_fx_helper.h" |
||||||
#include "wave.h" |
#include "wave.h" |
||||||
|
|
||||||
#include "../mixing_console.hpp" |
#include "../mixing_console.hpp" |
||||||
|
|
||||||
class MixingConsoleScenarioTest : public testing::TestWithParam<MixerOutput> {}; |
class MixingConsoleScenarioTest : public testing::TestWithParam<MixerOutput> {}; |
||||||
|
|
||||||
TEST_P(MixingConsoleScenarioTest, MixerOutputTest) |
TEST_P(MixingConsoleScenarioTest, MixerOutputTest) |
||||||
{ |
{ |
||||||
MixerOutput v = this->GetParam(); |
MixerOutput v = this->GetParam(); |
||||||
std::string str = toString(v); |
std::string str = toString(v); |
||||||
MixerOutput mo = toIndex(str.c_str()); |
MixerOutput mo = toIndex(str.c_str()); |
||||||
EXPECT_EQ(v, mo); |
EXPECT_EQ(v, mo); |
||||||
} |
} |
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(MixerOutputTest, MixingConsoleScenarioTest, testing::Range(MixerOutput::OutputStart, MixerOutput::kFXCount)); |
INSTANTIATE_TEST_SUITE_P(MixerOutputTest, MixingConsoleScenarioTest, testing::Range(MixerOutput::OutputStart, MixerOutput::kFXCount)); |
||||||
|
|
||||||
typedef MixingConsole<8> Mixer; |
typedef MixingConsole<8> Mixer; |
||||||
|
|
||||||
void setupMixingConsoleFX(Mixer* mixer) |
void setupMixingConsoleFX(Mixer* mixer) |
||||||
{ |
{ |
||||||
mixer->getTube()->setMute(false); |
mixer->getTube()->setMute(false); |
||||||
mixer->getTube()->setOverdrive(0.25f); |
mixer->getTube()->setOverdrive(0.25f); |
||||||
|
|
||||||
mixer->getChorus()->setMute(false); |
mixer->getChorus()->setMute(false); |
||||||
mixer->getChorus()->setRate(0.4f); |
mixer->getChorus()->setRate(0.4f); |
||||||
mixer->getChorus()->setDepth(0.5f); |
mixer->getChorus()->setDepth(0.5f); |
||||||
|
|
||||||
mixer->getFlanger()->setMute(false); |
mixer->getFlanger()->setMute(false); |
||||||
mixer->getFlanger()->setRate(0.03f); |
mixer->getFlanger()->setRate(0.03f); |
||||||
mixer->getFlanger()->setDepth(0.75f); |
mixer->getFlanger()->setDepth(0.75f); |
||||||
mixer->getFlanger()->setFeedback(0.5f); |
mixer->getFlanger()->setFeedback(0.5f); |
||||||
|
|
||||||
mixer->getOrbitone()->setMute(false); |
mixer->getOrbitone()->setMute(false); |
||||||
mixer->getOrbitone()->setRate(0.4f); |
mixer->getOrbitone()->setRate(0.4f); |
||||||
mixer->getOrbitone()->setDepth(0.5f); |
mixer->getOrbitone()->setDepth(0.5f); |
||||||
|
|
||||||
mixer->getPhaser()->setMute(false); |
mixer->getPhaser()->setMute(false); |
||||||
mixer->getPhaser()->setRate(0.1f); |
mixer->getPhaser()->setRate(0.1f); |
||||||
mixer->getPhaser()->setDepth(1.0f); |
mixer->getPhaser()->setDepth(1.0f); |
||||||
mixer->getPhaser()->setFeedback(0.5f); |
mixer->getPhaser()->setFeedback(0.5f); |
||||||
mixer->getPhaser()->setNbStages(12); |
mixer->getPhaser()->setNbStages(12); |
||||||
|
|
||||||
mixer->getDelay()->setMute(false); |
mixer->getDelay()->setMute(false); |
||||||
mixer->getDelay()->setLeftDelayTime(0.5f); |
mixer->getDelay()->setLeftDelayTime(0.5f); |
||||||
mixer->getDelay()->setLeftDelayTime(0.7f); |
mixer->getDelay()->setLeftDelayTime(0.7f); |
||||||
mixer->getDelay()->setFeedback(0.7f); |
mixer->getDelay()->setFeedback(0.7f); |
||||||
mixer->getDelay()->setFlutterRate(0.7f); |
mixer->getDelay()->setFlutterRate(0.7f); |
||||||
mixer->getDelay()->setFlutterAmount(0.7f); |
mixer->getDelay()->setFlutterAmount(0.7f); |
||||||
|
|
||||||
mixer->getPlateReverb()->setMute(false); |
mixer->getPlateReverb()->setMute(false); |
||||||
mixer->getPlateReverb()->set_bypass(false); |
mixer->getPlateReverb()->set_bypass(false); |
||||||
mixer->getPlateReverb()->size(0.7f); |
mixer->getPlateReverb()->size(0.7f); |
||||||
mixer->getPlateReverb()->hidamp(0.5f); |
mixer->getPlateReverb()->hidamp(0.5f); |
||||||
mixer->getPlateReverb()->lodamp(0.5f); |
mixer->getPlateReverb()->lodamp(0.5f); |
||||||
mixer->getPlateReverb()->lowpass(0.3f); |
mixer->getPlateReverb()->lowpass(0.3f); |
||||||
mixer->getPlateReverb()->diffusion(0.65f); |
mixer->getPlateReverb()->diffusion(0.65f); |
||||||
mixer->getPlateReverb()->level(1.0f); |
mixer->getPlateReverb()->level(1.0f); |
||||||
|
|
||||||
mixer->getShimmerReverb()->setMute(false); |
mixer->getShimmerReverb()->setMute(false); |
||||||
mixer->getShimmerReverb()->setInputGain(0.65f); |
mixer->getShimmerReverb()->setInputGain(0.65f); |
||||||
mixer->getShimmerReverb()->setTime(0.89f); |
mixer->getShimmerReverb()->setTime(0.89f); |
||||||
mixer->getShimmerReverb()->setDiffusion(0.75f); |
mixer->getShimmerReverb()->setDiffusion(0.75f); |
||||||
mixer->getShimmerReverb()->setLP(0.8f); |
mixer->getShimmerReverb()->setLP(0.8f); |
||||||
} |
} |
||||||
|
|
||||||
TEST(MixingConsole, DryProcessing) |
#define ACTIVE_FX(scenarioId, fx) const bool b ## fx = ((scenarioId & MixerOutput::fx) == MixerOutput::fx) |
||||||
{ |
|
||||||
const float32_t epsilon = 1e-7; |
void setupMixingConsoleFX(Mixer* mixer, int scenarioId) |
||||||
const size_t length = 2; |
{ |
||||||
|
ACTIVE_FX(scenarioId, FX_Tube); |
||||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, length); |
ACTIVE_FX(scenarioId, FX_Chorus); |
||||||
mixer->reset(); |
ACTIVE_FX(scenarioId, FX_Flanger); |
||||||
|
ACTIVE_FX(scenarioId, FX_Orbitone); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_Tube, 0.0f); |
ACTIVE_FX(scenarioId, FX_Phaser); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_Chorus, 0.0f); |
ACTIVE_FX(scenarioId, FX_Delay); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_Flanger, 0.0f); |
ACTIVE_FX(scenarioId, FX_PlateReverb); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_Orbitone, 0.0f); |
ACTIVE_FX(scenarioId, FX_ShimmerReverb); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_Phaser, 0.0f); |
|
||||||
mixer->setSendLevel(0, MixerOutput::FX_Delay, 0.0f); |
mixer->setChannelLevel(0, 1.0f); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_PlateReverb, 0.0f); |
mixer->setPan(0, 0.5f); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 0.0f); |
|
||||||
|
|
||||||
for(unsigned i = MixerOutput::OutputStart; i < (MixerOutput::kFXCount - 1); ++i) |
} |
||||||
{ |
|
||||||
mixer->setReturnLevel(static_cast<MixerOutput>(i), MixerOutput::MainOutput, 0.0f); |
TEST(MixingConsole, ZeroSamplesTest) |
||||||
} |
{ |
||||||
|
const size_t length = 4; |
||||||
mixer->setChannelLevel(0, 1.0f); |
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, length); |
||||||
mixer->setPan(0, 0.5f); |
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); |
|
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
mixer->reset(); |
||||||
|
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
float32_t in[length] = {0.1, 0.2}; |
|
||||||
float32_t out[StereoChannels::kNumChannels][length]; |
setupMixingConsoleFX(mixer); |
||||||
for(size_t i = 0; i < StereoChannels::kNumChannels; ++i) memset(out[i], 0, length * sizeof(float32_t)); |
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
|
|
||||||
mixer->setInputSampleBuffer(0, in); |
mixer->setChannelLevel(0, 1.0f); |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
|
|
||||||
mixer->process( |
mixer->setPan(0, 0.5f); |
||||||
out[StereoChannels::Left ], |
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
out[StereoChannels::Right] |
|
||||||
); |
float32_t samples[] = {0.0f, 0.0f, 0.0f, 0.0f}; |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
mixer->setInputSampleBuffer(0, samples); |
||||||
|
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
EXPECT_EQ(out[StereoChannels::Left ][0], out[StereoChannels::Right][0]); |
|
||||||
EXPECT_EQ(out[StereoChannels::Left ][1], out[StereoChannels::Right][1]); |
mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); |
||||||
EXPECT_LT(std::abs(out[StereoChannels::Left ][0] - (sqrt(2.0f) / 20.0f)), epsilon); |
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
EXPECT_LT(std::abs(out[StereoChannels::Left ][1] - (sqrt(2.0f) / 10.0f)), epsilon); |
|
||||||
|
float32_t outL[4]; |
||||||
delete mixer; |
float32_t outR[4]; |
||||||
} |
mixer->process(outL, outR); |
||||||
|
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
TEST(MixingConsole, ShimmerProcessing) |
|
||||||
{ |
mixer->setSendLevel(0, MixerOutput::FX_Tube, 1.0f); |
||||||
const float32_t epsilon = 1e-7; |
mixer->setSendLevel(0, MixerOutput::FX_Delay, 1.0f); |
||||||
const size_t length = 2; |
mixer->setSendLevel(0, MixerOutput::FX_PlateReverb, 1.0f); |
||||||
|
|
||||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, length); |
mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::FX_Orbitone, 1.0f); |
||||||
mixer->reset(); |
mixer->setReturnLevel(MixerOutput::FX_Orbitone, MixerOutput::MainOutput, 0.5f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_Orbitone, MixerOutput::FX_PlateReverb, 1.0f); |
||||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.0f); |
mixer->setReturnLevel(MixerOutput::FX_Delay, MixerOutput::MainOutput, 0.5f); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f); |
mixer->setReturnLevel(MixerOutput::FX_PlateReverb, MixerOutput::MainOutput, 0.5f); |
||||||
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 1.0f); |
EXPECT_EQ(0, FULL_INSPECT(mixer, true)); |
||||||
mixer->setChannelLevel(0, 1.0f); |
|
||||||
mixer->setPan(0, 0.5f); |
delete mixer; |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
} |
||||||
|
|
||||||
|
TEST(MixingConsole, DryProcessing) |
||||||
float32_t in[length] = {0.1, 0.2}; |
{ |
||||||
float32_t out1[StereoChannels::kNumChannels][length]; |
const float32_t epsilon = 1e-7; |
||||||
for(size_t i = 0; i < StereoChannels::kNumChannels; ++i) memset(out1[i], 0, length * sizeof(float32_t)); |
const size_t length = 2; |
||||||
|
|
||||||
mixer->setInputSampleBuffer(0, in); |
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, length); |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
mixer->reset(); |
||||||
|
|
||||||
mixer->process( |
mixer->setSendLevel(0, MixerOutput::FX_Tube, 0.0f); |
||||||
out1[StereoChannels::Left ], |
mixer->setSendLevel(0, MixerOutput::FX_Chorus, 0.0f); |
||||||
out1[StereoChannels::Right] |
mixer->setSendLevel(0, MixerOutput::FX_Flanger, 0.0f); |
||||||
); |
mixer->setSendLevel(0, MixerOutput::FX_Orbitone, 0.0f); |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
mixer->setSendLevel(0, MixerOutput::FX_Phaser, 0.0f); |
||||||
|
mixer->setSendLevel(0, MixerOutput::FX_Delay, 0.0f); |
||||||
mixer->reset(); |
mixer->setSendLevel(0, MixerOutput::FX_PlateReverb, 0.0f); |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 0.0f); |
||||||
|
|
||||||
float32_t out2[StereoChannels::kNumChannels][length]; |
for(unsigned i = MixerOutput::OutputStart; i < (MixerOutput::kFXCount - 1); ++i) |
||||||
mixer->setInputSampleBuffer(0, in); |
{ |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
mixer->setReturnLevel(static_cast<MixerOutput>(i), MixerOutput::MainOutput, 0.0f); |
||||||
|
} |
||||||
mixer->process( |
|
||||||
out2[StereoChannels::Left ], |
mixer->setChannelLevel(0, 1.0f); |
||||||
out2[StereoChannels::Right] |
mixer->setPan(0, 0.5f); |
||||||
); |
mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
|
|
||||||
EXPECT_EQ(out1[StereoChannels::Left ][0], out2[StereoChannels::Left ][0]); |
float32_t in[length] = {0.1, 0.2}; |
||||||
EXPECT_EQ(out1[StereoChannels::Right][0], out2[StereoChannels::Right][0]); |
float32_t out[StereoChannels::kNumChannels][length]; |
||||||
EXPECT_EQ(out1[StereoChannels::Left ][1], out2[StereoChannels::Left ][1]); |
for(size_t i = 0; i < StereoChannels::kNumChannels; ++i) memset(out[i], 0, length * sizeof(float32_t)); |
||||||
EXPECT_EQ(out1[StereoChannels::Right][1], out2[StereoChannels::Right][1]); |
|
||||||
|
mixer->setInputSampleBuffer(0, in); |
||||||
delete mixer; |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
} |
|
||||||
|
mixer->process( |
||||||
TEST(MixingConsole, ShimmerNoiseProcessing) |
out[StereoChannels::Left ], |
||||||
{ |
out[StereoChannels::Right] |
||||||
const size_t length = 1024; |
); |
||||||
|
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, length); |
|
||||||
mixer->reset(); |
EXPECT_EQ(out[StereoChannels::Left ][0], out[StereoChannels::Right][0]); |
||||||
|
EXPECT_EQ(out[StereoChannels::Left ][1], out[StereoChannels::Right][1]); |
||||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.0f); |
EXPECT_LT(std::abs(out[StereoChannels::Left ][0] - (sqrt(2.0f) / 20.0f)), epsilon); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f); |
EXPECT_LT(std::abs(out[StereoChannels::Left ][1] - (sqrt(2.0f) / 10.0f)), epsilon); |
||||||
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 1.0f); |
|
||||||
mixer->setChannelLevel(0, 1.0f); |
delete mixer; |
||||||
mixer->setPan(0, 0.5f); |
} |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
|
||||||
|
TEST(MixingConsole, ShimmerProcessing) |
||||||
float32_t in[length]; |
{ |
||||||
for(size_t i = 0; i < length; ++i) in[i] = getRandomValue(); |
const float32_t epsilon = 1e-7; |
||||||
|
const size_t length = 2; |
||||||
float32_t out[StereoChannels::kNumChannels][length]; |
|
||||||
for(size_t i = 0; i < StereoChannels::kNumChannels; ++i) memset(out[i], 0, length * sizeof(float32_t)); |
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, length); |
||||||
|
mixer->reset(); |
||||||
mixer->setInputSampleBuffer(0, in); |
|
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.0f); |
||||||
|
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f); |
||||||
mixer->process( |
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 1.0f); |
||||||
out[StereoChannels::Left ], |
mixer->setChannelLevel(0, 1.0f); |
||||||
out[StereoChannels::Right] |
mixer->setPan(0, 0.5f); |
||||||
); |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
|
||||||
|
float32_t in[length] = {0.1, 0.2}; |
||||||
delete mixer; |
float32_t out1[StereoChannels::kNumChannels][length]; |
||||||
} |
for(size_t i = 0; i < StereoChannels::kNumChannels; ++i) memset(out1[i], 0, length * sizeof(float32_t)); |
||||||
|
|
||||||
TEST(MixingConsole, SimpleProcessing) |
mixer->setInputSampleBuffer(0, in); |
||||||
{ |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
const unsigned nbRepeats = 2; |
|
||||||
unsigned size; |
mixer->process( |
||||||
float32_t** samples = readWaveFile(AUDIO_SOURCE_FILE, size); |
out1[StereoChannels::Left ], |
||||||
float32_t* sampleOutL = new float32_t[size * nbRepeats]; |
out1[StereoChannels::Right] |
||||||
float32_t* sampleOutR = new float32_t[size * nbRepeats]; |
); |
||||||
memset(sampleOutL, 0, size * nbRepeats * sizeof(float32_t)); |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
memset(sampleOutR, 0, size * nbRepeats * sizeof(float32_t)); |
|
||||||
|
mixer->reset(); |
||||||
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
|
|
||||||
setupMixingConsoleFX(mixer); |
float32_t out2[StereoChannels::kNumChannels][length]; |
||||||
|
mixer->setInputSampleBuffer(0, in); |
||||||
mixer->getTube()->setOverdrive(0.15f); |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
mixer->setSendLevel(0, MixerOutput::FX_Tube, 1.0f); |
|
||||||
mixer->setSendLevel(0, MixerOutput::FX_Phaser, 1.0f); |
mixer->process( |
||||||
// mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::MainOutput, 1.0f);
|
out2[StereoChannels::Left ], |
||||||
// mixer->setSendLevel(0, MixerOutput::FX_Chorus, 1.0f);
|
out2[StereoChannels::Right] |
||||||
// mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f);
|
); |
||||||
mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::FX_Chorus, 1.0f); |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
mixer->setReturnLevel(MixerOutput::FX_Chorus, MixerOutput::FX_ShimmerReverb, 1.0f); |
|
||||||
mixer->setReturnLevel(MixerOutput::FX_Phaser, MixerOutput::FX_Delay, 1.0f); |
EXPECT_EQ(out1[StereoChannels::Left ][0], out2[StereoChannels::Left ][0]); |
||||||
|
EXPECT_EQ(out1[StereoChannels::Right][0], out2[StereoChannels::Right][0]); |
||||||
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.25f); |
EXPECT_EQ(out1[StereoChannels::Left ][1], out2[StereoChannels::Left ][1]); |
||||||
mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::MainOutput, 0.1f); |
EXPECT_EQ(out1[StereoChannels::Right][1], out2[StereoChannels::Right][1]); |
||||||
mixer->setReturnLevel(MixerOutput::FX_Chorus, MixerOutput::MainOutput, 0.15f); |
|
||||||
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 0.3f); |
delete mixer; |
||||||
mixer->setReturnLevel(MixerOutput::FX_Delay, MixerOutput::MainOutput, 0.3f); |
} |
||||||
|
|
||||||
for(unsigned j = 0; j < nbRepeats; ++j) |
TEST(MixingConsole, ShimmerNoiseProcessing) |
||||||
{ |
{ |
||||||
mixer->setInputSampleBuffer(0, samples[0], samples[1]); |
const size_t length = 1024; |
||||||
mixer->process(sampleOutL + j * size, sampleOutR + j * size); |
|
||||||
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, length); |
||||||
} |
mixer->reset(); |
||||||
saveWaveFile(getResultFile("result-mixing-console.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
|
|
||||||
|
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.0f); |
||||||
delete mixer; |
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 1.0f); |
||||||
delete[] samples[0]; |
mixer->setChannelLevel(0, 1.0f); |
||||||
delete[] samples[1]; |
mixer->setPan(0, 0.5f); |
||||||
delete[] samples; |
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
delete[] sampleOutL; |
|
||||||
delete[] sampleOutR; |
float32_t in[length]; |
||||||
} |
for(size_t i = 0; i < length; ++i) in[i] = getRandomValue(); |
||||||
|
|
||||||
|
float32_t out[StereoChannels::kNumChannels][length]; |
||||||
|
for(size_t i = 0; i < StereoChannels::kNumChannels; ++i) memset(out[i], 0, length * sizeof(float32_t)); |
||||||
|
|
||||||
|
mixer->setInputSampleBuffer(0, in); |
||||||
|
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
|
|
||||||
|
mixer->process( |
||||||
|
out[StereoChannels::Left ], |
||||||
|
out[StereoChannels::Right] |
||||||
|
); |
||||||
|
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
|
|
||||||
|
delete mixer; |
||||||
|
} |
||||||
|
|
||||||
|
TEST(MixingConsole, StandardUsageProcessing) |
||||||
|
{ |
||||||
|
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 = 2; |
||||||
|
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)); |
||||||
|
|
||||||
|
Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); |
||||||
|
|
||||||
|
setupMixingConsoleFX(mixer); |
||||||
|
|
||||||
|
mixer->getTube()->setOverdrive(0.15f); |
||||||
|
mixer->setSendLevel(0, MixerOutput::FX_Tube, 1.0f); |
||||||
|
mixer->setSendLevel(0, MixerOutput::FX_Phaser, 1.0f); |
||||||
|
// mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::MainOutput, 1.0f);
|
||||||
|
// mixer->setSendLevel(0, MixerOutput::FX_Chorus, 1.0f);
|
||||||
|
// mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f);
|
||||||
|
mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::FX_Chorus, 1.0f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_Chorus, MixerOutput::FX_ShimmerReverb, 1.0f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_Phaser, MixerOutput::FX_Delay, 1.0f); |
||||||
|
|
||||||
|
mixer->setSendLevel(0, MixerOutput::MainOutput, 0.25f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_Tube, MixerOutput::MainOutput, 0.1f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_Chorus, MixerOutput::MainOutput, 0.15f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 0.3f); |
||||||
|
mixer->setReturnLevel(MixerOutput::FX_Delay, MixerOutput::MainOutput, 0.3f); |
||||||
|
|
||||||
|
for(unsigned j = 0; j < nbRepeats; ++j) |
||||||
|
{ |
||||||
|
mixer->setInputSampleBuffer(0, samples[0], samples[1]); |
||||||
|
mixer->process(sampleOutL + j * size, sampleOutR + j * size); |
||||||
|
EXPECT_EQ(0, INSPECT(mixer, fullInspector)); |
||||||
|
} |
||||||
|
saveWaveFile(getResultFile(full_test_name + ".wav", true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); |
||||||
|
|
||||||
|
delete mixer; |
||||||
|
|
||||||
|
delete[] samples[0]; |
||||||
|
delete[] samples[1]; |
||||||
|
delete[] samples; |
||||||
|
delete[] sampleOutL; |
||||||
|
delete[] sampleOutR; |
||||||
|
} |
||||||
|
|
||||||
|
// TEST_P(FXScenarioTest, FXProcessingScenario)
|
||||||
|
// {
|
||||||
|
// 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 = 2;
|
||||||
|
// 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));
|
||||||
|
|
||||||
|
// Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size);
|
||||||
|
|
||||||
|
// setupMixingConsoleFX(mixer);
|
||||||
|
|
||||||
|
// int scenarioId = this->GetParam();
|
||||||
|
// setupMixingConsoleFXForScenario(mixer, scenarioId);
|
||||||
|
|
||||||
|
// for(unsigned j = 0; j < nbRepeats; ++j)
|
||||||
|
// {
|
||||||
|
// mixer->setInputSampleBuffer(0, samples[0], samples[1]);
|
||||||
|
// mixer->process(sampleOutL + j * size, sampleOutR + j * size);
|
||||||
|
// EXPECT_EQ(0, INSPECT(mixer, fullInspector));
|
||||||
|
// }
|
||||||
|
// saveWaveFile(getResultFile(full_test_name + ".wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16);
|
||||||
|
|
||||||
|
// delete mixer;
|
||||||
|
|
||||||
|
// delete[] samples[0];
|
||||||
|
// delete[] samples[1];
|
||||||
|
// delete[] samples;
|
||||||
|
// delete[] sampleOutL;
|
||||||
|
// delete[] sampleOutR;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// INSTANTIATE_TEST_SUITE_P(MixingConsole, FXScenarioTest, testing::Range(0, 1 << (MixerOutput::kFXCount - 1)));
|
@ -1,66 +1,70 @@ |
|||||||
#include <gtest/gtest.h> |
#include <gtest/gtest.h> |
||||||
|
|
||||||
#include "test_fx_helper.h" |
#include "test_fx_helper.h" |
||||||
#include "wave.h" |
|
||||||
|
#include "../effect_platervbstereo.h" |
||||||
#include "../effect_platervbstereo.h" |
|
||||||
|
TEST(FXPlateReverb, Migration) |
||||||
TEST(FXElement, PlateReverbMigration) |
{ |
||||||
{ |
const testing::TestInfo* test_info = testing::UnitTest::GetInstance()->current_test_info(); |
||||||
const unsigned nbRepeats = 4; |
std::string full_test_name = test_info->test_case_name(); |
||||||
|
full_test_name += "."; |
||||||
AudioEffectPlateReverb* reverb = new AudioEffectPlateReverb(SAMPLING_FREQUENCY); |
full_test_name += test_info->name(); |
||||||
reverb->set_bypass(false); |
|
||||||
reverb->size(0.7f); |
const unsigned nbRepeats = 4; |
||||||
reverb->hidamp(0.5f); |
|
||||||
reverb->lodamp(0.5f); |
AudioEffectPlateReverb* reverb = new AudioEffectPlateReverb(SAMPLING_FREQUENCY); |
||||||
reverb->lowpass(0.3f); |
reverb->set_bypass(false); |
||||||
reverb->diffusion(0.65f); |
reverb->size(0.7f); |
||||||
reverb->level(1.0f); |
reverb->hidamp(0.5f); |
||||||
|
reverb->lodamp(0.5f); |
||||||
unsigned size; |
reverb->lowpass(0.3f); |
||||||
float32_t** samples = readWaveFile(AUDIO_SOURCE_FILE, size); |
reverb->diffusion(0.65f); |
||||||
float32_t* sampleOutL = new float32_t[size * nbRepeats]; |
reverb->level(1.0f); |
||||||
float32_t* sampleOutR = new float32_t[size * nbRepeats]; |
|
||||||
memset(sampleOutL, 0, size * nbRepeats * sizeof(float32_t)); |
size_t size; |
||||||
memset(sampleOutR, 0, size * nbRepeats * sizeof(float32_t)); |
float32_t** samples = readWaveFile(AUDIO_SOURCE_FILE, size); |
||||||
|
float32_t* sampleOutL = new float32_t[size * nbRepeats]; |
||||||
unsigned index = 0; |
float32_t* sampleOutR = new float32_t[size * nbRepeats]; |
||||||
for(unsigned i = 0; i < nbRepeats; ++i) |
memset(sampleOutL, 0, size * nbRepeats * sizeof(float32_t)); |
||||||
{ |
memset(sampleOutR, 0, size * nbRepeats * sizeof(float32_t)); |
||||||
for(unsigned j = 0; j < size; ++j) |
|
||||||
{ |
unsigned index = 0; |
||||||
reverb->processSample(samples[0][j], samples[1][j], sampleOutL[index], sampleOutR[index]); |
for(unsigned i = 0; i < nbRepeats; ++i) |
||||||
++index; |
{ |
||||||
} |
for(unsigned j = 0; j < size; ++j) |
||||||
} |
{ |
||||||
saveWaveFile(getResultFile("result-PlateReverb-new.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); |
reverb->processSample(samples[0][j], samples[1][j], sampleOutL[index], sampleOutR[index]); |
||||||
|
++index; |
||||||
unsigned indexOut = 0; |
} |
||||||
for (unsigned i = 0; i < nbRepeats; ++i) |
} |
||||||
{ |
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-new.wav", true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); |
||||||
unsigned len = size; |
|
||||||
unsigned indexIn = 0; |
unsigned indexOut = 0; |
||||||
|
for (unsigned i = 0; i < nbRepeats; ++i) |
||||||
while(len > 0) |
{ |
||||||
{ |
unsigned len = size; |
||||||
unsigned grainSize = (len < 1024 ? len : 1024); |
unsigned indexIn = 0; |
||||||
|
|
||||||
reverb->doReverb(samples[0] + indexIn, samples[1] + indexIn, sampleOutL + indexOut, sampleOutR + indexOut, grainSize); |
while(len > 0) |
||||||
|
{ |
||||||
indexIn += grainSize; |
unsigned grainSize = (len < 1024 ? len : 1024); |
||||||
indexOut += grainSize; |
|
||||||
len -= grainSize; |
reverb->doReverb(samples[0] + indexIn, samples[1] + indexIn, sampleOutL + indexOut, sampleOutR + indexOut, grainSize); |
||||||
} |
|
||||||
|
indexIn += grainSize; |
||||||
} |
indexOut += grainSize; |
||||||
saveWaveFile(getResultFile("result-PlateReverb-legacy.wav"), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); |
len -= grainSize; |
||||||
|
} |
||||||
delete[] sampleOutL; |
|
||||||
delete[] sampleOutR; |
} |
||||||
delete[] samples[0]; |
saveWaveFile(getResultFile(full_test_name + ".PlateReverb-legacy.wav", true), sampleOutL, sampleOutR, nbRepeats * size, static_cast<unsigned>(SAMPLING_FREQUENCY), 16); |
||||||
delete[] samples[1]; |
|
||||||
delete[] samples; |
delete[] sampleOutL; |
||||||
|
delete[] sampleOutR; |
||||||
delete reverb; |
delete[] samples[0]; |
||||||
} |
delete[] samples[1]; |
||||||
|
delete[] samples; |
||||||
|
|
||||||
|
delete reverb; |
||||||
|
} |
@ -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