download MKPartRecorder.m
Language: ObjectiveC
Copyright: (c) 1988-1992, NeXT Computer, Inc. (c) 1999-2005, The MusicKit Project. (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT (c) 1994 Stanford University
LOC: 105
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: MKPartRecorder.m,v 1.10 2005/05/04 11:46:53 leighsmith Exp $  
  Defined In: The MusicKit
  HEADER FILES: MusicKit.h

  Description:
    A simple class which records MKNotes to a MKPart. That is, it acts as
    an MKInstrument that realizes MKNotes by adding them to its MKPart.
 
  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-2005, The MusicKit Project.
*/
/* Modification History prior to commit to CVS repository:

   03/13/90/daj - Minor changes for new private category scheme.
   04/21/90/daj - Small mods to get rid of -W compiler warnings.
   08/27/90/daj - Changed to zone API.
*/

#import "_musickit.h"
#import "_noteRecorder.h"
#import "ConductorPrivate.h"
#import "InstrumentPrivate.h"
#import "PartPrivate.h"
#import "ScoreRecorderPrivate.h"

#import "MKPartRecorder.h"

@implementation MKPartRecorder

#import "noteRecorderMethods.m"

#define VERSION2 2
#define VERSION3 3 /* Changed Nov 7, 1992 */

+ (void) initialize
{
    if (self != [MKPartRecorder class])
      return;
    [MKPartRecorder setVersion: VERSION3]; //sb: suggested by Stone conversion guide (replaced self)
    return;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
  /* TYPE: Archiving; Writes object.
     You never send this message directly.  
     Should be invoked with NXWriteRootObject(). 
     Invokes superclass write: then archives timeUnit. 
     Optionally archives part using NXWriteObjectReference().
     */
{
    [super encodeWithCoder:aCoder];
    NSAssert((sizeof(MKTimeUnit) == sizeof(int)), @"write: method error.");
    [aCoder encodeValueOfObjCType:"i" at:&timeUnit];
    [aCoder encodeConditionalObject:part];
    [aCoder encodeConditionalObject:_scoreRecorder];
    [aCoder encodeValuesOfObjCTypes:"c",&compensatesDeltaT];
}

- (id)initWithCoder:(NSCoder *)aDecoder
  /* You never send this message directly.  
     Should be invoked via NXReadObject(). 
     See write:. */
{
    int version;
    [super initWithCoder:aDecoder];
    version = [aDecoder versionForClassName: @"MKPartRecorder"];
    if (version >= VERSION2) {
	[aDecoder decodeValueOfObjCType:"i" at:&timeUnit];
	part = [[aDecoder decodeObject] retain];
	_scoreRecorder = [[aDecoder decodeObject] retain];
    }
    if (version >= VERSION3) {
	[aDecoder decodeValuesOfObjCTypes:"c",&compensatesDeltaT];
    }
    /* from awake (sb) */
    noteReceiver = [self noteReceiver];
    
    return self;
}

- copyWithZone: (NSZone *) zone
{
    MKPartRecorder *newObj = [super copyWithZone:zone];
    newObj->noteReceiver = [newObj noteReceiver];
    return newObj;
}

/* If receiver is a member of a MKScoreRecorder or is in performance, 
     returns self and does nothing. Otherwise frees the receiver. */
- (void) dealloc
{
    if ([self inPerformance] || _scoreRecorder) {
	NSLog(@"Assertion failure, attempting deallocation of MKPartRecorder %p while still in performance\n", self);
    }
    [noteReceiver release];
    noteReceiver = nil;
    [super dealloc];
}

- init
  /* TYPE: Creating
   * This message is sent to when a new instance is created.
   * The default implementation returns the receiver and creates a single
   * NoteReceiver.
   * A subclass
   * implementation should first send [super init].
   */
{
    self = [super init];
    if(self != nil) {
	[self addNoteReceiver: noteReceiver = [MKNoteReceiver new]];
	timeUnit = MK_second;    
    }
    return self;
}

void _MKSetScoreRecorderOfPartRecorder(MKPartRecorder *aPR, id aSR)
{
    aPR->_scoreRecorder = aSR;
}

- (void) setPart: (MKPart *) aPart
  /* Sets MKPart to which notes are sent. */
{
    part = aPart;
}

- (MKPart *) part
{
    return part;
}

- _realizeNote: (MKNote *) aNote fromNoteReceiver: (MKNoteReceiver *) aNoteReceiver
{
    if (!noteSeen) {
	[MKConductor _afterPerformanceSel: @selector(_afterPerformance) to: self argCount: 0];
	[_scoreRecorder _firstNote: aNote];
	// [part _addPerformanceObj: self];  // We used to do this, but it doesn't actually do anything and isn't correct wrt types.
	[self firstNote: aNote];
	noteSeen = YES;
    }
    return [self realizeNote: aNote fromNoteReceiver: aNoteReceiver];
}

/* Sent by conductor at end of performance. Private */
- _afterPerformance
{
    // [part _removePerformanceObj: self]; // We used to do this, but it doesn't actually do anything and isn't correct wrt types.
    [self afterPerformance];
    noteSeen = NO;
    return self;
}

/* Copies the note, adjusting its timetag and possibly adjusting its 
 duration according to tempo, then sends addNote: to the MKPart. 
*/
- realizeNote: (MKNote *) aNote fromNoteReceiver: (MKNoteReceiver *) aNoteReceiver
{
    aNote = [aNote copyWithZone: NSDefaultMallocZone()];
    [aNote setTimeTag: _MKTimeTagForTimeUnit(aNote, timeUnit, compensatesDeltaT)];
    if ([aNote noteType] == MK_noteDur) 
        [aNote setDur: _MKDurForTimeUnit(aNote, timeUnit)];
    [part addNote: aNote];
    return self;
}

@end

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