This is sampfunc.c in view mode; [Download] [Up]
#include "../H/ugens.h" #include "../H/sfheader.h" #include <stdio.h> #include <sys/file.h> #include <sys/types.h> extern SFHEADER sfdesc[NFILES]; double sampfunc(p,n_args) float *p; int n_args; { int fnumber,skipin; float *thefunct; /* p0 == number of the function, p1 == amount to skip */ fnumber = p[0]; skipin = p[1]; thefunct = (float *) floc(fnumber); return(thefunct[skipin]); } double sampfunci(p,n_args) /* interpolated version of sampfunc -- DAS 5/90 */ float *p; int n_args; { int fnumber,size,skipin, skipin2; float *thefunct, frac; /* p0 == number of the function, p1 == amount to skip */ fnumber = p[0]; skipin = p[1]; frac = p[1] - skipin; thefunct = (float *) floc(fnumber); size = fsize(fnumber); if(skipin >= size-2) { skipin = size - 1; skipin2 = skipin; } else skipin2 = skipin + 1; return(thefunct[skipin] + frac * (thefunct[skipin2]-thefunct[skipin])); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.