MKPartPerformer Class Reference

A MKPartPerformer object performs the MKNotes in a particular MKPart. More...

#import <MKPartPerformer.h>

Inheritance diagram for MKPartPerformer:

MKPerformer

List of all members.

Public Member Functions

(id) - init
 Initializes the receiver by creating and adding its single MKNoteSender.
(id) - setPart:
 Associates the receiver with aPart.
(MKPart *) - part
 Returns the receiver's MKPart object.
(id) - activateSelf
 Activates the receiver for a performance.
(void) - deactivate
 Deactivates the receiver and frees its NSMutableArray of MKNotes.
(id) - perform
 Performs nextNote (by sending it to its MKNoteSender's connections) and then prepares the receiver for its next MKNote performance.
(id) - setFirstTimeTag:
 Sets the value of the receiver's firstTimeTag variable to aTimeTag.
(id) - setLastTimeTag:
 Sets the value of the receiver's lasTimeTag variable to aTimeTag.
(double) - firstTimeTag
 Returns the value of the receiver's firstTimeTaginstance variable.
(double) - lastTimeTag
 Returns the value of the receiver's lasTimeTaginstance variable.
(id) - copyWithZone:
 Creates and returns a new MKPartPerformer as a copy of the receiver.
(void) - encodeWithCoder:
 You never send this message directly.
(id) - initWithCoder:
 You never send this message directly.

Static Public Member Functions

(id) + setFastActivation:
 If yesOrNo is YES, MKPartPerformers do not copy the MKPart's NSMutableArray of MKNotes when they activate.
(BOOL) + fastActivation
 Returns whether Fast Activation mode is enabled for the class.


Detailed Description

A MKPartPerformer object performs the MKNotes in a particular MKPart.

Every MKPartPerformer has exactly one MKNoteSender. A MKPartPerformer is associated with a MKPart through its setPart: method. While a single MKPartPerformer can only be associated with one MKPart, any number of MKPartPerformers can by associated with the same MKPart. If you're performing a MKScore, you can use MKScorePerformer to create MKPartPerformers for you (one for each MKPart in the MKScore).

When you activate a MKPartPerformer (through activateSelf) the object copies its MKPart's NSMutableArray of MKNotes (it doesn't copy the MKNotes themselves). When the MKPartPerformer performs, it sequences over its copy of the NSMutableArray, allowing you to edit the MKPart (by adding or removing MKNotes) without disturbing the performance - changes made to a MKPart during a performance are not seen by the MKPartPerformer. However, since only the NSMutableArray of MKNotes is copied but not the MKNotes themselves, you should neither alter nor free a MKPart's MKNotes during a performance.

As an optimization for real time, you can enable a "Fast Activation mode", on a class-wide basis. Any MKPartPerformer activated when this mode is in effect does not retain its own copy of its MKPart's NSMutableArray. In this mode, you must not edit the MKPart while the MKPartPerformer is using it.

With the timing variables firstTimeTag and lastTimeTag, you can specify the first and last timeTag values that are considered for performance. Keep in mind that you can offset the timing of a performance by setting the timeShift variable defined in MKPerformer, and you can limit the duration of the performance by setting the duration variable.

An example will clarify how firstTimeTagworks. If firstTimeTag is set to 3 and the MKPartPerformer is activated at time 0, then the first note will sound at time 3. If the MKPartPerformer is activated at time 1, the first note will sound at time 4. If timeShift is set to -1 and the MKPartPerformer is activated at time 1, the first note will sound at time 3.

See also:
MKPerformer, MKScorePerformer, MKPart

Member Function Documentation

+ (id) setFastActivation: (BOOL)  yesOrNo  

If yesOrNo is YES, MKPartPerformers do not copy the MKPart's NSMutableArray of MKNotes when they activate.

Parameters:
yesOrNo is a BOOL.
Returns:
Returns an id. Fast Activation mode is provided for real-time situations where instantaneous activation is required, such as when triggering a sequence. In this mode, MKNotes may not be added or removed from the MKPart while the MKPartPerformer is using it.

+ (BOOL) fastActivation  

Returns whether Fast Activation mode is enabled for the class.

Returns:
Returns a BOOL. The default is NO. See setFastActivation:.

