#define BIAS 0x84 /* define the add-in bias for 16 bit samples */ #define CLIP 32635 #define FRAMESIZE 160 #define LPC_FILTORDER 10 typedef struct { unsigned short period; unsigned char gain; char k[LPC_FILTORDER]; char pad; } lpcparams_t; /* * we can't use 'sizeof(lpcparams_t)' because some compilers * add random padding so define size of record that goes over net. */ #define LPCRECSIZE 14 typedef struct { double Oldper, OldG, Oldk[LPC_FILTORDER + 1], bp[LPC_FILTORDER + 1]; int pitchctr; } lpcstate_t; void lpc_init(lpcstate_t* state); void lpc_analyze(short *buf, lpcparams_t *params); int lpc_synthesize(short *buf, lpcparams_t *params, lpcstate_t* state, double speedup); #define MAXWINDOW 1000 /* Max analysis window length */ #define FS 8000.0 /* Sampling rate */ #define DOWN 5 /* Decimation for pitch analyzer */ #define PITCHORDER 4 /* Model order for pitch analyzer */ #define FC 600.0 /* Pitch analyzer filter cutoff */ #define MINPIT 50.0 /* Minimum pitch */ #define MAXPIT 300.0 /* Maximum pitch */ #define MINPER (int)(FS/(DOWN*MAXPIT)+.5) /* Minimum period */ #define MAXPER (int)(FS/(DOWN*MINPIT)+.5) /* Maximum period */ #define WSCALE 1.5863 /* Energy loss due to windowing */ #define BUFLEN ((FRAMESIZE * 3) / 2) /* This reduces the output gain so we are less likely to clip. */ #define GAIN_REDUCTION 0.8