ftp.nice.ch/pub/next/unix/audio/cmix.s.tar.gz#/cmix/proto/srhalf.m

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

#import <objc/objc.h>
#import <soundkit/soundkit.h>
/* compile cc -o srhalf -O srhalf.m -lNeXT_s -lsys_s */
/* usage: srhalf infile outfile */

main(argc,argv)
int argc;
char *argv[];
{
	/* simple program to copy everyother sample from one file
	   to another (halve sampling rate) */

	id aSound,bSound;
	char *inname,*outname;
	unsigned char *adata,*bdata;
	short *ardata,*brdata;
	int error,nsamps,i,j;
	int counter = 0;
	
	inname = argv[1];
	outname = argv[2];
	printf("%s %s\n",inname,outname);
	aSound = [Sound new];
	bSound = [Sound new];
	error = [aSound readSoundfile:inname];
	if (error) die(error);
	nsamps = [aSound sampleCount];
	error = [bSound setDataSize:nsamps dataFormat:SND_FORMAT_LINEAR_16
		samplingRate:SND_RATE_LOW  channelCount:1 infoSize:1004];
	if(error) die(error);
	adata = [aSound data];
	ardata = (short *)adata;
	bdata = [bSound data];
	brdata = (short *)bdata;
	j=nsamps; i=nsamps/2;
	
	for(i=0,j=0; j<nsamps; i++,j += 2) 
			brdata[i] = ardata[j];
	
		
	printf("Writing soundfile to disk\n");
	[bSound writeSoundfile:outname];
}
die(error)
{
	printf("%s\n",SNDSoundError(error));
	exit(-1);
}

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