Lines Matching refs:st

88    SpeexDecorrState *st = speex_alloc(sizeof(SpeexDecorrState));
89 st->rate = rate;
90 st->channels = channels;
91 st->frame_size = frame_size;
93 st->psy = vorbis_psy_init(rate, 2*frame_size);
94 spx_drft_init(&st->lookup, 2*frame_size);
95 st->wola_mem = speex_alloc(frame_size*sizeof(float));
96 st->curve = speex_alloc(frame_size*sizeof(float));
98 st->y = speex_alloc(frame_size*sizeof(float));
100 st->buff = speex_alloc(channels*2*frame_size*sizeof(float));
101 st->ringID = speex_alloc(channels*sizeof(int));
102 st->order = speex_alloc(channels*sizeof(int));
103 st->alpha = speex_alloc(channels*sizeof(float));
104 st->ring = speex_alloc(channels*ALLPASS_ORDER*sizeof(float));
107 st->vorbis_win = speex_alloc((2*frame_size+20)*sizeof(float));
109 st->vorbis_win[i] = sin(.5*M_PI* sin(M_PI*i/(2*frame_size))*sin(M_PI*i/(2*frame_size)) );
110 st->seed = rand();
115 st->ring[ch][i] = 0;
116 st->ringID[ch] = 0;
117 st->alpha[ch] = 0;
118 st->order[ch] = 10;
120 return st;
141 EXPORT void speex_decorrelate(SpeexDecorrState *st, const spx_int16_t *in, spx_int16_t *out, int strength)
152 for (ch=0;ch<st->channels;ch++)
155 int N=2*st->frame_size;
166 buff = st->buff+ch*2*st->frame_size;
167 ring = st->ring[ch];
168 ringID = st->ringID[ch];
169 order = st->order[ch];
170 alpha = st->alpha[ch];
172 for (i=0;i<st->frame_size;i++)
173 buff[i] = buff[i+st->frame_size];
174 for (i=0;i<st->frame_size;i++)
175 buff[i+st->frame_size] = in[i*st->channels+ch];
177 x = buff+st->frame_size;
187 for (i=0;i<st->frame_size;i++)
189 st->y[i] = alpha*(x[i-ALLPASS_ORDER+order]-beta*x[i-ALLPASS_ORDER+order-1])*st->vorbis_win[st->frame_size+i+order]
190 + x[i-ALLPASS_ORDER]*st->vorbis_win[st->frame_size+i]
193 ring[ringID++]=st->y[i];
194 st->y[i] *= st->vorbis_win[st->frame_size+i];
198 order = order+(irand(&st->seed)%3)-1;
203 /*order = 5+(irand(&st->seed)%6);*/
208 alpha = alpha + .4*uni_rand(&st->seed);
216 for (i=0;i<st->frame_size;i++)
218 float tmp = alpha*(x[i-ALLPASS_ORDER+order]-beta*x[i-ALLPASS_ORDER+order-1])*st->vorbis_win[i+order]
219 + x[i-ALLPASS_ORDER]*st->vorbis_win[i]
223 tmp *= st->vorbis_win[i];
226 st->y[i] += tmp;
232 for (i=0;i<2*st->frame_size;i++)
236 compute_curve(st->psy, buff, st->curve);
237 for (i=1;i<st->frame_size;i++)
242 x1 = uni_rand(&st->seed);
243 x2 = uni_rand(&st->seed);
245 gain = coef*sqrt(.1+st->curve[i]);
249 frame[0] = coef*uni_rand(&st->seed)*sqrt(.1+st->curve[0]);
250 frame[2*st->frame_size-1] = coef*uni_rand(&st->seed)*sqrt(.1+st->curve[st->frame_size-1]);
251 spx_drft_backward(&st->lookup,frame);
252 for (i=0;i<2*st->frame_size;i++)
253 frame[i] *= st->vorbis_win[i];
256 for (i=0;i<st->frame_size;i++)
259 float tmp = st->y[i] + frame[i] + st->wola_mem[i];
260 st->wola_mem[i] = frame[i+st->frame_size];
262 float tmp = st->y[i];
268 out[i*st->channels+ch] = tmp;
271 st->ringID[ch] = ringID;
272 st->order[ch] = order;
273 st->alpha[ch] = alpha;
278 EXPORT void speex_decorrelate_destroy(SpeexDecorrState *st)
281 vorbis_psy_destroy(st->psy);
282 speex_free(st->wola_mem);
283 speex_free(st->curve);
285 speex_free(st->buff);
286 speex_free(st->ring);
287 speex_free(st->ringID);
288 speex_free(st->alpha);
289 speex_free(st->vorbis_win);
290 speex_free(st->order);
291 speex_free(st->y);
292 speex_free(st);