CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
35 class AdditiveInstrument : public Instrument {
36 public:
37 AdditiveInstrument(); ///< Constructor
38 AdditiveInstrument(SumOfSines & sos);
39 AdditiveInstrument(unsigned numHarms, float noise);
40 AdditiveInstrument(SHARCSpectrum & spect);
41
42 AdditiveInstrument(AdditiveInstrument&); ///< copy constructor
43 ~AdditiveInstrument();
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
70 class VAdditiveInstrument : public Instrument {
71 public:
72 VAdditiveInstrument(); ///< Constructor
73 VAdditiveInstrument(SumOfSines & sos1, SumOfSines & sos2);
74 VAdditiveInstrument(VAdditiveInstrument&); ///< copy constructor
75 ~VAdditiveInstrument();
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