home *** CD-ROM | disk | FTP | other *** search
- #include <QuickTimeComponents.h>
- #include "PlayNotes.h"
-
-
- NoteAllocator na = nil;
- NoteChannel nc = nil;
- NoteRequest nr;
-
-
- OSErr SetupPlaying(void)
- {
- ComponentResult thisError;
- long t,i;
-
- na = 0;
- nc = 0;
-
- thisError = EnterMovies();
-
- /*
- * Open up the Note Allocator
- */
- na = OpenDefaultComponent('nota',0);
- if(!na)
- goto goHome;
-
- /*
- * Fill out a Note Request using NAStuffToneDescription
- * to help, and allocate a Note Channel
- */
- //nr.info.flags = 0; /* post qt 2.0 only */
- //nr.info.reserved = 0; /* post qt 2.0 only */
- nr.polyphony = 2; /* simultaneous tones */
- nr.typicalPolyphony = 0x00010000;
- thisError = NAStuffToneDescription(na,1,&nr.tone); /* 1 is Piano */
-
- thisError = NANewNoteChannel(na,&nr,&nc);
- if(thisError || !nc)
- goto goHome;
-
-
- goHome:
- return thisError;
-
- }
-
-
- OSErr StopPlaying(void)
- {
- if(nc)
- NADisposeNoteChannel(na,nc);
- if(na)
- CloseComponent(na);
-
- ExitMovies();
-
- }
-
- OSErr PlayANote(short pitch)
- {
- NAPlayNote(na,nc,pitch,80); /* middle C at velocity 80 */
-
- }
-
-