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.

problem in reading the file through the CODEC

Hi All 

  I am working on audio processing using the DSK C5510. Initially I open a file using fopen, fread commands and do the processing after which I write back into another file using fwrite say its called output.wav

 

Now I want to play this output.wav in my program so that can listen using the peripherals in DSK . Can some one suggest me a way of how to configure it from the program.

I have tried using the following code but didnt work. I am struck in developing the algorithm .

 

 #include "tonecfg.h"

#include "dsk5510.h"

#include "dsk5510_aic23.h"

#include "stdio.h"

#include "stdlib.h"

DSK5510_AIC23_Config config = { \

    0x0017,  /* 0 DSK5510_AIC23_LEFTINVOL  Left line input channel volume */ \

    0x0017,  /* 1 DSK5510_AIC23_RIGHTINVOL Right line input channel volume */\

    0x01f9,  /* 2 DSK5510_AIC23_LEFTHPVOL  Left channel headphone volume */  \

    0x01f9,  /* 3 DSK5510_AIC23_RIGHTHPVOL Right channel headphone volume */ \

    0x0011,  /* 4 DSK5510_AIC23_ANAPATH    Analog audio path control */      \

    0x0000,  /* 5 DSK5510_AIC23_DIGPATH    Digital audio path control */     \

    0x0000,  /* 6 DSK5510_AIC23_POWERDOWN  Power down control */             \

    0x0043,  /* 7 DSK5510_AIC23_DIGIF      Digital audio interface format */ \

    0x008d,  /* 8 DSK5510_AIC23_SAMPLERATE Sample rate control */            \

    0x0001   /* 9 DSK5510_AIC23_DIGACT     Digital interface activation */   \

};

FILE    *fpOut;

void main()

{

    DSK5510_AIC23_CodecHandle hCodec;

     long size;

     int sample;

     Int16 *c_play;

DSK5510_init();

hCodec = DSK5510_AIC23_openCodec(0, &config);

DSK5510_AIC23_setFreq(hCodec,DSK5510_AIC23_FREQ_8KHZ);

fpOut = fopen("G://workouts//NR//data//nrvelu.wav","r");

fseek(fpOut,0,SEEK_END);

size = ftell(fpOut);

fread(&c_play,sizeof(c_play),1,fpOut);

        fseek(fpOut,0,SEEK_SET);

for (sample = 0; sample < size ; sample++)

  {

while (!DSK5510_AIC23_write16(hCodec, *c_play));      //left channel

              while (!DSK5510_AIC23_write16(hCodec, *c_play++));  // right channel

}

DSK5510_AIC23_closeCodec(hCodec);

       fclose(fpOut);

}

 

 I am not sure how to read the raw file and listen using the headphones from the line out.

Can some one pls help me
Thanks in Advance
Regards
velappan

 

  • Hi Velappan,

    I am looking into your DSK5510 Codec issue today.

    Regards,
    Mark 

  • Hi Mark

          Could you find the problem with the Codec

     

    I actually tried another method

    void main()

    {

       short data;

       short i;            

       long size ;

      unsigned short *voiceptr;

     

      if ((fp = fopen("G://workouts//NR//data//nrvelu.wav","r")) == NULL)

      {

        printf("Can't open experiment parameter file\n");

        exit(0);

      }

     

       fseek(fp,0,SEEK_END);

      size = ftell(fp);

        printf("the file size = %ld",size);

     

      fseek(fp,0,SEEK_SET);

         fread(&voiceptr,sizeof(short),1,fp);   

     

      // Initialize McBSP1 as AIC23 SPI control channel

      mcbsp1Init(); 

     

      // Initialize the AIC23  

      aic23Init();

     

      // Initialize McBSP2 as AIC23 SPI data channel       

      mcbsp2Init();           

     

     

      // Playback data via AIC23

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

     {

        data = *voiceptr++;

        while (!aic23Tx(data));      // Send data to left channel

        while (!aic23Tx(data));      // Send data to right channel  

      }

     

      // Power down the AIC23 and reset McBSP

      aic23Powerdown();   

      mcbspReset(1);

      mcbspReset(2);

    }

     

    But still I am facing the problem. 

    Regards

    velappan