This is sndtofloat.c in view mode; [Download] [Up]
/* * sndtofloat.c * Convert a single-precision floating point soundfile to ascii decimal * floating point values. */ #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; float *data; NXSwappedFloat temp; if (argc != 3) { fprintf(stderr, "%s - convert a single precision floating point soundfile " "to ascii decimal floating point values.\n", argv[0]); fprintf(stderr, "Usage: %s soundfile ascii-file\n", argv[0]); 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); } if (s->dataFormat != SND_FORMAT_FLOAT) { fprintf(stderr, "*** WARNING: Soundfile is not single precision " "floating point\n\tNo decoding is done by this program.\n"); } sampleCount = s->dataSize / sizeof(float); /* channel independent */ data = (float *) ((char *)s + s->dataLocation); for (i = 0; i < sampleCount; i++) { temp = NXConvertHostFloatToSwapped(data[i]); fprintf(fp, "%f\n", (float) NXSwapBigFloatToHost(temp)); } fclose(fp); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.