comparison projects/scope/render.cpp @ 149:134bff10e561 ClockSync

Added simple one-variable one-measurement Kalman filter, Pid controller(which output is not used). Virtual clock is now much more precise and reactive for period. Still it is lagging behind a bit on the overall offset.
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 21 Sep 2015 03:12:21 +0100
parents 55c1e591cb2e
children e9c9404e3d1f
comparison
equal deleted inserted replaced
148:6cd38e261027 149:134bff10e561
47 // scope.setup(); //call this once in setup to initialise the scope 47 // scope.setup(); //call this once in setup to initialise the scope
48 // scope.setPort(0, 9999); 48 // scope.setPort(0, 9999);
49 // scope.setPort(1, 10000); 49 // scope.setPort(1, 10000);
50 // networkSend.setup(context->audioSampleRate, context->audioFrames, 0, 9999, "192.168.7.1"); 50 // networkSend.setup(context->audioSampleRate, context->audioFrames, 0, 9999, "192.168.7.1");
51 // clockSynchronizer.setup(); 51 // clockSynchronizer.setup();
52 virtualClock.init(); 52 virtualClock.init(context->audioFrames / context->audioSampleRate * 1e6);
53 clockSyncThread.init(true, 5000, virtualClock); //start as slave 53 clockSyncThread.init(true, 5000, virtualClock); //start as slave
54 gInverseSampleRate = 1.0/context->audioSampleRate; 54 gInverseSampleRate = 1.0/context->audioSampleRate;
55 55
56 gPhase1 = 0.0; 56 gPhase1 = 0.0;
57 gPhase2 = 0.0; 57 gPhase2 = 0.0;
82 for(unsigned int n=0; n<context->audioFrames; n++){ 82 for(unsigned int n=0; n<context->audioFrames; n++){
83 context->audioOut[n*2]=sinf(phase);//context->audioIn[n*2]; 83 context->audioOut[n*2]=sinf(phase);//context->audioIn[n*2];
84 phase+=200.0/44100.0*2*M_PI; 84 phase+=200.0/44100.0*2*M_PI;
85 if(phase>=2*M_PI) 85 if(phase>=2*M_PI)
86 phase-=2*M_PI; 86 phase-=2*M_PI;
87 context->audioOut[n*2+1]=rand()/(float)RAND_MAX;context->audioIn[n*2]; 87 context->audioOut[n*2+1]=rand()/(float)RAND_MAX;//context->audioIn[n*2];
88 } 88 }
89 count++; 89 count++;
90 /* 90 /*
91 // if((count&262143)==0){ 91 // if((count&262143)==0){
92 // static int nextCall=160000; 92 // static int nextCall=160000;