OscgUG Class Reference

OscgUG is the basic oscillator and supports amplitude and frequency as memory arguments. More...

#import <OscgUG.h>

Inheritance diagram for OscgUG:

MKUnitGenerator

List of all members.

Public Member Functions

(id) - setInc:
 Sets increment as an integer as specified.
(id) - setFreq:
 Sets oscillator frequency in Hz.
(id) - setAmp:
 Sets amplitude as specifed.
(id) - setPhase:
 Sets oscillator phase in degrees.
(id) - runSelf
 You never send this message.
(id) - idleSelf
 You never send this message.
(id) - setOutput:
 Set output patchPoint of the oscillator.
(id) - setTable:length:
 Sets the lookup table of the oscillator.
(id) - setTable:
 Like setTable:length:, but uses a default length.
(id) - setTableToSineROM
 Sets the lookup table to the DSP sine ROM, if address space is Y.
(id) - setTable:length:defaultToSineROM:
 This method is provided as a convenience.
(id) - setTable:defaultToSineROM:
 Like setTable:length:defaultToSineROM:, but uses a default length.
(unsigned) - tableLength
 Returns the length of the assigned table or 0 if no table is assigned.

Static Public Member Functions

(BOOL) + shouldOptimize:
 Specifies that all arguments are to be optimized if possible except the phase.


Detailed Description

OscgUG is the basic oscillator and supports amplitude and frequency as memory arguments.

This is a non-interpolating oscillator. That means that its fidelity depends on the size of the table (larger tables have lower distortion) and the highest frequency represented in the table. For high-quality synthesis, an interpolating oscillator, such as OscgafiUG is preferable. However, an interpolating oscillator is also more expensive, in terms of DSP cycles. OscgUG is useful in cases where density of texture is more important than fidelity of individual sounds.

Restrictions: The wavetable length must be a power of 2. The wavetable increment must be nonnegative.

Memory Spaces

OscgUGab a output b table space


Member Function Documentation

+ (BOOL) shouldOptimize: (unsigned)  arg  

Specifies that all arguments are to be optimized if possible except the phase.

Parameters:
arg is an unsigned.
Returns:
Returns an BOOL.

Reimplemented from MKUnitGenerator.

- (id) setFreq: (double)  aFreq  

Sets oscillator frequency in Hz.

Parameters:
aFreq is a double.
Returns:
Returns an id. If wavetable has not yet been set, stores the value for runSelf to use to set the frequency later.

- (id) setAmp: (double)  aAmp  

Sets amplitude as specifed.

Parameters:
aAmp is a double.
Returns:
Returns an id.

- (id) setPhase: (double)  aPhase  

Sets oscillator phase in degrees.

Parameters:
aPhase is a double.
Returns:
Returns an id. If wavetable has not yet been set, stores the value for -runSelf to use to set the phase later.

- (id) runSelf  

You never send this message.

Returns:
Returns an id. It's invoked by sending the run message to the object. Sets the oscillator phase if setPhase: was called before the WaveTable was set. Sets frequency to the last value set with setFreq:. If WaveTable has not been set, and table space is Y, sets table to DSP SINE ROM.

Reimplemented from MKUnitGenerator.

- (id) idleSelf  

You never send this message.

Returns:
Returns an id. It's invoked by sending the idle message to the object. Sets the output patchpoint to sink (thus ensuring that the object does not produce any output) and deallocates any MKWaveTable memory that the object had allocated . Note that you must send setOutput: and run again to use the object after sending idle.

Reimplemented from MKUnitGenerator.

- (id) setOutput: (id)  aPatchPoint  

Set output patchPoint of the oscillator.

Parameters:
aPatchPoint is an id.
Returns:
Returns an id.

- (id) setTable: (id)  anObj
length: (int)  aLength 

Sets the lookup table of the oscillator.

anObj can be a MKSynthData object or a MKWaveTable (MKPartials or MKSamples).

This method first releases its claim on the locally-allocated MKSynthData, if any. (see below). Then, if anObj is a MKSynthData object, the SynthData object is used directly. If anObj is a MKWaveTable, the receiver first searches in its MKOrchestra's shared object table to see if there is already an existing MKSynthData based on the same MKWaveTable, of the same length, and in the required memory space. Otherwise, a local MKSynthData object is created and installed in the shared object table so that other unit generators running simultaneously may share it. If the requested size is too large, because there is not sufficient DSP memory, smaller sizes are tried. You can determine what size was used by sending the tableLength message. If anObj is nil, this method simply releases the locally-allocated MKSynthData, if any.

Note that altering the contents of a MKWaveTable will have no effect once it has been installed, even if you call setTable:length: again after modifying the MKWaveTable. The reason is that the MKOrchestra's shared data mechanism finds the requested object based on its id, rather than its contents.

You should not free MKWaveTables used as arguments to OscgUG until the performance is over.

If the table is not a power of 2, returns nil and generates the error MK_ugsPowerOf2Err.

Parameters:
anObj is an id.
aLength is an int.
Returns:
Returns an id.

- (id) setTable: (id)  anObj  

Like setTable:length:, but uses a default length.

Parameters:
anObj is an id.
Returns:
Returns an id.

- (id) setTableToSineROM  

Sets the lookup table to the DSP sine ROM, if address space is Y.

Returns:
Returns an id. Otherwise generates an error. Deallocates local wave table, if any.

- (id) setTable: (id)  anObj
length: (int)  aLength
defaultToSineROM: (BOOL)  yesOrNo 

This method is provided as a convenience.

Parameters:
anObj is an id.
aLength is an int.
yesOrNo is a BOOL.
Returns:
Returns an id. It tries to do 'the right thing' in cases where the table cannot be allocated.
If the table can be allocated, it behaves like setTable:length:. If the table cannot be allocated, and the table memory space of the receiver is Y, sends [self setTableToSineROM].

A common use of this method is to pass YES as the argument yesOrNo only if the MKSynthPatch is beginning a new phrase (the assumtion is that it is better to keep the old wavetable than to use the sine ROM in this case). Another use of this method is to specifically request the sine ROM by passing nil as anObj. If the sine ROM is used, the aLength argument is ignored.

If anObj is not nil and the sine ROM is used, generates the error MK_spsSineROMSubstitutionErr. If yesOrNo is YES but the receiver's table memory space is X, the error MK_spsCantGetMemoryErr is generated.

- (id) setTable: (id)  anObj
defaultToSineROM: (BOOL)  yesOrNo 

Like setTable:length:defaultToSineROM:, but uses a default length.

Parameters:
anObj is an id.
yesOrNo is a BOOL.
Returns:
Returns an id.

- (unsigned) tableLength  

Returns the length of the assigned table or 0 if no table is assigned.

Returns:
Returns an unsigned int.


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