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.

CCS / TIDC-CC3200MODLAUNCHXL:WIFI_AUDIO_APP: AUDIO FROM SPI FLASH

Part Number: TIDC-CC3200MODLAUNCHXL
Other Parts Discussed in Thread: CC3200

Tool/software: Code Composer Studio

Hello TI
Pls help me. I need to play an audio file, which I recorded on a SPI FLASH.

using the SPI TRANSFER command, I write the information to g_ucRxBuff (g_ucRxBuff is a circular buffer) then I fill it with the playBuffer. But in response I hear only hiss and squeals. Interestingly, with a different number of bytes sent for iteration in a cycle, the sound changes. What I'm doing is not right, ask me leading questions, I'll definitely answer so that it's easier for you to understand the situation.

In the WIFI_AUDIO_APP example, I completely disabled Speaker_task, and Network_task.
And also I changed Microphone_task this way:

void Microphone( void *pvParameters )
{
    long lRetVal = -1;
    unsigned char array_to_send_spi [2];
              short page16 = 0x00   ;
    //RESET SPI
           MAP_SPIReset(GSPI_BASE);

           //SPI CONFIG
           MAP_SPIConfigSetExpClk(GSPI_BASE,MAP_PRCMPeripheralClockGet(PRCM_GSPI),
                            SPI_IF_BIT_RATE,SPI_MODE_MASTER,SPI_SUB_MODE_0,
                            (SPI_SW_CTRL_CS |
                            SPI_4PIN_MODE |
                            SPI_TURBO_OFF |
                            SPI_CS_ACTIVELOW |
                            SPI_WL_8));
               if(g_loopback) // g_loopback = 1
                {
                    Report("\n \r READING \n \r");
                                       Report("\n \r first page is 0");
                                       array_to_send_spi[0] = (unsigned char)((page16) >> 6);
                                       array_to_send_spi[1] = (unsigned char)((page16) << 2);
                                                    Report("\r");
                                                    Report("Page = %d", page16);
                                                    Report("\r");

                                       MAP_SPIEnable(GSPI_BASE);
                                       MAP_SPITransfer(GSPI_BASE,READING,g_ucBuff,1,
                                                                                  SPI_CS_ENABLE);
                                       MAP_SPITransfer(GSPI_BASE,array_to_send_spi,g_ucBuff,2,
                                                                                  SPI_CS_ENABLE);
                                       for(i=0; i<242; i++) //528 bytes is size of page. I have 242 pages of data
                                         {

                                          MAP_SPITransfer(GSPI_BASE,g_ucTxBuff, g_ucRxBuff,528,
                                                                                  SPI_CS_ENABLE);
                                          FillBuffer(pPlayBuffer, (unsigned char*)(g_ucRxBuff->pucReadPtr), 528);

                                          UpdateReadPtr(g_ucRxBuff, 528);
                                          MAP_UtilsDelay(1000);
                                         }

                                       MAP_SPITransfer(GSPI_BASE,g_ucTxBuff, g_ucRxBuff,1,
                                                       SPI_CS_DISABLE);
                                       MAP_UtilsDelay(8000000);

                                                    MAP_SPIDisable(GSPI_BASE);
                                                    Report("\r Reading complete \r");


                }
}

