ftp.nice.ch/pub/next/unix/audio/cmix.s.tar.gz#/cmix/head/sfextend.c

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

#include "../H/sfheader.h"
#include <stdio.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <errno.h>
static SFCODE	ampcode = {
	SF_MAXAMP,
	sizeof(SFMAXAMP) + sizeof(SFCODE)
}; 

main(argc,argv)
int argc;
char **argv;

{
	int i,sf,result;
	struct stat sfst;
	long dur;
	SFHEADER sfh;
	char *sfname;
	double atof(),amount;
	long position,frame;
	char zero[16]; /* assuming a channel block contains 4*4bytes at most*/

	
	if(argc != 3) {
              printf("format: sfextend  amount_to_add_to_duration  filename\n");
	      exit(-1);
	}
	amount = atof(*++argv);
	sfname = *++argv;
	rwopensf(sfname,sf,sfh,sfst,"sfprint",result,2)
	if(result < 0) exit(-1);
	dur = amount * sfsrate(&sfh) * sfclass(&sfh) * sfchans(&sfh);
	frame = sfclass(&sfh) * sfchans(&sfh);
	dur -= dur % frame;
	for(i=0; i<frame; i++) zero[i] = 0;
	if((position = lseek(sf,dur,2)) < 0)
		printf("Bad lseek on file\n");
	if(write(sf,(char *)zero,frame) <= 0) 
		printf("Bad write on end of file\n");
	putlength(sfname,sf,&sfh);
	close(sf);
}

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