st.h

Go to the documentation of this file.
00001 #ifndef SCI_ST 
00002 #define SCI_ST 
00003 
00004 #include "wav.h" 
00005 
00006 /*
00007  * July 5, 1991
00008  * Copyright 1991 Lance Norskog And Sundry Contributors
00009  * This source code is freely redistributable and may be used for
00010  * any purpose.  This copyright notice must be maintained. 
00011  * Lance Norskog And Sundry Contributors are not responsible for 
00012  * the consequences of using this software.
00013  */
00014 #if (defined(netbsd) || defined(freebsd) || defined(__APPLE__)) && !defined(unix) 
00015 #define unix
00016 #endif
00017 
00018 #define IMPORT  extern
00019 #define EXPORT 
00020 
00021 /*
00022  * Sound Tools sources header file.
00023  */
00024 
00025 #include <stdio.h>
00026 
00027 /*
00028  * Handler structure for each format.
00029  */
00030 
00031 
00032 /* Signal parameters */
00033 
00034 struct  signalinfo {
00035         long            rate;           /* sampling rate */
00036         int             size;           /* word length of data */
00037         int             style;          /* format of sample numbers */
00038         int             channels;       /* number of sound channels */
00039 };
00040 
00041 /* Loop parameters */
00042 
00043 struct  loopinfo {
00044         int             start;          /* first sample */
00045         int             length;         /* length */
00046         int             count;          /* number of repeats, 0=forever */
00047         int             type;           /* 0=no, 1=forward, 2=forward/back */
00048 };
00049 
00050 /* Instrument parameters */
00051 
00052 /* vague attempt at generic information for sampler-specific info */
00053 
00054 struct  instrinfo {
00055         char            MIDInote;       /* for unity pitch playback */
00056         char            MIDIlow, MIDIhi;/* MIDI pitch-bend range */
00057         char            loopmode;       /* semantics of loop data */
00058         char            nloops;         /* number of active loops */
00059         unsigned char   smpte[4];       /* SMPTE offset (hour:min:sec:frame) */
00060                                         /* this is a film audio thing */
00061 };
00062 
00063 
00064 #define MIDI_UNITY 60           /* MIDI note number to play sample at unity */
00065 
00066 /* Loop modes */
00067 #define LOOP_NONE          0    
00068 #define LOOP_8             1    /* 8 loops: don't know ?? */
00069 #define LOOP_SUSTAIN_DECAY 2    /* AIFF style: one sustain & one decay loop */
00070 
00071 /* Pipe parameters */
00072 
00073 struct  pipeinfo {
00074         FILE    *pout;                  /* Output file */
00075         FILE    *pin;                   /* Input file */
00076 };
00077 
00078 /*
00079  *  Format information for input and output files.
00080  */
00081 
00082 #define PRIVSIZE        100
00083 
00084 #define NLOOPS          8
00085 
00086 struct soundstream {
00087         struct  signalinfo info;        /* signal specifications */
00088         struct  instrinfo instr;        /* instrument specification */
00089         struct  loopinfo loops[NLOOPS]; /* Looping specification */
00090         char    swap;                   /* do byte- or word-swap */
00091         char    seekable;               /* can seek on this file */
00092         char    *filename;              /* file name */
00093         char    *filetype;              /* type of file */
00094         char    *comment;               /* comment string */
00095         FILE    *fp;                    /* File stream pointer */
00096         double  priv[PRIVSIZE/8];       /* format's private data area */
00097         int     ierr;
00098 };
00099 
00100 IMPORT struct soundstream informat, outformat;
00101 typedef struct soundstream *ft_t;
00102 
00103 /* flags field */
00104 #define FILE_STEREO     1       /* does file format support stereo? */
00105 #define FILE_LOOPS      2       /* does file format support loops? */
00106 #define FILE_INSTR      4       /* does file format support instrument specificications? */
00107 
00108 
00109 /* Size field */
00110 #define BYTESCI 1
00111 #define WORDSCI 2
00112 #define LONGSCI 4
00113 #define FLOATSCI        5
00114 #define DOUBLESCI       6
00115 #define IEEE    7               /* IEEE 80-bit floats.  Is it necessary? */
00116 
00117 
00118 /* Style field */
00119 #define UNSIGNED        1       /* unsigned linear: Sound Blaster */
00120 #define SIGN2           2       /* signed linear 2's comp: Mac */
00121 #define ULAW            3       /* U-law signed logs: US telephony, SPARC */
00122 #define ALAW            4       /* A-law signed logs: non-US telephony */
00123 
00124 IMPORT char *sizes[], *styles[];
00125 
00126 #if     defined(__STDC__) || defined(ARM)
00127 #define P1(x) x
00128 #define P2(x,y) x, y
00129 #define P3(x,y,z) x, y, z
00130 #define P4(x,y,z,w) x, y, z, w
00131 #else
00132 #define P1(x)
00133 #define P2(x,y)
00134 #define P3(x,y,z)
00135 #define P4(x,y,z,w)
00136 #endif
00137 
00138 /* Utilities to read and write shorts and longs little-endian and big-endian */
00139 unsigned short rlshort(P1(ft_t ft));                    /* short little-end */
00140 unsigned short rbshort(P1(ft_t ft));                    /* short big-end    */
00141 void wlshort(P2(ft_t ft, unsigned short us));   /* short little-end */
00142 void wbshort(P2(ft_t ft, unsigned short us));   /* short big-end    */
00143 unsigned long  rllong(P1(ft_t ft));                     /* long little-end  */
00144 unsigned long  rblong(P1(ft_t ft));                     /* long big-end     */
00145 void wllong(P2(ft_t ft, unsigned long ul));     /* long little-end  */
00146 void wblong(P2(ft_t ft, unsigned long ul));     /* long big-end     */
00147 /* Read and write words and longs in "machine format".  Swap if indicated.  */
00148 unsigned short rshort(P1(ft_t ft));                     
00149 void wshort(P2(ft_t ft, unsigned short us));
00150 unsigned long  rlong(P1(ft_t ft));              
00151 void  wlong(P2(ft_t ft, unsigned long ul));
00152 float          rfloat(P1(ft_t ft));
00153 void wfloat(ft_t ft, float f);
00154 double         rdouble(P1(ft_t ft));
00155 void           wdouble(P2(ft_t ft, double d));
00156 
00157 /* Utilities to byte-swap values */
00158 unsigned int   swapi(P1(unsigned int us));              /* Swap int */
00159 unsigned short swapw(P1(unsigned short us));            /* Swap short */
00160 unsigned long  swapl(P1(unsigned long ul));             /* Swap long */
00161 float          swapf(P1(float f));                      /* Swap float */
00162 double         swapd(P1(double d));                     /* Swap double */
00163 
00164 #ifdef ARM
00165 IMPORT double sfloor(P1(double x));   /* Hack our way around the flawed */
00166 IMPORT double sceil(P1(double x));    /* UnixLib floor ceil functions */
00167 #endif
00168 
00169 
00170 IMPORT void report(P2(char *, ...)),  warn(P2(char *, ...)),
00171          fail(P2(char *, ...));
00172 
00173 typedef unsigned int u_i;
00174 typedef unsigned long u_l;
00175 typedef unsigned short u_s;
00176 
00177 IMPORT float volume;    /* expansion coefficient */
00178 IMPORT int dovolume;
00179 
00180 IMPORT float amplitude; /* Largest sample so far */
00181 
00182 /* export flags */
00183 IMPORT int summary;     /* just print summary of information */
00184 
00185 IMPORT char *myname;
00186 
00187 IMPORT int soxpreview;  /* Preview mode: be fast and ugly */
00188 
00189 #define MAXRATE 50L * 1024                      /* maximum sample rate */
00190 
00191 #if  defined(unix) || defined (__OS2__) || defined(aix)
00192 /* Some wacky processors don't have arithmetic down shift, so do divs */
00193 /* Most compilers will turn this into a shift if they can, don't worry */
00194 #define RIGHT(datum, bits)      ((datum) / (1L << bits)) 
00195 #define LEFT(datum, bits)       ((datum) << bits) 
00196 #else
00197 /* x86 & 68k PC's have arith shift ops and dumb compilers */
00198 #define RIGHT(datum, bits)      ((datum) >> bits)
00199 #define LEFT(datum, bits)       ((datum) << bits)
00200 #endif
00201 
00202 #ifndef M_PI
00203 #define M_PI    3.14159265358979323846
00204 #endif
00205 
00206 #if     defined(unix) || defined(AMIGA) || defined (__OS2__) \
00207         || defined(OS9) || defined(ARM) || defined(aix)
00208 #define READBINARY      "r"
00209 #define WRITEBINARY     "w"
00210 #endif
00211 #ifdef  VMS
00212 #define READBINARY      "r", "mbf=16", "ctx=stm" 
00213 #define WRITEBINARY     "w", "ctx=stm"
00214 #endif
00215 #if defined(DOS) || defined(_MSC_VER)
00216 #define READBINARY      "rb"
00217 #define WRITEBINARY     "wb"
00218 #endif
00219 
00220 /* default values */ 
00221 #ifndef READBINARY 
00222 #define READBINARY "r"
00223 #endif
00224 
00225 #ifndef WRITEBINARY
00226 #define WRITEBINARY "w"
00227 #endif
00228 
00229  
00230 
00231 
00232 /* Error code reporting */
00233 #ifdef  QNX
00234 #include <errno.h>
00235 #endif
00236 
00237 #if defined(unix) || defined(__OS2__) || defined(aix)
00238 #include <errno.h>
00239 extern int errno;
00240 #endif
00241 
00242 #ifdef  __OS2__
00243 #define REMOVE remove
00244 #else
00245 #define REMOVE unlink
00246 #endif
00247 
00248 char *version();                        /* return version number */
00249 /* ummmm??? */
00250 
00251 #include "machine.h" 
00252 
00253 #if defined(__alpha)|defined(__ia64__)
00254 int wavread __PARAMS((ft_t ft, int *buf, long int len));
00255 #else
00256 int wavread __PARAMS((ft_t ft, long int *buf, long int len));
00257 #endif
00258 
00259 
00260 void  wavstartread __PARAMS((ft_t ft,WavInfo *,int flag));
00261 void wavwrite __PARAMS((ft_t ft, long int *buf, long int len));
00262 void wavstartwrite __PARAMS((ft_t ft));
00263 void wavstopwrite  __PARAMS((ft_t ft));
00264 void wavwritehdr  __PARAMS((ft_t ft));
00265 
00266 #if defined(__alpha)|defined(__ia64__)
00267 int rawread __PARAMS((ft_t ft,int * buf,long nsamp));
00268 #else
00269 int rawread __PARAMS((ft_t ft,long * buf,long nsamp));
00270 #endif
00271 void rawwrite __PARAMS((ft_t ft,long *buf, long nsamp) );
00272 
00273 #endif 

Generated on Sun Mar 4 15:04:00 2007 for Scilab [trunk] by  doxygen 1.5.1