00001 /* 00002 $Id: MKFileWriter.h 3430 2009-02-21 22:46:59Z leighsmith $ 00003 Defined In: The MusicKit 00004 00005 Description: 00006 A MKFileWriter is an MKInstrument that realizes MKNotes by writing them to 00007 a file on the disk. An abstract superclass, MKFileWriter 00008 provides common functionality and declares subclass responsibilities 00009 for the subclasses MKMidifileWriter and MKScorefileWriter. 00010 Note: In this release, MKMidifileWriter is not provided. Use a MKScore object 00011 to write a Midifile. 00012 00013 A MKFileWriter is associated with a file, either by the 00014 file's name or with a file pointer. If you associate 00015 a MKFileWriter with a file name (through the setFile: 00016 method) the object will take care of opening and closing 00017 the file for you: the file is opened for writing when the 00018 object first receives the realizeNote: message 00019 and closed after the performance. The 00020 file is overwritten each time it's opened. 00021 00022 The setStream: method associates a MKFileWriter with a file 00023 pointer. In this case, opening and closing the file 00024 is the responsibility of the application. The MKFileWriter's 00025 file pointer is set to NULL after each performance. 00026 00027 To design a subclass of MKFileWriter you must implement 00028 the method realizeNote:fromNoteReceiver:. 00029 00030 Two other methods, initializeFile and finishFile, can 00031 be redefined in a subclass, although neither 00032 must be. initializeFile is invoked 00033 just before the first MKNote is written to the 00034 file and should perform any special 00035 initialization such as writing a file header. 00036 00037 finishFile is invoked after each performance 00038 and should perform any post-performance cleanup. 00039 The values returned by initializeFile and finishFile are ignored. 00040 00041 Original Author: David A. Jaffe 00042 00043 Copyright (c) 1988-1992, NeXT Computer, Inc. 00044 Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT 00045 Portions Copyright (c) 1994 Stanford University. 00046 Portions Copyright (c) 1999-2001, The MusicKit Project. 00047 */ 00077 #ifndef __MK_FileWriter_H___ 00078 #define __MK_FileWriter_H___ 00079 00080 #import <Foundation/Foundation.h> 00081 00082 #import "MKInstrument.h" 00083 #import "timeunits.h" 00084 00085 @interface MKFileWriter : MKInstrument 00086 { 00087 MKTimeUnit timeUnit; 00088 NSMutableString *filename; /* Or NULL. */ 00089 NSMutableData *stream; /* Pointer of open file. */ 00090 double timeShift; 00091 BOOL compensatesDeltaT; 00092 int _fd; 00093 } 00094 00105 - init; 00106 00117 - setTimeUnit: (MKTimeUnit) aTimeUnit; 00118 00127 - (MKTimeUnit) timeUnit; 00128 00138 + (NSString *) fileExtension; 00139 00148 - (NSString *) fileExtension; 00149 00160 - setFile: (NSString *) aName; 00161 00171 - setStream: (NSMutableData *) aStream; 00172 00179 - (NSMutableData *) stream; 00180 00190 - copyWithZone: (NSZone *) zone; 00191 00196 - (NSString *) file; 00197 00207 - finishFile; 00208 00219 - initializeFile; 00220 00231 - firstNote: (MKNote *) aNote; 00232 00242 - afterPerformance; 00243 00248 - (double) timeShift; 00249 00258 - setTimeShift: (double) timeShift; 00259 00260 - (void) encodeWithCoder: (NSCoder *) aCoder; 00261 - (id) initWithCoder: (NSCoder *) aDecoder; 00262 00263 @end 00264 00265 #endif