This is fof.c in view mode; [Download] [Up]
/* * Generated by the NeXT Interface Builder. */ #import <stdio.h> #import <fcntl.h> #import <string.h> #include <sound/sound.h> #include <math.h> #define TWO_PI 6.28 #define SRATE 22050.0 #define FOF_LENGTH 100.0 /* fof routine by Perry R. Cook Stanford CCRMA 1991. You specify formant centers and amplitudes, the program synthesizes a soundfile. See fofinstructions for details. */ main(ac,av) int ac; char *av[]; { char *sound_file; double freq0,freq1,freq2,freq3,gain1,gain2,gain3; SNDSoundStruct *sound_out; short *data_out; double window,time,period,win_freq; int i,j,k,m,total_samples; if (ac==10) { total_samples = atoi(av[1]); freq0 = atoi(av[2]); freq1 = atoi(av[3]) * TWO_PI / SRATE; freq2 = atoi(av[4]) * TWO_PI / SRATE; freq3 = atoi(av[5]) * TWO_PI / SRATE; gain1 = atoi(av[6]); gain2 = atoi(av[7]); gain3 = atoi(av[8]); sound_file = av[9]; SNDAlloc(&sound_out, total_samples * 2,SND_FORMAT_LINEAR_16, SRATE,1,20); data_out = (short *) sound_out + sound_out->dataLocation; time = 0; if (freq0>0) period = SRATE / freq0; else period = total_samples-1; win_freq = TWO_PI / FOF_LENGTH; while (time < total_samples - period) { j = time; for (k=0;k<FOF_LENGTH;k++) { window = 1.0 - cos(win_freq * k); data_out[j+k] += gain1 * sin(k*freq1) * window; data_out[j+k] += gain2 * sin(k*freq2) * window; data_out[j+k] += gain3 * sin(k*freq3) * window; } time +=period; } SNDWait(SNDWriteSoundfile(sound_file,sound_out)); SNDFree(sound_out); } else printf("Format is fof numSamples f0 f1 f2 f3 gain1 gain2 gain3 soundfile.snd\n"); return; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.