Naive debugging approach for the mixing console

pull/495/head
Vincent 2 years ago
parent 3f8120d101
commit 1d483dd4f7
  1. 130
      src/mixing_console.hpp
  2. 10
      src/mixing_console_constants.h
  3. 11
      src/test/test_mixing_console.cpp

@ -22,7 +22,6 @@
#pragma once
#include "mixing_console_constants.h"
#include "fx.h"
#include "fx_tube.h"
#include "fx_chorus.h"
#include "fx_flanger.h"
@ -238,6 +237,9 @@ public:
void init()
{
memset(this->channel_level_, 0, nb_inputs * sizeof(float32_t));
for(size_t i = 0; i <= StereoChannels::kNumChannels; ++i) memset(this->pan_[i], 0, nb_inputs * sizeof(float32_t));
for(size_t i = 0; i < MixerOutput::kFXCount; ++i)
memset(this->levels_[i], 0, (nb_inputs + MixerOutput::kFXCount - 1) * sizeof(float32_t));
@ -372,4 +374,130 @@ private:
FXUnit2<AudioEffectPlateReverb>* plate_reverb_;
FXUnit2<ShimmerReverb>* shimmer_reverb_;
FXUnit2<Dry>* dry_;
#if defined(DEBUG)
public:
void dump(std::ostream& out, const std::string& key = "") const
{
std::stringstream ss;
ss.fill(' ');
ss.precision(4);
ss << std::fixed;
out << "\t" << "MixingConsole dump - START - " << key.c_str() << std::endl;
out << "\t" << "Input levels & Pan:" << std::endl;
ss.str("");
ss << std::left;
ss << "\t";
ss.width(11);
ss << "";
ss.width(8);
ss << "Level";
ss.width(8);
ss << "Pan L";
ss.width(8);
ss << "Pan R";
ss.width(8);
ss << "Pan";
out << ss.str() << std::endl;
ss.str("");
for(size_t i = 0; i < nb_inputs; ++i)
{
ss << std::left;
ss << "\t" << "* Input " << (i + 1) << ": ";
ss.precision(4);
ss << std::showpos;
ss << std::fixed;
ss.width(8);
ss << this->channel_level_[i];
ss.width(8);
ss << this->pan_[StereoChannels::Left][i];
ss.width(8);
ss << this->pan_[StereoChannels::Right][i];
ss.width(8);
ss << this->pan_[StereoChannels::kNumChannels][i];
ss << std::endl;
}
out << ss.str() << std::endl;
out << "\t" << "Mixing Console input samples:" << std::endl;
ss.str("");
ss.fill(' ');
ss << std::left;
ss << "\t";
ss.width(11);
ss << "";
for(size_t i = 0; i < nb_inputs; ++i)
{
ss << "Input " << (i + 1) << " ";
}
for(size_t i = 0; i < (MixerOutput::kFXCount - 1); ++i)
{
ss.width(7);
ss << toString(static_cast<MixerOutput>(i)) << " ";
}
out << ss.str() << std::endl;
const char* LR = "LR";
ss.str("");
for(size_t c = 0; c < StereoChannels::kNumChannels; ++c)
{
ss << std::left;
ss << "\t" << "* Input " << LR[c] << ": ";
ss.precision(4);
ss << std::showpos;
ss << std::fixed;
for(size_t i = 0; i < (nb_inputs + MixerOutput::kFXCount - 1); ++i)
{
ss.width(8);
ss << this->input_samples_[c][i];
}
ss << std::endl;
}
out << ss.str() << std::endl;
out << "\t" << "Mixing Console levels:" << std::endl;
ss.str("");
ss << std::left;
ss << "\t";
ss.width(11);
ss << " ";
for(size_t i = 0; i < nb_inputs; ++i)
{
ss << "Input " << (i + 1) << " ";
}
for(size_t i = 0; i < (MixerOutput::kFXCount - 1); ++i)
{
ss.width(7);
ss << toString(static_cast<MixerOutput>(i)) << " ";
}
out << ss.str() << std::endl;
ss.str("");
for(size_t c = 0; c < MixerOutput::kFXCount; ++c)
{
ss << std::left;
ss << "\t";
ss.width(9);
ss << toString(static_cast<MixerOutput>(c));
ss << ": ";
ss.precision(4);
ss << std::showpos;
ss << std::fixed;
for(size_t i = 0; i < (nb_inputs + MixerOutput::kFXCount - 1); ++i)
{
ss.width(8);
ss << this->levels_[c][i];
}
ss << std::endl;
}
out << ss.str() << std::endl;
out << "MixingConsole dump - END - " << key.c_str() << std::endl;
}
#endif
};

@ -28,7 +28,7 @@ enum MixerOutput
kFXCount
};
inline const char* toString(MixerOutput enum_val)
inline std::string toString(MixerOutput enum_val)
{
static constexpr std::array<const char*, MixerOutput::kFXCount> names
{
@ -38,13 +38,13 @@ inline const char* toString(MixerOutput enum_val)
"Orbitone",
"Phaser",
"Delay",
"PlateReverb",
"ShimmerReverb",
"MainOutput"
"Plate Reverb",
"Shimmer Reverb",
"Main Output"
};
static_assert(names.size() == MixerOutput::kFXCount, "Enum MixerOutput and string array size mismatch");
return names[static_cast<size_t>(enum_val)];
return std::string(names[static_cast<size_t>(enum_val)]);
}
inline MixerOutput toIndex(const char* str)

@ -169,11 +169,16 @@ TEST(MixingConsole, DryProcessing)
float32_t out[StereoChannels::kNumChannels][length];
for(size_t i = 0; i < StereoChannels::kNumChannels; ++i) memset(out[i], 0, length * sizeof(float32_t));
mixer->dump(std::cout);
mixer->setInputSampleBuffer(0, in);
mixer->dump(std::cout);
mixer->process(
out[StereoChannels::Left ],
out[StereoChannels::Right]
);
mixer->dump(std::cout);
EXPECT_EQ(out[StereoChannels::Left ][0], out[StereoChannels::Right][0]);
EXPECT_EQ(out[StereoChannels::Left ][1], out[StereoChannels::Right][1]);
EXPECT_LT(std::abs(out[StereoChannels::Left ][0] - (sqrt(2.0f) / 20.0f)), epsilon);
@ -183,20 +188,26 @@ TEST(MixingConsole, DryProcessing)
mixer->setSendLevel(0, MixerOutput::FX_ShimmerReverb, 1.0f);
mixer->setReturnLevel(MixerOutput::FX_ShimmerReverb, MixerOutput::MainOutput, 1.0f);
mixer->setPan(0, 0.5f);
mixer->dump(std::cout);
mixer->setInputSampleBuffer(0, in);
mixer->dump(std::cout);
mixer->process(
out[StereoChannels::Left ],
out[StereoChannels::Right]
);
mixer->dump(std::cout);
float32_t out2[StereoChannels::kNumChannels][length];
mixer->reset();
mixer->dump(std::cout);
mixer->setInputSampleBuffer(0, in);
mixer->dump(std::cout);
mixer->process(
out2[StereoChannels::Left ],
out2[StereoChannels::Right]
);
mixer->dump(std::cout);
EXPECT_EQ(out[StereoChannels::Left ][0], out2[StereoChannels::Left ][0]);
EXPECT_EQ(out[StereoChannels::Left ][1], out2[StereoChannels::Left ][1]);

Loading…
Cancel
Save