#import <MKFileWriter.h>
Public Member Functions | |
(id) | - init |
Initializes the object by setting both stream and filename to NULL. | |
(id) | - setTimeUnit: |
Sets the unit in which the object measures time. | |
(MKTimeUnit) | - timeUnit |
Returns the unit in which the object measures time, either MK_second, MK_timeTag or MK_beat. | |
(NSString *) | - fileExtension |
Returns the file extension used by the object. | |
(id) | - setFile: |
Associates the object with the file aName. | |
(id) | - setStream: |
Points the object's stream pointer to aStream. | |
(NSMutableData *) | - stream |
Returns the object's stream pointer, or NULL if it isn't set. | |
(id) | - copyWithZone: |
Creates and returns a copy of the object. | |
(NSString *) | - file |
Returns the object's file name, if any. | |
(id) | - finishFile |
This can be overridden by a subclass to perform post-performance activities. | |
(id) | - initializeFile |
This can be overriden by a subclass to perform file initialization, such as writing a file header. | |
(id) | - firstNote: |
You never invoke this method; it's invoked automatically just before the object writes its first MKNote. | |
(id) | - afterPerformance |
You never invoke this method; it's invoked automatically just after a performance. | |
(double) | - timeShift |
Returns the object's performance time offset, in seconds. | |
(id) | - setTimeShift: |
Sets a constant value to be added to MKNotes' times when they are written out to the file. | |
Static Public Member Functions | |
(NSString *) | + fileExtension |
Returns the file extension used by the object. |
A MKFileWriter is associated with a file on disk or a data object, either by the file's name or through an NSMutableData object. If you associate a MKFileWriter with a file name (through the setFile: method) the object opens and closes the file for you: The file is opened for writing when the object first receives the realizeNote: message and closed after the performance. A MKFileWriter remembers its file name between performances, but the file is overwritten each time it's opened.
The setStream: method sets the FileWriter's stream instance variable to the given NSMutableData object. Creating and saving the NSMutableData object is the responsibility of the application. After each performance, stream is set to nil.
The subclass responsibility realizeNote:fromNoteReceiver:, inherited from MKInstrument, is passed on to the MKFileWriter subclasses. Two other methods, initializeFile and finishFile, can be redefined in a subclass, although neither must be. initializeFile is invoked just before the first MKNote is written to the file and should perform any special initialization such as writing a file header. finishFile is invoked after each performance and should perform any post-performance cleanup. The values returned by initializeFile and finishFile are ignored.
- (id) init |
Initializes the object by setting both stream and filename to NULL.
- (id) setTimeUnit: | (MKTimeUnit) | aTimeUnit |
Sets the unit in which the object measures time.
aTimeUnit | is a MKTimeUnit. |
- (MKTimeUnit) timeUnit |
Returns the unit in which the object measures time, either MK_second, MK_timeTag or MK_beat.
+ (NSString *) fileExtension |
Returns the file extension used by the object.
Reimplemented in MKScorefileWriter, and MKScorefileWriter.
- (NSString *) fileExtension |
Returns the file extension used by the object.
Reimplemented in MKScorefileWriter, and MKScorefileWriter.
- (id) setFile: | (NSString *) | aName |
Associates the object with the file aName.
aName | is a NSString. |
Reimplemented in MKScorefileWriter.
- (id) setStream: | (NSMutableData *) | aStream |
Points the object's stream pointer to aStream.
aStream | is an NSMutableData. |
Reimplemented in MKScorefileWriter.
- (NSMutableData *) stream |
Returns the object's stream pointer, or NULL if it isn't set.
- (id) copyWithZone: | (NSZone *) | zone |
Creates and returns a copy of the object.
zone | is an NSZone. |
Reimplemented from MKInstrument.
Reimplemented in MKScorefileWriter.
- (NSString *) file |
Returns the object's file name, if any.
- (id) finishFile |
This can be overridden by a subclass to perform post-performance activities.
Reimplemented in MKScorefileWriter.
- (id) initializeFile |
This can be overriden by a subclass to perform file initialization, such as writing a file header.
Reimplemented in MKScorefileWriter.
- (id) firstNote: | (MKNote *) | aNote |
You never invoke this method; it's invoked automatically just before the object writes its first MKNote.
It opens a stream to the object's filename (if set) and then sends initializeFile to the object.
aNote | is an id. |
Reimplemented from MKInstrument.
- (id) afterPerformance |
You never invoke this method; it's invoked automatically just after a performance.
Reimplemented from MKInstrument.
- (double) timeShift |
Returns the object's performance time offset, in seconds.
- (id) setTimeShift: | (double) | timeShift |
Sets a constant value to be added to MKNotes' times when they are written out to the file.
It's up to the subclass to use this value.
timeShift | is a double. |