📄 tf_main.h
字号:
/* ###########################################################################
*
* ------ / / /\ / /--- ----- / ---- / /
* / / / / \ / /--- -/- / \-- /---/
* / \--- / / /--- / / ----/ / /
*
* t i n y m u s i c s y n t h e s i z e r
*
* TuneFish v0.9.5 - March 2004
*
* Copyright 2004, Christian Loos
* snej@braincontrol.org
*
* Additional Credits:
* - Using Freeverb code by Jezar at Dreampoint - http://www.dreampoint.co.uk
* - Using FFT code by Stephan M. Sprenger
*
* ########################################################################### */
#ifndef TUNEFISH_MAIN_H
#define TUNEFISH_MAIN_H
#ifdef _WIN32
#include <windows.h>
#include <dsound.h>
#else
#include <pthread.h>
#include <SDL/SDL.h>
#endif
#include <cmath>
#include <time.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
//#include "mmgr.h"
namespace Tunefish
{
#include "tf_config.h"
// ####################################################################################################
//
// DEFINES
//
// ####################################################################################################
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MID(x,y,z) MAX((x), MIN((y), (z)))
#define SIGN(x) (x<0.0f) ? -1.0f : ((x>0.0f) ? 1.0f : 0.0f)
#define UNDENORMALISE(sample) if(((*(unsigned int*)&sample)&0x7f800000)==0) sample=0.0f
// ####################################################################################################
//
// TYPEDEFS
//
// ####################################################################################################
#ifndef _WIN32
typedef int HWND;
#endif
//typedef unsigned char BYTE;
//typedef unsigned short WORD;
//typedef unsigned long DWORD;
typedef signed char SBYTE;
typedef signed short SWORD;
typedef signed long SDWORD;
typedef void (* INSTR_CALLBACK)(BYTE instr);
typedef void (* EFFECT_CALLBACK)(BYTE effect, BYTE param);
// ####################################################################################################
//
// CONSTANTS
//
// ####################################################################################################
static const DWORD FREQUENCY = 44100;
static const DWORD CHANNELS = 2;
static const DWORD BITS = 16;
static const DWORD BYTES_PER_SEC = FREQUENCY*CHANNELS*(BITS/8);
static const DWORD BYTES_PER_SAM = CHANNELS*(BITS/8);
static const DWORD DSP_BLOCKSIZE = 2048;
static const float DSP_TIMESPAN = 1.0f/((float)FREQUENCY/(float)DSP_BLOCKSIZE);
static const DWORD DSPBLOCKS_PER_SEC = 16;
static const float PI = 3.1415926535897932384626433832795f;
static const float PI2 = PI * 2.0f;
static const float PI2_FREQUENCY_2 = PI2 / FREQUENCY / 2;
static const float PI_SQUARED = PI * PI;
//static const DWORD PI2_DW = (DWORD)(PI2*100000000);
static const int EQ_NUM_BANDS = 6;
static const int COMBINE_ADD = 1;
static const int COMBINE_MUL = 2;
// ####################################################################################################
//
// CLASSES
//
// ####################################################################################################
class Synth;
class Song;
class State;
class Channel;
class Generator;
class DSP;
class Filter;
class XDelay;
class Reverb;
class Chorus;
class Phaser;
class Distort;
class Waveshaper;
class ParamEQ;
class Lowpass;
class Highpass;
class Bandpass;
class Surround;
class Gain;
// ####################################################################################################
//
// FUNCTIONS
//
// ####################################################################################################
#if defined ( __sun ) && defined ( __SVR4 )
inline float fmodf(float v1, float v2)
{
return (float)fmod((double)v1, (double)v2);
}
inline float powf(float v1, float v2)
{
return (float)pow((double)v1, (double)v2);
}
#endif
#if defined (_M_IX86) && defined (_WIN32)
inline int float2int(float f)
{
int i;
_asm fld dword ptr f
_asm fistp dword ptr i
return i;
}
#else
inline int float2int(float f)
{
return (int)f;
}
#endif
inline unsigned short noteToFrequency(unsigned char note)
{
return (unsigned short)((440.0f / 32.0f) * pow(2.0f,((float)note - 9.0f) / 12.0f));
}
void create_lookup_tables();
// ####################################################################################################
//
// INCLUDES
//
// ####################################################################################################
#include "tf_filter.h"
#include "tf_bandpass.h"
#include "tf_chorus.h"
#include "tf_distort.h"
#include "tf_gain.h"
#include "tf_highpass.h"
#include "tf_lowpass.h"
#include "tf_parameq.h"
#include "tf_phaser.h"
#include "tf_reverb.h"
#include "tf_surround.h"
#include "tf_waveshaper.h"
#include "tf_xdelay.h"
#include "tf_dsp.h"
#include "tf_generator.h"
#include "tf_channel.h"
#include "tf_state.h"
#include "tf_song.h"
#include "tf_soundout.h"
#include "tf_synth.h"
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -