CSL  6.0
BasicFMInstrument.h
Go to the documentation of this file.
1 ///
2 /// BasicFMInstrument.h -- Simple and fancy FM example instrument classes.
3 /// See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 ///
5 /// This instrument implements single-operator FM with ADSR envelopes for the
6 /// amplitude and modulation index envelopes; it provides 13 parameter accessors
7 /// for use by OSC.
8 ///
9 /// Accessors
10 /// "du", set_duration_f
11 /// "am", set_amplitude_f
12 /// "in", set_index_f
13 /// "cf", set_c_freq_f
14 /// "mf", set_m_freq_f
15 /// "po", set_position_f
16 /// "aa", set_attack_f -- amplitude envelope ADSR
17 /// "ad", set_decay_f
18 /// "as", set_sustain_f
19 /// "ar", set_release_f
20 /// "ia", set_iattack_f -- mod. index envelope ADSR
21 /// "id", set_idecay_f
22 /// "is", set_isustain_f
23 /// "ir", set_irelease_f
24 ///
25 /// OSC note formats (6 or 14 arguments):
26 /// dur, ampl, c_fr, m_fr, ind, pos
27 /// dur, ampl, c_fr, m_fr, ind, pos, att, dec, sus, rel, i_att, i_dec, i_sus, i_rel
28 
29 #ifndef INCLUDE_Basic_FM_Instrument_H
30 #define INCLUDE_Basic_FM_Instrument_H
31 
32 #include "Instrument.h"
33 #include "Mixer.h"
34 
35 namespace csl {
36 
37 ///
38 /// FMInstrument
39 ///
40 class FMInstrument : public Instrument {
41 public:
42  FMInstrument(); ///< Constructor
43  FMInstrument(FMInstrument&); ///< copy constructor
44  ~FMInstrument();
45  /// Plug functions
46  virtual void setParameter(unsigned selector, int argc, void **argv, const char *types);
47  /// Play functions
48  void parseArgs(int argc, void **argv, const char *types);
49  virtual void playOSC(int argc, void **argv, const char *types);
50 
51  void playNote(float dur = 1, float ampl = 1,
52  float c_fr = 110, float m_fr = 110, float ind = 1, float pos = 0,
53  float att = 0.1, float dec = 0.1, float sus = 0.5, float rel = 0.1,
54  float i_att = 0.1, float i_dec = 0.1, float i_sus = 0.5, float i_rel = 0.1);
55  void playMIDI(float dur, int chan, int key, int vel);
56 
57  ///< These are the UGens of the DSP graph (i.e., the FM instrument)
58  ADSR mAEnv, mIEnv; ///< amplitude & modulation index envelopes
59  Osc mCar, mMod; ///< 2 sine oscillators, carrier and modulator
60  Panner mPanner; ///< stereo panner
61 };
62 
63 ///
64 /// FancyFMInstrument - FM with vibrato (with AR-envelope), attack chiff (filtered noise with AR-envelope),
65 /// and random freq. drift and ampl. swell envelopes
66 ///
68 public:
69  FancyFMInstrument(); ///< Constructor
71 
72  void setParameter(unsigned selector, int argc, void **argv, const char *types);
73  void playOSC(int argc, void **argv, const char *types);
74  void playMIDI(float dur, int chan, int key, int vel);
75  ///< These are the additional UGens of the DSP graph (i.e., the FM instrument)
76  Envelope mVibEnv; ///< vibrato envelope
77  ADSR mChiffEnv; ///< attack-chiff envelope
78  Osc mVibrato; ///< sine oscillator for vibrato
79  WhiteNoise mChiff; ///< chiff noise
80  Butter mChFilter; ///< chiff filter
82 };
83 
84 }
85 
86 #endif
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
void setParameter(unsigned selector, int argc, void **argv, const char *types)
Plug functions.
virtual void setParameter(unsigned selector, int argc, void **argv, const char *types)
Plug functions.
FancyFMInstrument()
Constructor.
void parseArgs(int argc, void **argv, const char *types)
Play functions.
White noise – equal power per frequency.
Definition: Noise.h:45
Butter mChFilter
chiff filter
virtual void playOSC(int argc, void **argv, const char *types)
WhiteNoise mChiff
chiff noise
FMInstrument.
Osc mVibrato
sine oscillator for vibrato
ADSR mIEnv
amplitude & modulation index envelopes
#define Osc
Definition: CSL_Types.h:169
CSL port of the public domain Freeverb reverberator.
Definition: Freeverb.h:23
ADSR = 4-segment attack/decay/sustain/release envelope class.
Definition: Envelope.h:153
Instrument class (abstract)
Definition: Instrument.h:56
FancyFMInstrument - FM with vibrato (with AR-envelope), attack chiff (filtered noise with AR-envelope...
void playMIDI(float dur, int chan, int key, int vel)
These are the additional UGens of the DSP graph (i.e., the FM instrument)
Butterworth IIR (2nd order recursive) filter.
Definition: Filters.h:137
Osc mMod
2 sine oscillators, carrier and modulator
void playNote(float dur=1, float ampl=1, float c_fr=110, float m_fr=110, float ind=1, float pos=0, float att=0.1, float dec=0.1, float sus=0.5, float rel=0.1, float i_att=0.1, float i_dec=0.1, float i_sus=0.5, float i_rel=0.1)
FMInstrument()
Constructor.
The CSL mono-to-stereo L/R panner class.
Definition: Mixer.h:66
Panner mPanner
stereo panner
void playMIDI(float dur, int chan, int key, int vel)
These are the UGens of the DSP graph (i.e., the FM instrument)
Envelope mVibEnv
vibrato envelope
ADSR mChiffEnv
attack-chiff envelope
Envelope: a collection of LineSegments; may have an input (scale) and act like a processor, or have no input and act like a control UGen. I inherit Scalable setScale, setOffset for inputs.
Definition: Envelope.h:89
void playOSC(int argc, void **argv, const char *types)