home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Examples / SoundAndMusic / SoundLibrary / recordtest.c < prev   
Text File  |  1990-10-10  |  1KB  |  56 lines

  1.  
  2. /*
  3.  * recordtest - record many short soundfiles, such that when they are played
  4.  * back with playtest, an uninterrupted sound occurs.
  5.  */
  6.  
  7. #import <sound/sound.h>
  8. #import <stdio.h>
  9.  
  10. main (int argc, char *argv[])
  11. {
  12.     int size, err, j;
  13.     SNDSoundStruct *s[10], *s2;
  14.  
  15.     if (argc < 2) {
  16.     printf("usage : recordtest file ...\n");
  17.     exit(0);
  18.     }
  19.     
  20.     //
  21.     // Allocate a fixed-sized buffer for each file
  22.     //
  23.     for (j=1; j<argc; j++) {
  24.     err = SNDAlloc(&s[j],4096,SND_FORMAT_MULAW_8,SND_RATE_CODEC,1,0);
  25.     if (err) fprintf(stderr,"recordtest : cannot allocate buffers\n");
  26.     }
  27.     
  28.     //
  29.     // enqueue all the recording requests
  30.     //
  31.     printf("recording...\n");
  32.     for (j=1; j<argc; j++) {
  33.     err = SNDStartRecording(s[j],j,1,0,0,0);
  34.     if (err) fprintf(stderr,"recordtest : cannot start recording\n");
  35.     }
  36.     
  37.     //
  38.     // Wait for all of the requests to complete
  39.     //
  40.     SNDWait(0);
  41.     
  42.     //
  43.     // Write out the files
  44.     //
  45.     printf("writing files...\n");
  46.     for (j=1; j<argc; j++) {
  47.     err = SNDWriteSoundfile(argv[j],s[j]);
  48.     if (err) fprintf(stderr,"recordtest : cannot write file %s...\n", 
  49.                                     argv[j]);
  50.     }
  51.     
  52.     exit(0);
  53. }
  54.  
  55.  
  56.