The Synthesis ToolKit in C++ (STK)

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
8namespace 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
stk::Delay
STK non-interpolating delay line class.
Definition: Delay.h:25
stk::Delay::tick
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition: Delay.h:124
stk::Delay::lastOut
StkFloat lastOut(void) const
Return the last computed output value.
Definition: Delay.h:81
stk::Effect
STK abstract effects parent class.
Definition: Effect.h:22
stk::JCRev
John Chowning's reverberator class.
Definition: JCRev.h:32
stk::JCRev::lastOut
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed stereo frame.
Definition: JCRev.h:100
stk::JCRev::JCRev
JCRev(StkFloat T60=1.0)
Class constructor taking a T60 decay time argument (one second default value).
stk::JCRev::setT60
void setT60(StkFloat T60)
Set the reverberation T60 decay time.
stk::JCRev::tick
StkFrames & tick(StkFrames &frames, unsigned int channel=0)
Take a channel of the StkFrames object as inputs to the effect and replace with stereo outputs.
stk::JCRev::clear
void clear(void)
Reset and clear all internal state.
stk::JCRev::tick
StkFrames & tick(StkFrames &iFrames, StkFrames &oFrames, unsigned int iChannel=0, unsigned int oChannel=0)
Take a channel of the iFrames object as inputs to the effect and write stereo outputs to the oFrames ...
stk::JCRev::tick
StkFloat tick(StkFloat input, unsigned int channel=0)
Input one sample to the effect and return the specified channel value of the computed stereo frame.
Definition: JCRev.h:112
stk::OnePole
STK one-pole filter class.
Definition: OnePole.h:21
stk::OnePole::tick
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition: OnePole.h:80
stk::StkFrames
An STK class to handle vectorized audio data.
Definition: Stk.h:279
stk::Stk::handleError
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
stk
The STK namespace.
Definition: ADSR.h:6

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