home *** CD-ROM | disk | FTP | other *** search
- /* Play function by A.A.Efros.
- PLAY is C function to be used with Song Editor Data files.
-
- PLAY uses Sound, Delay and Nosound functions. There are no such functions
- in some C-Compilers. In this case one should use file TONE.C (#include
- <tone.c>) which is included in Song Editor system.
-
- To call function PLAY one should:
- play( [FileName], [SongName]);
- For example:
- play('music.dat','Glory');
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- play(FileName, SongName)
-
- char FileName[11], SongName[15];
- {
- int q = 1, fr, t, ver = 1;
- char ch, st[1000];
- FILE *data;
-
- if ((data = fopen(FileName,"r")) != NULL)
- {
- while (q)
- {
- fscanf(data, "%s", st);
- if ((ver = strcmp(SongName, st)) == 0)
- {
- do
- {
- q = fscanf(data,"%d%d%c", &fr, &t, &ch);
- sound(fr);
- delay(t); /* tone(fr,t); for others compilers */
- nosound();
- } while (ch != '\n' && q != EOF);
- break;
- }
- q = (fgets(st,1000,data) != NULL);
- }
- fclose(data);
- if (ver != 0)
- printf("\007 %s song is not found!\n", SongName);
- }
- else
- printf("\007 %s file is not found!\n", FileName);
- }