This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

programming Echo audio effect on DSK6455 : problem implementing delay line, processor not fast enough?

Other Parts Discussed in Thread: TMS320C6455

Good morning,

I am currently trying to implement simple audio effects such as echo reverberation...  When i run my program the audio output is really dirty.  I am not sure why my code doesnt work.

My code :

#include "dsk6455.h"

#include "dsk6455_aic23.h"

 

/* Codec configuration settings */

DSK6455_AIC23_Config config = {

    0x0117, // 0 DSK6455_AIC23_LEFTINVOL  Left line input channel volume

    0x0017, // 1 DSK6455_AIC23_RIGHTINVOL Right line input channel volume

    0x00d8, // 2 DSK6455_AIC23_LEFTHPVOL  Left channel headphone volume

    0x00d8, // 3 DSK6455_AIC23_RIGHTHPVOL Right channel headphone volume

    0x0011, // 4 DSK6455_AIC23_ANAPATH    Analog audio path control

    0x0001, // 5 DSK6455_AIC23_DIGPATH    Digital audio path control

    0x0000, // 6 DSK6455_AIC23_POWERDOWN  Power down control

    0x0043, // 7 DSK6455_AIC23_DIGIF      Digital audio interface format

    0x0081, // 8 DSK6455_AIC23_SAMPLERATE Sample rate control

    0x0001 // 9 DSK6455_AIC23_DIGACT     Digital interface activation

};

void main()

{

    DSK6455_AIC23_CodecHandle hCodec;

    Uint32 leftsample,x[2201],  y=0;

    Int16 i;

                // initailize x with zeros

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

                               x[i] =0

 

    // initializes the board

    DSK6455_init();

     DSK6455_DIP_init();

 

    /* Start the codec */

    hCodec = DSK6455_AIC23_openCodec(0, &config);

    DSK6455_AIC23_setFreq(hCodec,DSK6455_AIC23_FREQ_44KHZ);  //set sampling frequency to 44Khz

               

                while(1)

                {

            /* read a sample from the left channel */

            while (!DSK6455_AIC23_read32(hCodec, &leftsample));

             

                    // 0.5s delay line

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

                               x[i] = x[i-1];

                               x[0] = leftsample+y;

                    y = leftsample + x[22000] /2 ;

                    leftsample = y;

                                 

                /* Send a sample to the left channel */

                while (!DSK6455_AIC23_write32(hCodec,  2*leftsample));

            }

 

    /* Close the codec */

    DSK6455_AIC23_closeCodec(hCodec);

}

 

For exemple when i replace the part in red with

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

                               x[i] = x[i-1];

                               x[0] = leftsample+y;

                    y = leftsample + x[5] /2 ;

                    leftsample = y;

   i can hear the sound of music input with good quality. The more i increases the worst the audio output gets. So I thought that the DSP doesnt process fast enougth betweem to samples. The TMS320C6455 is 1Ghz fast. If this is the problem, how can I implement delay lines?

Thank you for your help

Regards

Samuel

  • Samuel,

    If you go to the TI Wiki Pages and search for IW6000, you will find an archived training class that we used to present. You can download the Student Guide and take a look at section 8 in which the course discusses real-time operation. Somewhere on the Wiki there should be a version of this class that was designed for the C6455 in particular, but I did not find it right away.

    In your case, the Double Buffer chapter will not be the exact solution, but the concept will be there of meeting real-time deadlines and what you might consider as alternatives.

    How much time do you have between audio samples?
    How many DSP clock cycles are there during that period?
    How many DSP clock cycles are used for each pass through the copy loop?

    Your best solution will come from looking at your application differently. Think of it not as a C program running with infinite speed, and instead think of it as a Digital Signal Processing Application on a high-performance processor with powerful peripherals. Even though the C6455 is reasonably priced for the capability it delivers, the DSP core is wasted when it spends lots of time moving data. Here are some thoughts:

    • Instead of moving the data, move a pointer.
    • Instead of using the DSP to move data, use the EDMA3 module.
    • Use the Compiler's highest level of optimization to improve the speed of the code.
    • Use C/Asm intrinsics to move more data per copy operation (see the Compiler User's Guide).
    • If you can live with a delay in the output sample, use the techniques discussed in the workshop section that was mentioned above.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.