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.

CC3200 Based on 3254 chip Audio stream through wireless transmission

Other Parts Discussed in Thread: CC3200

Hello,TI ,Engineer

         cc3200   "wifi_audio_app"demo,

         I want to use STATION mode to transmit PCM audio stream,do not use smartconfig mode.So I transplant program"Wlan_station"demo to "wifi_audio_app"demo.

        cc3200 Device to transmit PCM audio stream to a 60002 port on a computer.Computer analysis of received audio stream。While the headphone is connected to the LINE_OUT, listen to the sound of LINE_IN.

      cc3200   LINE_IN------------------------------------------------>LINE_OUT(headphone)   

                              |

                              |----------------------------------------------------->PC 

        I found the sound quality is too bad, the player is very fast.  Packet loss phenomenon in network transmission.But,The LINE_OUT output sound quality is very good.

        my program = "wifi_audio_app" + " waln_station"

        

SlSockAddrIn_t sAddr;
int iSockID;
int iAddrSize;

void ConnectClientSocket ( void )
{
             sAddr.sin_family = SL_AF_INET;//IPV4
             sAddr.sin_port = sl_Htons((unsigned short)60002);
             sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)(/*g_ulStaIp*/0xc0a8647B));
             iAddrSize = sizeof(SlSockAddrIn_t);
             iSockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
}

 

 

 

void Microphone( void *pvParameters )
{
         long lRetVal = -1;
         while(1)
         {
                  while(1)
                   {
                            int iBufferFilled = 0;
                           iBufferFilled = GetBufferSize(pRecordBuffer);
                           if(iBufferFilled >= (2*PACKET_SIZE))
                           {
                                 if(g_EthOKFlag)//Connect to the network to transmit audio data
                                 {

 #if 0
                                                    lRetVal = sendto(g_UdpSock.iSockDesc, \
                                                                                     (char*)(pRecordBuffer->pucReadPtr),PACKET_SIZE,\
                                                                                     0,(struct sockaddr*)&(g_UdpSock.Client),\
                                                                                      sizeof(g_UdpSock.Client));
                                                   if(lRetVal < 0)
                                                   {
                                                           UART_PRINT("Unable to send data\n\r");
                                                           LOOP_FOREVER();
                                                   }
#endif
                                                  //
                                                  // send audio message by wifi
                                                  //
                                                 lRetVal = sl_SendTo(iSockID, (char*)(pRecordBuffer->pucReadPtr), PACKET_SIZE, 0,
                                                                                       (SlSockAddr_t *)&sAddr, iAddrSize);

                                              }
                                              else
                                              {
                                                                      lRetVal = FillBuffer(pPlayBuffer,\
                                                                                                          (unsigned char*)(pRecordBuffer->pucReadPtr), \
                                                                                                            PACKET_SIZE);
                                                                      if(lRetVal < 0)
                                                                      {
                                                                           UART_PRINT("Unable to fill buffer\n\r");
                                                                      }
                                                                     g_iReceiveCount++;
                                              }
                                            UpdateReadPtr(pRecordBuffer, PACKET_SIZE);
                                            g_iSentCount++;
                                            osi_Sleep(2);
                                       }
                                }
                                //MAP_UtilsDelay(1000);
                                osi_Sleep(1000);
                         }

}

 

