changeset 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 dd24379336f1
children 0a5a94de9dd0
files core/ClockSync.cpp include/ClockSync.h projects/scope/render.cpp
diffstat 3 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/core/ClockSync.cpp	Mon Sep 14 17:35:18 2015 +0100
+++ b/core/ClockSync.cpp	Mon Sep 14 21:31:09 2015 +0100
@@ -261,8 +261,6 @@
 	}
 	return 1;
 }
-#include <I2c_Codec.h>
-extern I2c_Codec* gAudioCodec;
 void ClockSync::processOffset(double offset){
 	static int calls=0;
 	// TODO: change the flow control below so that it can happen multiple times
@@ -297,7 +295,9 @@
 			calls=11;
 			//TODO: correct for offset
 			float targetSamplingRate=offset>0 ? 44097 : 44103;
+#ifndef USE_JUCE
 			gAudioCodec->setAudioSamplingRate(targetSamplingRate);
+#endif
 //			pastOut[1]=pastOut[2]=pastIn[1]=pastIn[2]=offset;
 			printf("------setAudioSmplingRate to %f\n", targetSamplingRate);
 		}
--- a/include/ClockSync.h	Mon Sep 14 17:35:18 2015 +0100
+++ b/include/ClockSync.h	Mon Sep 14 21:31:09 2015 +0100
@@ -5,6 +5,11 @@
 #include "UdpClient.h"
 #include "Clock.h"
 #include "VirtualClock.h"
+#ifdef USE_JUCE
+#else
+#include <I2c_Codec.h>
+extern I2c_Codec* gAudioCodec;
+#endif /* USE_JUCE */
 
 enum ptpMessageConsts{
 	kSyncMessageLength=sizeof(myClock_t)+sizeof(int)
--- a/projects/scope/render.cpp	Mon Sep 14 17:35:18 2015 +0100
+++ b/projects/scope/render.cpp	Mon Sep 14 21:31:09 2015 +0100
@@ -77,15 +77,14 @@
 		clockSyncThread.startThread(); //make sure you uncomment .init in setup()
 	}
 	static float phase=0;
-	float phaseInc=200.0/44100.0*2*M_PI;
+	float phaseInc=gFrequency1/44100.0*2*M_PI;
 //	rt_printf("phaseInc: %f, phase: %f\n",phaseInc,phase);
 	for(unsigned int n=0; n<context->audioFrames; n++){
-		context->audioOut[n*2]=sinf(phaseInc);//context->audioIn[n*2];
-		context->audioOut[n*2+1]=sinf(phaseInc);//context->audioIn[n*2];
+		context->audioOut[n*2]=sinf(phase);//context->audioIn[n*2];
 		phase+=200.0/44100.0*2*M_PI;
 		if(phase>=2*M_PI)
 			phase-=2*M_PI;
-//		context->audioOut[n*2+1]=rand()/(float)RAND_MAX;context->audioIn[n*2];
+		context->audioOut[n*2+1]=rand()/(float)RAND_MAX;context->audioIn[n*2];
 	}
 	count++;
 	/*