Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Freeverb Main Loop

The C++ code for the main processing loop of Freeverb is shown in Fig.3.9. Notice that it sums the two stereo input channels to create a mono signal that is fed to the reverberator, which then computes a stereo output signal.

Figure 3.9: Freeverb processing function.

void revmodel::processreplace(float *inputL, float *inputR, 
  float *outputL, float *outputR, long numsamples, int skip)
  float outL,outR,input;
  int i;

  while(numsamples-- > 0)
      outL = outR = 0;
      input = (*inputL + *inputR) * gain;

      // Accumulate comb filters in parallel
      for(i=0; i<numcombs; i++) {
        outL += combL[i].process(input);
        outR += combR[i].process(input);

      // Feed through allpasses in series
      for(i=0; i<numallpasses; i++) {
        outL = allpassL[i].process(outL);
        outR = allpassR[i].process(outR);

      // Calculate output REPLACING anything already there
      *outputL = outL*wet1 + outR*wet2 + *inputL*dry;
      *outputR = outR*wet1 + outL*wet2 + *inputR*dry;

      // Increment sample pointers, allowing for interleave 
      // (if any)
      inputL += skip; // For stereo buffers, skip = 2
      inputR += skip;
      outputL += skip;
      outputR += skip;

From the code in Fig.3.9, we see that the left and right reverberator output channels outL and outR are combined with the left and right input channels inputL and inputR as follows:

$\displaystyle \left[\begin{array}{c} \texttt{outputL} \\ [2pt] \texttt{outputR} \end{array}\right] =
\texttt{dry}\left[\begin{array}{c} \texttt{inputL} \\ [2pt] \texttt{inputR} \end{array}\right] +
\left[\begin{array}{cc} \texttt{wet1} & \texttt{wet2} \\ [2pt] \texttt{wet2} & \texttt{wet1} \end{array}\right]
\left[\begin{array}{c} \texttt{outL} \\ [2pt] \texttt{outR} \end{array}\right]

The dry parameter (initially set to 0 in tuning.h, and typically changed using a graphical user interface (GUI)), determines how much of the original (stereo) input signal is mixed to the output, and wet1 and wet2 determine how much of the reverberated signal is mixed to the output, and also how much ``stereo separation'' occurs in the reverberation. In particular, if $ \texttt{wet1}=\texttt{wet2}$ , there is no stereo separation since the same reverberator output signal is sent to the left and right output channels. (Note that there is no decorrelating delay-line like we saw at the output of JCRev in Fig.3.7.) Setting $ \texttt{wet2}=0$ yields maximally different left and right reverberation signals, thus maximizing ``stereo separation'' in the reverb. The default values, determined by tuning.h and revmodel.cpp, are $ \texttt{wet1}=1$ and $ \texttt{wet2}=0$ .

Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work]  [Order a printed hardcopy]  [Comment on this page via email]

``Physical Audio Signal Processing'', by Julius O. Smith III, W3K Publishing, 2010, ISBN 978-0-9745607-2-4
Copyright © 2024-06-28 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University