home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / TUNEPL.ZIP / tuneplay.c next >
C/C++ Source or Header  |  1992-11-12  |  2KB  |  67 lines

  1. #define  INCL_BASE
  2. #define  INCL_NOPM
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <os2.h>
  6. #include "tuneplyr.h"
  7.  
  8. #define  TP_VERSION        "V1.0"
  9. char allTunes[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  10.  
  11. void play_tune(char *fileName, char tuneNo);
  12.  
  13. int main(int argc, char *argv[])
  14. {
  15. char *nextTune;
  16.  
  17.    printf("\nTunePlayer %s, Copyright (c) 1992, CoralSoft, Inc.", TP_VERSION);
  18.    if (argc != 3)
  19.       {
  20.       printf("\nUsage:\n");
  21.       printf("\n\ttuneplay [tune file] [tune number]\n");
  22.       printf("\n\tWhere [tune file] = Data file created by 'Tune Editor'");
  23.       printf("\n\t                    application (*.$$a)");
  24.       printf("\n\t      [tune number] = Number of the tune (0-9A-Z)");
  25.       printf("\nTunePlay allows background or batch playing of tunes\n");
  26.       printf("\ncreated with the OS/2 Tune Editor, found in the OS/2");
  27.       printf("\nProductivity Folder.  When you save a tune file, it");
  28.       printf("\nis given the extension '.$$a'.  By default, these files");
  29.       printf("\nare stored on your boot drive in the \\OS2\\APPS directory");
  30.       printf("\nBy specifying '*' for the tune number, all tunes in the");
  31.       printf("\nfile will be played with a slight pause between each.");
  32.       return -1;
  33.       }
  34.  
  35.    if (*argv[2] != '*')
  36.       play_tune(argv[1], *argv[2]);
  37.    else
  38.       {
  39.       for (nextTune= allTunes; *nextTune; nextTune++)
  40.          {
  41.          play_tune(argv[1], *nextTune);
  42.          DosSleep(1000L);
  43.          }
  44.       }
  45.    return 0;
  46.  
  47. }
  48.  
  49. void play_tune(char *fileName, char tuneNo)
  50. {
  51. int rc;
  52. PTUNENOTE tuneBase;
  53. BYTE tuneName[26];
  54.  
  55.    memset(tuneName, 0, 26);
  56.    rc= createTune(fileName, tuneNo, &tuneBase, tuneName);
  57.    if (rc)
  58.       return;
  59.    if (!tuneBase)
  60.       return;
  61.    printf("\nPlaying > %s", tuneName);
  62.    fflush(stdout);
  63.    playTune(tuneBase);
  64.    closeTune(tuneBase);
  65.  
  66. }
  67.