The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

FM.h
1#ifndef STK_FM_H
2#define STK_FM_H
3
4#include "Instrmnt.h"
5#include "ADSR.h"
6#include "FileLoop.h"
7#include "SineWave.h"
8#include "TwoZero.h"
9
10namespace stk {
11
12/***************************************************/
35/***************************************************/
36
37 class FM : public Instrmnt
38{
39 public:
41
44 FM( unsigned int operators = 4 );
45
47 virtual ~FM( void );
48
50 void loadWaves( const char **filenames );
51
53 virtual void setFrequency( StkFloat frequency );
54
56 void setRatio( unsigned int waveIndex, StkFloat ratio );
57
59 void setGain( unsigned int waveIndex, StkFloat gain );
60
62 void setModulationSpeed( StkFloat mSpeed ) { vibrato_.setFrequency( mSpeed ); };
63
65 void setModulationDepth( StkFloat mDepth ) { modDepth_ = mDepth; };
66
68 void setControl1( StkFloat cVal ) { control1_ = cVal * 2.0; };
69
71 void setControl2( StkFloat cVal ) { control2_ = cVal * 2.0; };
72
74 void keyOn( void );
75
77 void keyOff( void );
78
80 void noteOff( StkFloat amplitude );
81
83 virtual void controlChange( int number, StkFloat value );
84
86 virtual StkFloat tick( unsigned int ) = 0;
87
89
96 virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) = 0;
97
98 protected:
99
100 std::vector<ADSR *> adsr_;
101 std::vector<FileLoop *> waves_;
102 SineWave vibrato_;
103 TwoZero twozero_;
104 unsigned int nOperators_;
105 StkFloat baseFrequency_;
106 std::vector<StkFloat> ratios_;
107 std::vector<StkFloat> gains_;
108 StkFloat modDepth_;
109 StkFloat control1_;
110 StkFloat control2_;
111 StkFloat fmGains_[100];
112 StkFloat fmSusLevels_[16];
113 StkFloat fmAttTimes_[32];
114
115};
116
117} // stk namespace
118
119#endif
stk::FM
STK abstract FM synthesis base class.
Definition: FM.h:38
stk::FM::setControl1
void setControl1(StkFloat cVal)
Set the value of control1.
Definition: FM.h:68
stk::FM::loadWaves
void loadWaves(const char **filenames)
Load the rawwave filenames in waves.
stk::FM::setModulationDepth
void setModulationDepth(StkFloat mDepth)
Set the modulation depth.
Definition: FM.h:65
stk::FM::controlChange
virtual void controlChange(int number, StkFloat value)
Perform the control change specified by number and value (0.0 - 128.0).
stk::FM::setModulationSpeed
void setModulationSpeed(StkFloat mSpeed)
Set the modulation speed in Hz.
Definition: FM.h:62
stk::FM::noteOff
void noteOff(StkFloat amplitude)
Stop a note with the given amplitude (speed of decay).
stk::FM::setRatio
void setRatio(unsigned int waveIndex, StkFloat ratio)
Set the frequency ratio for the specified wave.
stk::FM::setGain
void setGain(unsigned int waveIndex, StkFloat gain)
Set the gain for the specified wave.
stk::FM::keyOff
void keyOff(void)
Start envelopes toward "off" targets.
stk::FM::setFrequency
virtual void setFrequency(StkFloat frequency)
Set instrument parameters for a particular frequency.
stk::FM::tick
virtual StkFloat tick(unsigned int)=0
Compute and return one output sample.
stk::FM::~FM
virtual ~FM(void)
Class destructor.
stk::FM::tick
virtual StkFrames & tick(StkFrames &frames, unsigned int channel=0)=0
Fill a channel of the StkFrames object with computed outputs.
stk::FM::setControl2
void setControl2(StkFloat cVal)
Set the value of control1.
Definition: FM.h:71
stk::FM::FM
FM(unsigned int operators=4)
Class constructor, taking the number of wave/envelope operators to control.
stk::FM::keyOn
void keyOn(void)
Start envelopes toward "on" targets.
stk::Instrmnt
STK instrument abstract base class.
Definition: Instrmnt.h:20
stk::SineWave
STK sinusoid oscillator class.
Definition: SineWave.h:26
stk::SineWave::setFrequency
void setFrequency(StkFloat frequency)
Set the data interpolation rate based on a looping frequency.
stk::StkFrames
An STK class to handle vectorized audio data.
Definition: Stk.h:279
stk::TwoZero
STK two-zero filter class.
Definition: TwoZero.h:21
stk
The STK namespace.
Definition: ADSR.h:6

The Synthesis ToolKit in C++ (STK)
©1995--2021 Perry R. Cook and Gary P. Scavone. All Rights Reserved.