A
download MKNoteFilter.m
Language: ObjectiveC
Copyright: (c) 1988-1992, NeXT Computer, Inc. (c) 1999-2004, The MusicKit Project. (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT (c) 1994 Stanford University
LOC: 89
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: MKNoteFilter.m,v 1.11 2004/12/13 02:28:47 leighsmith Exp $
  Defined In: The MusicKit
  HEADER FILES: MusicKit.h

  Description:
    MKNoteFilter is an abstract class.
    MKNoteFilter adds some of the functionality of MKPerformer to that of
    MKInstrument. In particular, it adds the ability to send to elements
    in a collection of MKNoteSenders.
 
    You subclass MKNoteFilter and override realizeNote:fromNoteSender:
    to do multiplexing of the input and output paths of the MKNoteFilter.
    MKNoteFilters may modify MKNotes.
    The only requirement is that any modification
    you make before sending a MKNote is undone afterwards. I.e. the
    'copy on write or memory' principle is used.
 
  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-2004, The MusicKit Project.
 */
/* Modification history prior to commiting to CVS:

  03/21/90/daj - Added archiving.
  04/21/90/daj - Small mods to get rid of -W compiler warnings.
  08/23/90/daj - Changed to zone API.
  03/08/95/daj - Added setting of owner in addNoteSender.
*/

#import "_musickit.h"

#import "InstrumentPrivate.h"
#import "MKNoteSender.h"
#import "MKNoteFilter.h"

@implementation MKNoteFilter

#define VERSION2 2

+ (void) initialize
{
    if (self != [MKNoteFilter class])
      return;
    [MKNoteFilter setVersion: VERSION2];
    return;
}

- init
{
    self = [super init]; /* Creates noteReceivers */
    if(self != nil) {
	noteSenders = [[NSMutableArray alloc] init];	
    }
    return self;
}

- (void) encodeWithCoder: (NSCoder *) aCoder
  /* You never send this message directly.  
     Invokes superclass encodeWithCoder: and archives noteSender List. */
{
    [super encodeWithCoder: aCoder];
    
    // Check if decoding a newer keyed coding archive
    if([aCoder allowsKeyedCoding]) {
	[aCoder encodeObject: noteSenders forKey: @"MKNoteFilter_noteSenders"];
    }
    else {
	[aCoder encodeObject: noteSenders];
    }
}

- (id) initWithCoder: (NSCoder *) aDecoder
  /* You never send this message directly.  
     See encodeWithCoder:. */
{
    self = [super initWithCoder: aDecoder];
    
    // Check if decoding a newer keyed coding archive
    if([aDecoder allowsKeyedCoding]) {
	[noteSenders release];
	noteSenders = [[aDecoder decodeObjectForKey: @"MKNoteFilter_noteSenders"] retain];
    }
    else {
	if ([aDecoder versionForClassName: @"MKNoteFilter"] == VERSION2) 
	    noteSenders = [[aDecoder decodeObject] retain];
    }
    return self;
}

#import "noteDispatcherMethods.m"

- copyWithZone: (NSZone *) zone
    /* Copies object, copying MKNoteSenders and MKNoteReceivers. */
{
    MKNoteFilter *newObj = [super copyWithZone: zone];
    unsigned int i;
    unsigned int n = [noteSenders count];
    
    newObj->noteSenders = [[NSMutableArray alloc] initWithCapacity: n];
    for (i = 0; i < n; i++) {
	id ns_copy = [[noteSenders objectAtIndex: i] copy];
	[newObj addNoteSender: ns_copy];
	[ns_copy release];
    }
    return newObj;
}

- (MKNoteSender *) addNoteSender: (MKNoteSender *) aNoteSender
  /* If aNoteSender is already owned by the receiver, returns nil.
     Otherwise, aNoteSender is removed from its owner, the owner
     of aNoteSender is set to self, aNoteSender is added to 
     noteSenders (as the last element) and aNoteSender is returned. 
     For some subclasses, it is inappropriate for anyone
     other than the subclass instance itself to send this message. 
     If you override this method, first forward it to super.
     If the receiver is in performance, this message is ignored and nil
     is returned.
     */
{
    id owner = [aNoteSender owner];
    
    if (owner == self)
	return nil;
    if (noteSeen)
	return nil;
    [owner removeNoteSender: aNoteSender];
    if (![noteSenders containsObject: aNoteSender])
	[noteSenders addObject: aNoteSender];
    [aNoteSender _setOwner: self];    /* Tell it we're the owner */
    [aNoteSender _setPerformer: nil]; /* Tell it we're not a performer */
    return aNoteSender;
}

- (MKNoteSender *) removeNoteSender: (MKNoteSender *) aNoteSender
  /* If aNoteSender is not owned by the receiver, returns nil.
     Otherwise, removes aNoteSender from the receiver's MKNoteSender List
     and returns aNoteSender. 
     For some subclasses, it is inappropriate for anyone
     other than the subclass instance itself to send this message. 
     If the receiver is in a performance, this message is ignored and nil is
     returned. */
{
    if ([aNoteSender owner] != self)
	return nil;
    if (noteSeen)
	return nil;
    [noteSenders removeObject: aNoteSender];
    [aNoteSender _setOwner: nil];
    return aNoteSender;
}

- (void) dealloc
  /* TYPE: Creating
   * This invokes releaseNoteSenders.
   * Then it frees itself.
   */
{
    [self releaseNoteSenders];
    [noteSenders release];
    [super dealloc];
}

@end

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