CSL  6.0
AdditiveInstrument.h
Go to the documentation of this file.
1 ///
2 /// AdditiveInstrument.h -- Sum-of-sines synthesis instrument class.
3 ///
4 /// See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 ///
6 ///
7 /// Accessors
8 /// "du", set_duration_f
9 /// "am", set_amplitude_f
10 /// "fr", set_freq_f
11 /// "po", set_position_f
12 /// "aa", set_attack_f -- amplitude envelope ADSR
13 /// "ad", set_decay_f
14 /// "as", set_sustain_f
15 /// "re", set_release_f
16 /// "pt", set_partial_f
17 /// "ps", set_partials_f
18 ///
19 /// OSC note formats (4 or 8 arguments):
20 /// dur, ampl, c_fr, pos
21 /// dur, ampl, c_fr, pos, att, dec, sus, rel
22 
23 #ifndef INCLUDE_ADDITIVE_Instrument_H
24 #define INCLUDE_ADDITIVE_Instrument_H
25 
26 #include "Instrument.h"
27 #include "Mixer.h"
28 
29 namespace csl {
30 
31 ///
32 /// AdditiveInstrument
33 ///
34 
36 public:
37  AdditiveInstrument(); ///< Constructor
39  AdditiveInstrument(unsigned numHarms, float noise);
41 
42  AdditiveInstrument(AdditiveInstrument&); ///< copy constructor
44  /// Plug functions
45  void setParameter(unsigned selector, int argc, void **argv, const char *types);
46  /// Play functions
47  void playOSC(int argc, void **argv, const char *types);
48 
49  void playNote(float dur = 1, float ampl = 1,
50  float c_fr = 110, float pos = 0,
51  float att = 0.05, float dec = 0.05, float sus = 0.5, float rel = 0.5);
52  void playMIDI(float dur, int chan, int key, int vel);
53 
54  ADSR mAEnv; ///< amplitude envelope
55  SumOfSines mSOS; ///< sum-of-sine oscillator
56  Panner mPanner; ///< stereo panner
57 
58 protected:
59  void init();
60 };
61 
62 ///
63 /// VAdditiveInstrument = vector-additive - cross-fade between 2 SOS spectra
64 /// Envelope mXEnv(dur, pause, xfade, 0.0f)
65 /// float paus = fRandV(0.5) * dur;
66 /// float fade = fRandV(dur - paus);
67 /// AR(float t, float i, float a, float r);
68 ///
69 
71 public:
72  VAdditiveInstrument(); ///< Constructor
74  VAdditiveInstrument(VAdditiveInstrument&); ///< copy constructor
76  /// Plug functions
77  void setParameter(unsigned selector, int argc, void **argv, const char *types);
78  /// Play functions
79  void playOSC(int argc, void **argv, const char *types);
80 
81  void playNote(float dur = 1, float ampl = 1,
82  float c_fr = 110, float pos = 0,
83  float att = 0.05, float dec = 0.05, float sus = 0.5, float rel = 0.5);
84  void playMIDI(float dur, int chan, int key, int vel);
85 
86  ADSR mAEnv; ///< amplitude envelope
87  AR mXEnv; ///< cross-fade envelope, AR with init delay
88  SumOfSines mSOS1, mSOS2; ///< 2 sum-of-sine oscillators
89  Panner mPanner; ///< stereo panner
90 };
91 
92 }
93 
94 #endif
void playOSC(int argc, void **argv, const char *types)
Play functions.
Panner mPanner
stereo panner
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
void playOSC(int argc, void **argv, const char *types)
Play functions.
AdditiveInstrument.
VAdditiveInstrument()
Constructor.
AR mXEnv
cross-fade envelope, AR with init delay
void playMIDI(float dur, int chan, int key, int vel)
void playNote(float dur=1, float ampl=1, float c_fr=110, float pos=0, float att=0.05, float dec=0.05, float sus=0.5, float rel=0.5)
ADSR mAEnv
amplitude envelope
SumOfSines mSOS
sum-of-sine oscillator
Panner mPanner
stereo panner
ADSR mAEnv
amplitude envelope
ADSR = 4-segment attack/decay/sustain/release envelope class.
Definition: Envelope.h:153
Instrument class (abstract)
Definition: Instrument.h:56
void setParameter(unsigned selector, int argc, void **argv, const char *types)
Plug functions.
void setParameter(unsigned selector, int argc, void **argv, const char *types)
Plug functions.
void playMIDI(float dur, int chan, int key, int vel)
void playNote(float dur=1, float ampl=1, float c_fr=110, float pos=0, float att=0.05, float dec=0.05, float sus=0.5, float rel=0.5)
AR = 3-segment attack/release envelope class.
Definition: Envelope.h:199
The CSL mono-to-stereo L/R panner class.
Definition: Mixer.h:66
VAdditiveInstrument = vector-additive - cross-fade between 2 SOS spectra Envelope mXEnv(dur...
SHARC spectrum class.
Definition: SHARC.h:76
SumOfSines mSOS2
2 sum-of-sine oscillators