Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

TMS320C6748 LCDK Audio Signal Processing using starterware- adaptive filtering- problem with programming

$
0
0

Hello,

I got stuck by programming an audio adaptive filter.

The adaptive filter schould remove  a cosine noise, with frequency of 443 Hz from the input audio signal, but I can´t hear any output signal in my headset after filtering.

Please, Could you have a look into my code and point me where could be mistake and how to correct it?

My program is located instead of

memcpy((void *)txBufPtr[lastSentTxBuf],
                   (void *)rxBufPtr[lastFullRxBuf],
                   AUDIO_BUF_SIZE);

in main in mcaspPlayBk.c

there is the program:

                       //Adaptive FIR filtering using LMS criterion//
 /*
  d+n'                                                                                                   d+n'...........data+narrow band noise
  ----------------------------------------------------------+                               n ...........estimated noise, correlated with n'                                                                                 |                                y ...........filter  output

                                                                                |                                e............error signal

                                                                               |
                                                                            + V   e
                                                                              (+)->------+-->OUT
                                      A                                     - A             |
                                      /                                          |             |
                         +----------------------+                      |             |
   n                    |                               |         y            |             |
  ---------------->|    ADAPT. FILT     |----------------+             |
                          |                               |                                    |
                         +----------------------+                                    |
                            /                Adaptation                               |
                           +-------------------------------------------------+
*/
/*
  SampleP,SampleL                                                                                                
  ------------------------------------------------------------+                             
                                                                                  |                                                                                                                                                                                               |

                                                                                  |
                                                                              + V   e_P,e_L
                                                                                (+)->-------+-->OUT
                                      A                                       - A               |
                                      /                                            |               |
                         +----------------------+                        |               |
  SINE441F     |                               | SumP,SumL |               |
  ---------------->|    ADAPT. FILT     |------------------+              |
                          |                               |                                        |
                         +----------------------+                                        |
                            /                Adaptation                                   |
                           +----------------------------------------------------+
*/
    //Samples on negative indices needed, using periodicity of SINE441//

   for(j=0;j<HLEN-1;j++){
       for(i=0;i<HLEN;i++){
             SumP+=(float)SINE441F[j+100-i]*h_adapt_P[i];//100 is number of samples in period; fs=44100Hz, f=441Hz;
             SumL+=(float)SINE441F[j+100-i]*h_adapt_L[i];
       }
       SampleP=*((unsigned short*)rxBufPtr[lastFullRxBuf]+4*(j));
          SampleL=*((unsigned short*)rxBufPtr[lastFullRxBuf]+(4*(j)+2));

          e_P[j]=SampleP-SumP;
          e_L[j]=SampleL-SumL;

          //OUT//
          *((unsigned short*)txBufPtr[lastSentTxBuf]+4*j)=(unsigned short)e_P[j];
          *((unsigned short*)txBufPtr[lastSentTxBuf]+4*j+2)=(unsigned short)e_L[j];


          //LMS adaptation of filter coefficients//
          for(i=0;i<HLEN;i++){
            h_adapt_P[i]+=(float)SINE441F[j+100-i]*BETA*e_P[j];
          }


   }

   //No need of data on negative indices//

   for(j=HLEN-1;j<BUFLEN;j++){
       for(i=0;i<HLEN;i++){
          SumP+=(float)SINE441F[j-i]*h_adapt_P[i];
          SumL+=(float)SINE441F[j-i]*h_adapt_L[i];
       }
       SampleP=*((unsigned short*)rxBufPtr[lastFullRxBuf]+4*(j));
       SampleL=*((unsigned short*)rxBufPtr[lastFullRxBuf]+(4*(j)+2));

       e_P[j]=SampleP-SumP;
       e_L[j]=SampleL-SumL;

       //OUT//
       *((unsigned short*)txBufPtr[lastSentTxBuf]+4*j)=(unsigned short)e_P[j];
       *((unsigned short*)txBufPtr[lastSentTxBuf]+4*j+2)=(unsigned short)e_L[j];


       //LMS adaptation of filter coefficients//
       for(i=0;i<HLEN;i++){
         h_adapt_P[i]+=(float)SINE441F[j-i]*BETA*e_P[j];
       }
   }

Thanks for any pieces of advice.

Petr Duga


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>