Example (review)

#import <MusicKit/MusicKit.h>
#import <MKSynthPatches/MKSynthPatches.h>
MKNote *aNote;
MKPart *aPart;
MKScore *aScore;
MKEnvelope *env;
	
double times[] = {0,0.1,2.1,2.7,3.0};
double values[] = {0,1,0.5,0.1,0};
aScore = [[MKScore alloc] init];	
aPart = [[MKPart alloc] init];	
aNote = [[MKNote alloc] init];	
env = [[MKEnvelope alloc] init];
[env setPointCount: 5 xArray: times yArray: values];	
[env setStickPoint: 2]; 	
[aNote setPar: MK_ampEnv toEnvelope: env];
[aNote setPar: MK_freq toDouble: 440.0];
[aNote setTimeTag: 1.0];            /* Play after 1 beat */	
[aNote setDur: 1.0];                /* Duration is 1 beat */	
[aScore addPart: aPart];	
[aPart addNote: aNote];	
aNote = [[MKNote alloc] init];      /* Another Note for info */
[aNote setPar: MK_synthPatch toString: @"Wave1i"];
[aPart setInfo: aNote];
[aScore writeScorefile: @"test.score"];
system("playscore test.score");    /* We'll show how to do this in the program later. */