Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


JCRev.h
1 #ifndef STK_JCREV_H
2 #define STK_JCREV_H
3 
4 #include "Effect.h"
5 #include "Delay.h"
6 #include "OnePole.h"
7 
8 namespace stk {
9 
10 /***************************************************/
29 /***************************************************/
30 
31 class JCRev : public Effect
32 {
33  public:
35  JCRev( StkFloat T60 = 1.0 );
36 
38  void clear( void );
39 
41  void setT60( StkFloat T60 );
42 
44 
52  StkFloat lastOut( unsigned int channel = 0 );
53 
55 
62  StkFloat tick( StkFloat input, unsigned int channel = 0 );
63 
65 
74  StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
75 
77 
86  StkFrames& tick( StkFrames& iFrames, StkFrames &oFrames, unsigned int iChannel = 0, unsigned int oChannel = 0 );
87 
88  protected:
89 
90  Delay allpassDelays_[3];
91  Delay combDelays_[4];
92  OnePole combFilters_[4];
93  Delay outLeftDelay_;
94  Delay outRightDelay_;
95  StkFloat allpassCoefficient_;
96  StkFloat combCoefficient_[4];
97 
98 };
99 
100 inline StkFloat JCRev :: lastOut( unsigned int channel )
101 {
102 #if defined(_STK_DEBUG_)
103  if ( channel > 1 ) {
104  oStream_ << "JCRev::lastOut(): channel argument must be less than 2!";
105  handleError( StkError::FUNCTION_ARGUMENT );
106  }
107 #endif
108 
109  return lastFrame_[channel];
110 }
111 
112 inline StkFloat JCRev :: tick( StkFloat input, unsigned int channel )
113 {
114 #if defined(_STK_DEBUG_)
115  if ( channel > 1 ) {
116  oStream_ << "JCRev::tick(): channel argument must be less than 2!";
117  handleError( StkError::FUNCTION_ARGUMENT );
118  }
119 #endif
120 
121  StkFloat temp, temp0, temp1, temp2, temp3, temp4, temp5, temp6;
122  StkFloat filtout;
123 
124  temp = allpassDelays_[0].lastOut();
125  temp0 = allpassCoefficient_ * temp;
126  temp0 += input;
127  allpassDelays_[0].tick(temp0);
128  temp0 = -(allpassCoefficient_ * temp0) + temp;
129 
130  temp = allpassDelays_[1].lastOut();
131  temp1 = allpassCoefficient_ * temp;
132  temp1 += temp0;
133  allpassDelays_[1].tick(temp1);
134  temp1 = -(allpassCoefficient_ * temp1) + temp;
135 
136  temp = allpassDelays_[2].lastOut();
137  temp2 = allpassCoefficient_ * temp;
138  temp2 += temp1;
139  allpassDelays_[2].tick(temp2);
140  temp2 = -(allpassCoefficient_ * temp2) + temp;
141 
142  temp3 = temp2 + ( combFilters_[0].tick( combCoefficient_[0] * combDelays_[0].lastOut() ) );
143  temp4 = temp2 + ( combFilters_[1].tick( combCoefficient_[1] * combDelays_[1].lastOut() ) );
144  temp5 = temp2 + ( combFilters_[2].tick( combCoefficient_[2] * combDelays_[2].lastOut() ) );
145  temp6 = temp2 + ( combFilters_[3].tick( combCoefficient_[3] * combDelays_[3].lastOut() ) );
146 
147  combDelays_[0].tick(temp3);
148  combDelays_[1].tick(temp4);
149  combDelays_[2].tick(temp5);
150  combDelays_[3].tick(temp6);
151 
152  filtout = temp3 + temp4 + temp5 + temp6;
153 
154  lastFrame_[0] = effectMix_ * (outLeftDelay_.tick(filtout));
155  lastFrame_[1] = effectMix_ * (outRightDelay_.tick(filtout));
156  temp = (1.0 - effectMix_) * input;
157  lastFrame_[0] += temp;
158  lastFrame_[1] += temp;
159 
160  return 0.7 * lastFrame_[channel];
161 }
162 
163 } // stk namespace
164 
165 #endif
166 

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