⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tf_reverb.h

📁 一个96K的3D游戏源码
💻 H
字号:

/* ###########################################################################
*
*    ------  /   /  /\   /  /---  -----  /  ----  /   /
*       /   /   /  /  \ /  /---   -/-   /   \--  /---/
*      /    \---  /    /  /---    /    /  ----/ /   /
*
*       t i n y   m u s i c   s y n t h e s i z e r 
* 
* Copyright 2004, Christian Loos
* snej@braincontrol.org
*
* ########################################################################### */

#ifndef TUNEFISH_REVERB_H
#define TUNEFISH_REVERB_H

const int	      NUMCOMBS		      = 8;
const int	      NUMALLPASSES	   = 4;
const float	      MUTED			      = 0;
const float	      FIXEDGAIN		   = 0.015f;
const float       SCALEWET		      = 3;
const float       SCALEDRY		      = 2;
const float       SCALEDAMP		   = 0.4f;
const float       SCALEROOM		   = 0.28f;
const float       OFFSETROOM		   = 0.7f;
const float       INITIALROOM		   = 0.5f;
const float       INITIALDAMP		   = 0.5f;
const float       INITIALWET		   = 1/SCALEWET;
const float       INITIALDRY		   = 0;
const float       INITIALWIDTH	   = 1;
const float       INITIALMODE		   = 0;
const float       FREEZEMODE		   = 0.5f;
const int	      STEREOSPREAD	   = 23;

// These values assume 44.1KHz sample rate
// they will probably be OK for 48KHz sample rate
// but would need scaling for 96KHz (or other) sample rates.
// The values were obtained by listening tests.
const int         COMBTUNINGL1		= 1116;
const int         COMBTUNINGR1		= 1116+STEREOSPREAD;
const int         COMBTUNINGL2		= 1188;
const int         COMBTUNINGR2		= 1188+STEREOSPREAD;
const int         COMBTUNINGL3		= 1277;
const int         COMBTUNINGR3		= 1277+STEREOSPREAD;
const int         COMBTUNINGL4		= 1356;
const int         COMBTUNINGR4		= 1356+STEREOSPREAD;
const int         COMBTUNINGL5		= 1422;
const int         COMBTUNINGR5		= 1422+STEREOSPREAD;
const int         COMBTUNINGL6		= 1491;
const int         COMBTUNINGR6		= 1491+STEREOSPREAD;
const int         COMBTUNINGL7		= 1557;
const int         COMBTUNINGR7		= 1557+STEREOSPREAD;
const int         COMBTUNINGL8		= 1617;
const int         COMBTUNINGR8		= 1617+STEREOSPREAD;
const int         ALLPASSTUNINGL1	= 556;
const int         ALLPASSTUNINGR1	= 556+STEREOSPREAD;
const int         ALLPASSTUNINGL2	= 441;
const int         ALLPASSTUNINGR2	= 441+STEREOSPREAD;
const int         ALLPASSTUNINGL3	= 341;
const int         ALLPASSTUNINGR3	= 341+STEREOSPREAD;
const int         ALLPASSTUNINGL4	= 225;
const int         ALLPASSTUNINGR4	= 225+STEREOSPREAD;

class Reverb : public Filter
{
public:
   Reverb();
   ~Reverb();

   // ---------------------------------------------------------------
   //    Structs
   // ---------------------------------------------------------------

   struct Comb
   {
      float	   m_fltFeedback;
      float	   m_fltFilterstore;
      float	   m_fltDamp1;
      float	   m_fltDamp2;
      float	*  m_fltBuffer;
      int		m_intBufsize;
      int		m_intBufidx;
   };

   struct Allpass
   {
      float	   m_fltFeedback;
      float	*  m_fltBuffer;
      int		m_intBufsize;
      int		m_intBufidx;
   };

   // ---------------------------------------------------------------
   //    Variables
   // ---------------------------------------------------------------

   float	      m_fltGain;
   float	      m_fltRoomsize;
   float       m_fltRoomsize1;
   float	      m_fltDamp;
   float       m_fltDamp1;
   float	      m_fltWet;
   float       m_fltWet1;
   float       m_fltWet2;
   float	      m_fltDry;
   float	      m_fltWidth;
   float	      m_fltMode;

   // Comb filters
   Comb	      m_CombL[NUMCOMBS];
   Comb	      m_CombR[NUMCOMBS];

   // Allpass filters
   Allpass	   m_AllpassL[NUMALLPASSES];
   Allpass	   m_AllpassR[NUMALLPASSES];

   // Buffers for the combs
   float	      m_fltBufcombL1[COMBTUNINGL1];
   float	      m_fltBufcombR1[COMBTUNINGR1];
   float	      m_fltBufcombL2[COMBTUNINGL2];
   float	      m_fltBufcombR2[COMBTUNINGR2];
   float	      m_fltBufcombL3[COMBTUNINGL3];
   float	      m_fltBufcombR3[COMBTUNINGR3];
   float	      m_fltBufcombL4[COMBTUNINGL4];
   float	      m_fltBufcombR4[COMBTUNINGR4];
   float	      m_fltBufcombL5[COMBTUNINGL5];
   float	      m_fltBufcombR5[COMBTUNINGR5];
   float	      m_fltBufcombL6[COMBTUNINGL6];
   float	      m_fltBufcombR6[COMBTUNINGR6];
   float	      m_fltBufcombL7[COMBTUNINGL7];
   float	      m_fltBufcombR7[COMBTUNINGR7];
   float	      m_fltBufcombL8[COMBTUNINGL8];
   float	      m_fltBufcombR8[COMBTUNINGR8];

   // Buffers for the allpasses
   float	      m_fltBufallpassL1[ALLPASSTUNINGL1];
   float	      m_fltBufallpassR1[ALLPASSTUNINGR1];
   float	      m_fltBufallpassL2[ALLPASSTUNINGL2];
   float	      m_fltBufallpassR2[ALLPASSTUNINGR2];
   float	      m_fltBufallpassL3[ALLPASSTUNINGL3];
   float	      m_fltBufallpassR3[ALLPASSTUNINGR3];
   float	      m_fltBufallpassL4[ALLPASSTUNINGL4];
   float	      m_fltBufallpassR4[ALLPASSTUNINGR4];

   // ---------------------------------------------------------------
   //    Functions
   // ---------------------------------------------------------------

   inline float   process_allpass(Allpass *apass, float input);
   inline float   process_comb(Comb *comb, float input);

   void           setup(float roomsize, float damp, float wet, float dry, float width, float mode);
   void           process(DWORD len);
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -