Home | History | Annotate | Download | only in libspeex

Lines Matching refs:st

128 void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len);
161 spx_word32_t Davg1; /* 1st recursive average of the residual power difference */
163 spx_float_t Dvar1; /* Estimated variance of 1st estimator */
410 SpeexEchoState *st = (SpeexEchoState *)speex_alloc(sizeof(SpeexEchoState));
412 st->K = nb_speakers;
413 st->C = nb_mic;
414 C=st->C;
415 K=st->K;
424 st->frame_size = frame_size;
425 st->window_size = 2*frame_size;
426 N = st->window_size;
427 M = st->M = (filter_length+st->frame_size-1)/frame_size;
428 st->cancel_count=0;
429 st->sum_adapt = 0;
430 st->saturated = 0;
431 st->screwed_up = 0;
433 st->sampling_rate = 8000;
434 st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate);
436 st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate);
437 st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate);
439 st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;
440 st->beta_max = (.5f*st->frame_size)/st->sampling_rate;
442 st->leak_estimate = 0;
444 st->fft_table = spx_fft_init(N);
446 st->e = (spx_word16_t*)speex_alloc(C*N*sizeof(spx_word16_t));
447 st->x = (spx_word16_t*)speex_alloc(K*N*sizeof(spx_word16_t));
448 st->input = (spx_word16_t*)speex_alloc(C*st->frame_size*sizeof(spx_word16_t));
449 st->y = (spx_word16_t*)speex_alloc(C*N*sizeof(spx_word16_t));
450 st->last_y = (spx_word16_t*)speex_alloc(C*N*sizeof(spx_word16_t));
451 st->Yf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
452 st->Rf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
453 st->Xf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
454 st->Yh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
455 st->Eh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
457 st->X = (spx_word16_t*)speex_alloc(K*(M+1)*N*sizeof(spx_word16_t));
458 st->Y = (spx_word16_t*)speex_alloc(C*N*sizeof(spx_word16_t));
459 st->E = (spx_word16_t*)speex_alloc(C*N*sizeof(spx_word16_t));
460 st->W = (spx_word32_t*)speex_alloc(C*K*M*N*sizeof(spx_word32_t));
462 st->foreground = (spx_word16_t*)speex_alloc(M*N*C*K*sizeof(spx_word16_t));
464 st->PHI = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t));
465 st->power = (spx_word32_t*)speex_alloc((frame_size+1)*sizeof(spx_word32_t));
466 st->power_1 = (spx_float_t*)speex_alloc((frame_size+1)*sizeof(spx_float_t));
467 st->window = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
468 st->prop = (spx_word16_t*)speex_alloc(M*sizeof(spx_word16_t));
469 st->wtmp = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
471 st
474 st->window[i] = (16383-SHL16(spx_cos(DIV32_16(MULT16_16(25736,i<<1),N)),1));
475 st->window[N-i-1] = st->window[i];
479 st->window[i] = .5-.5*cos(2*M_PI*i/N);
481 for (i=0;i<=st->frame_size;i++)
482 st->power_1[i] = FLOAT_ONE;
484 st->W[i] = 0;
489 st->prop[0] = QCONST16(.7, 15);
490 sum = EXTEND32(st->prop[0]);
493 st->prop[i] = MULT16_16_Q15(st->prop[i-1], decay);
494 sum = ADD32(sum, EXTEND32(st->prop[i]));
498 st->prop[i] = DIV32(MULT16_16(QCONST16(.8f,15), st->prop[i]),sum);
502 st->memX = (spx_word16_t*)speex_alloc(K*sizeof(spx_word16_t));
503 st->memD = (spx_word16_t*)speex_alloc(C*sizeof(spx_word16_t));
504 st->memE = (spx_word16_t*)speex_alloc(C*sizeof(spx_word16_t));
505 st->preemph = QCONST16(.9,15);
506 if (st->sampling_rate<12000)
507 st->notch_radius = QCONST16(.9, 15);
508 else if (st->sampling_rate<24000)
509 st->notch_radius = QCONST16(.982, 15);
511 st->notch_radius = QCONST16(.992, 15);
513 st->notch_mem = (spx_mem_t*)speex_alloc(2*C*sizeof(spx_mem_t));
514 st->adapted = 0;
515 st->Pey = st->Pyy = FLOAT_ONE;
518 st->Davg1 = st->Davg2 = 0;
519 st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
522 st->play_buf = (spx_int16_t*)speex_alloc(K*(PLAYBACK_DELAY+1)*st->frame_size*sizeof(spx_int16_t));
523 st->play_buf_pos = PLAYBACK_DELAY*st->frame_size;
524 st->play_buf_started = 0;
526 return st;
530 EXPORT void speex_echo_state_reset(SpeexEchoState *st)
533 st->cancel_count=0;
534 st->screwed_up = 0;
535 N = st->window_size;
536 M = st->M;
537 C=st->C;
538 K=st->K;
540 st->W[i] = 0;
543 st->foreground[i] = 0;
546 st->X[i] = 0;
547 for (i=0;i<=st->frame_size;i++)
549 st->power[i] = 0;
550 st->power_1[i] = FLOAT_ONE;
551 st->Eh[i] = 0;
552 st->Yh[i] = 0;
554 for (i=0;i<st->frame_size;i++)
556 st->last_y[i] = 0;
560 st->E[i] = 0;
564 st->x[i] = 0;
567 st->notch_mem[i] = 0;
569 st->memD[i]=st->memE[i]=0;
571 st->memX[i]=0;
573 st->saturated = 0;
574 st->adapted = 0;
575 st->sum_adapt = 0;
576 st->Pey = st->Pyy = FLOAT_ONE;
578 st->Davg1 = st->Davg2 = 0;
579 st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
581 for (i=0;i<3*st->frame_size;i++)
582 st->play_buf[i] = 0;
583 st->play_buf_pos = PLAYBACK_DELAY*st->frame_size;
584 st->play_buf_started = 0;
589 EXPORT void speex_echo_state_destroy(SpeexEchoState *st)
591 spx_fft_destroy(st->fft_table);
593 speex_free(st->e);
594 speex_free(st->x);
595 speex_free(st->input);
596 speex_free(st->y);
597 speex_free(st->last_y);
598 speex_free(st->Yf);
599 speex_free(st->Rf);
600 speex_free(st->Xf);
601 speex_free(st->Yh);
602 speex_free(st->Eh);
604 speex_free(st->X);
605 speex_free(st->Y);
606 speex_free(st->E);
607 speex_free(st->W);
609 speex_free(st->foreground);
611 speex_free(st->PHI);
612 speex_free(st->power);
613 speex_free(st->power_1);
614 speex_free(st->window);
615 speex_free(st->prop);
616 speex_free(st->wtmp);
618 speex_free(st->wtmp2);
620 speex_free(st->memX);
621 speex_free(st->memD);
622 speex_free(st->memE);
623 speex_free(st->notch_mem);
625 speex_free(st->play_buf);
626 speex_free(st);
636 EXPORT void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out)
639 /*speex_warning_int("capture with fill level ", st->play_buf_pos/st->frame_size);*/
640 st->play_buf_started = 1;
641 if (st->play_buf_pos>=st->frame_size)
643 speex_echo_cancellation(st, rec, st->play_buf, out);
644 st->play_buf_pos -= st->frame_size;
645 for (i=0;i<st->play_buf_pos;i++)
646 st->play_buf[i] = st->play_buf[i+st->frame_size];
649 if (st->play_buf_pos!=0)
652 st->play_buf_pos = 0;
654 for (i=0;i<st->frame_size;i++)
659 EXPORT void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play)
661 /*speex_warning_int("playback with fill level ", st->play_buf_pos/st->frame_size);*/
662 if (!st->play_buf_started)
667 if (st->play_buf_pos<=PLAYBACK_DELAY*st->frame_size)
670 for (i=0;i<st->frame_size;i++)
671 st->play_buf[st->play_buf_pos+i] = play[i];
672 st->play_buf_pos += st->frame_size;
673 if (st->play_buf_pos <= (PLAYBACK_DELAY-1)*st->frame_size)
676 for (i=0;i<st->frame_size;i++)
677 st->play_buf[st->play_buf_pos+i] = play[i];
678 st->play_buf_pos += st->frame_size;
686 EXPORT void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out, spx_int32_t *Yout)
688 speex_echo_cancellation(st, in, far_end, out);
692 EXPORT void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out)
708 N = st->window_size;
709 M = st->M;
710 C = st->C;
711 K = st->K;
713 st->cancel_count++;
725 filter_dc_notch16(in+chan, st->notch_radius, st->input+chan*st->frame_size, st->frame_size, st->notch_mem+2*chan, C);
728 for (i=0;i<st->frame_size;i++)
732 tmp32 = SUB32(EXTEND32(st->input[chan*st->frame_size+i]), EXTEND32(MULT16_16_P15(st->preemph, st->memD[chan])));
737 if (st->saturated == 0)
738 st->saturated = 1;
743 if (st->saturated == 0)
744 st->saturated = 1;
747 st->memD[chan] = st->input[chan*st->frame_size+i];
748 st->input[chan*st->frame_size+i] = EXTRACT16(tmp32);
754 for (i=0;i<st->frame_size;i++)
757 st->x[speak*N+i] = st->x[speak*N+i+st->frame_size];
758 tmp32 = SUB32(EXTEND32(far_end[i*K+speak]), EXTEND32(MULT16_16_P15(st->preemph, st->memX[speak])));
764 st->saturated = M+1;
769 st->saturated = M+1;
772 st->x[speak*N+i+st->frame_size] = EXTRACT16(tmp32);
773 st->memX[speak] = far_end[i*K+speak];
783 st->X[(j+1)*N*K+speak*N+i] = st->X[j*N*K+speak*N+i];
786 spx_fft(st->fft_table, st->x+speak*N, &st->X[speak*N]);
792 Sxx += mdf_inner_prod(st->x+speak*N+st->frame_size, st->x+speak*N+st->frame_size, st->frame_size);
793 power_spectrum_accum(st->X+speak*N, st->Xf, N);
801 spectral_mul_accum16(st->X, st->foreground+chan*N*K*M, st->Y+chan*N, N, M*K);
802 spx_ifft(st->fft_table, st->Y+chan*N, st->e+chan*N);
803 for (i=0;i<st->frame_size;i++)
804 st->e[chan*N+i] = SUB16(st->input[chan*st->frame_size+i], st->e[chan*N+i+st->frame_size]);
805 Sff += mdf_inner_prod(st->e+chan*N, st->e+chan*N, st->frame_size);
811 if (st->adapted)
812 mdf_adjust_prop (st->W, N, M, C*K, st->prop);
814 if (st->saturated == 0)
822 weighted_spectral_mul_conj(st->power_1, FLOAT_SHL(PSEUDOFLOAT(st->prop[j]),-15), &st->X[(j+1)*N*K+speak*N], st->E+chan*N, st->PHI, N);
824 st->W[chan*N*K*M + j*N*K + speak*N + i] += st->PHI[i];
829 st->saturated--;
842 if (j==0 || st->cancel_count%(M-1) == j-1)
846 st->wtmp2[i] = EXTRACT16(PSHR32(st->W[chan*N*K*M + j*N*K + speak*N + i],NORMALIZE_SCALEDOWN+16));
847 spx_ifft(st->fft_table, st->wtmp2, st->wtmp);
848 for (i=0;i<st->frame_size;i++)
850 st->wtmp[i]=0;
852 for (i=st->frame_size;i<N;i++)
854 st->wtmp[i]=SHL16(st->wtmp[i],NORMALIZE_SCALEUP);
856 spx_fft(st->fft_table, st->wtmp, st->wtmp2);
859 st->W[chan*N*K*M + j*N*K + speak*N + i] -= SHL32(EXTEND32(st->wtmp2[i]),16+NORMALIZE_SCALEDOWN-NORMALIZE_SCALEUP-1);
861 spx_ifft(st->fft_table, &st->W[chan*N*K*M + j*N*K + speak*N], st->wtmp);
862 for (i=st->frame_size;i<N;i++)
864 st->wtmp[i]=0;
866 spx_fft(st->fft_table, st->wtmp, &st->W[chan*N*K*M + j*N*K + speak*N]);
874 for (i=0;i<=st->frame_size;i++)
875 st->Rf[i] = st->Yf[i] = st->Xf[i] = 0;
883 spectral_mul_accum(st->X, st->W+chan*N*K*M, st->Y+chan*N, N, M*K);
884 spx_ifft(st->fft_table, st->Y+chan*N, st->y+chan*N);
885 for (i=0;i<st->frame_size;i++)
886 st->e[chan*N+i] = SUB16(st->e[chan*N+i+st->frame_size], st->y[chan*N+i+st->frame_size]);
887 Dbf += 10+mdf_inner_prod(st->e+chan*N, st->e+chan*N, st->frame_size);
888 for (i=0;i<st->frame_size;i++)
889 st->e[chan*N+i] = SUB16(st->input[chan*st->frame_size+i], st->y[chan*N+i+st->frame_size]);
890 See += mdf_inner_prod(st->e+chan*N, st->e+chan*N, st->frame_size);
902 st->Davg1 = ADD32(MULT16_32_Q15(QCONST16(.6f,15),st->Davg1), MULT16_32_Q15(QCONST16(.4f,15),SUB32(Sff,See)));
903 st->Davg2 = ADD32(MULT16_32_Q15(QCONST16(.85f,15),st->Davg2), MULT16_32_Q15(QCONST16(.15f,15),SUB32(Sff,See)));
904 st->Dvar1 = FLOAT_ADD(FLOAT_MULT(VAR1_SMOOTH, st->Dvar1), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.4f,15),Sff), MULT16_32_Q15(QCONST16(.4f,15),Dbf)));
905 st->Dvar2 = FLOAT_ADD(FLOAT_MULT(VAR2_SMOOTH, st->Dvar2), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.15f,15),Sff), MULT16_32_Q15(QCONST16(.15f,15),Dbf)));
908 st->Davg1 = .6*st->Davg1 + .4*(Sff-See);
909 st->Davg2 = .85*st->Davg2 + .15*(Sff-See);
910 st->Dvar1 = .36*st->Dvar1 + .16*Sff*Dbf;
911 st->Dvar2 = .7225*st->Dvar2 + .0225*Sff*Dbf;
919 else if (FLOAT_GT(FLOAT_MUL32U(st->Davg1, ABS32(st->Davg1)), FLOAT_MULT(VAR1_UPDATE,(st->Dvar1))))
921 else if (FLOAT_GT(FLOAT_MUL32U(st->Davg2, ABS32(st->Davg2)), FLOAT_MULT(VAR2_UPDATE,(st->Dvar2))))
927 st->Davg1 = st->Davg2 = 0;
928 st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
931 st->foreground[i] = EXTRACT16(PSHR32(st->W[i],16));
934 for (i=0;i<st->frame_size;i++)
935 st->e[chan*N+i+st->frame_size] = MULT16_16_Q15(st->window[i+st->frame_size],st->e[chan*N+i+st->frame_size]) + MULT16_16_Q15(st->window[i],st->y[chan*N+i+st->frame_size]);
941 if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg1), ABS32(st->Davg1)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar1)))
943 if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg2), ABS32(st->Davg2)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar2)))
949 st->W[i] = SHL32(EXTEND32(st->foreground[i]),16);
953 for (i=0;i<st->frame_size;i++)
954 st->y[chan*N+i+st->frame_size] = st->e[chan*N+i+st->frame_size];
955 for (i=0;i<st->frame_size;i++)
956 st->e[chan*N+i] = SUB16(st->input[chan*st->frame_size+i], st->y[chan*N+i+st->frame_size]);
959 st->Davg1 = st->Davg2 = 0;
960 st->Dvar1 = st->Dvar2 = FLOAT_ZERO;
969 for (i=0;i<st->frame_size;i++)
973 tmp_out = SUB32(EXTEND32(st->input[chan*st->frame_size+i]), EXTEND32(st->e[chan*N+i+st->frame_size]));
975 tmp_out = SUB32(EXTEND32(st->input[chan*st->frame_size+i]), EXTEND32(st->y[chan*N+i+st->frame_size]));
977 tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE[chan])));
981 if (st->saturated == 0)
982 st->saturated = 1;
985 st->memE[chan] = tmp_out;
989 dump_audio(in, far_end, out, st->frame_size);
993 for (i=0;i<st->frame_size;i++)
995 st->e[chan*N+i+st->frame_size] = st->e[chan*N+i];
996 st->e[chan*N+i] = 0;
1001 Sey += mdf_inner_prod(st->e+chan*N+st->frame_size, st->y+chan*N+st->frame_size, st->frame_size);
1002 Syy += mdf_inner_prod(st->y+chan*N+st->frame_size, st->y+chan*N+st->frame_size, st->frame_size);
1003 Sdd += mdf_inner_prod(st->input+chan*st->frame_size, st->input+chan*st->frame_size, st->frame_size);
1006 spx_fft(st->fft_table, st->e+chan*N, st->E+chan*N);
1007 for (i=0;i<st->frame_size;i++)
1008 st->y[i+chan*N] = 0;
1009 spx_fft(st->fft_table, st->y+chan*N, st->Y+chan*N);
1012 power_spectrum_accum(st->E+chan*N, st->Rf, N);
1013 power_spectrum_accum(st->Y+chan*N, st->Yf, N);
1017 /*printf ("%f %f %f %f\n", Sff, See, Syy, Sdd, st->update_cond);*/
1027 st->screwed_up += 50;
1028 for (i=0;i<st->frame_size*C;i++)
1033 st->screwed_up++;
1036 st->screwed_up=0;
1038 if (st->screwed_up>=50)
1041 speex_echo_state_reset(st);
1050 Sxx += mdf_inner_prod(st->x+speak*N+st->frame_size, st->x+speak*N+st->frame_size, st->frame_size);
1051 power_spectrum_accum(st->X+speak*N, st->Xf, N);
1056 for (j=0;j<=st->frame_size;j++)
1057 st->power[j] = MULT16_32_Q15(ss_1,st->power[j]) + 1 + MULT16_32_Q15(ss,st->Xf[j]);
1060 for (j=st->frame_size;j>=0;j--)
1063 Eh = PSEUDOFLOAT(st->Rf[j] - st->Eh[j]);
1064 Yh = PSEUDOFLOAT(st->Yf[j] - st->Yh[j]);
1068 st->Eh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Eh[j]), st->spec_average, st->Rf[j]);
1069 st->Yh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Yh[j]), st->spec_average, st->Yf[j]);
1071 st->Eh[j] = (1-st->spec_average)*st->Eh[j] + st->spec_average*st->Rf[j];
1072 st->Yh[j] = (1-st->spec_average)*st->Yh[j] + st->spec_average*st->Yf[j];
1080 tmp32 = MULT16_32_Q15(st->beta0,Syy);
1081 if (tmp32 > MULT16_32_Q15(st->beta_max,See))
1082 tmp32 = MULT16_32_Q15(st->beta_max,See);
1086 st->Pey = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pey) , FLOAT_MULT(alpha,Pey));
1087 st->Pyy = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pyy) , FLOAT_MULT(alpha,Pyy));
1088 if (FLOAT_LT(st->Pyy, FLOAT_ONE))
1089 st->Pyy = FLOAT_ONE;
1091 if (FLOAT_LT(st->Pey, FLOAT_MULT(MIN_LEAK,st->Pyy)))
1092 st->Pey = FLOAT_MULT(MIN_LEAK,st->Pyy);
1093 if (FLOAT_GT(st->Pey, st->Pyy))
1094 st->Pey = st->Pyy;
1096 st->leak_estimate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIVU(st->Pey, st->Pyy),14));
1098 if (st->leak_estimate > 16383)
1099 st->leak_estimate = 32767;
1101 st->leak_estimate = SHL16(st->leak_estimate,1);
1102 /*printf ("%f\n", st->leak_estimate);*/
1106 tmp32 = MULT16_32_Q15(st->leak_estimate,Syy);
1121 RER = (.0001*Sxx + 3.*MULT16_32_Q15(st->leak_estimate,Syy)) / See;
1130 if (!st->adapted && st->sum_adapt > SHL32(EXTEND32(M),15) && MULT16_32_Q15(st->leak_estimate,Syy) > MULT16_32_Q15(QCONST16(.03f,15),Syy))
1132 st->adapted = 1;
1135 if (st->adapted)
1138 for (i=0;i<=st->frame_size;i++)
1142 r = MULT16_32_Q15(st->leak_estimate,SHL32(st->Yf[i],3));
1143 e = SHL32(st->Rf[i],3)+1;
1152 /*st->power_1[i] = adapt_rate*r/(e*(1+st->power[i]));*/
1153 st->power_1[i] = FLOAT_SHL(FLOAT_DIV32_FLOAT(r,FLOAT_MUL32U(e,st->power[i]+10)),WEIGHT_SHIFT+16);
1171 for (i=0;i<=st->frame_size;i++)
1172 st->power_1[i] = FLOAT_SHL(FLOAT_DIV32(EXTEND32(adapt_rate),ADD32(st->power[i],10)),WEIGHT_SHIFT+1);
1176 st->sum_adapt = ADD32(st->sum_adapt,adapt_rate);
1180 for (i=0;i<st->frame_size;i++)
1181 st->last_y[i] = st->last_y[st->frame_size+i];
1182 if (st->adapted)
1185 for (i=0;i<st->frame_size;i++)
1186 st->last_y[st->frame_size+i] = in[i]-out[i];
1190 st->last_y[i] = st->x[i];*/
1196 void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *residual_echo, int len)
1202 N = st->window_size;
1206 st->y[i] = MULT16_16_Q15(st->window[i],st->last_y[i]);
1209 spx_fft(st->fft_table, st->y, st->Y);
1210 power_spectrum(st->Y, residual_echo, N);
1213 if (st->leak_estimate > 16383)
1216 leak2 = SHL16(st->leak_estimate, 1);
1218 if (st->leak_estimate>.5)
1221 leak2 = 2*st->leak_estimate;
1224 for (i=0;i<=st->frame_size;i++)
1229 EXPORT int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr)
1235 (*(int*)ptr) = st->frame_size;
1238 st->sampling_rate = (*(int*)ptr);
1239 st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate);
1241 st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate);
1242 st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate);
1244 st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;
1245 st->beta_max = (.5f*st->frame_size)/st->sampling_rate;
1247 if (st->sampling_rate<12000)
1248 st->notch_radius = QCONST16(.9, 15);
1249 else if (st->sampling_rate<24000)
1250 st->notch_radius = QCONST16(.982, 15);
1252 st->notch_radius = QCONST16(.992, 15);
1255 (*(int*)ptr) = st->sampling_rate;
1259 *((spx_int32_t *)ptr) = st->M * st->frame_size;
1263 int M = st->M, N = st->window_size, n = st->frame_size, i, j;
1270 st->wtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],16+NORMALIZE_SCALEDOWN));
1271 spx_ifft(st->fft_table, st->wtmp2, st->wtmp);
1273 spx_ifft(st->fft_table, &st->W[j*N], st->wtmp);
1276 filt[j*n+i] = PSHR32(MULT16_16(32767,st->wtmp[i]), WEIGHT_SHIFT-NORMALIZE_SCALEDOWN);