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.

Listening the audio file from the program

Other Parts Discussed in Thread: CCSTUDIO

Hi All 


I am a student working on TMS320C5510 DSK. I had read a audio file from the program  ( using fopen and fread) and done processing and then had written back in a another file (using fwrite) .

Now to confirm whether it is done the processing or not I plot the both file using MATLAB and verify.In order to listen the audio file and confirm it once again I open the audio file using window's player.

But there must be a option for me to listen from the line out of the DSK from the program i have written. Can anyone tell me what is the procedure to achieve it.

 

thanks in Advance 

Regards

velappan

  • Hi,

    You can use tone example which sends out a tone signal to audio CODEC. You need to set CODEC for audio files.

    You send out your audio data to CODEC. 

    Regards,

    Hyun

  •  

    Hi Hyun

    I actually tried doing  similar to the sine tone, but not I get only a tone sound and not the actual audio.

    Will the configuration file for the tone example  work for the case of audio files  ? 

     

    I did this actually 

     

    #include "tonecfg.h"

     

    #include "dsk5510.h"

    #include "dsk5510_aic23.h"

    #include "stdio.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);

    }

     

    Regards

    velappan

     

     

  • Hi,

     

    Two things I want to check with you. 

    1. Have you verified your original tone code working?

    2. Audio data is right? I mean endianess of data. PC and DSP are different. You may need bit swap of each data.

     

    Regards,

    Hyun

  • Hi

      Yes. After processing I open the Audio file using a media player and I could listen. 

          Swap each bit of the data why should I do that . I have no idea about it sir.

     

    I also tried using 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); }

       Still I am not hearing the audio data, only a continous tone .

    Regards

    velappan

     

     

     

     

     

  • Hi,


    You need read a kind of packet data (512 samples) to the memory and send data to codec.

    You seems only read one sample and send to codec.

     

    Regards,

    Hyun


     

     

     

  • Hi 

     

     Yeah I was reading  one sample and sending  to the codec till the end of file. Thought this might work.  

     

    If I need to packet it say 512 , then what must be done ?

     

    Is it like I read 512 and send to the codec in the mean time fill another 512 sample and keep it ready for the next time and do it continuously till the end of file ... 

     

    Regards

    velappan 

  • Hi,

     

    Yes that is what I meant. What is your bits/sample? is it 16-bits per sample?

    Regards,

    Hyun

  • ok will do that .

    Yeah 16 bits per sample.

    Thanks and Regards

    velappan

  • Hello Hyun Kim

    I had gone through the example given in the TI folder . It had a example called dsk_app1.pjt. 

    I had run through the .out file found that I could listen to audio.

     

    I am wondering how did the program work because I couldn't find the function that will write back in the codec ( in my prev prog I tried DSK5510_AIC23_write16) . I could see two buffers are used and DMA transfer is established. I am not sure how to make my program work similar to it

     

    Because in my case I have processed the audio and written back in a file for plotting purpose. So if I want to packet the audio how should I achieve it . 

     

    I have been stuck in the final part of my project. 

    Kindly help regarding it 

    Thanks in advance 

    Regards

    velappan

     

  • Hi,

    It's using DMA and it's different from direct CPU memory access. You can see dsk_app1cfg_c.c file how it is configured.

    You can tap into it at saving data to your PC where copyData happen.

    Regards,

    Hyun

     

  • Hi

    So If i need to listen to audio by opening the file I need to do the following step

    1) Open the file and copy 512 bytes to Ping and when it is full copy to Pong

    2) when Ping is full process it  i.e send to the transmit channel and to the codec and then do it for the same way for the Pong buffer also

    3) repeat the steps till the end of the file

    I will try this

    Regards

    velappan

  • Hi,

     

    You're in the right track. One thing I want to make sure that your reading data time should fast enough to keep up sending audio data without stopping.

    Regards,

    Hyun

  • Hi Hyun Kim

    Now I am facing another problem.  I add a Configuration file in my project and when I build I get a fatal error saying  could not open source file soundcfg.h

    this soundcfg.h is the file i included in my main program. 

     

    The compiler options I specified is  -g -mg -q -fr"G:\workouts\NR\Debug" -i"." -i"..\inc" -d"_DEBUG" -ml -mn -v5510:2

     

    I am not sure where the problem could be

     

    Regards

    velappan  

     

  • Hi,

    You need to add include path for your .h files. 

    Try -i".;..\inc"

    Regards,

    Hyun

  • Hi 

    Actually i had included that option 

     

    I had given -g -mg -q -fr".\Debug" -i"." -i"..\inc" -d"_DEBUG" -ml -mn -v5510:2

     

    Regards

    velappan

  • 0383.FYP.rar

     

    Hyun

    I am using CCS 2.12.7 . I had tried with different compile options. I had attached the pjt files . Can you check it 

     

    Regards

    velappan

  • Hi,

     

    I made a compiling success. Here are steps:

    1. Make a comment //#include "loopbackcfg.h"

    2. Add "playbackcfg.cmd" in the project

    3. Recompile dsk5510bslx.lib project

    4. Compile it.

    --------------------------  dsk5510bslx.pjt - Debug  --------------------------

    Build Complete,

      0 Errors, 0 Warnings, 0 Remarks.

    ----------------------------  playback.pjt - Debug  ----------------------------

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_fft.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_hwindow.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_init.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_mainTest.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_proc.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_ss.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_vad.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"Debug.lkf" "playbackcfg.s55"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -g -mg -q -fr"./Debug" -i"." -i"../inc" -i"C:/CCStudio_v3.1/c5500/dsk5510/include" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"Debug.lkf" "playbackcfg_c.c"

     

    "c:\ccstudio_v2\c5500\cgtools\bin\cl55" -@"Debug.lkf"

     

    Build Complete,

      0 Errors, 0 Warnings, 0 Remarks.

     

    Recursive Build Complete,

      Total Count: 0 Errors, 0 Warnings, 0 Remarks.

     

    Regards,

    Hyun

  • Hi Hyun 

    I did the steps as you said and then I compiled my file i found there was another error Chip not defined. Then i check the compiler options you had specified I didnt include -d "CHIP_5510"  So when i included it I got build complete and when i load my .out file it says no C source not available and when i run it immediately reaches exit. 

     

    Regards

    velappan 

  • Hi Hyun Kim

    Regarding my previous post I found what went wrong .

     

    I had to include rts55x.lib library to the linker -l option. Now I am facing a new problem . I get  0 errors 1 warning .

    the warning says

     "c:\ti\c5500\cgtools\bin\cl55" -@"Debug.lkf"

    >> G:\workouts\FYP\playbackcfg.cmd, line 226: warning: 

                   (.args) not found

    But I thought will neglect the warning and load the .out file to my surprise I could listen the audio which i play. But also noticed one more thing It is not working all the time. 
    I am sure the options I specify i going wrong some where . I ll copy paste the project informations so could help me with it 
    ; Code Composer Project File, Version 2.0 (do not modify or remove this line)

    [Project Settings]
    ProjectName="tone"
    ProjectDir="G:\workouts\FYP\"
    ProjectType=Executable
    CPUFamily=TMS320C55XX
    Tool="Compiler"
    Tool="DspBiosBuilder"
    Tool="Linker"
    Config="Debug"
    Config="Release"

    [Source Files]
    Source="C:\ti\c5500\dsk5510\lib\dsk5510bsl\Debug\dsk5510bslx.lib"
    Source="playback.cdb"
    Source="src\floatPoint_nr_fft.c"
    Source="src\floatPoint_nr_hwindow.c"
    Source="src\floatPoint_nr_init.c"
    Source="src\floatPoint_nr_mainTest.c"
    Source="src\floatPoint_nr_proc.c"
    Source="src\floatPoint_nr_ss.c"
    Source="src\floatPoint_nr_vad.c"
    Source="playbackcfg.cmd"

    [Generated Files]
    Source="playbackcfg.s55"
    Source="playbackcfg_c.c"

    ["Compiler" Settings: "Debug"]
    Options=-g -mg -q -o2 -fr".\Debug" -i"." -i"..\inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2

    ["Compiler" Settings: "Release"]
    Options=-mg -q -fr".\Release" -i"." -ml -mn -v5510:2

    ["DspBiosBuilder" Settings: "Debug"]
    Options=-v55

    ["DspBiosBuilder" Settings: "Release"]
    Options=-v55

    ["Linker" Settings: "Debug"]
    Options=-q -c -heap0x2000 -o".\Debug\playback.out" -stack0x800 -sysstack0x400 -w -x -l"rts55x.lib"

    ["Linker" Settings: "Release"]
    Options=-q -c -o".\Release\tone.out" -x -l"dsk5510bslx.lib"
    and my build report says 
    ----------------------------  playback.pjt - Debug  ----------------------------
    "c:\ti\plugins\bios\gconfgen" playback.cdb

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_fft.c"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_hwindow.c"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_init.c"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_mainTest.c"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_proc.c"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_ss.c"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"../Debug.lkf" "floatPoint_nr_vad.c"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"Debug.lkf" "playbackcfg.s55"

    "c:\ti\c5500\cgtools\bin\cl55" -g -mg -q -o2 -fr"./Debug" -i"." -i"../inc" -d"_DEBUG" -d"CHIP_5510" -ml -mn -v5510:2 -@"Debug.lkf" "playbackcfg_c.c"

    "c:\ti\c5500\cgtools\bin\cl55" -@"Debug.lkf"
    >> G:\workouts\FYP\playbackcfg.cmd, line 226: warning: 
                   (.args) not found

    Build Complete,
      0 Errors, 1 Warnings, 0 Remarks.
    With this case I could listen to the audio but when i
    build again I get 
    0 Errors, 0 Warnings, 0 Remarks but the program doesn't work

    I am not able to figure it out. 
    Regards
    velappan
  • Hi,

    It's good you made some progress. I don't see what is wrong with it either.

    BTW, what do you mean it's not working all the time? Please explain it in detail.

    Regards,

    Hyun

  • Hi Hyun

    Yeah progressed but didn't make it till end . 

    When I build my project I get warning . But when I build the next time it doesn't come. When I load the .out file my program doesnt run. 

     

    I couldn't debug what is the problem. I feel that some options is left when building the project thats the reason in my previous post i had mention the options I included when building the project . 

     

    I have one more doubt you said to build the dsk5510bslx pjt . I dont get why I should do that . As i had already included in the dsk5510bslx.lib in the linker options

     

    One more thing when i try to see the dependencies I get a warning in Infinite loop of Nested Included Files  in csl.h , swi.h

    Regards

    velappan

     

     

     

  •  

    Hi Hyun

     

    I initially added only the dsk5510bslx.lib to the linking sections -l option. I build my project then when i started I also opened the stack view to see what is happening .it started from c_int and immediately It went to exit .

     

    Then I added rts55x.lib also to the -l option and started building the project it gave me one warning which I had mention below 

     

    ----------------------------  playback.pjt - Debug  ----------------------------

    "c:\ti\c5500\cgtools\bin\cl55" -@"Debug.lkf"

    >> G:\workouts\FYP\playbackcfg.cmd, line 226: warning: 

                   (.args) not found

    Build Complete,

      0 Errors, 1 Warnings, 0 Remarks.

    My program runs fine I could listen to the song when i try to listen .
    But when i close the session and open the CCS again and started to add the pjt and build 
    ----------------------------  playback.pjt - Debug  ----------------------------

    Build Complete,

      0 Errors, 0 Warnings, 0 Remarks.

     

    This time my program doesn't work. 

     

    I am not able to figure it out why its not working all the time. I seriously think some options is not given when building .

    Kindly need your help

    P.F.A

    Thanks and Regards

    velappan 5126.fyp1.rar

     

  • Hi Hyun

    Is there a procedure to build the project . I mean the way to add the .c , .cdb and .cmd files ?

    I find it difficult to understand why it works some time and not all . 

    I observed one thing if it works once and i keep changing the input files and buid it again it works fine. But when I power off the board and On it again I find things different the program which run before didnt work . I am  facing this problem only for the .pjt which I had attached in the previous post. 

    Regards

    velappan

  •  

    Hi Hyun

    I think I found what is wrong in my code. 

    I check the assembly section of the code and found it was going to infinite loop 

     

    _DSK5510_AIC23_rset

    ... 

    ...

    ...

     

     

    022128 ED31BF001F8E             XAR3 = dbl(*(#1f8eh))

    02212E DF6105                   AC0 = uns(*AR3)

    022131 10050A                   AC0 = AC0 <<  #10

    022134 220B                     AR3 = AC0

    022136 A96B 99                  AR1 = *AR3(T0) || readport()

    022139 180299                   AR1 = AR1 & #2

    02213C 5091                     AR1 = AR1 >>> #1

    02213E 0409E7                   if (AR1 == #0) goto 0x022128

     

    This section keeps repeating so thats why I am not able to listen to the audio data.

    It is when starting the Codec. 

     

    But I don't know how to solve it . All things seems to be correct for me.

    If you could find any error let me know. It would be a great help

    Thanks and Regards

    velappan

     

  • Hi,

     

    If you are in stuck in that infinite loop, AR1 is never set to 1. Is it happening always or time to time?

    Can you try with skipping  _DSK5510_AIC23_rset? 

    Regards,


  • Hi Hyun.

    I initially declared the 

     // Start the codec

      hCodec = DSK5510_AIC23_openCodec(0, &config);

     

    So my program used to struck there itself  . I wanted to make sure is it because of this line.

     

    After all the file processing I called declared this and then tried the codec.

     

    The program gets struck here itself.

     

    Regards

    velappan

  • Hi Hyun 

    I observed few things which I would like to share with you so that I can get a solution for the problem.

     

    Steps making it work

    1) Add files to the project

    2) Add the .cmd file 

    3) Add the dsk5510bslx.lib to the project

    4) Build it

    5) Load the program and I realized it doesn't work. It just ends because I have not added the run time library 

    6) In the linker options(-l)  i gave rts55x.lib

    7) Build it 

    8) Load the program . Files processing is done and when i click the song I could listen the data

     

    If I close the session and open again then add the project, build it and I load the program now its not working .

    Only If I follow the above steps I could listen to the audio

    The Problem for not listening to the audio is the read port is not working  ( which I had mention in the previous post ) . I observed it in the assembly code of the project.

     

    Could you please help me with it. 

    Thanks and Regards

    velappan