00001 /* 00002 $Id: MKPartPerformer.h 3250 2005-05-11 02:16:30Z leighsmith $ 00003 Defined In: The MusicKit 00004 00005 Description: 00006 A MKPartPerformer object performs the MKNotes in a particular MKPart. 00007 Every MKPartPerformer has exactly one MKNoteSender. A MKPartPerformer is 00008 associated with a MKPart through its setPart: method. While a single 00009 MKPartPerformer can only be associated with one MKPart, any number of 00010 MKPartPerformers can by associated with the same MKPart. If you're 00011 performing a MKScore, you can use MKScorePerformer to create 00012 MKPartPerformers for you (one for each MKPart in the MKScore). 00013 00014 When you activate a MKPartPerformer (through activateSelf) the object 00015 copies its MKPart's NSArray of MKNotes (it doesn't copy the MKNotes 00016 themselves). When it's performed, the MKPartPerformer sequences over 00017 its copy of the NSArray, allowing you to edit the MKPart (by adding or 00018 removing MKNotes) without disturbing the performance -- changes made to 00019 a MKPart during a performance are not seen by the MKPartPerformer. 00020 However, since only the NSArray of MKNotes is copied but not the MKNotes 00021 themselves, you should neither alter nor free a MKPart's MKNotes during a 00022 performance. 00023 00024 The timing variables firstTimeTag, lastTimeTag, beginTime, 00025 and duration affect the timing and performance duration of a 00026 MKPartPerformer. Only the MKNotes with timeTag values between 00027 firstTimeTag and lastTimeTag (inclusive) are performed. Each of these 00028 notes performance times is computed as its timeTag plus timeShift. 00029 If the newly computed performance time is greater than duration, the MKNote 00030 is suppressed and the MKPartPerformer is deactivated. 00031 00032 CF: MKScorePerformer, MKPart 00033 00034 Original Author: David A. Jaffe 00035 00036 Copyright (c) 1988-1992, NeXT Computer, Inc. 00037 Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT 00038 Portions Copyright (c) 1994 Stanford University. 00039 Portions Copyright (c) 1999-2001, The MusicKit Project. 00040 */ 00081 #ifndef __MK_PartPerformer_H___ 00082 #define __MK_PartPerformer_H___ 00083 00084 #import "MKPerformer.h" 00085 #import "MKScorePerformer.h" 00086 00087 @interface MKPartPerformer : MKPerformer 00088 { 00089 MKNote *nextNote; /* The next note to perform. Updated in -perform. */ 00090 MKPart *part; /* The MKPart associated with this object. */ 00091 double firstTimeTag; /* The smallest timeTag value considered for performance. */ 00092 double lastTimeTag; /* The greatest timeTag value considered for performance. */ 00093 00094 @private 00095 int noteIndex; 00096 int noteCount; 00097 NSArray *noteArray; 00098 MKScorePerformer *scorePerformer; 00099 } 00100 00101 00115 +setFastActivation:(BOOL)yesOrNo; 00116 /* If you send [MKPartPerformer setFastActivation:YES], MKPartPerformers 00117 activated from then on will NOT copy the MKPart's NSArray of MKNotes. 00118 That is, they will use [part notesNoCopy] instead of [part notes]. 00119 If you use this mode, you may not modify the part while the MKPartPerformer 00120 is active. Default is NO. 00121 */ 00122 00130 +(BOOL)fastActivation; 00131 00142 - init; 00152 - setPart: (MKPart *) aPart; 00153 00158 - (MKPart *) part; 00159 00180 - activateSelf; 00181 00190 - (void) deactivate; 00191 00209 - perform; 00210 00220 - setFirstTimeTag: (double) aTimeTag; 00221 00231 - setLastTimeTag: (double) aTimeTag; 00232 00240 - (double) firstTimeTag; 00241 00249 - (double) lastTimeTag; 00250 00262 - copyWithZone: (NSZone *) zone; 00263 00264 /* 00265 You never send this message directly. 00266 Invokes superclass write: then archives firstTimeTag and lastTimeTag. 00267 Optionally archives part using NXWriteObjectReference(). 00268 */ 00269 - (void) encodeWithCoder: (NSCoder *) aCoder; 00270 00271 /* 00272 Note that -init is not sent to newly unarchived objects. 00273 */ 00274 - (id) initWithCoder: (NSCoder *) aDecoder; 00275 00276 @end 00277 00278 #endif