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

📄 tf_synth.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 2003, Christian Loos
* snej@braincontrol.org
*
* ########################################################################### */

#ifndef TUNEFISH_SYNTH_H
#define TUNEFISH_SYNTH_H

class Synth
{
public:
   Synth(Song *song, double *dblEffects);
   ~Synth();

   // ---------------------------------------------------------------
   //    Constants
   // ---------------------------------------------------------------

   static const int PROCSPEED_MINUS_THREE;
   static const int PROCSPEED_MINUS_TWO;
   static const int PROCSPEED_MINUS_ONE;
   static const int PROCSPEED_NORMAL;
   static const int PROCSPEED_PLUS_ONE;
   static const int PROCSPEED_PLUS_TWO;
   static const int PROCSPEED_PLUS_THREE;

   static const float FREQMOD_MINUS_THREE_OCT;
   static const float FREQMOD_MINUS_TWO_OCT;
   static const float FREQMOD_MINUS_ONE_OCT;
   static const float FREQMOD_NORMAL;
   static const float FREQMOD_PLUS_ONE_OCT;
   static const float FREQMOD_PLUS_TWO_OCT;
   static const float FREQMOD_PLUS_THREE_OCT;
  
   // ---------------------------------------------------------------
   //    Structs
   // ---------------------------------------------------------------

   struct SynthRenderData
   {
      BYTE           m_bSpeedCounter;
      double         m_dblTicklength;
      DWORD          m_dwCalcdatalen;

      DWORD          m_WaveSize;
      void *         m_WaveOut;
   };

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

   bool              m_blnSynthRunning;
   bool              m_blnPlayLoop;

   DWORD             m_dwAudioBufferSize;
   DWORD             m_dwSamplesInChanBuffer;

   int               m_intRow;

   float             m_fltGain;

   float             m_fltGlobalFreqMod;
   int               m_intProcSpeed;

   Song *            m_Song;
   Channel **        m_Channels;
   DSP *             m_DSP;
   SynthRenderData * m_RenderData;

   INSTR_CALLBACK    m_CallbackInstr;
   EFFECT_CALLBACK   m_CallbackEffect;

   BYTE              m_bScopeR[64];
   BYTE              m_bScopeL[64];
   BYTE              m_bScopePos;

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

   void              play(float gain, bool loop);
   void              stop();
   bool              render();
   bool              initrender();
   void              exitrender();
   bool              process(bool *more);
   void              setInstrCallback(INSTR_CALLBACK callback);
   void              setEffectCallback(EFFECT_CALLBACK callback);
   void              setNoteProcessingSpeed(int speed);
   void              setGlobalFrequencyModifier(float modifier);
   void              triggerInstrument(unsigned char channel, 
                                       unsigned char note, 
                                       unsigned char instr, 
                                       unsigned char volume,
                                       unsigned char panning);
};

#endif

⌨️ 快捷键说明

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