diff projects/scope/render.cpp @ 117:ada68d50e56a scope-refactoring

ReceiveAudioThread hs been ported to BBB. The scope project now is sending audio locally and receiving it at the same time
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 20 Aug 2015 16:37:15 +0100
parents 3168919fdb07
children 26ad97b8aa9e
line wrap: on
line diff
--- a/projects/scope/render.cpp	Wed Aug 19 23:22:39 2015 +0100
+++ b/projects/scope/render.cpp	Thu Aug 20 16:37:15 2015 +0100
@@ -1,5 +1,6 @@
 #include <BeagleRT.h> 
 #include <NetworkSend.h>
+#include <ReceiveAudioThread.h>
 #include <cmath>
 
 float gPhase1, gPhase2;
@@ -17,9 +18,11 @@
 // in from the call to initAudio().
 //
 // Return true on success; returning false halts the program.
-
+ReceiveAudioThread receiveAudio;
 bool setup(BeagleRTContext *context, void *userData)
 {
+	receiveAudio.bindToPort(9999);
+	receiveAudio.init(context->audioFrames);
 	scope.setup();  //call this once in setup to initialise the scope
 //	networkSend.setup(context->audioSampleRate, 0, 9999, "192.168.7.1");
 	 
@@ -42,6 +45,9 @@
 void render(BeagleRTContext *context, void *userData)
 {
 	static int count=0;
+	if(count==0)
+		receiveAudio.startThread();
+
 	for(unsigned int n = 0; n < context->audioFrames; n++) {
 	    
 		float chn0 = sinf(gPhase1);
@@ -74,6 +80,8 @@
 			gPhase2 -= 2.0 * M_PI;
 		
 	}
+	if(count>100)
+		receiveAudio.getSamplesSrc(context->audioOut, context->audioFrames, 1);
 	count++;
 }