comparison core/ClockSync.cpp @ 144:55c1e591cb2e ClockSync

Added ifdefs for USE_JUCE compatibility
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 14 Sep 2015 21:31:09 +0100
parents 44d07fa9bd03
children 134bff10e561
comparison
equal deleted inserted replaced
143:dd24379336f1 144:55c1e591cb2e
259 //printf("Unexpected message type\n"); // we should never get here 259 //printf("Unexpected message type\n"); // we should never get here
260 return -1; 260 return -1;
261 } 261 }
262 return 1; 262 return 1;
263 } 263 }
264 #include <I2c_Codec.h>
265 extern I2c_Codec* gAudioCodec;
266 void ClockSync::processOffset(double offset){ 264 void ClockSync::processOffset(double offset){
267 static int calls=0; 265 static int calls=0;
268 // TODO: change the flow control below so that it can happen multiple times 266 // TODO: change the flow control below so that it can happen multiple times
269 //(base it upon the length of movingAverage rather than the number of calls) 267 //(base it upon the length of movingAverage rather than the number of calls)
270 if(calls<10) { //get an initial guess 268 if(calls<10) { //get an initial guess
295 printf("%10.3f, %10.3f, %10.3f, %10.3f\n", in, offset, offset-pastOut[2], maxOffset); //unfiltered, filtered 293 printf("%10.3f, %10.3f, %10.3f, %10.3f\n", in, offset, offset-pastOut[2], maxOffset); //unfiltered, filtered
296 if(fabsf(offset)>10 && calls>30){ 294 if(fabsf(offset)>10 && calls>30){
297 calls=11; 295 calls=11;
298 //TODO: correct for offset 296 //TODO: correct for offset
299 float targetSamplingRate=offset>0 ? 44097 : 44103; 297 float targetSamplingRate=offset>0 ? 44097 : 44103;
298 #ifndef USE_JUCE
300 gAudioCodec->setAudioSamplingRate(targetSamplingRate); 299 gAudioCodec->setAudioSamplingRate(targetSamplingRate);
300 #endif
301 // pastOut[1]=pastOut[2]=pastIn[1]=pastIn[2]=offset; 301 // pastOut[1]=pastOut[2]=pastIn[1]=pastIn[2]=offset;
302 printf("------setAudioSmplingRate to %f\n", targetSamplingRate); 302 printf("------setAudioSmplingRate to %f\n", targetSamplingRate);
303 } 303 }
304 } 304 }
305 calls++; 305 calls++;