Arduino STK 4.6.2
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#include "MemoryLoop.h"
10
11namespace stk {
12
13/***************************************************/
36/***************************************************/
37
38class FM : public Instrmnt
39{
40 public:
42
45 FM( unsigned int operators = 4 );
46
48 virtual ~FM( void );
49
51 void loadWaves( const char **filenames );
52
54 virtual void setFrequency( StkFloat frequency );
55
57 void setRatio( unsigned int waveIndex, StkFloat ratio );
58
60 void setGain( unsigned int waveIndex, StkFloat gain );
61
63 void setModulationSpeed( StkFloat mSpeed ) { vibrato_.setFrequency( mSpeed ); };
64
66 void setModulationDepth( StkFloat mDepth ) { modDepth_ = mDepth; };
67
69 void setControl1( StkFloat cVal ) { control1_ = cVal * 2.0f; };
70
72 void setControl2( StkFloat cVal ) { control2_ = cVal * 2.0f; };
73
75 void keyOn( void );
76
78 void keyOff( void );
79
81 void noteOff( StkFloat amplitude );
82
84 virtual void controlChange( int number, StkFloat value );
85
87 virtual StkFloat tick( unsigned int ) = 0;
88
90
97 virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) = 0;
98
99 protected:
100
101 std::vector<ADSR *> adsr_;
102 std::vector<FileLoop *> waves_;
103 SineWave vibrato_;
104 TwoZero twozero_;
105 unsigned int nOperators_;
106 StkFloat baseFrequency_;
107 std::vector<StkFloat> ratios_;
108 std::vector<StkFloat> gains_;
109 StkFloat modDepth_;
110 StkFloat control1_;
111 StkFloat control2_;
112 StkFloat fmGains_[100];
113 StkFloat fmSusLevels_[16];
114 StkFloat fmAttTimes_[32];
115
116};
117
118} // stk namespace
119
120#endif
void setControl1(StkFloat cVal)
Set the value of control1.
Definition FM.h:69
void loadWaves(const char **filenames)
Load the rawwave filenames in waves.
void setModulationDepth(StkFloat mDepth)
Set the modulation depth.
Definition FM.h:66
virtual void controlChange(int number, StkFloat value)
Perform the control change specified by number and value (0.0 - 128.0).
void setModulationSpeed(StkFloat mSpeed)
Set the modulation speed in Hz.
Definition FM.h:63
void noteOff(StkFloat amplitude)
Stop a note with the given amplitude (speed of decay).
void setRatio(unsigned int waveIndex, StkFloat ratio)
Set the frequency ratio for the specified wave.
void setGain(unsigned int waveIndex, StkFloat gain)
Set the gain for the specified wave.
void keyOff(void)
Start envelopes toward "off" targets.
virtual void setFrequency(StkFloat frequency)
Set instrument parameters for a particular frequency.
virtual StkFloat tick(unsigned int)=0
Compute and return one output sample.
virtual ~FM(void)
Class destructor.
virtual StkFrames & tick(StkFrames &frames, unsigned int channel=0)=0
Fill a channel of the StkFrames object with computed outputs.
void setControl2(StkFloat cVal)
Set the value of control1.
Definition FM.h:72
FM(unsigned int operators=4)
Class constructor, taking the number of wave/envelope operators to control.
void keyOn(void)
Start envelopes toward "on" targets.
Instrmnt(void)
Class constructor.
Definition Instrmnt.h:23
STK sinusoid oscillator class.
Definition SineWave.h:26
An STK class to handle vectorized audio data.
Definition Stk.h:287
STK two-zero filter class.
Definition TwoZero.h:21
The STK namespace.
Definition ADSR.h:8