This is emphasize.c in view mode; [Download] [Up]
#import <stdio.h> #import <fcntl.h> #import <string.h> #import <math.h> #import <sound/sound.h> /* emphasize routine by Perry R. Cook Stanford CCRMA 1991. This applies a one-pole filter to a soundfile and writes out the filter file. The default pole location is good for pre-emphasis before Linear Predictive Coding of a speech sound. */ main(ac,av) int ac; char *av[]; { char *file_name_in,*file_name_out; char file_name[100]; float coeff=0.0,output=0.0,float_data[5000]; int i,fd,fd2,n_read,n_write; if (ac>=3) { if (ac==3) { coeff = -0.95; file_name_in = av[1]; file_name_out = av[2]; } else { coeff = atof(av[1]); file_name_in = av[2]; file_name_out = av[3]; } 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 = 1; while (n_read>0) { n_read = read(fd,float_data,20000); for (i=0;i<n_read/4;i++) { output = (output * coeff) + float_data[i]; float_data[i] = output; } n_write = write(fd2,&float_data,n_read); } close(fd); close(fd2); } else printf("I couldn't find your input file!!!\n"); } else printf("Format is emphasize [coefficient] 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.