ftp.nice.ch/pub/next/unix/audio/cmix.s.tar.gz#/cmix/objc/Comb.m

This is Comb.m in view mode; [Download] [Up]

#import "Comb.h"

@implementation Comb: Object
{
	float rev,sr,*delayLine;
	int phs,len;
}
+ create {
	id newInstance;
	newInstance = [ self new ];
	return newInstance;
}
-loopt:(float)loop sRate:(int)aSR revTime:(float)arevtime {
	char *malloc();
	double pow();
	sr = aSR;
	len = loop * aSR + .5;
	rev = (float)pow(.001,(double)(loop/arevtime));
	if((delayLine = (float *)malloc((int)(len *  4))) == 0) {
		printf("can't malloc memory for delayline\n");
		exit(-1);
	}
	for(phs = 0; phs< len; phs++) delayLine[phs] = 0;
	phs = 0;
}
- (float)bang: (float) sample {
	float temp;
	if(phs >= len) phs = 0;
	temp = delayLine[phs];
	delayLine[phs] = delayLine[phs++] * rev + sample;
	return (temp) ;
}
- freeup {
	free(delayLine);
	return;
}
@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.