AnsweredAssumed Answered

Audio+Net+VDK project

Question asked by BlueIceScream on Jan 12, 2011
Latest reply on Jan 31, 2011 by TomA

Hi everyone. i have question.

 

i use bf518 ez-board. i want create  the project which use audio codec and Lwip and base it on VDK.

This project must do :

 

1) use mic as source for audio data

2) use headphone and mic as loopback.(i must here data which is getting from mic)

2) send audio data from mic by net to host

3) recieve audio data from net

4) use headphone out as destination for received audio data from net

 

i use audioloopback example and change  code for use this example in VDK as thread. it work correctly and all fine;

also for send data i use multisender example and also change it for my project/ it work correctly i test it;

 

but when i use this examples both i have problem. when audio data sending i here in my headphone other tone . also if i disable cable which uses for send data to mic from host, this tone not disappear. what wrong?

 

this is code for creating loopback  (in lwip_sysboot_threadtype)

 

 

 

u16 NetData [BUFFER_SIZE_PER_CHANNEL];
 
u16 InboundData [BUFFER_SIZE_PER_CHANNEL * NUM_CHANNELS];
u16 OutboundData[BUFFER_SIZE_PER_CHANNEL * NUM_CHANNELS];


void ProcessInput(void)
{
    u32 i,n;

 
    if (PingPong == 0)
    {
        
        n=0;
        for (i=0; i < ((BUFFER_SIZE_PER_CHANNEL * NUM_CHANNELS)/2); i+= NUM_CHANNELS)           
        {
            OutboundData[DAC_LEFT_CHANNEL+i]    = InboundData[ADC_LEFT_CHANNEL+i];
            OutboundData[DAC_RIGHT_CHANNEL+i]   = InboundData[ADC_RIGHT_CHANNEL+i];
           
           
            NetData[DAC_LEFT_CHANNEL+n]    = InboundData[ADC_LEFT_CHANNEL+i];
            NetData[DAC_RIGHT_CHANNEL+n]   = InboundData[ADC_RIGHT_CHANNEL+i];
          
                  
            n++;
            flagrise=true;
           
        }     
                    
    }
    else   
    {
  
         n=((BUFFER_SIZE_PER_CHANNEL * NUM_CHANNELS)/2);
    
        for (i=((BUFFER_SIZE_PER_CHANNEL * NUM_CHANNELS)/2); i < (BUFFER_SIZE_PER_CHANNEL * NUM_CHANNELS); i+= NUM_CHANNELS)          
        {   
            OutboundData[DAC_LEFT_CHANNEL+i]    = InboundData[ADC_LEFT_CHANNEL+i];
            OutboundData[DAC_RIGHT_CHANNEL+i]   = InboundData[ADC_RIGHT_CHANNEL+i];

            

 

               NetData[DAC_LEFT_CHANNEL+n]    = InboundData[ADC_LEFT_CHANNEL+i];
            NetData[DAC_RIGHT_CHANNEL+n]   = InboundData[ADC_RIGHT_CHANNEL+i];
           
            n++;
            flagrise=true;
        }
       
    }
           
}

 

 

and this code to send data  (in MulticastSender thread)

 

extern unsigned short NetData[44];

 

void MulticastSenderThread::Run()
{


    struct sockaddr_in addr;
int fd;

ex=true;

if ((fd=socket(AF_INET,SOCK_DGRAM,0)) < 0)

{
     perror("socket");
     exit(1);
}



memset(&addr,0,sizeof(addr));
addr.sin_family=AF_INET;
addr.sin_addr.s_addr=inet_addr(MULTICAST_GROUP);
addr.sin_port=htons(MULTICAST_PORT);




while (1)
{
if ((flagrise))
{
     flagrise=false;
 
     if (sendto(fd,NetData,sizeof(NetData),0,(struct sockaddr *) &addr,sizeof(addr)) < 0)
     {
        perror("sendto");
        exit(1);
     }


}


}

 

 

 

variables values(in .h file):


BUFFER_SIZE_PER_CHANNEL=44 ;

NUM_CHANNELS=2;

 

also if i send any data, i hear this tone(even if send one byte). If i comment sendto function tone disappear. If i add VDK::Sleep (1000) for in data sending cycle tone rate change. where problem? need help. thx for all.

Outcomes