OscgafUG Class Reference

OscgafUG is similar to OscgUG, but supports patchpoints for frequency and amplitude. More...

#import <OscgafUG.h>

Inheritance diagram for OscgafUG:

OscgafUGs MKUnitGenerator

List of all members.


Detailed Description

OscgafUG is similar to OscgUG, but supports patchpoints for frequency and amplitude.

OscgafUGs is the superclass for OscgafUG (non-interpolating or "drop-sample") and OscgafiUG (interpolating or "high-quality") oscillators. They are, in turn, derived from dsp macros /usr/local/lib/dsp/ugsrc/oscgaf.asm and oscgafi.asm. OscgafiUG and OscgafUG implement no methods of their own. They get all their behavior from OscgafUGs.

The fidelity of OscgafUG depends on the size of the table (larger tables have lower distortion) and the highest frequency represented in the table. For high-quality synthesis, OcgafiUG, is preferable. However, OscgafUG is less expensive (in terms of DSP cycles) and is useful in cases where density of texture is more important than fidelity of individual sounds.

The remainder of this discussion deals focuses on OscgafUGs, which embodies the characteristics that OscgafiUG and OscgafUG share.

OscgafUGs includes patchpoint arguments for amplitude and frequency control. That is, those parameters are intended to be determined by the output of some other unit generator, such as AsympUG. See the example synthpatch /LocalDeveloper/Examples/MusicKit/exampsynthpatch/FM.m for an example of its use.

Amplitude control is straightforward. The output of OscgafUGs is simply the value of the lookup table times whatever comes in via the ampEnvInput patchpoint. Frequency control is more complicated. The signal needed for freqEnvInput is not actually the frequency in Hertz, but the phase increment, which is the amount the lookup table index changes during each sample. This number depends on the desired frequency, the length of the lookup table, the sampling rate, and a constant called MK_OSCFREQSCALE. MK_OSCFREQSCALE is a power of two which represents the maximum possible increment. Input to freqEnvInput must be divided by this number in order to insure that it remains in the 24-bit signal range. The signal is then scaled back up by this number within OscgafUGs, with a possible additional scaling by the incRatio (see below).

A method called incAtFreq: has been provided which takes all the above factors into account and returns the increment for a given frequency. The lookup table must be set first, via the -setTable: method, since the length of the table must be known to perform the calculation. If more than one OscgafUGs is to be controlled by the same increment envelope signal (such as in a typical FM patch), they can have different frequencies by using the -setIncRatio: method. Since the input increment signal is scaled by MK_OSCFREQSCALE*incRatio within OscgafUGs, the resulting frequency will be correspondingly changed. The incRatio defaults to 1.0.

Alternatively, the increment scaler can be set directly with -setIncScaler:. This simply sets the increment scaler to the value you provide, ignoring MK_OSCFREQSCALE, incRatio, etc.

Memory Spaces

OscgafUGsabcd a output b amplitude input c increment (derivative of freq) input d table space


The documentation for this class was generated from the following file:

Generated on Sat Dec 5 17:01:16 2009 for MusicKit by  doxygen 1.5.6