47 |
#include "discsignal.hh" |
#include "discsignal.hh" |
48 |
#include "contsignal.hh" |
#include "contsignal.hh" |
49 |
|
|
50 |
|
#define LPC_FILTORDER 10 |
51 |
|
#define FRAMESIZE 160 |
52 |
|
#ifdef OLDCC |
53 |
|
# define signed |
54 |
|
# define const |
55 |
|
#endif |
56 |
|
#define LPCRECSIZE 14 |
57 |
|
|
58 |
|
#define MAXWINDOW 1000 /* Max analysis window length */ |
59 |
|
#define FS 8000.0 /* Sampling rate */ |
60 |
|
|
61 |
|
#define DOWN 5 /* Decimation for pitch analyzer */ |
62 |
|
#define PITCHORDER 4 /* Model order for pitch analyzer */ |
63 |
|
#define FC 600.0 /* Pitch analyzer filter cutoff */ |
64 |
|
#define MINPIT 50.0 /* Minimum pitch */ |
65 |
|
#define MAXPIT 300.0 /* Maximum pitch */ |
66 |
|
|
67 |
|
#define MINPER (int)(FS/(DOWN*MAXPIT)+.5) /* Minimum period */ |
68 |
|
#define MAXPER (int)(FS/(DOWN*MINPIT)+.5) /* Maximum period */ |
69 |
|
|
70 |
|
#define WSCALE 1.5863 /* Energy loss due to windowing */ |
71 |
|
|
72 |
|
#define BUFLEN ((FRAMESIZE * 3) / 2) |
73 |
|
|
74 |
|
#define SILENCEFIX /* Enable absolute silence fix */ |
75 |
|
|
76 |
|
/* The LPC coder does truly awful things when driven into clipping. |
77 |
|
If you set GAIN_ADJUST to a number less than 1.0, samples will |
78 |
|
be scaled by that factor to avoid overdriving the coder. */ |
79 |
|
|
80 |
|
#define GAIN_ADJUST 0.9 |
81 |
|
|
82 |
|
typedef struct |
83 |
|
{ |
84 |
|
unsigned short period; |
85 |
|
unsigned char gain; |
86 |
|
char pad; |
87 |
|
signed char k[LPC_FILTORDER]; |
88 |
|
} lpcparams_t; |
89 |
|
|
90 |
|
|
91 |
|
typedef struct |
92 |
|
{ |
93 |
|
double Oldper; |
94 |
|
double OldG; |
95 |
|
double Oldk[LPC_FILTORDER + 1]; |
96 |
|
double bp[LPC_FILTORDER + 1]; |
97 |
|
int pitchctr; |
98 |
|
} lpcstate_t; |
99 |
|
|
100 |
|
|
101 |
class lpc: public Algo { |
class lpc: public Algo { |
102 |
// Associations |
// Associations |
103 |
// Attributes |
// Attributes |
104 |
// Operations |
// Operations |
105 |
public: |
public: |
106 |
lpc ( ContSignal signal ); |
int lpc_start(void); |
107 |
|
void lpc_init(lpcstate_t* state); |
108 |
|
void lpc_analyze(const unsigned char *buf, lpcparams_t *params); |
109 |
|
void lpc_synthesize(unsigned char *buf, lpcparams_t *params, lpcstate_t* state); |
110 |
|
void lpc_end(void); |
111 |
|
/* lpc ( ContSignal signal ); |
112 |
lpc ( DiscSignal signal ); |
lpc ( DiscSignal signal ); |
113 |
lpc ( ContLogSignal signal ); |
lpc ( ContLogSignal signal ); |
114 |
lpc ( DiscLogSignal signal ); |
lpc ( DiscLogSignal signal ); |
115 |
|
*/ |
116 |
}; |
}; |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
#endif |
#endif |