00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _AFLIBCONVERTER_H_
00027 #define _AFLIBCONVERTER_H_
00028
00029 #ifndef MAX
00030 #define MAX(x,y) ((x)>(y) ?(x):(y))
00031 #endif
00032 #ifndef MIN
00033 #define MIN(x,y) ((x)<(y) ?(x):(y))
00034 #endif
00035
00036 #define MAX_HWORD (32767)
00037 #define MIN_HWORD (-32768)
00038
00039 typedef char BOOL;
00040 typedef short HWORD;
00041 typedef unsigned short UHWORD;
00042 typedef int WORD;
00043 typedef unsigned int UWORD;
00044 #define IBUFFSIZE 4096
00045
00074 class aflibConverter {
00075
00076 public:
00077
00078
00079 aflibConverter (
00080 bool high_quality,
00081 bool linear_interpolation,
00082 bool filter_interpolation);
00083
00084 ~aflibConverter();
00085
00086 void
00087 initialize(
00088 double factor,
00089 int channels);
00090
00091 int
00092 resample(
00093 int& inCount,
00094 int outCount,
00095 HWORD inArray[],
00096 HWORD outArray[]);
00097
00098
00099 private:
00100
00101 aflibConverter();
00102
00103 aflibConverter(const aflibConverter& op);
00104
00105 const aflibConverter&
00106 operator=(const aflibConverter& op);
00107
00108 int
00109 err_ret(char *s);
00110
00111 void
00112 deleteMemory();
00113
00114 int
00115 readData(
00116 int inCount,
00117 HWORD inArray[],
00118 HWORD *outPtr[],
00119 int dataArraySize,
00120 int Xoff,
00121 bool init_count);
00122
00123
00124 inline HWORD
00125 WordToHword(WORD v, int scl)
00126 {
00127 HWORD out;
00128 WORD llsb = (1<<(scl-1));
00129 v += llsb;
00130 v >>= scl;
00131 if (v>MAX_HWORD) {
00132 #ifdef DEBUG
00133 if (pof == 0)
00134 fprintf(stderr, "*** resample: sound sample overflow\n");
00135 else if ((pof % 10000) == 0)
00136 fprintf(stderr, "*** resample: another ten thousand overflows\n");
00137 pof++;
00138 #endif
00139 v = MAX_HWORD;
00140 } else if (v < MIN_HWORD) {
00141 #ifdef DEBUG
00142 if (nof == 0)
00143 fprintf(stderr, "*** resample: sound sample (-) overflow\n");
00144 else if ((nof % 1000) == 0)
00145 fprintf(stderr, "*** resample: another thousand (-) overflows\n");
00146 nof++;
00147 #endif
00148 v = MIN_HWORD;
00149 }
00150 out = (HWORD) v;
00151 return out;
00152 };
00153
00154 int
00155 SrcLinear(
00156 HWORD X[],
00157 HWORD Y[],
00158 double factor,
00159 UWORD *Time,
00160 UHWORD& Nx,
00161 UHWORD Nout);
00162
00163 int
00164 SrcUp(
00165 HWORD X[],
00166 HWORD Y[],
00167 double factor,
00168 UWORD *Time,
00169 UHWORD& Nx,
00170 UHWORD Nout,
00171 UHWORD Nwing,
00172 UHWORD LpScl,
00173 HWORD Imp[],
00174 HWORD ImpD[],
00175 BOOL Interp);
00176
00177 int
00178 SrcUD(
00179 HWORD X[],
00180 HWORD Y[],
00181 double factor,
00182 UWORD *Time,
00183 UHWORD& Nx,
00184 UHWORD Nout,
00185 UHWORD Nwing,
00186 UHWORD LpScl,
00187 HWORD Imp[],
00188 HWORD ImpD[],
00189 BOOL Interp);
00190
00191 WORD
00192 FilterUp(
00193 HWORD Imp[],
00194 HWORD ImpD[],
00195 UHWORD Nwing,
00196 BOOL Interp,
00197 HWORD *Xp,
00198 HWORD Ph,
00199 HWORD Inc);
00200
00201 WORD
00202 FilterUD(
00203 HWORD Imp[],
00204 HWORD ImpD[],
00205 UHWORD Nwing,
00206 BOOL Interp,
00207 HWORD *Xp,
00208 HWORD Ph,
00209 HWORD Inc,
00210 UHWORD dhb);
00211
00212 int
00213 resampleFast(
00214 int& inCount,
00215 int outCount,
00216 HWORD inArray[],
00217 HWORD outArray[]);
00218
00219 int
00220 resampleWithFilter(
00221 int& inCount,
00222 int outCount,
00223 HWORD inArray[],
00224 HWORD outArray[],
00225 HWORD Imp[], HWORD ImpD[],
00226 UHWORD LpScl, UHWORD Nmult, UHWORD Nwing);
00227
00228
00229 static HWORD SMALL_FILTER_IMP[];
00230 static HWORD LARGE_FILTER_IMP[];
00231
00232 bool interpFilt;
00233 bool largeFilter;
00234 bool linearInterp;
00235 HWORD ** X;
00236 HWORD ** Y;
00237 UWORD Time;
00238 double factor;
00239 int nChans;
00240 bool initial;
00241
00242 };
00243
00244
00245 #endif