[Speex-dev] echo cancellation on Blackfin DSK

Damien Guiserix damienguiserix at gmail.com
Wed Apr 25 01:25:55 PDT 2007


Hello,


I'm new on DSP and i want to implant speex echo canceller on the Blackfin
DSK version of speex to work on the BF533 EZ-KIT LITE

But i can perform the echo canceller to work


This is my code, so if somebody can tell me where i'm wrong

//-----------------------------------------------------------------------------

// CallBackFunction() - Gets called by the audio pseudo-driver when a new
audio

//                      block is ready to be played.

//-----------------------------------------------------------------------------

int CallBackFunction(PVOID inputBuffer, PVOID outputBuffer, PVOID userData)

{

  ezTurnOnLED(LED_CALLBACK);

  CYCLES_START(g_CycleStats);



  int                    i;

  volatile ARTYP_16BITS *in =(ARTYP_16BITS *)inputBuffer;

  volatile ARTYP_16BITS *out=(ARTYP_16BITS *)outputBuffer;

  volatile ARTYP_16BITS *out2;

  short                 *in_left = in_buffer_calc;   //for stereo encoding

  short                 *out_left = out_buffer_calc; //for stereo encoding

  short                                                 *out2_buffer_calc;



  if (SPEEX_DISABLED == g_iSpeexEnabled) //Activated by a pushbutton

  {

  memcpy((void *)out, (void *)in,

           SPEEX_FRAME_SIZE*NUM_CHANNELS*sizeof(ARTYP_16BITS));

  }

  else //Speex is enabled so do a lot more work

  {

#ifndef ACTIVATE_STEREO

    // Demux the stereo  stream

    for(i = 0; i < SPEEX_FRAME_SIZE; i++)

    {

      *in_left++ = *in++; // channel 1

      in++; // channel 2

    }

    in_left = in_buffer_calc;

    speex_bits_reset(&g_Bits);



    // Encode the frame

    speex_encode_int(g_pvEnc, (spx_int16_t *)in_left, &g_Bits);

    nbBits = speex_bits_write(&g_Bits, cbits, 200);

    speex_bits_rewind(&g_Bits);

    SpeexEchoState *st=
speex_echo_state_init(SPEEX_FRAME_SIZE,filter_length);

    speex_echo_cancel(st,(spx_int16_t *)in_left,(spx_int16_t
*)out_left,(spx_int16_t *)out2,NULL);

    speex_echo_state_destroy(st);



    // Decode the frame

    speex_decode_int(g_pvDec, &g_Bits, (spx_int16_t *)out_left);

#ifdef ALWAYS_PASS_THROUGH

    memcpy(out_buffer_calc, in_buffer_calc,

    SPEEX_FRAME_SIZE*sizeof(SND_FIXED_16_TYPE));

#endif //ALWAYS_PASS_THROUGH

    // Mux the Speex output onto the stereo audio stream

    for(i = 0; i < SPEEX_FRAME_SIZE; i++)

    {

      *out++ = *out_left; // channel 1

      *out++ = *out_left++; // channel 2

    }

#else //ACTIVATE_STEREO

    speex_bits_reset(&g_Bits);



    // Encode the frame

    speex_encode_stereo_int((spx_int16_t *)in, SPEEX_FRAME_SIZE, &g_Bits);

    speex_encode_int(g_pvEnc, (spx_int16_t *)in, &g_Bits);

    g_nBits = speex_bits_write(&g_Bits, g_cBits, 200);

    speex_bits_rewind(&g_Bits);

    // Decode the frame

    speex_decode_int(g_pvDec, &g_Bits, (spx_int16_t *)out);

    speex_decode_stereo_int((spx_int16_t *)out, SPEEX_FRAME_SIZE,
&g_StereoState);



#ifdef ALWAYS_PASS_THROUGH

    memcpy(out, in,
SPEEX_FRAME_SIZE*NUM_CHANNELS*sizeof(SND_FIXED_16_TYPE));

#endif //ALWAYS_PASS_THROUGH

#endif //ACTIVATE_STEREO

}



  if (1 == ezIsButtonPushed(BUTTON_QUIT)) { g_EOS = 1; } //Quit Btn pressed

  CYCLES_STOP(g_CycleStats);

  ezTurnOffLED(LED_CALLBACK);

  //speex_echo_state_destroy(st);

  return 0;

}


thanks

Damien Guiserix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20070425/285161ae/attachment.htm


More information about the Speex-dev mailing list