如何调整speex echo canceller来处理浮点样本?

时间:2011-05-03 06:47:58

标签: echo speex

美好的一天!我如何使用浮动样本进行回声消除处理?我试图改变中心功能的界面和主体:

void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out);

void float_speex_echo_cancellation(SpeexEchoState *st, const float rec[], const float play[], float out[]);

...
       for (i=0;i<st->frame_size;i++)
      {
         spx_word32_t tmp_out;
         tmp_out = SUB32(EXTEND32(st->input[chan*st->frame_size+i]), EXTEND32(st->e[chan*N+i+st->frame_size]));
         tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE[chan])));

         if (in[i*C+chan] <= -32000 || in[i*C+chan] >= 32000)
         {
         if (st->saturated == 0)
            st->saturated = 1;
         }

         **out[i*C+chan] = (spx_int16_t)WORD2INT(tmp_out);**

         st->memE[chan] = tmp_out;
      }
...

  ...

     for (i=0;i<st->frame_size;i++)
          {
             spx_word32_t tmp_out;
             tmp_out = SUB32(EXTEND32(st->input[chan*st->frame_size+i]), EXTEND32(st->e[chan*N+i+st->frame_size]));
             tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE[chan])));

             if (in[i*C+chan] <= -32000 || in[i*C+chan] >= 32000)
             {
             if (st->saturated == 0)
                st->saturated = 1;
             }

             **out[i*C+chan] = /*(spx_int16_t)WORD2INT(*/tmp_out*/)*/;**

             st->memE[chan] = tmp_out;
          }
    ...

static inline void filter_dc_notch16(const spx_int16_t *in, spx_word16_t radius, spx_word16_t *out, int len, spx_mem_t *mem, int stride)
{
   int i;
   spx_word16_t den2;
   den2 = (spx_word16_t)(radius*radius + .7f*(1.f-radius)*(1.f-radius));
   for (i=0;i<len;i++)
   {
      spx_int16_t vin = in[i*stride];
      spx_word32_t vout = mem[0] + SHL32(EXTEND32(vin),15);
      mem[0] = mem[1] + 2*(-vin + radius*vout);
      mem[1] = SHL32(EXTEND32(vin),15) - MULT16_32_Q15(den2,vout);
      out[i] = SATURATE32(PSHR32(MULT16_32_Q15(radius,vout),15),32767);
   }
}

 static inline void float_filter_dc_notch16(const /*spx_int16_t*/spx_word16_t *in, spx_word16_t radius, spx_word16_t *out, int len, spx_mem_t *mem, int stride)
{
   int i;
   spx_word16_t den2;
   den2 = /*(spx_word16_t)*/(radius*radius + .7f*(1.f-radius)*(1.f-radius));
   for (i=0;i<len;i++)
   {
      /*spx_int16_t*/spx_word16_t vin = in[i*stride];
      spx_word32_t vout = mem[0] + SHL32(EXTEND32(vin),15);
      mem[0] = mem[1] + 2*(-vin + radius*vout);
      mem[1] = SHL32(EXTEND32(vin),15) - MULT16_32_Q15(den2,vout);
      out[i] = /*SATURATE32(*/PSHR32(MULT16_32_Q15(radius,vout),15)/*,32767)*/;
   }
}

所以,我阻止了从float类型输出结果到short int的转换,但是现在我得到一个警告:

speex_warning(“回声消除器开始表现得很有趣并且被打了一拳(重置)。它发誓它现在会表现。”);

指向具有50个值的st-&gt; screwed_up参数,并且所有样本都设置为零的迹象:

...

 if (!(Syy>=0 && Sxx>=0 && See >= 0)
   || !(Sff < N*1e9 && Syy < N*1e9 && Sxx < N*1e9)
  )

{ st->screwed_up += 50; for (i=0;iframe_size*C;i++) out[i] = 0; }

...

我该怎么办?

enter code here

1 个答案:

答案 0 :(得分:0)

为什么要使用浮点样本? 标准线性PCM音频根据所选比特率表示为整数样本 - 8位,16位等等。

你从哪里获得输入?

如果我是你,我会将你得到的任何短信转换成Speex,以便它可以使用它。