MusicKit  0.0.0
MKInstrument.h
00001 /*
00002   $Id$
00003   Defined In: The MusicKit
00004 
00005  Description: 
00006    MKInstrument is an abstract class that defines the general mechanism for
00007    obtaining and realizing MKNotes during a MusicKit performance.  Each
00008    subclass of MKInstrument defines its particular manner of realization by
00009    implementing realizeNote:fromNoteReceiver:.
00010   
00011    Every MKInstrument contains a NSMutableArray of MKNoteReceivers, objects
00012    that receive MKNotes during a performance.  Each subclass of MKInstrument
00013    should implement its init method to automatically create and add
00014    some number of MKNoteReceivers to a newly created instance.  When a
00015    MKNoteReceiver receives a MKNote (through the receiveNote: method), it
00016    causes realizeNote:fromNoteReceiver: to be sent to its MKInstrument with
00017    the MKNote as the first argument and the MKNoteReceiver's id as the second
00018    argument.
00019   
00020    An MKInstrument is considered to be in performance from the time it
00021    realizes its first MKNote until the peformance is over.
00022   
00023    The MKInstrument subclasses provided by the MusicKit are:
00024   
00025    Subclass             Realization
00026    --------             -----------
00027    MKNoteFilter         Processes the MKNote and sends it on.
00028    MKNoteRecorder       Adds the MKNote to a MKPart or writes it to a file.
00029    MKSynthInstrument    Synthesizes a musical sound on the DSP.
00030   
00031    CF: MKNoteReceiver
00032 
00033   Original Author: David Jaffe
00034 
00035   Copyright (c) 1988-1992, NeXT Computer, Inc.
00036   Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT
00037   Portions Copyright (c) 1994 Stanford University
00038   Portions Copyright (c) 1999-2004, The MusicKit Project.
00039 */
00084 #ifndef __MK_Instrument_H___
00085 #define __MK_Instrument_H___
00086 
00087 #import <Foundation/Foundation.h>
00088 //#import <Foundation/NSObject.h>
00089 //#import <Foundation/NSArray.h>
00090 #import "MKNote.h"
00091 #import "MKNoteReceiver.h"
00092 
00093 @interface MKInstrument: NSObject <NSCoding>
00094 {
00096     NSMutableArray *noteReceivers;
00097 
00098 @protected
00099     BOOL noteSeen;
00100     void *_afterPerfMsgPtr;
00101 }
00102 
00103 
00113 - init; 
00114 
00133 - realizeNote: (MKNote *) aNote fromNoteReceiver: (MKNoteReceiver *) aNoteReceiver;
00134 
00150 - firstNote: (MKNote *) aNote;
00151 
00162 - (NSArray *) noteReceivers;
00163 
00173 - (int) indexOfNoteReceiver: (MKNoteReceiver *) aNoteReceiver;
00174 
00185 - (BOOL) isNoteReceiverPresent: (MKNoteReceiver *) aNoteReceiver; 
00186 
00199 - addNoteReceiver: (MKNoteReceiver *) aNoteReceiver;
00200 
00214 - removeNoteReceiver: (MKNoteReceiver *) aNoteReceiver; 
00215 
00223 - (void) dealloc; 
00224 
00231 - disconnectNoteReceivers;
00232 
00243 - removeFromPerformance;
00244 
00254 - removeNoteReceivers; 
00255 
00268 - (BOOL) inPerformance;
00269 
00281 - afterPerformance; 
00282 
00295 - copyWithZone: (NSZone *) zone; 
00296 
00313 - (MKNoteReceiver *) noteReceiver; 
00314 
00315  /* 
00316   * You never send this message directly.  Archives noteReceiver Array.
00317   */
00318 - (void) encodeWithCoder: (NSCoder *) aCoder;
00319 
00320  /* 
00321   * You never send this message directly.  
00322   * Note that -init is not sent to newly unarchived objects.
00323   * See write:. 
00324   */
00325 - (id) initWithCoder: (NSCoder *) aDecoder;
00326 
00334 - allNotesOff;
00335 
00336 @end
00337 
00338 #endif