📄 tf_generator.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_GENERATOR_H
#define TUNEFISH_GENERATOR_H
const int WF_OFF = 0;
const int WF_SINE = 1;
const int WF_SAWTOOTH = 2;
const int WF_SQUAREWAVE = 3;
const int WF_TRIANGLE = 4;
const int WF_WHITENOISE = 5;
const int WF_PINKNOISE = 6;
class Generator
{
public:
Generator();
~Generator();
// ---------------------------------------------------------------
// Structs
// ---------------------------------------------------------------
struct Oscillator
{
bool m_blnActive; // Active?
BYTE m_bCombiner; // Combine method (COMBINE_ADD or COMBINE_MUL)
float m_fltAmplitude; // Amplitude ( 0.0 to 1.0 )
BYTE m_bAmpLFO; // Amplitude LFO No. (0=off)
float m_fltStartPitch; // Start pitch ( 0 = dependent to note )
float m_fltPitchMod; // Pitch Mod.
BYTE m_bPitchLFO; // Pitch LFO No. (0=off)
float m_fltPitchStep; // Pitch frequency step
float m_fltPitchStepAcc; // Pitch frequency step accelleration
BYTE m_bWaveform; // Waveform
float m_fltPanning; // Panning (-1.0 to 1.0)
BYTE m_bPanningLFO; // Panning LFO No. (0=off)
float m_fltPhaseShiftL; // Phase shift left (0.0 - 1.0)
float m_fltPhaseShiftR; // Phase shift left (0.0 - 1.0)
float m_fltPulseWidth; // Pulse width for WF_SQUAREWAVE
BYTE m_bPulseWidthLFO; // Pulse width LFO
};
struct LFO
{
BYTE m_bWaveform;
bool m_blnResetWithNote;
float m_fltRate;
float m_fltDepth;
};
struct GFilter
{
bool m_blnFActive; // Filter active?
WORD m_wCutoff; // Frequency cutoff (Hz)
float m_fltResonance; // Resonance ( 0.0 to 1.0 )
BYTE m_bCutoffLFO; // Cutoff LFO No.
BYTE m_bResonanceLFO; // Resonance LFO No.
};
// ---------------------------------------------------------------
// Variables
// ---------------------------------------------------------------
// Oscillators
Oscillator m_O[3];
// Amplitude Parameters
bool m_blnContinuous; // Continuous tone?
float m_fltAttack; // Attack (ms)
float m_fltDecay; // Decay (ms)
float m_fltSustain; // Sustain (ms)
float m_fltRelease; // Release (ms)
float m_fltSustainAmp; // Sustain Amplitude ( 0.0 to 1.0 )
// Filters
GFilter m_Lowpass;
GFilter m_Highpass;
// LFOs
LFO m_LFO[6];
// Distortion
BYTE m_bDistortion;
// Gain
float m_fltGain;
// ---------------------------------------------------------------
// Functions
// ---------------------------------------------------------------
void processLFOs(Channel *channel, float *fltLFO);
bool process(Channel *channel, DWORD len, float globalfreqmod);
static inline float waveform_sine(float pos);
static inline float waveform_sawtooth(float pos);
static inline float waveform_squarewave(float pos, float width);
static inline float waveform_triangle(float pos);
static inline float waveform_whitenoise(float pos);
static inline float waveform_pinknoise(float pos);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -