This is makefloat.c in view mode; [Download] [Up]
/* makefloat routine by Perry R. Cook Stanford CCRMA 1991 This makes a (mono) soundfile into floating point samples, with no header. Use before LPC, etc. */ #import <stdio.h> #import <fcntl.h> #import <string.h> #import <sound/sound.h> struct headerform { char pref[4]; int hdr_length; int file_length; int mode; int samp_rate; int num_channels; char comment[1000]; }; main(ac,av) int ac; char *av[]; { char *file_name_in,*file_name_out; char mode[4],file_name[100]; short data[5000]; unsigned char codec_data[5000]; float float_data[5000]; struct headerform hdr; int i,fd,fd2,n_read,n_write; if (ac==3) { file_name_in = av[1]; file_name_out = av[2]; fd = open(file_name_in,0); if (fd!=-1) { if (!strcmp(file_name_in,file_name_out)) { fprintf(stderr,"Input and output files can't have same name!!\n"); exit(0); } fd2 = creat(&file_name_out[0], 0644); n_read = read(fd,hdr.pref,4); n_read = read(fd,&hdr.hdr_length,4); n_read = read(fd,&hdr.file_length,4); n_read = read(fd,&hdr.mode,4); n_read = read(fd,&hdr.samp_rate,4); n_read = read(fd,&hdr.num_channels,4); n_read = read(fd,&hdr.comment,hdr.hdr_length-24); while (n_read>0) { if (hdr.samp_rate == 8012) { n_read = read(fd,codec_data,5000); for (i=0;i<n_read;i++) float_data[i] = (float) SNDiMulaw(codec_data[i]); n_write = write(fd2,&float_data,n_read*4); } else { n_read = read(fd,data,10000); for (i=0;i<n_read/2;i++) float_data[i] = data[i]; n_write = write(fd2,&float_data,n_read*2); } } close(fd); close(fd2); } else printf("I couldn't find your input file!!!\n"); } else printf("Format is makefloat infile.snd outfile.snd\n"); return; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.