Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Recorder.h
1 #ifndef STK_RECORDER_H
2 #define STK_RECORDER_H
3 
4 #include "Instrmnt.h"
5 #include "Iir.h"
6 #include "DelayL.h"
7 #include "Noise.h"
8 #include "SineWave.h"
9 #include "ADSR.h"
10 
11 namespace stk {
12 
13 /***************************************************/
34 /***************************************************/
35 
36 class Recorder : public Instrmnt
37 {
38  public:
40  Recorder( void );
41 
43  ~Recorder( void );
44 
46  void clear( void );
47 
49  void setFrequency( StkFloat val );
50 
52  void startBlowing( StkFloat amplitude, StkFloat rate );
53 
55  void stopBlowing( StkFloat rate );
56 
58  void noteOn( StkFloat frequency, StkFloat amplitude );
59 
61  void noteOff( StkFloat amplitude );
62 
64  void controlChange( int number, StkFloat value );
65 
67  StkFloat tick( unsigned int channel = 0 );
68 
70 
77  StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
78 
79  void setBlowPressure( StkFloat val );
80  void setVibratoGain( StkFloat val );
81  void setVibratoFrequency( StkFloat val );
82  void setNoiseGain( StkFloat val );
83  void setBreathCutoff( StkFloat val );
84  void setSoftness( StkFloat val );
85 
86  private:
87  DelayL pinDelay_;
88  DelayL poutDelay_;
89  DelayL jetDelay_;
90  Iir radiation_filter_;
91  Iir visco_in_filter_;
92  Iir visco_out_filter_;
93  Iir jetFilter_;
94  Noise turb_;
95  Iir turbFilter_;
96  SineWave vibrato_;
97  ADSR adsr_;
98 
99  //StkFloat M{ 0 };
100  //StkFloat maxPressure_( 0 );
101  double maxPressure_;
102  //StkFloat blow{ 0 };
103  StkFloat vibratoGain_;
104  StkFloat noiseGain_;
105  StkFloat breathCutoff_;
106  StkFloat outputGain_;
107  StkFloat psi_;
108 
109  StkFloat poutL_;
110  StkFloat pout_;
111  StkFloat poutm1_;
112  StkFloat poutm2_;
113  StkFloat pin_;
114  StkFloat pinm1_;
115  StkFloat pinm2_;
116 
117  StkFloat b1;
118  StkFloat b3;
119  StkFloat b4;
120 
121  StkFloat Uj_;
122  StkFloat Ujm1_;
123 
124  StkFloat Qj_;
125  StkFloat Qjm1_;
126  StkFloat Qjm2_;
127 
128  StkFloat Q1_;
129  StkFloat Q1m1_;
130  StkFloat Q1m2_;
131 
132  StkFloat Qp_;
133  StkFloat Qpm1_;
134 
135  StkFloat pm_;
136 };
137 
138 inline StkFrames& Recorder :: tick( StkFrames& frames, unsigned int channel )
139 {
140  unsigned int nChannels = lastFrame_.channels();
141 #if defined(_STK_DEBUG_)
142  if ( channel > frames.channels() - nChannels ) {
143  oStream_ << "Recorder::tick(): channel and StkFrames arguments are incompatible!";
144  handleError( StkError::FUNCTION_ARGUMENT );
145  }
146 #endif
147 
148  StkFloat *samples = &frames[channel];
149  unsigned int j, hop = frames.channels() - nChannels;
150  if ( nChannels == 1 ) {
151  for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
152  *samples++ = tick();
153  }
154  else {
155  for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
156  *samples++ = tick();
157  for ( j=1; j<nChannels; j++ )
158  *samples++ = lastFrame_[j];
159  }
160  }
161 
162  return frames;
163 }
164 
165 } // stk namespace
166 
167 #endif

The Synthesis ToolKit in C++ (STK)
©1995--2019 Perry R. Cook and Gary P. Scavone. All Rights Reserved.