home *** CD-ROM | disk | FTP | other *** search
- /*
- * recordfiletest - use the sound library to record directly to a file.
- * This example records from the codec microphone, but note that using
- * SNDStartRecordingFile() is especially useful for high sample rate
- * recording from the DSP. Also note that when recording from the DSP, the
- * dataFormat of the resulting soundfile must be changed to a playable format
- * (like SND_FORMAT_LINEAR_16) before it can be played back.
- *
- * The use W(qNDAlloc() causes virtual memory to be allocated, but since
- * samples are written directly to a file, this VM is never touched.
- */
- #import <sound/sound.h>
- #import <stdio.h>
-
- #define SECONDS 5.0
-
- main (int argc, char *argv[])
- {
- int err;
- SNDSoundStruct *s;
-
- if (argc != 2) {
- printf("usage : recordfiletest file\n");
- exit(1);
- }
-
- err = SNDAlloc(&s,SECONDS*SND_RATE_CODEC,SND_FORMAT_MULAW_8,
- SND_RATE_CODEC,1,0);
- if (err) fprintf(stderr,"recordfiletest : cannot allocate buffer\n");
-
- printf("recording...\n");
- err = SNDStartRecordingFile(argv[1],s,1,1,0,0,0);
- if (err) fprintf(stderr,"recordfiletest : cannot start recording\n");
-
- SNDWait(0);
- SNDFree(s);
- exit(0);
- }
-