home *** CD-ROM | disk | FTP | other *** search
- /*
- * July 5, 1991
- * Copyright 1991 Lance Norskog And Sundry Contributors
- * This source code is freely redistributable and may be used for
- * any purpose. This copyright notice must be maintained.
- * Lance Norskog And Sundry Contributors are not responsible for
- * the consequences of using this software.
- */
-
- /*
- * AUX sources header file.
- */
-
- #include <stdio.h>
-
- /*
- * Format information for input and output files.
- */
-
- #define PRIVSIZE 50
-
- struct format {
- int rate; /* sampling rate */
- int size; /* word length of data */
- int style; /* format of sample numbers */
- int channels; /* number of sound channels: 1, 2, or 4 */
- char swap; /* do byte- or word-swap */
- char seekable; /* can seek on this file */
- char *filetype; /* type of file */
- char *which; /* "input" or "output" */
- FILE *fp; /* File stream pointer */
- struct handler *h; /* handler struct for this file */
- char priv[PRIVSIZE]; /* handler's private data area */
- } informat, outformat;
-
- typedef struct format *ft_t;
-
- /* Size field */
- #define BYTE 1
- #define WORD 2
- #define LONG 4
- #define FLOAT 5
- #define DOUBLE 6
- #define IEEE 7 /* IEEE 80-bit floats. Is it necessary? */
-
- /* Style field */
- #define UNSIGNED 1 /* unsigned linear: Sound Blaster */
- #define SIGN2 2 /* signed linear 2's comp: Mac */
- #define ULAW 3 /* U-law signed logs: US telephony, SPARC */
- #define ALAW 4 /* A-law signed logs: non-US telephony */
-
- /*
- * Handler structure for each format.
- */
-
- struct handler {
- char **names; /* file type names */
- int (*startread)();
- int (*read)();
- int (*stopread)();
- int (*startwrite)();
- int (*write)();
- int (*stopwrite)();
- };
-
- extern struct handler handlers[];
-
- /* Handler types, coordinate with handlers.c */
- #define RAWTYPE 0
- #define VOCTYPE 1
- #define AUTYPE 2
- #define SFTYPE 3
-
- extern char *sizes[], *styles[];
-
- #ifdef __ANSI__
- #define P1(x) x
- #define P2(x,y) x, y
- #define P3(x,y,z) x, y, z
- #define P4(x,y,z,z) x, y, z, w
- #else
- #define P1(x)
- #define P2(x,y)
- #define P3(x,y,z)
- #define P4(x,y,z,w)
- #endif
-
- /* Utilities to read and write shorts and longs little-endian and big-endian */
- unsigned short rlshort(P1(ft_t ft)); /* short little-end */
- unsigned short rbshort(P1(ft_t ft)); /* short big-end */
- unsigned short wlshort(P2(ft_t ft, unsigned short us)); /* short little-end */
- unsigned short wbshort(P2(ft_t ft, unsigned short us)); /* short big-end */
- unsigned long rllong(P1(ft_t ft)); /* long little-end */
- unsigned long rblong(P1(ft_t ft)); /* long big-end */
- unsigned long wllong(P2(ft_t ft, unsigned long ul)); /* long little-end */
- unsigned long wblong(P2(ft_t ft, unsigned long ul)); /* long big-end */
- /* Read and write words and longs in "machine format". Swap if indicated. */
- unsigned short rshort(P1(ft_t ft));
- unsigned short wshort(P2(ft_t ft, unsigned short us));
- unsigned long rlong(P1(ft_t ft));
- unsigned long wlong(P2(ft_t ft, unsigned long ul));
- /* Utilities to byte-swap values */
- unsigned short swapw(P1(unsigned short us)); /* Swap short */
- unsigned long swapl(P1(unsigned long ul)); /* Swap long */
-