home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <fcntl.h>
-
- #include "convert.h"
- #include "bank.h"
-
- extern char musRunning; /* != 0 if music is playing */
-
- #include <malloc.h>
- #include <string.h>
- #define rlsmem(x,y) free(x)
- #define getmem(x) malloc(x)
- #define setmem(x,y,z) memset(x,z,y)
- #define movmem(x,y,z) memmove(y,x,z)
- #define max(x,y) ((x > y) ? x:y)
-
-
- /*
- Simple demonstration.
- Syntax: play <musfile.mus> <bankfile.snd>
- */
-
- main( argc, argv)
- int argc;
- char * argv[];
- {
- struct MusHeader mH;
- int meloFile;
- char * music;
- unsigned len;
- BankPtr theBank;
-
- if( argc < 3) {
- exit( 1);
- }
-
- /* Perform some initialisations ... */
- InitSnd();
-
- if( NULL == ( theBank = OpenBank( argv[ 2], 0))) {
- Terminate();
- exit( 1);
- }
- if( !LoadBank( theBank)) {
- Terminate();
- exit( 1);
- }
- meloFile = open( argv[ 1], O_RDONLY + O_BINARY);
- if( -1 == meloFile) {
- Terminate();
- exit( 1);
- }
-
- /* read the music file's header: */
- read( meloFile, &mH, sizeof( struct MusHeader));
- len = mH.dataSize;
- music = (char *) getmem( (unsigned) len);
- if( music == NULL) {
- exit( 1);
- }
-
- /* load all the data in memory: */
- read( meloFile, music, len);
-
- /* Start playing: */
- StartMelo( &mH, music, len, theBank);
-
- /* wait until end.... */
- WaitEndMelo();
-
- /* uninstall the clock driver: */
- Terminate();
-
- rlsmem( music, len);
- CloseBank( theBank);
- } /* main() */
-
-
-