The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

NRev.h
1#ifndef STK_NREV_H
2#define STK_NREV_H
3
4#include "Effect.h"
5#include "Delay.h"
6
7namespace stk {
8
9/***************************************************/
23/***************************************************/
24
25 class NRev : public Effect
26{
27 public:
29 NRev( StkFloat T60 = 1.0 );
30
32 void clear( void );
33
35 void setT60( StkFloat T60 );
36
38
46 StkFloat lastOut( unsigned int channel = 0 );
47
49
56 StkFloat tick( StkFloat input, unsigned int channel = 0 );
57
59
68 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
69
71
80 StkFrames& tick( StkFrames& iFrames, StkFrames &oFrames, unsigned int iChannel = 0, unsigned int oChannel = 0 );
81
82 protected:
83
84 Delay allpassDelays_[8];
85 Delay combDelays_[6];
86 StkFloat allpassCoefficient_;
87 StkFloat combCoefficient_[6];
88 StkFloat lowpassState_;
89
90};
91
92 inline StkFloat NRev :: lastOut( unsigned int channel )
93{
94#if defined(_STK_DEBUG_)
95 if ( channel > 1 ) {
96 oStream_ << "NRev::lastOut(): channel argument must be less than 2!";
97 handleError( StkError::FUNCTION_ARGUMENT );
98 }
99#endif
100
101 return lastFrame_[channel];
102}
103
104 inline StkFloat NRev :: tick( StkFloat input, unsigned int channel )
105{
106#if defined(_STK_DEBUG_)
107 if ( channel > 1 ) {
108 oStream_ << "NRev::tick(): channel argument must be less than 2!";
109 handleError( StkError::FUNCTION_ARGUMENT );
110 }
111#endif
112
113 StkFloat temp, temp0, temp1, temp2, temp3;
114 int i;
115
116 temp0 = 0.0;
117 for ( i=0; i<6; i++ ) {
118 temp = input + (combCoefficient_[i] * combDelays_[i].lastOut());
119 temp0 += combDelays_[i].tick(temp);
120 }
121
122 for ( i=0; i<3; i++ ) {
123 temp = allpassDelays_[i].lastOut();
124 temp1 = allpassCoefficient_ * temp;
125 temp1 += temp0;
126 allpassDelays_[i].tick(temp1);
127 temp0 = -(allpassCoefficient_ * temp1) + temp;
128 }
129
130 // One-pole lowpass filter.
131 lowpassState_ = 0.7 * lowpassState_ + 0.3 * temp0;
132 temp = allpassDelays_[3].lastOut();
133 temp1 = allpassCoefficient_ * temp;
134 temp1 += lowpassState_;
135 allpassDelays_[3].tick( temp1 );
136 temp1 = -( allpassCoefficient_ * temp1 ) + temp;
137
138 temp = allpassDelays_[4].lastOut();
139 temp2 = allpassCoefficient_ * temp;
140 temp2 += temp1;
141 allpassDelays_[4].tick( temp2 );
142 lastFrame_[0] = effectMix_*( -( allpassCoefficient_ * temp2 ) + temp );
143
144 temp = allpassDelays_[5].lastOut();
145 temp3 = allpassCoefficient_ * temp;
146 temp3 += temp1;
147 allpassDelays_[5].tick( temp3 );
148 lastFrame_[1] = effectMix_*( - ( allpassCoefficient_ * temp3 ) + temp );
149
150 temp = ( 1.0 - effectMix_ ) * input;
151 lastFrame_[0] += temp;
152 lastFrame_[1] += temp;
153
154 return lastFrame_[channel];
155}
156
157} // stk namespace
158
159#endif
160
stk::Delay
STK non-interpolating delay line class.
Definition Delay.h:25
stk::Effect
STK abstract effects parent class.
Definition Effect.h:22
stk::NRev
CCRMA's NRev reverberator class.
Definition NRev.h:26
stk::NRev::clear
void clear(void)
Reset and clear all internal state.
stk::NRev::NRev
NRev(StkFloat T60=1.0)
Class constructor taking a T60 decay time argument (one second default value).
stk::NRev::setT60
void setT60(StkFloat T60)
Set the reverberation T60 decay time.
stk::NRev::lastOut
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed stereo frame.
Definition NRev.h:92
stk::NRev::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::NRev::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 NRev.h:104
stk::NRev::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::StkFrames
An STK class to handle vectorized audio data.
Definition Stk.h:279
stk
The STK namespace.
Definition ADSR.h:6

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