#include <MusicKit/MusicKit.h>
main()
{
MKNote *aNote;
MKPart *aPart;
MKScore *aScore;
aScore = [MKScore score]; /* In 2.0, use alloc/init */
aPart = [MKPart new];
aNote = [MKNote new];
[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];
/* "info" code may be added here - see below */
[aScore writeScorefile: @"test.score"];
}
|
This example writes the file "test.score". However, if you want
to play that file with the ScorePlayer
application, you need to specify which
MKSynthPatch (DSP instrument)
to use. We do this by adding a special MKNote
called a "MKPart info" with a parameter
indicating the name of the MKSynthPatch:
aNote = [MKNote new]; /* Another MKNote for info */
[aNote setPar: MK_synthPatch toString: @"Pluck"];
[aPart setInfo: aNote]; |