File:  [NeXTSTEP 3.3 examples] / Examples / SoundAndMusic / SoundLibrary / recordfiletest.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:25 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

/*
 * 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 of SNDAlloc() 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);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.