#import <MKSynthPatch.h>
Public Member Functions | |
(id) | - synthInstrument |
Returns synthInstrument owning the receiver, if any. | |
(id) | - init |
Sent by the MKOrchestra only when a new MKSynthPatch has just been created and before its MKUnitGenerator connections have been made, as defined by the MKPatchTemplate. | |
(id) | - synthElementAt: |
Returns the MKUnitGenerator or MKSynthData at the specified index or nil if anIndex is out of bounds. | |
(void) | - mkdealloc |
(sb): changed to mkdealloc to prevent conflict with OpenStep deallocation. | |
(id) | - preemptFor: |
Sent when the receiver is running or finishing and is preempted by its MKSynthInstrument. | |
(id) | - noteOnSelf: |
You never invoke this method directly. | |
(id) | - noteUpdateSelf: |
You never invoke this method, it's invoked automatically by noteUpdate:. | |
(double) | - noteOffSelf: |
You never invoke this method; it's invoked automatically by noteOff:. | |
(id) | - noteEndSelf |
This method is invoked automatically when the MKNote stream is complete. | |
(id) | - noteOn: |
This starts or rearticulates a MKNote stream by sending noteOnSelf:aNote to the receiver. | |
(id) | - noteUpdate: |
Sent ordinarily only by the MKSynthInstrument when a noteUpdate is received. | |
(double) | - noteOff: |
Concludes a MKNote stream by sending [self noteOffSelf: aNote]. | |
(id) | - noteEnd |
Causes the receiver to become idle. | |
(id) | - moved: |
Sent when the MKOrchestra moves a MKSynthPatch's MKUnitGenerator during DSP memory compaction. | |
(int) | - status |
Returns the status of the receiver. | |
(BOOL) | - isEqual: |
Two MKSynthPatches are considered equal if they have the same noteTag. | |
(unsigned) | - hash |
Uses the noteTag to hash itself. | |
(id) | - patchTemplate |
Returns the MKPatchTemplate associated with the receiver. | |
(int) | - noteTag |
Returns the noteTag associated with the MKNote stream the receiver is currently playing. | |
(id) | - orchestra |
Returns the MKOrchestra instance to which the receiver belongs. | |
(BOOL) | - isFreeable |
Returns YES if the receiver may be freed; otherwise returns NO. | |
(id) | - controllerValues: |
Sent by the MKSynthInstrument to a MKSynthPatch when a new tag stream begins, before the noteOn: message is sent. | |
(id) | - next |
This method is used in conjunction with a MKSynthInstrument's preemptSynthPatchFor:patches: method. | |
(id) | - freeSelf |
Sent just before the receiver is free, a subclass can implement this method to provide specialized behavior. | |
(MKPhraseStatus) | - phraseStatus |
This is a convenience method for MKSynthPatch subclass implementors. | |
Static Public Member Functions | |
(id) | + patchTemplateFor: |
Returns an appropriate MKPatchTemplate with which to create an MKSynthPatch instance that will adequately synthesize currentNote. | |
(id) | + orchestraClass |
Always returns the MKOrchestra class. | |
(id) | + defaultPatchTemplate |
Returns the default MKPatchTemplate for the class. | |
Protected Attributes | |
NSMutableArray * | synthElements |
id | synthInstrument |
int | noteTag |
MKSynthStatus | status |
id | patchTemplate |
BOOL | isAllocated |
MKOrchestra * | orchestra |
MKSynthPatches are not created by the application; rather, they're created by the MKOrchestra. The MKOrchestra is also responsible for filling the MKSynthPatch instance with MKUnitGenerator and MKSynthData instances. It does this on the basis of a template provided by the MKSynthPatch class method patchTemplate. You implement this method in a subclass of MKSynthPatch to provide a MKPatchTemplate that specifies the mix of MKUnitGenerators and MKSynthData objects, in what order they're allocated, and how to connect them.
Typically, a MKSynthPatch is owned and operated by a MKSynthInstrument object. The MKSynthInstrument manages the allocation of MKSynthPatches in response to incoming MKNotes. Alternatively, MKSynthPatches may be used in a stand-alone fashion. In this case, you must allocate the objects by sending the MKOrchestra an allocSynthPatch: or allocSynthPatch:patchTemplate: message.
While in performance, a MKSynthPatch is identified by the noteTag of the MKNote stream that it's synthesizing.
+ (id) patchTemplateFor: | (MKNote *) | currentNote |
Returns an appropriate MKPatchTemplate with which to create an MKSynthPatch instance that will adequately synthesize currentNote.
Determines an appropriate patchTemplate and returns it. In some cases, it is necessary to look at the current note to determine which patch to use. This method is invoked by MKSynthInstrument whenever it needs to allocate a new MKSynthPatch instance. It may also be sent by an application to obtain the template to be used as the second argument to MKSynthInstrument's setSynthPatchCount:patchTemplate: method. Implementation of this method is a subclass responsibility such that when currentNote is nil, a default template is returned.
currentNote | is an MKNote instance. If currentNote is nil, the default template should be returned. |
Reimplemented in DBWave2vi, Fm1, Fm1v, Fm2cnvi, Fm2cvi, Fm2pnvi, Fm2pvi, Pluck, Shape, Shapev, Simp, Wave1, Wave1i, and Wave1v.
+ (id) orchestraClass |
Always returns the MKOrchestra class.
+ (id) defaultPatchTemplate |
Returns the default MKPatchTemplate for the class.
- (id) synthInstrument |
Returns synthInstrument owning the receiver, if any.
- (id) init |
Sent by the MKOrchestra only when a new MKSynthPatch has just been created and before its MKUnitGenerator connections have been made, as defined by the MKPatchTemplate.
- (id) synthElementAt: | (unsigned) | anIndex |
Returns the MKUnitGenerator or MKSynthData at the specified index or nil if anIndex is out of bounds.
anIndex | is an unsigned int and is zero-based. |
- (void) mkdealloc |
(sb): changed to mkdealloc to prevent conflict with OpenStep deallocation.
This is used to explicitly deallocate a MKSynthPatch you previously allocated manually from the MKOrchestra with allocSynthPatch: or allocSynthPatch:patchTemplate:. It sends noteEnd to the receiver, then causes the receiver to become deallocated and returns nil. This message is ignored (and self is returned) if the receiver is owned by a MKSynthInstrument.
- (id) preemptFor: | (MKNote *) | aNote |
Sent when the receiver is running or finishing and is preempted by its MKSynthInstrument.
This happens, for example, when a MKSynthInstrument with 3 voices receives a fourth note. It preempts one of the voices by sending it preemptFor:newNote followed by noteOn:newNote. The default implementation does nothing and returns self. Normally, a time equal to the value returned by MKPreemptDuration() is allowed to elapse before the preempting MKNote begins. A subclass can specify that the new MKNote happen immediately by returning nil.
aNote | is an MKNote instance. |
- (id) noteOnSelf: | (MKNote *) | aNote |
You never invoke this method directly.
The default implementation returns the receiver. Subclass may override this method to do any initialization needed for each noteOn. noteOnSelf: is sent whenever a new MKNote stream commences, even if the MKSynthPatch is already running. The subclass can determine whether or not the MKSynthPatch is already running by examing the status instance variable. It should also check for preemption with -phraseStatus.
The message noteEnd is sent to the receiver if this method returns nil.
aNote | is an MKNote instance. |
Reimplemented in DBWave2vi, Fm1i, Fm2cnvi, Fm2cvi, Fm2pnvi, Fm2pvi, Pluck, Shape, Simp, and Wave1i.
- (id) noteUpdateSelf: | (MKNote *) | aNote |
You never invoke this method, it's invoked automatically by noteUpdate:.
A subclass can implement this method to provide behavior appropriate to reception of a noteUpdate. noteUpdateSelf: should send whatever messages are necessary to update the state of the DSP as reflected by the parameters in aNote.
aNote | is an MKNote instance. |
Reimplemented in DBWave2vi, Fm1i, Fm2cnvi, Fm2cvi, Fm2pnvi, Fm2pvi, Pluck, Shape, Simp, and Wave1i.
- (double) noteOffSelf: | (MKNote *) | aNote |
You never invoke this method; it's invoked automatically by noteOff:.
It is sent when a noteOff or end-of-noteDur is received. However, a subclass may provide an implementation that describes its response to a noteOff, the beginning of the final segment of the note or phrase. The return value is the amount of time to wait, in seconds, before the MKSynthPatch can be released. For example, a MKSynthPatch that has 2 envelope handlers should implement this method to send finish to each envelope handler and return the maximum of the two. The default implementation returns 0.0.
aNote | is an MKNote instance. |
Reimplemented in DBWave2vi, Fm1i, Fm2cnvi, Fm2cvi, Fm2pnvi, Fm2pvi, Pluck, Shape, Simp, and Wave1i.
- (id) noteEndSelf |
This method is invoked automatically when the MKNote stream is complete.
Reimplemented in DBWave2vi, Fm1i, Fm2cnvi, Fm2cvi, Fm2pnvi, Fm2pvi, Pluck, Shape, Simp, and Wave1i.
- (id) noteOn: | (MKNote *) | aNote |
This starts or rearticulates a MKNote stream by sending noteOnSelf:aNote to the receiver.
If noteOnSelf: returns self, the receiver's status is set to MK_running and the receiver is returned. If noteOnSelf: returns nil, noteEnd is sent to the receiver and nil is returned. Ordinarily sent only by MKSynthInstrument.
aNote | is an MKNote instance. |
- (id) noteUpdate: | (MKNote *) | aNote |
Sent ordinarily only by the MKSynthInstrument when a noteUpdate is received.
Implemented as [self noteUpdateSelf:aNote].
aNote | is an MKNote instance. |
- (double) noteOff: | (MKNote *) | aNote |
Concludes a MKNote stream by sending [self noteOffSelf: aNote].
Sets the receiver's status to MK_finishing. This method is ordinarily invoked only by an MKSynthInstrument.
aNote | is an MKNote. |
- (id) noteEnd |
Causes the receiver to become idle.
- (id) moved: | (MKUnitGenerator *) | aUG |
Sent when the MKOrchestra moves a MKSynthPatch's MKUnitGenerator during DSP memory compaction.
aUG is the unit generator that was moved. A subclass can override this method to provide specialized behavior. The default implementation does nothing.
aUG | is an MKUnitGenerator instance. |
- (int) status |
Returns the status of the receiver.
- (BOOL) isEqual: | (MKSynthPatch *) | anObject |
Two MKSynthPatches are considered equal if they have the same noteTag.
This is used by the MKSynthInstrument to search for a MKSynthPatch matching a certain noteTag.
anObject | is an MKSynthPatch instance. |
- (unsigned) hash |
Uses the noteTag to hash itself.
- (id) patchTemplate |
- (int) noteTag |
Returns the noteTag associated with the MKNote stream the receiver is currently playing.
- (id) orchestra |
Returns the MKOrchestra instance to which the receiver belongs.
- (BOOL) isFreeable |
Returns YES if the receiver may be freed; otherwise returns NO.
- (id) controllerValues: | (id) | controllers |
Sent by the MKSynthInstrument to a MKSynthPatch when a new tag stream begins, before the noteOn: message is sent.
The default implementation does nothing. You may override it in a subclass as desired.
Note that the sustain pedal controller is handled automatically by the MKSynthPatch class. Note that pitchbend is not a controller in MIDI. Thus the current pitchbend is included in the MKNote passed to noteOn:, not in the HashTable. See the HashTable spec sheet for details on how to access the values in controllers. The table should not be altered by the receiver.
controllers | is a HashTable that describes the state of the MIDI controllers by mapping integer controller numbers to integer controller values. |
- (id) next |
This method is used in conjunction with a MKSynthInstrument's preemptSynthPatchFor:patches: method.
- (id) freeSelf |
Sent just before the receiver is free, a subclass can implement this method to provide specialized behavior.
- (MKPhraseStatus) phraseStatus |
This is a convenience method for MKSynthPatch subclass implementors.
The value returned takes into account whether the phrase is preempted, the noteType of the current MKNote and the status of the receiver. If not called by a MKSynthPatch subclass, returns MK_noPhraseActivity.
- (NSMutableArray*) synthElements [protected] |
Array of MKUnitGenerator and MKSynthData objects.
- (id) synthInstrument [protected] |
The MKSynthInstrument object currently in possession of the MKSynthPatch or nil if none.
- (int) noteTag [protected] |
Tag of notes currently implemented by this MKSynthPatch.
- (MKSynthStatus) status [protected] |
Status of patch. One of MK_running, MK_finishing or MK_idle. You should never set it explicitly in your subclass.
- (id) patchTemplate [protected] |
MKPatchTemplate of this patch.
- (BOOL) isAllocated [protected] |
YES if the object is allocated.
- (MKOrchestra*) orchestra [protected] |
MKOrchestra instance on which the object is allocated and on which this MKSynthPatch is running.