download MKFileWriter.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: 34
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

/*
  $Id: MKFileWriter.h,v 1.7 2005/05/11 02:13:30 leighsmith Exp $
  Defined In: The MusicKit

  Description:
    A MKFileWriter is an MKInstrument that realizes MKNotes by writing them to
    a file on the disk. An abstract superclass, MKFileWriter
    provides common functionality and declares subclass responsibilities
    for the subclasses MKMidifileWriter and MKScorefileWriter.
    Note: In this release, MKMidifileWriter is not provided. Use a MKScore object
    to write a Midifile.

    A MKFileWriter is associated with a file, either by the
    file's name or with a file pointer.  If you assoicate
    a MKFileWriter 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 writing when the
    object first receives the realizeNote: message
    and closed after the performance.  The
    file is overwritten each time it's opened.

    The setStream: method associates a MKFileWriter with a file
    pointer.  In this case, opening and closing the file
    is the responsibility of the application.  The MKFileWriter's
    file pointer is set to NULL after each performance.

    To design a subclass of MKFileWriter you must implement
    the method realizeNote:fromNoteReceiver:.

    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.

  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 MKFileWriter
  @brief A MKFileWriter is an MKInstrument that realizes MKNotes by writing them to a file on
  the disk.  An abstract class, MKFileWriter provides common functionality for the
  MusicKit subclasses such as MKScorefileWriter (currently the only subclass of
  MKFileWriter).

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 <b>setFile:</b> method) the object opens and closes the file for you:
The file is opened for writing when the object first receives the <b>realizeNote:</b>
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 <b>setStream:</b> method sets the FileWriter's <b>stream</b> instance
variable to the given NSMutableData object.  Creating and saving the NSMutableData
object is the responsibility of the application.  After each performance, <b>stream</b>
is set to nil.

The subclass responsibility <b>realizeNote:fromNoteReceiver:</b>, inherited from
MKInstrument, is passed on to the MKFileWriter subclasses.  Two other methods,
<b>initializeFile</b> and <b>finishFile</b>, can be redefined in a subclass,
although neither must be.  <b>initializeFile</b> is invoked just before the
first MKNote is written to the file and should perform any special initialization
such as writing a file header.  <b>finishFile</b> is invoked after each
performance and should perform any post-performance cleanup.  The values
returned by <b>initializeFile</b> and <b>finishFile</b> are ignored.
*/
#ifndef __MK_FileWriter_H___
#define __MK_FileWriter_H___

#import <Foundation/Foundation.h>

#import "MKInstrument.h"
#import "timeunits.h"

@interface MKFileWriter : MKInstrument
{
    MKTimeUnit timeUnit;
    NSMutableString *filename;        /* Or NULL. */
    NSMutableData *stream;            /* Pointer of open file. */
    double timeShift;
    BOOL compensatesDeltaT;
    int _fd;
}

/*!
  @return Returns an id.
  @brief Initializes the object by setting both <b>stream</b> and
  <b>filename</b> to NULL.

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

/*!
  @param  aTimeUnit is a MKTimeUnit.
  @return Returns an id.
  @brief Sets the unit in which the object measures time.

  <i>aTimeUnit</i>
  can be <b>MK_second</b> for measurement in seconds,  <b>MK_beat</b>
  for beats or <b>MK_timeTag</b> for the value in the Note's timeTag
  field.  The default is <b>MK_second</b>.
*/
- setTimeUnit: (MKTimeUnit) aTimeUnit;

/*!
  @return Returns a MKTimeUnit.
  @brief Returns the unit in which the object measures time, either
  <b>MK_second</b>, <b>MK_timeTag</b> or <b>MK_beat</b>.

  The default
  is <b>MK_second</b>.
*/
- (MKTimeUnit) timeUnit;

/*!
  @return Returns a NSString.
  @brief Returns the file extension used by the object.

  The default
  implementation returns the value of the <b>fileExtension</b> class
  method.  A subclass can implement this method to allow different
  default file extensions for different instances.
*/
+ (NSString *) fileExtension;

/*!
  @return Returns a NSString.
  @brief Returns the file extension used by the object.

  The default
  implementation returns the value of the <b>fileExtension</b> class
  method.  A subclass can implement this method to allow different
  default file extensions for different instances.
*/
- (NSString *) fileExtension;

/*!
  @param  aName is a NSString.
  @return Returns an id.
  @brief Associates the object with the file <i>aName</i>.

  The file is
  opened when the first MKNote is realized (written to the file) and
  closed at the end of the performance.  If the object is already in a
  performance, this does nothing and returns <b>nil</b>, otherwise
  returns the object.
*/
- setFile: (NSString *) aName; 

/*!
  @param  aStream is an NSMutableData.
  @return Returns an id.
  @brief Points the object's <b>stream</b> pointer to <i>aStream</i>.

  You
  must open and close the <i>aStream</i> yourself.  If the object is
  already in a performance, this does nothing and returns <b>nil</b>,
  otherwise returns the object.
*/
- setStream: (NSMutableData *) aStream; 

/*!
  @return Returns an NSMutableData.
  @brief Returns the object's <b>stream</b> pointer, or NULL if it isn't set.

  The pointer is set to NULL after each performance.
*/
- (NSMutableData *) stream; 

/*!
  @param  zone is an NSZone.
  @return Returns an id.
  @brief Creates and returns a copy of the object.

  The new object's
  <i>filename</i> and <i>stream</i> instance variables are set to
  NULL.
*/
- copyWithZone: (NSZone *) zone; 

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

/*!
  @return Returns an id.
  @brief This can be overridden by a subclass to perform post-performance
  activities.

  You never send the <b>finishFile</b>
  message directly to a MKFileWriter; it's invoked automatically after
  each performance.  The return value is ignored.
*/
- finishFile; 

/*!
  @return Returns an id.
  @brief This can be overriden by a subclass to perform file initialization,
  such as writing a file header.

  You never send the
  <b>initializeFile</b> message directly to a MKFileWriter; it's invoked
  from the <b>firstNote:</b> method.  The return value is
  ignored.
*/
- initializeFile; 

/*!
  @brief 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
  <i>filename</i> (if set) and then sends <b>initializeFile</b> to the
  object.
  @param  aNote is an id.
  @return Returns an id.
*/
- firstNote: (MKNote *) aNote; 

/*!
  @return Returns an id.
  @brief You never invoke this method; it's invoked automatically just after
  a performance.

  It closes the object's <i>stream</i> (if the object
  opened it itself in the <b>firstNote:</b> method) and sets it to
  NULL.
*/
- afterPerformance; 

/*!
  @return Returns a double.
  @brief Returns the object's performance time offset, in seconds.
*/
- (double) timeShift;

/*!
  @brief 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.
  @param  timeShift is a double.
  @return Returns an id.
*/
- setTimeShift: (double) timeShift;

- (void) encodeWithCoder: (NSCoder *) aCoder;
- (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