DSP.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * DSP.h
  3. * -----
  4. * Purpose: Mixing code for various DSPs (EQ, Mega-Bass, ...)
  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. OPENMPT_NAMESPACE_BEGIN
  13. #ifndef NO_DSP
  14. // Buffer Sizes
  15. #define SURROUNDBUFFERSIZE 2048 // 50ms @ 48kHz
  16. class CSurroundSettings
  17. {
  18. public:
  19. uint32 m_nProLogicDepth;
  20. uint32 m_nProLogicDelay;
  21. public:
  22. CSurroundSettings();
  23. };
  24. class CMegaBassSettings
  25. {
  26. public:
  27. uint32 m_nXBassDepth;
  28. uint32 m_nXBassRange;
  29. public:
  30. CMegaBassSettings();
  31. };
  32. struct BitCrushSettings
  33. {
  34. int m_Bits;
  35. BitCrushSettings();
  36. };
  37. class CSurround
  38. {
  39. public:
  40. CSurroundSettings m_Settings;
  41. // Surround Encoding: 1 delay line + low-pass filter + high-pass filter
  42. int32 nSurroundSize;
  43. int32 nSurroundPos;
  44. int32 nDolbyDepth;
  45. // Surround Biquads
  46. int32 nDolbyHP_Y1;
  47. int32 nDolbyHP_X1;
  48. int32 nDolbyLP_Y1;
  49. int32 nDolbyHP_B0;
  50. int32 nDolbyHP_B1;
  51. int32 nDolbyHP_A1;
  52. int32 nDolbyLP_B0;
  53. int32 nDolbyLP_B1;
  54. int32 nDolbyLP_A1;
  55. int32 SurroundBuffer[SURROUNDBUFFERSIZE];
  56. public:
  57. CSurround();
  58. public:
  59. void SetSettings(const CSurroundSettings &settings) { m_Settings = settings; }
  60. // [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100]
  61. bool SetXBassParameters(uint32 nDepth, uint32 nRange);
  62. // [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms]
  63. void SetSurroundParameters(uint32 nDepth, uint32 nDelay);
  64. void Initialize(bool bReset, DWORD MixingFreq);
  65. void Process(int * MixSoundBuffer, int * MixRearBuffer, int count, uint32 nChannels);
  66. private:
  67. void ProcessStereoSurround(int * MixSoundBuffer, int count);
  68. void ProcessQuadSurround(int * MixSoundBuffer, int * MixRearBuffer, int count);
  69. };
  70. class CMegaBass
  71. {
  72. public:
  73. CMegaBassSettings m_Settings;
  74. // Bass Expansion: low-pass filter
  75. int32 nXBassFlt_Y1;
  76. int32 nXBassFlt_X1;
  77. int32 nXBassFlt_B0;
  78. int32 nXBassFlt_B1;
  79. int32 nXBassFlt_A1;
  80. // DC Removal Biquad
  81. int32 nDCRFlt_Y1lf;
  82. int32 nDCRFlt_X1lf;
  83. int32 nDCRFlt_Y1rf;
  84. int32 nDCRFlt_X1rf;
  85. int32 nDCRFlt_Y1lb;
  86. int32 nDCRFlt_X1lb;
  87. int32 nDCRFlt_Y1rb;
  88. int32 nDCRFlt_X1rb;
  89. public:
  90. CMegaBass();
  91. public:
  92. void SetSettings(const CMegaBassSettings &settings) { m_Settings = settings; }
  93. // [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100]
  94. void SetXBassParameters(uint32 nDepth, uint32 nRange);
  95. void Initialize(bool bReset, DWORD MixingFreq);
  96. void Process(int * MixSoundBuffer, int * MixRearBuffer, int count, uint32 nChannels);
  97. };
  98. class BitCrush
  99. {
  100. public:
  101. BitCrushSettings m_Settings;
  102. public:
  103. BitCrush();
  104. public:
  105. void SetSettings(const BitCrushSettings &settings) { m_Settings = settings; }
  106. void Initialize(bool bReset, DWORD MixingFreq);
  107. void Process(int * MixSoundBuffer, int * MixRearBuffer, int count, uint32 nChannels);
  108. };
  109. #endif // NO_DSP
  110. OPENMPT_NAMESPACE_END