ftp.nice.ch/pub/next/unix/audio/sndutil.1.3.s.tar.gz#/sndutil-1.3/sndtools/sndtoasm.c

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

/*
 * sndtoasm.c
 *	Convert a soundfile to a DSP assembly language include file.
 */
#import <stdio.h>
#import <sound/sound.h>
#import <architecture/byte_order.h>

void main (int argc, char *argv[])
{
    int err, i, sampleCount;
    SNDSoundStruct *s;
    FILE *fp;
    short *data;

    if (argc != 3) {
	fprintf(stderr,
		"%s - convert a soundfile to a DSP assembly language include file\n",
		argv[0]);
	fprintf(stderr, "Usage: sndtoasm soundfile outfile.asm\n");
	exit(1);
    }
    err = SNDReadSoundfile(argv[1], &s);
    if (err) {
	fprintf(stderr, "Cannot read soundfile: %s\n", argv[1]);
	exit(1);
    }
    if ((fp = fopen(argv[2], "w")) == NULL) {
	fprintf(stderr, "Cannot open ascii file: %s\n", argv[2]);
	exit(1);
    }

    sampleCount = s->dataSize / sizeof(short);	/* channel independent */
    data = (short *) ((char *)s + s->dataLocation);

    for (i = 0; i < sampleCount; i++)
	fprintf(fp, "\tdc $%04hx\n",
		NXSwapBigShortToHost(((unsigned short *)data)[i]));
    fclose(fp);
}



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