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 #ifdef HAVE_CONFIG_H
00030 #include "config.h"
00031 #endif
00032
00033 #ifndef MAX
00034 #define MAX(x,y) ((x)>(y) ?(x):(y))
00035 #endif
00036 #ifndef MIN
00037 #define MIN(x,y) ((x)<(y) ?(x):(y))
00038 #endif
00039
00040 #define MAX_HWORD (32767)
00041 #define MIN_HWORD (-32768)
00042
00043 #define IBUFFSIZE 4096
00044
00075 class aflibData;
00076
00077 class aflibConverter {
00078
00079 public:
00080
00081
00082 aflibConverter (
00083 bool high_quality,
00084 bool linear_interpolation,
00085 bool filter_interpolation);
00086
00087 ~aflibConverter();
00088
00089 void
00090 initialize(
00091 double factor,
00092 int channels,
00093 double volume = 1.0);
00094
00095 int
00096 resample(
00097 int& inCount,
00098 int outCount,
00099 short inArray[],
00100 short outArray[]);
00101
00102
00103 private:
00104
00105 aflibConverter();
00106
00107 aflibConverter(const aflibConverter& op);
00108
00109 const aflibConverter&
00110 operator=(const aflibConverter& op);
00111
00112 int
00113 err_ret(char *s);
00114
00115 void
00116 deleteMemory();
00117
00118 int
00119 readData(
00120 int inCount,
00121 short inArray[],
00122 short *outPtr[],
00123 int dataArraySize,
00124 int Xoff,
00125 bool init_count);
00126
00127
00128 inline short
00129 WordToHword(int v, int scl)
00130 {
00131 short out;
00132 int llsb = (1<<(scl-1));
00133 v += llsb;
00134 v >>= scl;
00135 if (v>MAX_HWORD) {
00136 v = MAX_HWORD;
00137 } else if (v < MIN_HWORD) {
00138 v = MIN_HWORD;
00139 }
00140 out = (short) v;
00141 return out;
00142 };
00143
00144 int
00145 SrcLinear(
00146 short X[],
00147 short Y[],
00148 double factor,
00149 unsigned int *Time,
00150 unsigned short& Nx,
00151 unsigned short Nout);
00152
00153 int
00154 SrcUp(
00155 short X[],
00156 short Y[],
00157 double factor,
00158 unsigned int *Time,
00159 unsigned short& Nx,
00160 unsigned short Nout,
00161 unsigned short Nwing,
00162 unsigned short LpScl,
00163 short Imp[],
00164 short ImpD[],
00165 bool Interp);
00166
00167 int
00168 SrcUD(
00169 short X[],
00170 short Y[],
00171 double factor,
00172 unsigned int *Time,
00173 unsigned short& Nx,
00174 unsigned short Nout,
00175 unsigned short Nwing,
00176 unsigned short LpScl,
00177 short Imp[],
00178 short ImpD[],
00179 bool Interp);
00180
00181 int
00182 FilterUp(
00183 short Imp[],
00184 short ImpD[],
00185 unsigned short Nwing,
00186 bool Interp,
00187 short *Xp,
00188 short Ph,
00189 short Inc);
00190
00191 int
00192 FilterUD(
00193 short Imp[],
00194 short ImpD[],
00195 unsigned short Nwing,
00196 bool Interp,
00197 short *Xp,
00198 short Ph,
00199 short Inc,
00200 unsigned short dhb);
00201
00202 int
00203 resampleFast(
00204 int& inCount,
00205 int outCount,
00206 short inArray[],
00207 short outArray[]);
00208
00209 int
00210 resampleWithFilter(
00211 int& inCount,
00212 int outCount,
00213 short inArray[],
00214 short outArray[],
00215 short Imp[], short ImpD[],
00216 unsigned short LpScl, unsigned short Nmult, unsigned short Nwing);
00217
00218
00219 static short SMALL_FILTER_IMP[];
00220 static short LARGE_FILTER_IMP[];
00221
00222 bool interpFilt;
00223 bool largeFilter;
00224 bool linearInterp;
00225 short ** _II;
00226 short ** _JJ;
00227 unsigned int _Time;
00228 double _factor;
00229 int _nChans;
00230 bool _initial;
00231 double _vol;
00232
00233 };
00234
00235
00236 #endif