home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 369a.lha / SoundConvert_v1.1 / SoundConvert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-09  |  1.4 KB  |  60 lines

  1. /*
  2.             S O U N D C O N V E R T
  3.  
  4.                      V 1.1
  5.                
  6.          Written 4/12/89 by Greg Dunlap
  7.  
  8.    This program converts raw binary sampled sound data between the Amiga
  9. and the Macintosh. It converts both ways. Just give it the source and
  10. destination files when it asks for them and let it do all the rest!
  11.  
  12. */
  13.  
  14.  
  15. #include <stdio.h>
  16. #include <dos.h>
  17.  
  18. #define BUFFERSIZE 1024    /* Size of read/write buffer */
  19. #define FILENAMESIZE 256   /* Max length of file name */
  20.  
  21. void main()
  22. {
  23.  
  24.    char buffer[BUFFERSIZE];
  25.    char sourcefile[FILENAMESIZE], destfile[FILENAMESIZE];
  26.    int i;
  27.    int sfh, dfh;
  28.    int charsread, returnedlength;
  29.  
  30.    printf("Amiga <--> Macintosh sound converter V1.1, 4/12/89 by Greg Dunlap\n");
  31.    printf("Enter sourcefile: ");
  32.    scanf("%s",sourcefile);
  33.    printf("Enter destfile: ");
  34.    scanf("%s",destfile);
  35.    if ((sfh = Open(sourcefile, MODE_OLDFILE)) == 0)
  36.    {
  37.       printf("Error opening \"%s\" for input.\n",sourcefile);
  38.       exit();
  39.    }
  40.    if ((dfh = Open(destfile, MODE_NEWFILE)) == 0)
  41.    {
  42.       printf("Error opening \"%s\" for output.\n",destfile);
  43.       Close(sfh);
  44.       exit();
  45.    }
  46.    printf("Working..");
  47.    do
  48.    {
  49.       charsread = Read(sfh,buffer,BUFFERSIZE);
  50.       for(i=0; i<charsread; buffer[i++] -= 128);
  51.       if (charsread > 0)
  52.          returnedlength = Write(dfh,buffer,charsread);
  53.    } while(charsread == BUFFERSIZE && returnedlength == charsread);
  54.    Close(sfh);
  55.    Close(dfh);
  56.    printf("..done!\n");
  57. }
  58.  
  59.  
  60.