Mercurial > hg > beaglert
diff projects/scope/render.cpp @ 111:9928b6366227 scope-refactoring
Refactored the Scope class into NetworkSend and Scope classes. No need for a global pointer anymore!
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Wed, 19 Aug 2015 22:40:05 +0100 |
parents | ad8a93cd7c39 |
children | 3168919fdb07 |
line wrap: on
line diff
--- a/projects/scope/render.cpp Wed Aug 19 22:36:45 2015 +0100 +++ b/projects/scope/render.cpp Wed Aug 19 22:40:05 2015 +0100 @@ -6,7 +6,8 @@ float gFrequency1, gFrequency2; float gInverseSampleRate; -Scope scope(1); //create a scope object with numChannels +Scope scope(6); //create a scope object with 6 channels +NetworkSend networkSend; // initialise_render() is called once before the audio rendering starts. // Use it to perform any initialisation and allocation which is dependent @@ -16,9 +17,11 @@ // in from the call to initAudio(). // // Return true on success; returning false halts the program. + bool setup(BeagleRTContext *context, void *userData) { - scope.setup(context->audioSampleRate); //call this once in setup to initialise the scope + scope.setup(); //call this once in setup to initialise the scope +// networkSend.setup(context->audioSampleRate, 0, 9999, "192.168.7.1"); gInverseSampleRate = 1.0/context->audioSampleRate; @@ -27,6 +30,7 @@ gFrequency1 = 200.0; gFrequency2 = 201.0; + return true; } @@ -40,16 +44,20 @@ static int count=0; for(unsigned int n = 0; n < context->audioFrames; n++) { - float chn1 = sinf(gPhase1); - float chn2 = sinf(gPhase2); - - float chn3 = context->audioIn[n*2 + 0]; - float chn4 = context->audioIn[n*2 + 1]; - - float chn5 = context->analogIn[(int)n/2*8 + 0]; - float chn6 = context->analogIn[(int)n/2*8 + 1]; - if((n&1)==0) - scope.log(0, chn1); + float chn0 = sinf(gPhase1); + float chn1 = sinf(gPhase2); + + float chn2 = context->audioIn[n*2 + 0]; + float chn3 = context->audioIn[n*2 + 1]; + + float chn4 = context->analogIn[(int)n/2*8 + 0]; + float chn5 = context->analogIn[(int)n/2*8 + 1]; + scope.log(0, chn0); + scope.log(1, chn1); + scope.log(2, chn2); + scope.log(3, chn3); + scope.log(4, chn4); + scope.log(5, chn5); // scope.log(chn1, chn2, chn3, chn4, chn5, chn6); //call this once every audio frame