/* Copyright (c) 1992 - Rick A. Vander Kam - All rights reserved */
Description of the Fracdelay Unit Generator.
This unit generator implements a fractional-sample-length (interpolated) delay line, intended for use in the Karplus-Strong string model. It uses a circular buffer followed by a two-point FIR filter. Therefore, this UG does not result in a pure delay, but also affects the spectral characteristics of the signal (the FIR filter is low-pass). In addition to the method descriptions below, check out the Objective C source code in "RokNRoleApp.m" to see how this UG is actually used in the instrument.
Changes in delay-line length which do not cross integer boundaries can be handled by adjusting the bb0 and bb1 coefficients only. For glissando effects, the length must be adjusted in a way that seems "smooth," and much of the complexity of this UG is due to the need for keeping every output sample while the integer portion of the delay-line length is growing or shrinking by one sample. If this were not done, you would hear severe clicking and ratcheting while adjusting the tuning sliders. The implementation is a bit kludgy, but it works.
INSTANCE VARIABLES
===================
memObj is the SynthData object being used as delay memory (or nil if none).
length is the integer length of the delay line.
METHODS
=========
- setOutput:aPatchPoint
Used to connect the unit generator's output to aPatchPoint
-setInput:aPatchPoint
Used to connect the unit generator's input to aPatchPoint
-setFIRCell:aSynthData
Used to connect the unit generator's one-word storage cell (for the once-delayed output) to aSynthData, which must be of length 1.
-setChg:aDouble
Used to set an internal flag signalling that the delay line length must grow or shrink by one sample. The value of aDouble should be a small positive number (typ. 0.0001) for the case of growing, and a small negative number (typ. -0.0001) for the case of shrinking. The Chg flag should be zero at all other times. For the case of growing, the actual increase in length is automatically triggered when this flag is set and the bb0 coefficient is 0.0---that is, we "grow" one sample by first adjusting the FIR coefficients so that the filter provides a pure one-sample delay. This is the same as if the integer part of the length were one greater and the filter were providing zero delay, so we can switch from one configuration to the other with no loss of continuity. After the switch occurs, additional growing is immediately disabled internally (since the DSP can do things faster than the controlling Objective C program can dictate); however, you should still reset the two coefficients and the integer part of the length immediately after triggering a grow (or shrink), to avoid unexpected results. For shrinking, everything is the same except the value of the Chg flag, and the roles of the two coefficients are reversed. The actual shrink is triggered when the flag is set and bb1 is 0.0. See "RokNRoleApp.m" to find out how this all is done.
- setBb0:aDouble
Used to set the bb0 (undelayed output) coefficient to aDouble (0.0 to 0.999999)
- setBb1:aDouble
Used to set the bb1 (once-delayed output) coefficient to aDouble (always (0.999999 - bb0))
All of the following methods are exactly the same as the corresponding methods for the MusicKit's "DelayUG" unit generator. Please check the on-line documentation for a description.