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

This is sfshrink.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 sf,result,headersize;
        struct stat sfst;
        long dur;
        SFHEADER sfh;
        char *sfname;
        double atof(),amount;

        if(argc != 3) {
                printf("format: sfshrink  new_duration_in_seconds filename\n");
                exit(-1);
        }
        amount = atof(*++argv);
        sfname = *++argv;
        drwopensf(sfname,sf,sfh,sfst,"sfprint",result,2)
        if(result < 0) exit(-1);
        if(result == 1) headersize = SIZEOF_BSD_HEADER;
        else headersize = SIZEOF_NeXT_HEADER;
        printf("headersize = %d\n",headersize);

        dur = amount * sfsrate(&sfh) * sfclass(&sfh) 
                * sfchans(&sfh) + headersize;
        dur -= dur % (sfclass(&sfh) * sfchans(&sfh));
        if(ftruncate(sf,(long)dur) < 0) 
                printf("Bad truncation\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.