start to use code from the original resample codebase, since it uses fixed point math instead of float; however, the code is not at all complete right now, I just commit this to get it off my HD (neither the old nor the new code in resample.cpp work anyway)
svn-id: r10089
This commit is contained in:
parent
63cd3051f3
commit
ef373fe2e8
2 changed files with 689 additions and 488 deletions
1118
sound/resample.cpp
1118
sound/resample.cpp
File diff suppressed because it is too large
Load diff
|
@ -24,15 +24,64 @@
|
||||||
|
|
||||||
#include "sound/rate.h"
|
#include "sound/rate.h"
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
byte priv[1024];
|
/* this Float MUST match that in filter.c */
|
||||||
} eff_struct;
|
#define Float double/*float*/
|
||||||
typedef eff_struct *eff_t;
|
|
||||||
|
// From resample's stddef.h
|
||||||
|
typedef int16 HWORD;
|
||||||
|
typedef uint16 UHWORD;
|
||||||
|
typedef int32 WORD;
|
||||||
|
typedef uint32 UWORD;
|
||||||
|
|
||||||
|
#define MAX_HWORD (32767)
|
||||||
|
#define MIN_HWORD (-32768)
|
||||||
|
|
||||||
|
|
||||||
|
#define MAXNWING 8192
|
||||||
|
|
||||||
|
|
||||||
|
/* Private data for Lerp via LCM file */
|
||||||
|
typedef struct resamplestuff {
|
||||||
|
double Factor; /* Factor = Fout/Fin sample rates */
|
||||||
|
int quadr; /* non-zero to use qprodUD quadratic interpolation */
|
||||||
|
|
||||||
|
|
||||||
|
long Nq;
|
||||||
|
|
||||||
|
long dhb;
|
||||||
|
|
||||||
|
long a, b; /* gcd-reduced input,output rates */
|
||||||
|
long t; /* Current time/pos for exact-coeff's method */
|
||||||
|
|
||||||
|
long Xh; /* number of past/future samples needed by filter */
|
||||||
|
long Xoff; /* Xh plus some room for creep */
|
||||||
|
long Xread; /* X[Xread] is start-position to enter new samples */
|
||||||
|
long Xp; /* X[Xp] is position to start filter application */
|
||||||
|
long Xsize, Ysize; /* size (Floats) of X[],Y[] */
|
||||||
|
long Yposition; /* FIXME: offset into Y buffer */
|
||||||
|
Float *X, *Y; /* I/O buffers */
|
||||||
|
} *resample_t;
|
||||||
|
|
||||||
|
|
||||||
/** High quality rate conversion algorithm, based on SoX (http://sox.sourceforge.net). */
|
/** High quality rate conversion algorithm, based on SoX (http://sox.sourceforge.net). */
|
||||||
class ResampleRateConverter : public RateConverter {
|
class ResampleRateConverter : public RateConverter {
|
||||||
protected:
|
protected:
|
||||||
eff_struct effp;
|
resamplestuff rstuff;
|
||||||
|
|
||||||
|
int quadr; /* non-zero to use qprodUD quadratic interpolation */
|
||||||
|
|
||||||
|
UHWORD LpScl; /* Unity-gain scale factor */
|
||||||
|
UHWORD Nwing; /* Filter table size */
|
||||||
|
UHWORD Nmult; /* Filter length for up-conversions */
|
||||||
|
HWORD Imp[MAXNWING]; /* Filter coefficients */
|
||||||
|
HWORD ImpD[MAXNWING]; /* ImpD[n] = Imp[n+1]-Imp[n] */
|
||||||
|
|
||||||
|
HWORD *X1, *Y1;
|
||||||
|
HWORD *X2, *Y2;
|
||||||
|
|
||||||
|
UWORD Time; /* Current time/pos in input sample */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResampleRateConverter(st_rate_t inrate, st_rate_t outrate, int quality);
|
ResampleRateConverter(st_rate_t inrate, st_rate_t outrate, int quality);
|
||||||
~ResampleRateConverter();
|
~ResampleRateConverter();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue