home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -seriously_amiga- / sound / warpamp-ahi / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-09  |  18.2 KB  |  666 lines

  1.  
  2. #define AUDIO
  3. #define BUFSIZE  18432 * 8
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8.  
  9. #include <exec/types.h>
  10. #include <exec/libraries.h>
  11. #include <exec/lists.h>
  12. #include <exec/memory.h>
  13.  
  14. #include <clib/exec_protos.h>
  15. #include <clib/dos_protos.h>
  16.  
  17. #include <clib/asl_protos.h>
  18. #include <libraries/asl.h>
  19. #include <utility/tagitem.h>
  20.  
  21. #include <libraries/prelude.h>
  22. #include <clib/prelude_protos.h>
  23.  
  24. #include <devices/ahi.h>
  25.  
  26. #include <clib/powerpc_protos.h>
  27. #include <powerpc/memoryPPC.h>
  28.  
  29. #include "amp.h"
  30. #include "audio.h"
  31. #include "getbits.h"
  32. #include "huffman.h"
  33. #include "layer2.h"
  34. #include "layer3.h"
  35. #include "transform.h"
  36. #include "misc2.h"
  37. #include "dump.h"
  38.  
  39. int output=1;
  40. int filesize=0;
  41.  
  42. extern struct ExecBase *SysBase;
  43. struct PreludeBase *PreludeBase=NULL;
  44.  
  45. UBYTE version [] = "\0$VER: WarpAMP 0.9 (07.5.98)";
  46.  
  47. int    mysignal;
  48. ULONG   Signals;
  49.  
  50. UBYTE   *PlayBuffer[2];
  51. ULONG   Buffer;
  52. ULONG BufferFill;
  53. UBYTE *BufferPointer;
  54.  
  55. ULONG PlayCnt;
  56. ULONG PlayMode;
  57. ULONG PlayFreq;
  58. BOOL snd_eof;
  59. int noout=1;
  60. int ppcmem=1;
  61. int filespec=0;
  62. char infile[1024];
  63. struct FileRequester *smr=0;
  64. char *name;
  65. char fname[1024];
  66. FILE *fp;
  67. char prog[1024];
  68. FILE *fil=0;
  69. int useprog=0;
  70. int repeat=0;
  71. int quit=0;
  72.  
  73. extern struct Library *AslBase;
  74.  
  75. struct TagItem tags[]={
  76. ASLFR_DoPatterns,
  77. 1,
  78. ASLFR_InitialPattern,
  79. (ULONG)"#?.(mpg|mpeg|mp3|mp2)",
  80. ASLFR_DoMultiSelect,1,
  81. 0,0};
  82.  
  83. struct TagItem tags2[]={
  84. ASLFR_DoPatterns,
  85. 1,
  86. ASLFR_InitialPattern,
  87. (ULONG)"#?.(prg)",
  88. 0,0};
  89.  
  90.  
  91. //-------------------------------------
  92.  
  93. struct Device     *AHIDevice = NULL;
  94. struct MsgPort    *AHIPort = NULL;
  95. struct AHIRequest *AHIReq = NULL;
  96. struct AHIRequest *AHIReq2 = NULL;
  97. struct AHIRequest *AHIReqs[2];
  98. struct AHIRequest *link = NULL;
  99.  
  100. void CloseAHIDevice()
  101. {
  102.         if (AHIDevice)
  103.         {
  104.                 CloseDevice((struct IORequest *) AHIReq);
  105.                 AHIDevice = NULL;
  106.         }
  107.         if (AHIReq)
  108.         {
  109.                 DeleteIORequest(AHIReq);
  110.                 AHIReq = NULL;
  111.         }
  112.         if (AHIPort)
  113.         {
  114.                 DeleteMsgPort(AHIPort);
  115.                 AHIPort = NULL;
  116.         }
  117.  
  118.         if (AHIReq2)
  119.         {
  120.                 DeleteIORequest(AHIReq2);
  121.                 AHIReq2 = NULL;
  122.         }
  123. }
  124.  
  125. int InitAHIDevice(ULONG unit, ULONG version)
  126. {
  127.         if (AHIPort = CreateMsgPort())
  128.         {
  129.                 if (AHIReq = (AHIRequest *) CreateIORequest(AHIPort, sizeof(struct AHIRequest)))
  130.                 {
  131.                         AHIReq->ahir_Version = version;
  132.                         if (!OpenDevice(AHINAME, unit, (struct IORequest *) AHIReq, 0))
  133.                                 AHIDevice = AHIReq->ahir_Std.io_Device;
  134.                 }
  135.         }
  136.  
  137.         if (!AHIDevice)
  138.         {
  139.                 CloseAHIDevice();
  140.                 return FALSE;
  141.         }
  142.  
  143.         if (!(AHIReq2 = (AHIRequest *) CreateIORequest(AHIPort, sizeof(struct AHIRequest))))
  144.         {
  145.                 CloseAHIDevice();
  146.                 return FALSE;
  147.         }
  148.  
  149.         *AHIReq2 = *AHIReq;
  150.  
  151.         return TRUE;
  152. }
  153.  
  154. //-------------------------------------
  155.  
  156. int prelude=0;
  157.  
  158. int main(int argc, char **argv)
  159. {
  160.         struct Task *ThisTask;
  161.         int f;
  162.         BYTE OldPri;
  163.         struct PrlCtrl *prl;
  164.         int ahiunit = 0;
  165.  
  166.  AslBase=(struct Library *)OpenLibrary("asl.library",36);
  167.  if (!AslBase)
  168.  {
  169.   printf("Could not open asl.library!\n");
  170.   exit(0);
  171.  }
  172.         prelude=0;
  173.         ppcmem=1;
  174.         filespec=0;
  175.         output=1;
  176.         for (f=1;f<argc;f++)
  177.         {
  178.          if (strstr(argv[f],"-nobat")) ppcmem=0;
  179.          else if (strstr(argv[f],"-quiet")) output=0;
  180.          else if (strstr(argv[f],"-prelude")) prelude=1;       
  181.          else if (strstr(argv[f],"-program"))
  182.          {
  183.           useprog=1;
  184.           if (f+1<argc) {strcpy(prog,argv[f+1]);useprog=2;}
  185.           f=f+1;
  186.          }
  187.          else
  188.          {
  189.           strcpy(infile,argv[f]);filespec=1;
  190.          }
  191.         }
  192.  
  193.         ThisTask=FindTask(NULL);
  194.  
  195. if (!prelude)
  196. {
  197.         if (!InitAHIDevice(ahiunit, 4))
  198.         {
  199.                 fprintf(stderr, "\nError: Can't open AHI V4\n\n");
  200.                 return(5);
  201.         }
  202.         AHIReqs[0] = AHIReq;
  203.         AHIReqs[1] = AHIReq2;
  204.         link = NULL;
  205. }
  206. else
  207. {
  208.         PreludeBase=(struct PreludeBase *)OpenLibrary("prelude.library", 2);
  209.         if(PreludeBase==NULL) {
  210.                 fprintf(stderr, "\nError: Can't open prelude.library v2\n\n");
  211.                 return(5);
  212.         }
  213. }
  214.  
  215.         if (!ppcmem)
  216.         {
  217.          PlayBuffer[0]=AllocVecPPC(BUFSIZE, MEMF_CLEAR|MEMF_PUBLIC,8);
  218.          PlayBuffer[1]=AllocVecPPC(BUFSIZE, MEMF_CLEAR|MEMF_PUBLIC,8);
  219.         }
  220.         else
  221.         {
  222.          PlayBuffer[0]=AllocVecPPC(BUFSIZE,MEMF_CLEAR|MEMF_PUBLIC|MEMF_BAT|MEMF_CACHEOFF,8);
  223.          PlayBuffer[1]=AllocVecPPC(BUFSIZE,MEMF_CLEAR|MEMF_PUBLIC|MEMF_BAT|MEMF_CACHEOFF,8);
  224.         }
  225.  
  226.         if (PlayBuffer[0]==NULL || PlayBuffer[1]==NULL)
  227.         {
  228.                 if (PlayBuffer[0]) FreeVecPPC(PlayBuffer[0]);
  229.                 fprintf(stderr, "\nError: Out of memory for playback buffers\n\n");
  230.                 return(5);
  231.         }
  232.  
  233. if (prelude)
  234. {
  235.         prl=PreludeBase->PrlCtrl;
  236.         prl->PL_SigTask=ThisTask;
  237.         mysignal=AllocSignal(-1);
  238.         prl->PL_SigMask=1L<<mysignal;
  239. }
  240.  
  241.         A_DUMP_BINARY=FALSE;
  242.         A_QUIET=FALSE;
  243.         A_FORMAT_WAVE=FALSE;
  244.         A_SHOW_CNT=FALSE;
  245.         A_SET_VOLUME=-1;
  246.         A_SHOW_TIME=1;
  247.         A_AUDIO_PLAY=FALSE;
  248.         A_WRITE_TO_FILE=TRUE;
  249.         A_MSG_STDOUT=FALSE;
  250.         A_DOWNMIX=FALSE;
  251.  
  252.  
  253.         initialise_decoder();
  254.  
  255.  
  256.         if ((argc<2)||(!filespec))
  257.         {
  258.          int f;
  259.          smr=AllocAslRequest(ASL_FileRequest,0);
  260.          if (!smr)
  261.          {
  262.           printf("Could not open File-Requester!\n");
  263.           if (AslBase) CloseLibrary(AslBase);
  264.          }
  265.          if (!useprog)
  266.          {
  267.           if (!AslRequest(smr,tags))
  268.           {
  269.            printf("Could not open File-Requester!\n");
  270.            if (AslBase) CloseLibrary(AslBase);
  271.           }
  272.          }
  273.          else if (useprog!=2)
  274.          {
  275.           if (!AslRequest(smr,tags2))
  276.           {
  277.            printf("Could not open File-Requester!\n");
  278.            if (AslBase) CloseLibrary(AslBase);
  279.           }
  280.           name=&(fname[0]);
  281.           strcpy(name,((struct FileRequester *)smr)->fr_Drawer);
  282.           if (strlen(name)>0)
  283.           if ((name[strlen(name)-1]!='/')&&(name[strlen(name)-1]!=':')) strcat(name,"/");
  284.           strcat(name,smr->fr_File);
  285.           strcpy(prog,name);
  286.          }
  287.  
  288.         }
  289.         Buffer=0;
  290.         BufferPointer=PlayBuffer[0];
  291.         BufferFill=0;
  292.         PlayCnt=0;
  293.  
  294.         if (output)
  295.         {
  296.         fprintf(stderr, "\n\-------------------------------------------\n");
  297.         fprintf(stderr,"WarpAMP 0.9 - 1998, (C) by Steffen Haeuser\n");
  298.         fprintf(stderr,"based on amp (C) Tomislav Uzelac  1996,1997\n");
  299.         fprintf(stderr,"Prelude Play Code based on PreludeAMP which is\n");
  300.         fprintf(stderr,"(C) by Thomas Wenzel\n");
  301.         fprintf(stderr,"Use without infile to invoke Filerequester\n");
  302.         fprintf(stderr,"The Filerequester supports MultiSelect\n");
  303.         fprintf(stderr,"use -program to load a program consisting\n");
  304.         fprintf(stderr,"of a textfile, one title per line\n");
  305.         fprintf(stderr,"use a small-case repeat in the last line\n");
  306.         fprintf(stderr,"to run the program in a loop\n");
  307.         fprintf(stderr,"use -nobat to enable Caches\n");
  308.         fprintf(stderr,"use -prelude, if you own a Prelude Soundboard.\n");
  309.         fprintf(stderr,"-------------------------------------------\n");
  310.         if (prelude) fprintf(stderr,"prelude.library Native Mode used.\n");
  311.         else fprintf(stderr,"AHI Mode used.\n");
  312.         }
  313.         OldPri=SetTaskPri(ThisTask, 5);
  314.  
  315.         if (filespec)
  316.         {
  317.           fp=fopen(infile,"r");
  318.           if (!fp)
  319.           {
  320.            printf("Could not open file %s!\n",name);
  321.            if (AslBase) CloseLibrary(AslBase);
  322.            if (PreludeBase) CloseLibrary((struct Library *)PreludeBase);
  323.            if (smr) FreeAslRequest(smr);
  324.            exit(0);
  325.           }
  326.           else fclose(fp);
  327.           play(infile,0);
  328.           goto endit; // Goto's considered harmful :)
  329.         }
  330.         else if (!useprog)
  331.         {
  332.          for (f=1;f<=smr->fr_NumArgs;f++)
  333.          {
  334.           name=&(fname[0]);
  335.           strcpy(name,((struct FileRequester *)smr)->fr_Drawer);
  336.           if (strlen(name)>0)
  337.           if ((name[strlen(name)-1]!='/')&&(name[strlen(name)-1]!=':')) strcat(name,"/");
  338.           strcat(name,smr->fr_ArgList[f-1].wa_Name);
  339.           fp=fopen(name,"r");
  340.           if (!fp)
  341.           {
  342.            printf("Could not open file %s!\n",name);
  343.            if (AslBase) CloseLibrary(AslBase);
  344.            if (PreludeBase) CloseLibrary((struct Library *)PreludeBase);
  345.            if (smr) FreeAslRequest(smr);
  346.            exit(0);
  347.           }
  348.           else fclose(fp);
  349.           strcpy(infile,name);
  350.           play(infile, 0);
  351.           if (quit) goto endit;
  352.          }
  353.         }
  354.         else
  355.         {
  356.          char test[1024];
  357.          if (output) printf("\nPROGRAM: %s\n",prog);
  358. do
  359.         {
  360.          fil=fopen(prog,"r");
  361.          if (fil)
  362.          {
  363.           while(!feof(fil))
  364.           {
  365.            char ch;
  366.            char test2[1024];
  367.            char bla[10];
  368.            strcpy(test2,"");
  369.            do
  370.            {
  371.             fscanf(fil,"%s",test);
  372.             strcat(test2,test);
  373.             ch=fgetc(fil);
  374.             fseek(fil,-1,SEEK_CUR);
  375.             bla[0]=ch;
  376.             bla[1]=0;
  377.             if (ch!=10) strcat(test2,bla);
  378.            } while(ch!=10);
  379.            strcpy(test,test2);
  380.            if ((!feof(fil))&&(!strstr(test,"repeat")))
  381.            {
  382.             fp=fopen(test,"r");
  383.             if (!fp)
  384.             {
  385.              printf("Could not open file %s!\n",test);
  386.              if (AslBase) CloseLibrary(AslBase);
  387.              if (PreludeBase) CloseLibrary((struct Library *)PreludeBase);
  388.              if (smr) FreeAslRequest(smr);
  389.              exit(0);
  390.             }
  391.             else fclose(fp);
  392.             strcpy(infile,test);
  393.             play(infile,0);
  394.             if (quit) goto endit;
  395.            }
  396.            else if (strstr(test,"repeat"))
  397.            {
  398.             repeat=1;
  399.            }
  400.           }
  401.          }
  402.          else printf("Could not open Program File!!!\n");
  403.         } while(repeat);
  404.         if (fil) fclose(fil);
  405.        }
  406. endit:
  407.         SetTaskPri(ThisTask, OldPri);
  408.  
  409. if (!prelude)
  410. {
  411.         // Abort any pending iorequests
  412.         if (PlayCnt > 0)
  413.         {
  414.                 AbortIO((struct IORequest *) AHIReqs[Buffer^1]);
  415.                 WaitIO((struct IORequest *) AHIReqs[Buffer^1]);
  416.         }
  417.         if (PlayCnt > 1)
  418.         {
  419.                 AbortIO((struct IORequest *) AHIReqs[Buffer]);
  420.                 WaitIO((struct IORequest *) AHIReqs[Buffer]);
  421.         }
  422. }
  423. else
  424. {
  425.         PrlStop(0);
  426.         KillPrlPlayList();
  427. }
  428.         FreeVecPPC(PlayBuffer[0]);
  429.         FreeVecPPC(PlayBuffer[1]);
  430.         if(mysignal != -1) FreeSignal(mysignal);
  431.  
  432. if (!prelude) CloseAHIDevice();
  433. else
  434. {
  435.         if (PreludeBase) CloseLibrary((struct Library *) PreludeBase);
  436. }
  437.         if (smr) FreeAslRequest(smr);
  438.         if (AslBase) CloseLibrary((struct Library *)AslBase);
  439.         return(0);
  440. }
  441.  
  442.  
  443.  
  444. /* call this once at the beginning */
  445. void initialise_decoder(void) {
  446.         premultiply();
  447.         imdct_init();
  448.         calculate_t43();
  449. }
  450.  
  451. /* call this before each file is played */
  452. void initialise_globals(void) {
  453.         append=data=nch=0;
  454.         f_bdirty=TRUE;
  455.         bclean_bytes=0;
  456.  
  457.         memset(s,0,sizeof s);
  458.         memset(res,0,sizeof res);
  459. }
  460.  
  461.  
  462. void play(char *inFileStr, char *outFileStr) {
  463.         if (strcmp(inFileStr,"-")==0) {
  464.                 in_file=stdin;
  465.         }
  466.         else {
  467.                 BPTR MyLock;
  468.                 struct FileInfoBlock FIB;
  469.                 if ((in_file=fopen(inFileStr,"r"))==NULL) {
  470.                         fprintf(stderr, "Could not open file: %s\n",inFileStr);
  471.                         return;
  472.                 }
  473.                 MyLock=Lock(inFileStr,ACCESS_READ);
  474.                 Examine(MyLock,&FIB);
  475.                 filesize=FIB.fib_Size;
  476.                 if (MyLock) UnLock(MyLock);
  477.  
  478.         }
  479.         if (outFileStr) {
  480.                 if (strcmp(outFileStr,"-")==0)
  481.                         {out_file=stdout;noout=1;}
  482.         else
  483.                 {
  484.                  if ((out_file=fopen(outFileStr,"w"))==NULL) {
  485.                         fprintf(stderr, "Could not write to file: %s\n",outFileStr);
  486.                         return;
  487.                  }
  488.                  noout=0;
  489.                 }
  490.         }
  491.  
  492.         decodeMPEG();
  493.  
  494.         fclose(in_file);
  495.         if ((!A_AUDIO_PLAY)&&(!noout)) fclose(out_file);
  496.         if (output) fprintf(stderr, "\n");
  497. }
  498.  
  499. int decodeMPEG(void) {
  500.         struct AUDIO_HEADER header;
  501.         int cnt=0,g;
  502.  
  503.         initialise_globals();
  504.  
  505.         if ((g=gethdr(&header))!=0) {
  506.                 report_header_error(g);
  507.                 return -1;
  508.         }
  509.  
  510.         if (header.protection_bit==0) getcrc();
  511.  
  512.         show_header(&header);
  513.  
  514.         if (header.layer==1) {
  515.                 if (layer3_frame(&header,cnt)) {
  516.                         if (output) fprintf(stderr, " error. blip.\n");
  517.                         return -1;
  518.                 }
  519.         } else if (header.layer==2)
  520.                 if (layer2_frame(&header,cnt)) {
  521.                         if (output) fprintf(stderr, " error. blip.\n");
  522.                         return -1;
  523.                 }
  524.  
  525.  
  526. if (prelude)
  527. {
  528.         if (nch==2) PlayMode = PRL_FMT | PRL_FMTX | PRL_Stereo;
  529.         else        PlayMode = PRL_FMT | PRL_FMTX;
  530. }
  531.         PlayFreq=t_sampling_frequency[header.ID][header.sampling_frequency];
  532.  
  533.         /*
  534.          * decoder loop **********************************
  535.          */
  536.         snd_eof=FALSE;
  537.         cnt=0;
  538.         while (!snd_eof) {
  539.                 while (!snd_eof) {
  540.                         if ((g=gethdr(&header))!=0) {
  541.                         report_header_error(g);
  542.                                 snd_eof=TRUE;
  543.                                 break;
  544.       }
  545.  
  546.                         if (header.protection_bit==0) getcrc();
  547.  
  548.                         statusDisplay(&header,cnt);
  549.  
  550.                         if (header.layer==1) {
  551.                                 if (layer3_frame(&header,cnt)) {
  552.                                         if (output) fprintf(stderr, " error. blip.\n");
  553.                                         return -1;
  554.                                 }
  555.                         } else if (header.layer==2)
  556.                                 if (layer2_frame(&header,cnt)) {
  557.                                         if (output) fprintf(stderr, " error. blip.\n");
  558.                                         return -1;
  559.                                 }
  560.                         cnt++;
  561.                 }
  562.         }
  563.         return 0;
  564. }
  565.  
  566. void report_header_error(int err) {
  567.         if (!output) return;
  568.         switch (err) {
  569.                 case GETHDR_ERR: fprintf(stderr, "error reading mpeg bitstream. exiting.\n");
  570.                                  break;
  571.                 case GETHDR_NS:  fprintf(stderr, "this is a file in MPEG 2.5 format, which is not defined\n");
  572.                                  fprintf(stderr, "by ISO/MPEG. It is \"a special Fraunhofer format\".\n");
  573.                                  fprintf(stderr, "amp does not support this format. sorry.\n");
  574.                                  break;
  575.                 case GETHDR_FL1: fprintf(stderr, "ISO/MPEG layer 1 is not supported by amp (yet).\n");
  576.                                  break;
  577.                 case GETHDR_FF:  fprintf(stderr, "free format bitstreams are not supported. sorry.\n");
  578.                                  break;
  579.                 case GETHDR_SYN: fprintf(stderr, "oops, we're out of sync.\n");
  580.                      break;
  581.                 case GETHDR_EOF: break;
  582.         }
  583. }
  584.  
  585.  
  586. void statusDisplay(struct AUDIO_HEADER *header, int frameNo) {
  587.         int minutes,seconds;
  588.         if (!output) return;
  589.         if ((A_SHOW_CNT || A_SHOW_TIME) && !(frameNo%40))
  590.                 fprintf(stderr, "\r");
  591.         if (A_SHOW_CNT && !(frameNo%10) ) {
  592.                 fprintf(stderr, "Frame { %d } ",frameNo);
  593.         }
  594.         if (A_SHOW_TIME && !(frameNo%40)) {
  595.                 seconds=frameNo*1152/t_sampling_frequency[header->ID][header->sampling_frequency];
  596.                 minutes=seconds/60;
  597.                 seconds=seconds % 60;
  598.                 fprintf(stderr, "Time [%d:%02d]", minutes, seconds);
  599.         }
  600.         if (A_SHOW_CNT || A_SHOW_TIME)
  601.                 fflush(stderr);
  602. }
  603.  
  604. BOOL WayBehind=FALSE;
  605. void printout(void) {
  606.         int len;
  607.         int j;
  608.  
  609.         if (nch==2) j=32 * 18 * 2;
  610.         else        j=32 * 18;
  611.  
  612.         len=sizeof(short)*j;
  613.  
  614.         memcpy(BufferPointer, sample_buffer, len);
  615.         BufferPointer += len;
  616.         BufferFill    += len;
  617.  
  618.         if (BufferFill >= BUFSIZE)
  619.         {
  620. if (!prelude)
  621. {
  622.                         AHIReqs[Buffer]->ahir_Std.io_Command = CMD_WRITE;
  623.                         AHIReqs[Buffer]->ahir_Std.io_Flags   = 0;
  624.                         AHIReqs[Buffer]->ahir_Std.io_Data    = PlayBuffer[Buffer];
  625.                         AHIReqs[Buffer]->ahir_Std.io_Length  = BUFSIZE;
  626.                         AHIReqs[Buffer]->ahir_Std.io_Offset  = 0;
  627.                         AHIReqs[Buffer]->ahir_Type = (nch == 2 ? AHIST_S16S : AHIST_M16S);
  628.                         AHIReqs[Buffer]->ahir_Frequency = PlayFreq;
  629.                         AHIReqs[Buffer]->ahir_Volume = 0x10000;
  630.                         AHIReqs[Buffer]->ahir_Position = 0x8000;
  631.                         AHIReqs[Buffer]->ahir_Link = link;
  632.                         SendIO((struct IORequest *) AHIReqs[Buffer]);
  633.                         PlayCnt++;
  634.  
  635.                         if (link)
  636.                         {
  637.                                 Signals = Wait(SIGBREAKF_CTRL_C | (1L << AHIPort->mp_SigBit));
  638.  
  639.                                 WaitIO((struct IORequest *) link);
  640.                         }
  641.  
  642.                         link = AHIReqs[Buffer];
  643.                         Buffer ^= 1;
  644.  
  645.                         BufferPointer = PlayBuffer[Buffer];
  646.                         BufferFill=0;
  647. }
  648. else
  649. {
  650.                 PrlPlay(PlayBuffer[Buffer], BUFSIZE, PlayMode, PlayFreq);
  651.                 Buffer=1-Buffer;
  652.  
  653.                 BufferPointer=PlayBuffer[Buffer];
  654.                 BufferFill=0;
  655.  
  656.                 PlayCnt++;
  657.                 if(PlayCnt >1) Signals=Wait(1L<<mysignal | SIGBREAKF_CTRL_C);
  658. }
  659.  
  660.                 if(Signals & SIGBREAKF_CTRL_C) {snd_eof=TRUE;quit=1;}
  661.         }
  662. }
  663.  
  664. void die(char *str, ...) {
  665. }
  666.