waiting  your answer!



  • Georgiy,

    A few questions. What format is the audio saved on the external flash? What peripheral are you using to send the audio out (I2S)? 

    I would break this down into a few steps. Can you first verify the data you receive from the serial flash is what you expect? Lets verify the data here is valid. Next, can we check if your sending I2S data correctly out to an audio codec?

    Regards,


    VR

  • Hello, Vincent
    format is wma 16 bit 16 kHz, peripheral is the CC3200 Audio Boost, yes I2S.
    1) Yes, i recieve correct data from SPI, I checked with a logic analyzer.
    2) I don't know how to check data, which i send to audio codec.
  • Georgiy,

    You will not be able to use a WMA formatted audio to play audio. The problem here is that audio codec on the Audio Boosterpack, and the i2s peripheral needs uncompressed PCM audio at a certain bitrate (16KHz, 16 bit is the default, and will work).

    I would suggest converting your WMA audio to PCM audio, and giving this another go.

    Regards,

    VR
  • Dear Vincent


    I was wrong, I'm using wav format (windows pcm)

  • Georgiy,

    Okay. You will need to convert that wav format to true pcm only data. Often times, WAV isn't pure pcm audio. What i would suggest is downloading a any raw pcm audio sample from online (Google a pcm sample), and see if you can play this. This would tell us if its the format or something else.

    Regards,

    VR
  • Dear Vincent

    I downloaded a file format RAW PCM 16 khz 16 bit stereo, uploaded it to a serial flash, tried to play audio, but still hear hiss and buzz

    please answer these questions:

    1) How many bytes do I need to load into the pPlayBuffer for one iteration?

    On this function:

    illBuffer(pPlayBuffer, (unsigned char*)(g_ucRxBuff->pucReadPtr), 528);

    I'm sending 528 because it's the size of one page, but the example sent 1024 bytes (PACKETSIZE).

    2)Is the pPlayBuffer filled out somewhere else in the project?
    maybe this hissing due to the fact that data is connected to the correct data from serial flash and pPlayBuffer is filled with mixed incorrect data.

    Please tell us your thoughts on this issue, any help is very necessary!
    Sorry for my bad english!

    Waiting for your reply!

    Regards,

    George.

  • Alright.

    Next, i see you disabled the speaker task. Can you comment that back? The example works by filling and reading a circular buffer for the audio. The fillBuffer() function is only filling a circular buffer in RAM, and not sending this out. The speaker tasks polls this buffer, and if it sees enough data for one frame to send, it then sends this data over I2S.

    Hope that helps!

    VR
  • Hello Vincent,

    In the beginning I started the example in the callback mode. And when I disabled the speaker and network tasks, I still heard the sounds from the microphone. So I thought that the speaker task is only needed when we have two LaunchpadXL boards. Please look at the code:

    void Speaker( void *pvParameters )
    {
        long iRetVal = -1;
    
    
        while(1)
        {
            while(g_ucSpkrStartFlag || g_loopback)
            {     
    
                if(!g_loopback)
                {
                    fd_set readfds,writefds;
                    struct SlTimeval_t tv;
                    FD_ZERO(&readfds);
                    FD_ZERO(&writefds);
                    FD_SET(g_UdpSock.iSockDesc,&readfds);
                    FD_SET(g_UdpSock.iSockDesc,&writefds);
                    tv.tv_sec = 0;
                    tv.tv_usec = 2000000;
                    int rv = select(g_UdpSock.iSockDesc, &readfds, NULL, NULL, &tv);
                    if(rv <= 0)
                    {
                        continue;
                    }
                    if (FD_ISSET(g_UdpSock.iSockDesc, &readfds) )
                    {
                        g_iRetVal = recvfrom(g_UdpSock.iSockDesc, (char*)(speaker_data),\
                                              PACKET_SIZE*16, 0,\
                                              (struct sockaddr *)&(g_UdpSock.Client),\
                                              (SlSocklen_t*)&(g_UdpSock.iClientLength));
                    }
    
                    if(g_iRetVal>0)
                    {
                        iRetVal = FillBuffer(pPlayBuffer, (unsigned char*)speaker_data,\
                                              g_iRetVal);
                        if(iRetVal < 0)
                        {
                            UART_PRINT("Unable to fill buffer");
                            LOOP_FOREVER();
                        }
                    }
                }
                else
                {
                    MAP_UtilsDelay(1000);
                }
            }
            MAP_UtilsDelay(1000);
        }
    }

    Since gloopback = 1, the speaker task executes only delay.

    Maybe I should like to change this function?

      g_iRetVal = recvfrom(g_UdpSock.iSockDesc, (char*)(speaker_data),\
                                              PACKET_SIZE*16, 0,\
                                              (struct sockaddr *)&(g_UdpSock.Client),\
                                              (SlSocklen_t*)&(g_UdpSock.iClientLength));

    but I do not know how to do it and do I need it to accomplish my problem?

    So, now I've started the speaker task, but still I do not hear the melody from the serial flash

    Regards,

    George

  • Vincent!

    Today I worked and found a few interesting things!

    1) If I write a small piece of an audio file into the memory of the cc3200 and try to fill it with the pPlayBuffer buffer, then at first I hear a lot of noise, and then a couple of milliseconds of the audio I need.
    2) From this it can be concluded that I correctly fill the pPlayBuffer, to play the sound it needs to be done. But the data that I write in pPlayBuffer is not correct.
    3) At the same time, I correctly read it from a serial flash.

    Looking at these facts, I conclude that I do not correctly use the filling functions of arrays and buffers and do not correctly send them to pPlayBuffer, can you help me with this?

    thanks for your time!

    George.

  • George,

    Could you share both the Speaker and the Microphone thread code so i can check it out?

    Thanks,

    VR