Mercurial > hg > beaglert
diff projects/scope/render.cpp @ 131:ff28e56e5b7e scope-refactoring
Updated Network files to match Udpioplugin 18:fb5a61b10223
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Wed, 26 Aug 2015 02:02:10 +0100 |
parents | 2696a7f00053 |
children | e24c531220ee |
line wrap: on
line diff
--- a/projects/scope/render.cpp Tue Aug 25 11:14:25 2015 +0100 +++ b/projects/scope/render.cpp Wed Aug 26 02:02:10 2015 +0100 @@ -18,17 +18,17 @@ // in from the call to initAudio(). // // Return true on success; returning false halts the program. -//ReceiveAudioThread receiveAudio0; +ReceiveAudioThread receiveAudio0; //ReceiveAudioThread receiveAudio1; bool setup(BeagleRTContext *context, void *userData) { -// receiveAudio0.init(9999, context->audioFrames, 0); + receiveAudio0.init(10000, context->audioFrames, 0); // receiveAudio1.init(10000, context->audioFrames, 1); -// + // scope.setup(); //call this once in setup to initialise the scope // scope.setPort(0, 9999); // scope.setPort(1, 10000); - networkSend.setup(context->audioSampleRate, 0, 9999, "192.168.7.1"); + networkSend.setup(context->audioSampleRate, context->audioFrames, 0, 9999, "192.168.7.1"); gInverseSampleRate = 1.0/context->audioSampleRate; @@ -49,23 +49,24 @@ void render(BeagleRTContext *context, void *userData) { static int count=0; -// if(count==0){ -// printf("startHread\n"); -// ReceiveAudioThread::startThread(); -// } + if(count==0){ + printf("startHread\n"); + ReceiveAudioThread::startThread(); + } for(unsigned int n = 0; n < context->audioFrames; n++) { float chn0 = sinf(gPhase1); - float chn1 = sinf(gPhase2); +// 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]; - networkSend.log(chn0); -// scope.log(0, chn0); -// scope.log(1, chn1); + networkSend.log(context->audioIn[n]); +// networkSend.log(chn0); +// scope.log(0, chn0); +// scope.log(1, chn1); // scope.log(2, chn2); // scope.log(3, chn3); // scope.log(4, chn4); @@ -87,9 +88,19 @@ } if(count>0){ -// int readPointer0=receiveAudio0.getSamplesSrc(context->audioOut, context->audioFrames, 1, 2, 0); + float samplingRateRatio=1; + int channelsInDestinationBuffer=2; + int channelToWriteTo=0; + int length=receiveAudio0.getSamplesSrc(context->audioOut, context->audioFrames, + samplingRateRatio, channelsInDestinationBuffer, channelToWriteTo); + if(length!=context->audioFrames){ + rt_printf("Length mismatch: %d\n", length); + } // int readPointer1=receiveAudio1.getSamplesSrc(context->audioOut, context->audioFrames, 1, 2, 1); } + for(int n=0; n<context->audioFrames; n++){ + context->audioOut[n*2+1]=context->audioOut[n*2]; + } count++; }