MusicKit  0.0.0
numerics.h
00001 /* numerics.h */
00002 
00003 /* 6/1/95  - jos, created */
00004 /* 4/6/96  - gps, integrated all include files in musickit_c.h */ 
00005 /* 4/11/96 - gps, added SGI dependencies                       */ 
00006 
00007 
00008 #define NTICK 16
00009 #define MKTICKSIZE NTICK
00010 #define MKVECTORSIZE MKTICKSIZE
00011 
00012 #define MAX(a,b) ((a)<(b) ? (b) : (a))
00013 #define MIN(a,b) ((a)>(b) ? (b) : (a))
00014 
00015 typedef double word;            /* signed data */
00016 typedef double u_word;          /* unsigned data */
00017 typedef double dbl;             /* double precision */
00018 typedef double u_dbl;           /* unsigned double precision */
00019 
00020 #define MAX_WORD ((double)(1.0))
00021 #define MIN_WORD ((double)(-1.0))
00022 
00023 #define mk_int_to_word(ival) (((word)ival) / (((word)MAXINT)+1.0))
00024 #define mk_unsigned_int_to_word(ival) ((word)(ival) / (2.0*(((word)MAXINT)+1.0)))
00025 #define mk_double_to_word(dval) dval
00026 #define mk_word_to_short(dval) ((short)(MIN(MAX((dval*((word)MAXSHORT)), \
00027                                                 -((word)MAXSHORT)), \
00028                                             ((word)MAXSHORT))));
00029 void mk_double_to_word_array(word *wval, double *dval, int n);
00030 void mk_word_to_short_array(short *sval, double *wval, int n);
00031 #define mk_double_to_doubleword(dval) dval
00032 
00033 typedef double addr;                    /* 16 bit addresses  */
00034 typedef double MKPatchVector[16];       /* Patchvectors are 16-sample arrays */
00035 typedef double MKPatchVectorDouble[16]; /* Needed for init() code */
00036 typedef double PP[16];                  /* Abbreviated form */
00037 typedef double *pp;                     /* Use this in UGs */
00038 typedef double *synthdata;              /* Synthdata can be any length */
00039 
00040 typedef struct _MKWavetable {
00041     word *data;
00042     int size;
00043 } MKWavetable;
00044 
00045 enum roundingModes {rounding, truncation, magnitude_truncation};