comparison projects/scope/render.cpp @ 133:04b1678614c9 scope-refactoring

Using moving average for clock detection during synchronization seems to be working better but audio gets worse and worse
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 27 Aug 2015 03:33:32 +0100
parents e24c531220ee
children e77e2e712fbc
comparison
equal deleted inserted replaced
132:e24c531220ee 133:04b1678614c9
52 void render(BeagleRTContext *context, void *userData) 52 void render(BeagleRTContext *context, void *userData)
53 { 53 {
54 static int count=0; 54 static int count=0;
55 // if((count&262143)==0){ 55 // if((count&262143)==0){
56 // static int nextCall=160000; 56 // static int nextCall=160000;
57 if( ((count&(16384-1))==0 /*&& count>200000*/)){ 57 if( ((count&(2047-1))==0 /*&& count>200000*/)){
58 // rt_printf("b %d\n", count); 58 // rt_printf("b %d\n", count);
59 clockSynchronizer.update(networkSend.getTimestamp(), receiveAudio0.getTimestamp(), receiveAudio0.getLastTime()); 59 clockSynchronizer.update(networkSend.getTimestamp(), receiveAudio0.getTimestamp(), receiveAudio0.getLastTime());
60 // nextCall=count+100000; 60 // nextCall=count+100000;
61 // rt_printf("a %d\n", count); 61 // rt_printf("a %d\n", count);
62 } 62 }
63 // if(count == nextCall){ 63 // if(count == nextCall){
64 // clockSynchronizer.update(networkSend.getTimestamp(), receiveAudio0.getTimestamp(), receiveAudio0.getLastTime()); 64 // clockSynchronizer.update(networkSend.getTimestamp(), receiveAudio0.getTimestamp(), receiveAudio0.getLastTime());
65 // } 65 // }
66 if(count==0){ 66 if(count==0){
67 gAudioCodec->setAudioSamplingRate(44080); 67 gAudioCodec->setAudioSamplingRate( 44101);
68 printf("startHread\n"); 68 rt_printf("startHread\n");
69 ReceiveAudioThread::startThread(); 69 ReceiveAudioThread::startThread();
70 } 70 }
71 for(unsigned int n = 0; n < context->audioFrames; n++) { 71 for(unsigned int n = 0; n < context->audioFrames; n++) {
72 72
73 float chn0 = sinf(gPhase1); 73 float chn0 = sinf(gPhase1);