Debian Codegraph @

lib-src/libnyquist/nyquist/nyqstk/include/Flute.h

raw
1 /***************************************************/
2 /*! \class Flute
3 \brief STK flute physical model class.
4
5 This class implements a simple flute
6 physical model, as discussed by Karjalainen,
7 Smith, Waryznyk, etc. The jet model uses
8 a polynomial, a la Cook.
9
10 This is a digital waveguide model, making its
11 use possibly subject to patents held by Stanford
12 University, Yamaha, and others.
13
14 Control Change Numbers:
15 - Jet Delay = 2
16 - Noise Gain = 4
17 - Vibrato Frequency = 11
18 - Vibrato Gain = 1
19 - Breath Pressure = 128
20
21 by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
22 */
23 /***************************************************/
24
25 #ifndef STK_FLUTE_H
26 #define STK_FLUTE_H
27
28 #include "Instrmnt.h"
29 #include "JetTable.h"
30 #include "DelayL.h"
31 #include "OnePole.h"
32 #include "PoleZero.h"
33 #include "Noise.h"
34 #include "ADSR.h"
35 #include "SineWave.h"
36
37 namespace Nyq
38 {
39
40 class Flute : public Instrmnt
41 {
42 public:
43 //! Class constructor, taking the lowest desired playing frequency.
44 /*!
45 An StkError will be thrown if the rawwave path is incorrectly set.
46 */
47 Flute(StkFloat lowestFrequency);
48
49 //! Class destructor.
50 ~Flute();
51
52 //! Reset and clear all internal state.
53 void clear();
54
55 //! Set instrument parameters for a particular frequency.
56 void setFrequency(StkFloat frequency);
57
58 //! Set the reflection coefficient for the jet delay (-1.0 - 1.0).
59 void setJetReflection(StkFloat coefficient);
60
61 //! Set the reflection coefficient for the air column delay (-1.0 - 1.0).
62 void setEndReflection(StkFloat coefficient);
63
64 //! Set the length of the jet delay in terms of a ratio of jet delay to air column delay lengths.
65 void setJetDelay(StkFloat aRatio);
66
67 //! Apply breath velocity to instrument with given amplitude and rate of increase.
68 void startBlowing(StkFloat amplitude, StkFloat rate);
69
70 //! Decrease breath velocity with given rate of decrease.
71 void stopBlowing(StkFloat rate);
72
73 //! Start a note with the given frequency and amplitude.
74 void noteOn(StkFloat frequency, StkFloat amplitude);
75
76 //! Stop a note with the given amplitude (speed of decay).
77 void noteOff(StkFloat amplitude);
78
79 //! Perform the control change specified by \e number and \e value (0.0 - 128.0).
80 void controlChange(int number, StkFloat value);
81
82 protected:
83
84 StkFloat computeSample( void );
85
86 DelayL jetDelay_;
87 DelayL boreDelay_;
88 JetTable jetTable_;
89 OnePole filter_;
90 PoleZero dcBlock_;
91 Noise noise_;
92 ADSR adsr_;
93 SineWave vibrato_;
94 unsigned long length_;
95 StkFloat lastFrequency_;
96 StkFloat maxPressure_;
97 StkFloat jetReflection_;
98 StkFloat endReflection_;
99 StkFloat noiseGain_;
100 StkFloat vibratoGain_;
101 StkFloat outputGain_;
102 StkFloat jetRatio_;
103
104 };
105
106 } // namespace Nyq
107
108 #endif