- (id) init  

Initializes the receiver by creating and adding its single MKNoteSender.

Returns:
Returns an id. You must invoke this method after creating a new MKPartPerformer. A subclass implementation should send [super init] before performing its own initialization. The return value is ignored.

Reimplemented from MKPerformer.

- (id) setPart: (MKPart *)  aPart  

Associates the receiver with aPart.

Parameters:
aPart is an id.
Returns:
Returns an id. If the receiver is active, this does nothing and returns nil. Otherwise returns the receiver.

- (MKPart *) part  

Returns the receiver's MKPart object.

Returns:
Returns the MKPart instance over which we sequence.

- (id) activateSelf  

Activates the receiver for a performance.

Returns:
Returns an id. The receiver creates a copy of its MKPart's NSMutableArray of MKNotes (unless Fast Activation mode is enabled), sets nextNote to the first MKNote in the NSMutableArray, and sets nextPerform (an instance variable inherited from MKPerformer that defines the time to pperform nextNote) to the MKNote's timeTag plus timeShift.
You never invoke this method directly; it's invoked as part of the activate method inherited from MKPerformer. A subclass implementation should send [super activateSelf]. If activateSelf returns nil, the receiver isn't activated. The default implementation returns nil if there aren't any MKNotes in the receiver's MKNote NSMutableArray, otherwise it returns the receiver. The activate method performs further timing checks.

Reimplemented from MKPerformer.

- (void) deactivate  

Deactivates the receiver and frees its NSMutableArray of MKNotes.

You never invoke this method directly; it's invoked as part of the deactivate method inherited from MKPerformer. The return value is ignored.

Reimplemented from MKPerformer.

- (id) perform  

Performs nextNote (by sending it to its MKNoteSender's connections) and then prepares the receiver for its next MKNote performance.

Returns:
Returns an id. It does this by seting nextNote to the next MKNote in its NSMutableArray and setting nextPerform to that MKNote's timeTag minus the value of firstTimeTag. You never invoke this method directly; it's automatically invoked by the receiver's MKConductor during a performance. A subclass implementation should send [super perform]. The return value is ignored. To help support MIDI time code, perform sends all noteUpdates up to the current time when it is first invoked. This makes sure that all MKSynthInstruments and MIDI controllers have the proper values.

Reimplemented from MKPerformer.

- (id) setFirstTimeTag: (double)  aTimeTag  

Sets the value of the receiver's firstTimeTag variable to aTimeTag.

Parameters:
aTimeTag is a double.
Returns:
Returns an id. Only MKNotes within the time span from firstTimeTag to lastTimeTag are included in the performance.

Reimplemented from MKPerformer.

- (id) setLastTimeTag: (double)  aTimeTag  

Sets the value of the receiver's lasTimeTag variable to aTimeTag.

Parameters:
aTimeTag is a double.
Returns:
Returns an id. Only MKNotes within the time span from firstTimeTag to lastTimeTag are included in the performance.

Reimplemented from MKPerformer.

- (double) firstTimeTag  

Returns the value of the receiver's firstTimeTaginstance variable.

Returns:
Returns a double.

Reimplemented from MKPerformer.

- (double) lastTimeTag  

Returns the value of the receiver's lasTimeTaginstance variable.

Returns:
Returns a double.

Reimplemented from MKPerformer.

- (id) copyWithZone: (NSZone *)  zone  

Creates and returns a new MKPartPerformer as a copy of the receiver.

Parameters:
zone is an NSZone.
Returns:
Returns an id. The new object has its own MKNoteReceiver collection that contains copies of the receiver's MKNoteReceivers. The new MKNoteReceivers' connections (see the MKNoteReceiver class) are copied from the MKNoteReceivers in the receiver.

Reimplemented from MKPerformer.

- (void) encodeWithCoder: (NSCoder *)  aCoder  

You never send this message directly.

Archives noteSender array, timeShift, and duration. Also optionally archives conductor and delegate.

Reimplemented from MKPerformer.

- (id) initWithCoder: (NSCoder *)  aDecoder  

You never send this message directly.

Note that the status of an unarchived MKPerformer is always MK_inactive.

Reimplemented from MKPerformer.


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

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