It takes me too much time, no way, please help me, I will be very grateful

 

  • Hi,


    From above code it's not clear how you sending data over network as sendto part is inactive or commented? Also why are using sleep() after UpdateReadPtr(). Can you please post clean code snippet.


    Regards,
    Aashish
  • SlSockAddrIn_t  sAddr;
    int             iSockID;
    int             iAddrSize;
    
    void ConnectClientSocket ( void )
    {
    	sAddr.sin_family = SL_AF_INET;//IPV4
    	sAddr.sin_port = sl_Htons((unsigned short)60002);
    	sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)(/*g_ulStaIp*/0xc0a80165));
    	iAddrSize = sizeof(SlSockAddrIn_t);
    	iSockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
    }
    
    
    //****************************************************************************
    //
    //!    \brief start simplelink, wait for the sta to connect to the device and
    //!        run the ping test for that sta
    //!
    //!    \param  pvparameters is the pointer to the list of parameters that can be
    //!         passed to the task while creating it
    //!
    //!    \return None
    //
    //****************************************************************************
    void WlanAPMode( void *pvParameters )
    {
        int iTestResult = 0;
        unsigned char ucDHCP;
        long lRetVal = -1;
        int iSocketDesc;
    	static u8 uGetNTPTimer_Count = 0;
    	char wData[30]={0,};
    	static unsigned char uCreateScoket=0;
    
    
        InitializeAppVariables();
    
        //
        // Following function configure the device to default state by cleaning
        // the persistent settings stored in NVMEM (viz. connection profiles &
        // policies, power policy etc)
        //
        // Applications may choose to skip this step if the developer is sure
        // that the device is in its default state at start of applicaton
        //
        // Note that all profiles and persistent settings that were done on the
        // device will be lost
        //
        lRetVal = ConfigureSimpleLinkToDefaultState();//
        if(lRetVal < 0)
        {
            if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
                UART_PRINT("Failed to configure the device in its default state \n\r");
    
            LOOP_FOREVER();
        }
    
        UART_PRINT("Device is configured in default state \n\r");
    
        //
        // Asumption is that the device is configured in station mode already
        // and it is in its default state
        //
        lRetVal = sl_Start(NULL,NULL,NULL);
    
        if (lRetVal < 0)
        {
            UART_PRINT("Failed to start the device \n\r");
            LOOP_FOREVER();
        }
    
        UART_PRINT("Device started as STATION \n\r");
    
    		
    
    
        // Initialize AP security params
        SecurityParams.Key = (signed char *)SECURITY_KEY;
        SecurityParams.KeyLen = strlen(SECURITY_KEY);
        SecurityParams.Type = SECURITY_TYPE;
    
    	//
        // Connect to the Access Point
        //
        lRetVal = Network_IF_ConnectAP(SSID_NAME, SecurityParams);
        if(lRetVal < 0)
        {
           UART_PRINT("Connection to an AP failed\n\r");
           LOOP_FOREVER();
        }
     
    //
    //g_EthOKFlag:1 wlan connect successful;0 wlan connect failure
    // if( g_EthOKFlag ) { ConnectClientSocket(); } while(1) { osi_Sleep(1000);// // // If you disconnect, reconnect // if( g_EthOKFlag == false ) { lRetVal = Network_IF_ConnectAP(SSID_NAME, SecurityParams); if(lRetVal < 0) { UART_PRINT("Connection to an AP failed\n\r"); g_usConnectIndex = 0; LedSta.nBit.nLedYellowBlinkOnOffFg = 0; } else { ConnectClientSocket(); LedSta.nBit.nLedYellowBlinkOnOffFg = 1; } } } } void Microphone( void *pvParameters ) { long lRetVal = -1; FIL fp; FRESULT res; UINT Size; while(1) { while(1) { int iBufferFilled = 0; iBufferFilled = GetBufferSize(pRecordBuffer); if(iBufferFilled >= (2*PACKET_SIZE)) { if(g_EthOKFlag) { // // send audio message by wifi // lRetVal = sl_SendTo(iSockID, (char*)(pRecordBuffer->pucReadPtr), PACKET_SIZE, 0, (SlSockAddr_t *)&sAddr, iAddrSize); if( lRetVal <= 0 ) { uErrCount ++; } uPCMCount++; } else { lRetVal = FillBuffer(pPlayBuffer,\ (unsigned char*)(pRecordBuffer->pucReadPtr), \ PACKET_SIZE); if(lRetVal < 0) { UART_PRINT("Unable to fill buffer\n\r"); } } UpdateReadPtr(pRecordBuffer, PACKET_SIZE); g_iSentCount++; osi_Sleep(2); } } osi_Sleep(1000); } }

    hi

    1、       osi_Sleep(2);

        I want to call other TASK, so I need to call “osi_Sleep”。

    2、

             1、

    ”void WlanAPMode( void *pvParameters )“  Configuration station mode
    2、
    “void ConnectClientSocket ( void )”Configure the IP address and port number of the client  side.We will need to be sent to the device in the future.
    3、
    ”void Microphone( void *pvParameters )“Transmit the received audio stream to the corresponding device
  • Hi,


    2msec sleep in Microphone() task will cause to delay in transmitting packets that may result in noise. Comment the osi_Sleep(2); in Microphone() and try whether you are getting noise or not.


    Regards,
    Aashish
  • Hi,


    We are closing this thread, for follow up queries please open a new thread and add a link to this one for reference.


    Regards,
    Aashish