ftp.nice.ch/pub/next/unix/audio/cmusic.bs.N.tar.gz#/src/lib/libprocom/SCCS/s.fgetsample.c

This is s.fgetsample.c in view mode; [Download] [Up]

h27503
s 00002/00004/00038
d D 1.3 86/09/12 16:25:59 dgl 3 2
c fix to getheader.
e
s 00000/00000/00042
d D 1.2 85/11/26 23:00:52 dgl 2 1
c eliminated LOOKED_ALREADY from getheader to cure bug 
c re. trying to add property to stdin if no header exists yet.
e
s 00042/00000/00000
d D 1.1 85/11/25 09:57:09 dgl 1 0
c original version
e
u
U
f i 
t
T
I 1
/* %M%	%I%	(CARL)	%G%	%U% */

#include <stdio.h>
#include <carl/carl.h>
#include <carl/defaults.h>
#include <carl/procom.h>


fgetsample(xp, iop)
	float *xp;
	FILE *iop;
{
	register struct fltbuf *fbp;

	fbp = &fb[fileno(iop)];			/* get fid buffer pointer */
	if (fbp->gpflt == 0) {			/* first time? */
		set_sample_size(sizeof(float));
		if (finitbuf(iop))		/* setup buffer */
			return(-1);
D 3
		if (!fbp->prop) {		/* go get header */
			if (getheader(iop) < 0)
				return(-1);
		}
E 3
I 3
		if (!fbp->prop) 		/* go get header */
			getheader(iop);
E 3
	}

	if (fbp->pos >= fbp->n) {	/* get floatsam */
		if ((fbp->n = read(fileno(iop),(char *)fbp->fbuf,P_BUFSIZE))<=0)
			return(fbp->n);
		fbp->pos = 0;
		fbp->n /= fbp->ssize;
	}


	if (fbp->ssize == sizeof(float))
		*xp = fbp->fbuf[fbp->pos++];
	else {
		register short *sx = (short *) fbp->fbuf;
		*xp = (float) sx[fbp->pos++] / 32767.0;
	}

	return(fbp->ssize);		/* success */
}
E 1

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