EQ.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * EQ.h
  3. * ----
  4. * Purpose: Mixing code for equalizer.
  5. * Notes : Ugh... This should really be removed at some point.
  6. * Authors: Olivier Lapicque
  7. * OpenMPT Devs
  8. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  9. */
  10. #pragma once
  11. #include "openmpt/all/BuildSettings.hpp"
  12. #include "openmpt/base/Types.hpp"
  13. #include "openmpt/soundbase/MixSample.hpp"
  14. #include <array>
  15. #include <cstddef>
  16. OPENMPT_NAMESPACE_BEGIN
  17. #ifndef NO_EQ
  18. inline constexpr std::size_t MAX_EQ_CHANNELS = 4;
  19. inline constexpr std::size_t MAX_EQ_BANDS = 6;
  20. struct EQBANDSTATE
  21. {
  22. float x1 = 0.0f;
  23. float x2 = 0.0f;
  24. float y1 = 0.0f;
  25. float y2 = 0.0f;
  26. };
  27. struct EQBANDSETTINGS
  28. {
  29. float a0;
  30. float a1;
  31. float a2;
  32. float b1;
  33. float b2;
  34. float Gain;
  35. float CenterFrequency;
  36. };
  37. class CEQ
  38. {
  39. private:
  40. std::array<std::array<EQBANDSTATE, MAX_EQ_BANDS>, MAX_EQ_CHANNELS> m_ChannelState;
  41. std::array<EQBANDSETTINGS, MAX_EQ_BANDS> m_Bands;
  42. template <typename TMixSample>
  43. void ProcessTemplate(TMixSample *frontBuffer, TMixSample *rearBuffer, std::size_t countFrames, std::size_t numChannels);
  44. public:
  45. CEQ();
  46. void Initialize(bool bReset, uint32 MixingFreq);
  47. void Process(MixSampleInt *frontBuffer, MixSampleInt *rearBuffer, std::size_t countFrames, std::size_t numChannels);
  48. void Process(MixSampleFloat *frontBuffer, MixSampleFloat *rearBuffer, std::size_t countFrames, std::size_t numChannels);
  49. void SetEQGains(const uint32 *pGains, const uint32 *pFreqs, bool bReset, uint32 MixingFreq);
  50. };
  51. #endif // !NO_EQ
  52. OPENMPT_NAMESPACE_END