download MKFilePerformer.h
Language: ObjectiveC
Copyright: (c) 1988-1992, NeXT Computer, Inc. (c) 1994 Stanford University. (c) 1999-2001, The MusicKit Project. (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT
LOC: 35
Project Info
The MusicKit(musickit)
Server: SourceForge
Type: cvs
...sicKit\Frameworks\MusicKit\
   _ArielQP.h
   _DSPMK.h
   _error.h
   _midi.h
   _MKAppProxy.h
   _MKAppProxy.m
   _MKNameTable.h
   _MKNameTable.m
   _MKParameter.h
   _MTCHelper.h
   _MTCHelper.m
   _musickit.h
   _noteRecorder.h
   _OrchloopbeginUG.h
   _OrchloopbeginUG.m
   _ParName.h
   _ParName.m
   _scorefile.h
   _ScorefileVar.h
   _ScorefileVar.m
   _SharedSynthInfo.h
   _SharedSynthInfo.m
   _synthElementMethods.m
   _time.h
   ArielQP.h
   ArielQP.m
   classFuncs.h
   ConductorPrivate.h
   dsp_types.h
   DSPSerialPortDevice.h
   dspwrap.h
   EnvelopePrivate.h
   equalTempered.m
   errors.h
   fastFFT.c
   fastFFT.h
   GNUmakefile.postamble
   GNUmakefile.preamble.in
   InstrumentPrivate.h
   keynums.h
   libMusicKit.def
   Localized.strings
   make.sh
   Makefile.postamble
   Makefile.preamble
   midi_spec.h
   midifile.h
   midifile.m
   MidiPrivate.h
   midiTranslation.h
   MKConductor.h
   MKConductor.m
   MKConductorDelegate.h
   MKDeviceStatus.h
   MKEnvelope.h
   MKEnvelope.m
   MKFilePerformer.h
   MKFilePerformer.m
   MKFileWriter.h
   MKFileWriter.m
   MKInstrument.h
   MKInstrument.m
   MKMidi.h
   MKMidi.m
   MKMixerInstrument.h
   MKMixerInstrument.m
   MKMTCPerformer.h
   MKMTCPerformer.m
   MKNote.h
   MKNoteFilter.h
   MKNoteFilter.m
   MKNoteReceiver.h
   MKNoteReceiver.m
   MKNoteSender.h
   MKNoteSender.m
   MKOrchestra.h
   MKPart.m
   MKPartials.h
   MKPartials.m
   ...tialsWaveshapingTable.m
   MKPartPerformer.h
   MKPartPerformer.m
   MKPartRecorder.h
   MKPartRecorder.m
   MKPatch.h
   MKPatch.m
   MKPatchConnection.h
   MKPatchConnection.m
   MKPatchEntry.h
   MKPatchEntry.m
   MKPatchTemplate.h
   MKPatchTemplate.m
   MKPerformer.h
   MKPerformer.m
   MKPerformerDelegate.h
   MKPlugin.h
   MKSamplerInstrument.h
   MKSamplerInstrument.m
   MKSamples.h
   MKScore.h
   MKScore.m
   MKScorefileObject.h
   MKScorefilePerformer.h
   MKScorefilePerformer.m
   MKScorefileWriter.m
   MKScorePerformer.h
   MKScorePerformer.m
   MKScoreRecorder.h
   MKScoreRecorder.m
   MKSynthData.h
   MKSynthData.m
   MKSynthInstrument.h
   MKSynthPatch.h
   MKTimbre.h
   MKTimbre.m
   MKTuningSystem.h
   MKTuningSystem.m
   MKUnitGenerator.h
   MKUnitGenerator.m
   MKWaveTable.h
   MKWaveTable.m
   mtcMidi.m
   mtcMidiPrivate.m
   MusicKit-Info.plist
   MusicKit.h
   MusicKitConfig.h.in
   names.h
   noDVal.h
   noteDispatcherMethods.m
   NotePrivate.h
   noteRecorderCFuncs.m
   noteRecorderMethods.m
   orch.h
   OrchestraPrivate.h
   OrchloopbeginUG.h
   OrchloopbeginUG.m
   orchloopbeginUGInclude.m
   params.h
   parNames.m
   partialsDBInclude.m
   PartialsPrivate.h
   PartPerformerPrivate.h
   PartPrivate.h
   PartRecorderPrivate.h
   PatchTemplatePrivate.h
   PB.project
   PerformerPrivate.h
   pitches.h
   platform.make
   ...efilePerformerPrivate.h
   ScorePerformerPrivate.h
   ScorePrivate.h
   ScoreRecorderPrivate.h
   SynthDataPrivate.h
   synthElementCFuncs.m
   synthElementMethods.m
   SynthInstrumentPrivate.h
   SynthPatchList.h
   SynthPatchList.m
   SynthPatchPrivate.h
   timetagInclude.m
   timeunits.h
   tokenNames.m
   tokens.h
   trigonometry.c
   trigonometry.h
   TuningSystemPrivate.h
   UnitGeneratorPrivate.h
   win32-def.top
   writeBinary.m
   writeMidi.m
   writeScore.m

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*
  $Id: MKFilePerformer.h,v 1.10 2005/05/11 02:13:30 leighsmith Exp $  
  Defined In: The MusicKit

  Description:
    A MKFilePerformer reads data from a file on the disk,
    fashions a MKNote object from the data, and then performs
    the MKNote.  An abstract superclass, MKFilePerformer
    provides common functionality and declares subclass responsibilities
    for the subclasses MKMidifilePerformer and MKScorefilePerformer.

    Note: In release 1.0, MKMidifilePerformer is not provided. Use a MKScore object
    to read a Midifile.

    A MKFilePerformer is associated with a file, either by the
    file's name or with a file pointer.  If you assoicate
    a MKFilePerformer with a file name (through the setFile:
    method) the object will take care of opening and closing
    the file for you:  the file is opened for reading when the
    MKFilePerformer receives the activate message and closed when
    it receives deactivate.

    The setStream: method associates a MKFilePerformer with a file
    pointer.  In this case, opening and closing the file
    is the responsibility of the application.  The MKFilePerformer's
    file pointer is set to NULL after each performance
    so you must send another setStream: message in order to replay the file.

    Note:  The argument to -setStream: is a NSData or NSMutableData.

    The MKFilePerformer class declares two methods as subclass responsibilities:
    nextNote and performNote:. nextNote must be subclassed to access the next line of information
    from the file and from it create either a MKNote object or a
    time value.  It returns the MKNote that it creates, or, in the case of a time value,
    it sets the instance variable fileTime to represent the current time in the file
    and returns nil.

    The MKNote created by nextNote is passed as the argument
    to performNote: which is responsible for performing any manipulations on the
    MKNote and then sending it by invoking sendNote:.
    The return value of performNote: is disregarded.

    Both nextNote and performNote: are invoked
    by the perform method, which, recall from the MKPerformer
    class, is itself never called directly but is sent by a MKConductor.
    perform also checks and incorporates the time limit
    and performance offset established by the timing window
    variables inherited from MKPerformer; nextNote and
    performNote: needn't access nor otherwise be concerned
    about these variables.

    Two other methods, initFile and finishFile, can
    be redefined by a MKFilePerformer subclass, although neither
    must be.  initializeFile is invoked
    when the object is activated and should perform any special
    initialization such as reading the file's header or magic number.
    If initializeFile returns nil, the MKFilePerformer is deactivated.
    The default returns the receiver.

    finishFile is invoked when the MKFilePerformer is deactivated
    and should perform any post-performance cleanup.  Its return
    value is disregarded.

    A MKFilePerformer reads and performs one MKNote at a time.  This
    allows efficient performance of arbitrarily large files.
    Compare this to the MKScore object which reads and processes the entire file
    before performing the first note.  However, unlike the MKScore object,
    the MKFilePerformer doesn't allow individual timing control over the
    different MKNote streams in the file; the timing window
    specifications inherited from MKPerformer are applied to the entire
    file.

    Any number of MKFilePerformers can perform the same file concurrently.

  Original Author: David A. Jaffe

  Copyright (c) 1988-1992, NeXT Computer, Inc.
  Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT
  Portions Copyright (c) 1994 Stanford University.
  Portions Copyright (c) 1999-2001, The MusicKit Project.
*/
/*!
  @class MKFilePerformer
  @brief During a Music Kit performance, a MKFilePerformer reads and performs time-ordered
  music data from a file on the disk.  An abstract class, MKFilePerformer provides
  common functionality and declares subclass responsibilities for its one
  subclass, MKScorefilePerformer.

A MKFilePerformer is associated with a file either by the file's name or through
an NSMutableData instance.  If you associate a MKFilePerformer with a file name (through
the <b>setFile:</b> method) the object opens and closes the file for you:  The
file is opened for reading when the MKFilePerformer receives the <b>activate</b>
message and closed when it receives <b>deactivate</b>.  The <b>setFileStream:</b>
method associates a MKFilePerformer with an NSMutableData instance.  In this case, opening
and closing the file is the responsibility of the application.  The MKFilePerformer's
stream pointer is set to NULL after each performance so you must send another
<b>setFileStream:</b> message in order to replay the file.  Any number of MKFilePerformers
can perform the same file simultaneously.

The MKFilePerformer class declares two methods as subclass responsibilities: 
<b>nextNote</b> and <b>performNote:</b>.  A subclass implementation of<b>
nextNote</b> should be designed to read the next line of information in the file
and from it create either a MKNote object or a timeTag value (for the following
MKNote).  It returns the MKNote that it creates, or, in the case of a timeTag, it
sets the instance variable <b>fileTime</b> to represent the current time in the
file and returns <b>nil</b>.  <b>performNote:</b> should perform any desired
manipulations on the MKNote created by <b>nextNote</b> and then pass it as the
argument to <b>sendNote:</b> (sent to a MKNoteSender).  The value returned by
<b>performNote:</b> is ignored.

MKFilePerformer defines two timing variables, <b>firstTimeTag</b> and
<b>lastTimeTag</b>.  They represent the smallest and largest timeTag values that
are considered for performance:  MKNotes with timeTags that are less than
<b>firstTimeTag</b> are ignored; if <b>nextNote</b> creates a timeTag greater
than <b>lastTimeTag</b>, the MKFilePerformer is deactivated.

Creation of a MKFilePerformer's MKNoteSender(s) is a subclass responsibility.

  @see  MKScorefilePerformer, MKPerformer
*/
#ifndef __MK_FilePerformer_H___
#define __MK_FilePerformer_H___

#import <Foundation/Foundation.h>

#import "MKPerformer.h"

@interface MKFilePerformer : MKPerformer
{
    /*! @var filename File name or nil if the file pointer is specifed directly. */
    NSString *filename;
    /*! @var fileTime The current time in the file (in beats). */
    double fileTime;
    /*! @var stream Pointer to the MKFilePerformer's file, either NSMutableData or NSData */
    id stream;
    /*! @var firstTimeTag The smallest timeTag value considered for performance. */
    double firstTimeTag;
    /*! @var lastTimeTag The greatest timeTag value considered for performance. */
    double lastTimeTag;
}
 
/*!
  @brief Initializes the object by setting <b>stream</b> and <b>filename</b> to NULL.

  You invoke this method when creating a new instance of MKFilePerformer.  
  A subclass implementation should send <b>[super init]</b>
  before performing its own initialization.  The return value is ignored.
  @return Returns an id.
*/
- init;

- copyWithZone:(NSZone *)zone;

/*!
  @brief Associates the object with the file named <i>aName</i>.

  The file is opened when the object is activated and closed when its deactivated.
  If the object is active, does nothing and returns <b>nil</b>,
  otherwise returns the object.
  @param  aName is a NSString instance.
  @return Returns an id.
*/
- setFile: (NSString *) aName;

/*!
  @brief Returns the object's file name, if any.
  @return Returns an NSString.
 */
- (NSString *) file; 

/*!
  @brief Sets the object's stream to <i>aStream</i>.

  The sender must open and close the stream himself.  If the object is active,
  this does nothing and returns <b>nil</b>, otherwise returns the
  object.
  @param  aStream is an id.
  @return Returns an id.
*/
- setStream: (id) aStream; // TODO either NSMutableData, or NSData

/*!
  @brief Returns the object's encoded stream object, or NULL if it isn't set.
  @return Returns an id.
*/
- (id) stream; // TODO either NSMutableData, or NSData

/*!
  @brief Prepares the object for a performance by opening the associated file
  (if necessary) and invoking <b>nextNote</b> until it returns an
  appropriate MKNote - one with a timeTag between <b>firstTimeTag</b>
  and <b>lastTimeTag</b>, inclusive.

  If an appropriate MKNote isn't found, the object is deactivated.
  You never invoke this method; its invoked by the <b>activate</b> method inherited from MKPerformer.
  @return Returns an id.
*/
- activateSelf;

/*!
  @brief Returns the file name extension that's recognized by the class.

  The default implementation returns nil.  A subclass may override this
  method to specify its own file extension.
  @return Returns an NSString.
*/
+ (NSString *) fileExtension;

/*!
  @brief Returns an NSArray of NSStrings holding file extensions that
  are recognized by the class.

  The default implementation returns an NSArray whose single element
  NSString is given the value returned by the <b>fileExtension</b> method.
  A subclass may override this method to specify its own file extensions.
  @return Returns an NSArray.
*/
+ (NSArray *) fileExtensions;

/*!
  @brief Gets the next MKNote from the object's file by invoking
  <b>nextNote</b>, passes it as the argument to <b>performNote:</b>,
  then sets the value of <i>nextPerform</i>.

  You never invoke this method; it's invoked by the object's MKConductor.
  The return value is ignored.
  @return Returns an id.
*/
- perform; 

/*!
  @brief A subclass responsibility expected to manipulate and send
  <i>aNote</i>, which was presumably just read from a file.

  You never invoke this method; it's invoked automatically by the <b>perform</b>
  method.  The return type is ignored.
  @param  aNote is an MKNote instance.
  @return Returns an id.
*/
- performNote: (MKNote *) aNote; 

/*!
  @brief A subclass responsibility expected to fashion a MKNote or timeTag from the file.

  It should return the MKNote or <b>nil</b> if the next file
  entry is a timeTag.  In the latter case, <i>fileTime</i> should be
  updated.  You never invoke this method; it's invoked automatically
  by the <b>perform</b> method.
  @return Returns an MKNote instance.
*/
- (MKNote *) nextNote; 

/*!
  @brief A subclass can implement this method to perform file initialization.

  If <b>nil</b> is returned, the object is deactivated.  You never
  invoke this method; it's invoked automatically by
  <b>activateSelf</b>.  The default implementation does nothing and
  returns the object.
  @return Returns an id.
*/
- initializeFile;

/*!
  @brief Invokes <b>finishFile</b>, closes the object's file (if it was set
  through <b>setFile:</b>), and sets the <b>stream</b> instance variable to nil.

  You never invoke this method; its invoked automatically when the object is deactivated.
*/
- (void) deactivate; 

/*!
  @brief A subclass can implement this method for post-performance file
  operations.

  You shouldn't close the stream pointer as part of this method.
  You never invoke this method; it's invoked automatically by
  <b>deactivateSelf</b>.  The default implementation does nothing. 
  The return value is ignored.
  @return Returns an id.
*/
- finishFile; 

/*!
  @brief Sets the smallest timeTag considered for performance to <i>aTimeTag</i>.

  Returns the object.  If the object is active, does
  nothing and returns <b>nil</b>.
  @param  aTimeTag is a double.
  @return Returns an id.
*/
- setFirstTimeTag: (double) aTimeTag;

/*!
  @brief Sets the largest timeTag considered for performance to <i>aTimeTag</i>.

  Returns the object.  If the object is active, does
  nothing and returns <b>nil</b>.
  @param  aTimeTag is a double.
  @return Returns an id.
*/
- setLastTimeTag: (double) aTimeTag; 

/*!
  @brief Returns the object's <b>firstTimeTag</b> value.
  @return Returns a double.  
*/
- (double) firstTimeTag; 

/*!
  @brief Returns the object's <b>lastTimeTag</b> value.
  @return Returns a double.
*/
- (double) lastTimeTag;

/*!
  @brief You never invoke this method directly; to archive a MKFilePerformer,
  call the <b>NSArchiver</b> <b>archiveRoot</b> method.

  An archived MKFilePerformer maintains its <i>filename</i>, <i>firstTimeTag</i>,
  and <i>lastTimeTag</i> instance variables (as well as the instance
  variables defined in MKPerformer).
  @param  aCoder is an NSCoder instance.
*/
- (void) encodeWithCoder: (NSCoder *) aCoder;

/*!
  @brief You never invoke this method directly; to read an archived
  MKFilePerformer, call the <b>NSUnarchiver</b> methods.
  @param  aDecoder is an NSCoder instance.
  @return Returns an id.
*/
- (id) initWithCoder: (NSCoder *) aDecoder;

@end

#endif

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us