MusicKit  0.0.0
DSPConversion.h
00001 #ifndef __MK_DSPConversion_H___
00002 #define __MK_DSPConversion_H___
00003 /* DSPConversion.h - Functions having to do with data type conversion
00004  * Copyright 1988-1992, NeXT Inc.  All rights reserved.
00005  * Author: Julius O. Smith III
00006  */
00007 
00008 #include "MKDSPDefines.h"
00009 
00010 MKDSP_API int DSPFix24ToInt(DSPFix24 ival);
00011 
00012 MKDSP_API DSPFix24 DSPIntToFix24(int ival);
00013 
00014 MKDSP_API int DSPFix24ToIntArray(
00015     DSPFix24 *fix24Array,
00016     int *intArray,
00017     int wordCount);
00018 
00019 MKDSP_API int DSPIntToFix24Array(
00020     int *intArray,
00021     DSPFix24 *fix24Array,
00022     int wordCount);
00023 
00024 MKDSP_API float DSPIntToFloat(int ival);
00025 
00026 MKDSP_API int DSPFloatToIntCountClips(
00027     float fval,
00028     int *npc,                   /* no. positive clips */
00029     int *nnc);                  /* no. negative clips */
00030 
00031 MKDSP_API int DSPFloatToInt(float fval);
00032 
00033 MKDSP_API int DSPFloatToIntArray(
00034     float *floatArray,
00035     int *intArray,
00036     int wordCount);
00037 
00038 MKDSP_API int DSPIntToFloatArray(
00039     int *intArray,
00040     float *floatArray,
00041     int wordCount);
00042 
00043 MKDSP_API float DSPFix24ToFloat(int ival);
00044 
00045 MKDSP_API DSPFix24 DSPFloatToFix24(float fval);
00046 
00047 MKDSP_API int DSPFix24ToFloatArray(
00048     DSPFix24 *fix24Array,
00049     float *floatArray,
00050     int wordCount);
00051 
00052 MKDSP_API int DSPFloatToFix24Array(
00053     float *floatArray,
00054     DSPFix24 *fix24Array,
00055     int wordCount);
00056 
00057 MKDSP_API double DSPIntToDouble(int ival);
00058 
00059 MKDSP_API int DSPDoubleToIntCountClips(
00060     double dval,
00061     int *npc,                   /* no. positive clips */
00062     int *nnc);                  /* no. negative clips */
00063 
00064 MKDSP_API int DSPDoubleToInt(double dval);
00065 
00066 MKDSP_API int DSPDoubleToIntArray(
00067     double *doubleArray,
00068     int *intArray,
00069     int wordCount);
00070 
00071 MKDSP_API int DSPIntToDoubleArray(
00072     int *intArray,
00073     double *doubleArray,
00074     int wordCount);
00075 
00076 MKDSP_API double DSPFix24ToDouble(int ival);
00077 
00078 MKDSP_API int DSPFix24ToDoubleArray(
00079     DSPFix24 *fix24Array,
00080     double *doubleArray,
00081     int wordCount);
00082 
00083 MKDSP_API DSPFix24 DSPDoubleToFix24(double dval);
00084 
00085 MKDSP_API int DSPDoubleToFix24Array(
00086     double *doubleArray,
00087     DSPFix24 *fix24Array,
00088     int wordCount);
00089 
00090 
00091 MKDSP_API int DSPFix48ToInt(register DSPFix48 *aFix48P);
00092 /* 
00093  * Returns *aFix48P as an int, masking out the upper two bytes of the
00094  * DSPFix48 datum.  If aFix48P is NULL, it returns -1.
00095  */
00096 
00097 
00098 MKDSP_API DSPFix48 *DSPIntToFix48(int ival);
00099 /* 
00100  * Returns a pointer to a new DSPFix48 with the value as represented by ival.
00101  */
00102 
00103 
00104 MKDSP_API DSPFix48 *DSPIntToFix48UseArg(
00105     unsigned ival,
00106     register DSPFix48 *aFix48P);
00107 /* 
00108  * Returns, in *aFix48P, the value as represented by ival. 
00109  * aFix48P must point to a valid DSPFix48 struct. 
00110  */
00111 
00112 
00113 MKDSP_API DSPFix48 *DSPDoubleToFix48UseArg(
00114     double dval,
00115     register DSPFix48 *aFix48P);
00116 /* 
00117  * The double is assumed to be between -1.0 and 1.0.
00118  * Returns, in *aFix48P, the value as represented by dval. 
00119  * aFix48P must point to a valid DSPFix48 struct. 
00120  */
00121 
00122 
00123 MKDSP_API DSPFix48 *DSPDoubleToFix48(double dval);
00124 /* 
00125  * Returns, a pointer to a new DSPFix48 
00126  * with the value as represented by dval. 
00127  * The double is assumed to be between -1.0 and 1.0. 
00128  */
00129 
00130 
00131 MKDSP_API double DSPFix48ToDouble(register DSPFix48 *aFix48P);
00132 /* 
00133  * Returns *aFix48P as a double between 2^47 and -2^47.
00134  * If aFix48P is NULL, returns -1.0. 
00135  */
00136 
00137 
00138 /********** Float <--> Short *************/
00139 
00140 MKDSP_API  float DSPShortToFloat(short sval);
00141 
00142 MKDSP_API  int DSPFloatToShortCountClips(
00143     float fval, 
00144     int *npc,
00145     int *nnc);
00146 
00147 MKDSP_API  short DSPFloatToShort(float fval);
00148 
00149 MKDSP_API int DSPFloatToShortArray(
00150     float *floatArray,
00151     short *shortArray,
00152     int wordCount);
00153 
00154 MKDSP_API int DSPShortToFloatArray(
00155     short *shortArray,
00156     float *floatArray,
00157     int wordCount);
00158 
00159 /********** Double <--> Short *************/
00160 
00161 MKDSP_API  double DSPShortToDouble(short sval);
00162 
00163 MKDSP_API  int DSPDoubleToShortCountClips(
00164     double dval,
00165     int *npc,
00166     int *nnc);
00167 
00168 MKDSP_API  short DSPDoubleToShort(double dval);
00169 
00170 MKDSP_API int DSPDoubleToShortArray(
00171     double *doubleArray,
00172     short *shortArray,
00173     int wordCount);
00174 
00175 MKDSP_API int DSPShortToDoubleArray(
00176     short *shortArray,
00177     double *doubleArray,
00178     int wordCount);
00179 
00180 #endif