comparison 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
comparison
equal deleted inserted replaced
130:da1c61aa97ea 131:ff28e56e5b7e
16 // 16 //
17 // userData holds an opaque pointer to a data structure that was passed 17 // userData holds an opaque pointer to a data structure that was passed
18 // in from the call to initAudio(). 18 // in from the call to initAudio().
19 // 19 //
20 // Return true on success; returning false halts the program. 20 // Return true on success; returning false halts the program.
21 //ReceiveAudioThread receiveAudio0; 21 ReceiveAudioThread receiveAudio0;
22 //ReceiveAudioThread receiveAudio1; 22 //ReceiveAudioThread receiveAudio1;
23 bool setup(BeagleRTContext *context, void *userData) 23 bool setup(BeagleRTContext *context, void *userData)
24 { 24 {
25 // receiveAudio0.init(9999, context->audioFrames, 0); 25 receiveAudio0.init(10000, context->audioFrames, 0);
26 // receiveAudio1.init(10000, context->audioFrames, 1); 26 // receiveAudio1.init(10000, context->audioFrames, 1);
27 // 27
28 // scope.setup(); //call this once in setup to initialise the scope 28 // scope.setup(); //call this once in setup to initialise the scope
29 // scope.setPort(0, 9999); 29 // scope.setPort(0, 9999);
30 // scope.setPort(1, 10000); 30 // scope.setPort(1, 10000);
31 networkSend.setup(context->audioSampleRate, 0, 9999, "192.168.7.1"); 31 networkSend.setup(context->audioSampleRate, context->audioFrames, 0, 9999, "192.168.7.1");
32 32
33 gInverseSampleRate = 1.0/context->audioSampleRate; 33 gInverseSampleRate = 1.0/context->audioSampleRate;
34 34
35 gPhase1 = 0.0; 35 gPhase1 = 0.0;
36 gPhase2 = 0.0; 36 gPhase2 = 0.0;
47 // will be 0. 47 // will be 0.
48 48
49 void render(BeagleRTContext *context, void *userData) 49 void render(BeagleRTContext *context, void *userData)
50 { 50 {
51 static int count=0; 51 static int count=0;
52 // if(count==0){ 52 if(count==0){
53 // printf("startHread\n"); 53 printf("startHread\n");
54 // ReceiveAudioThread::startThread(); 54 ReceiveAudioThread::startThread();
55 // } 55 }
56 for(unsigned int n = 0; n < context->audioFrames; n++) { 56 for(unsigned int n = 0; n < context->audioFrames; n++) {
57 57
58 float chn0 = sinf(gPhase1); 58 float chn0 = sinf(gPhase1);
59 float chn1 = sinf(gPhase2); 59 // float chn1 = sinf(gPhase2);
60 60
61 // float chn2 = context->audioIn[n*2 + 0]; 61 // float chn2 = context->audioIn[n*2 + 0];
62 // float chn3 = context->audioIn[n*2 + 1]; 62 // float chn3 = context->audioIn[n*2 + 1];
63 63
64 // float chn4 = context->analogIn[(int)n/2*8 + 0]; 64 // float chn4 = context->analogIn[(int)n/2*8 + 0];
65 // float chn5 = context->analogIn[(int)n/2*8 + 1]; 65 // float chn5 = context->analogIn[(int)n/2*8 + 1];
66 networkSend.log(chn0); 66 networkSend.log(context->audioIn[n]);
67 // scope.log(0, chn0); 67 // networkSend.log(chn0);
68 // scope.log(1, chn1); 68 // scope.log(0, chn0);
69 // scope.log(1, chn1);
69 // scope.log(2, chn2); 70 // scope.log(2, chn2);
70 // scope.log(3, chn3); 71 // scope.log(3, chn3);
71 // scope.log(4, chn4); 72 // scope.log(4, chn4);
72 // scope.log(5, chn5); 73 // scope.log(5, chn5);
73 74
85 if(gPhase2 > 2.0 * M_PI) 86 if(gPhase2 > 2.0 * M_PI)
86 gPhase2 -= 2.0 * M_PI; 87 gPhase2 -= 2.0 * M_PI;
87 88
88 } 89 }
89 if(count>0){ 90 if(count>0){
90 // int readPointer0=receiveAudio0.getSamplesSrc(context->audioOut, context->audioFrames, 1, 2, 0); 91 float samplingRateRatio=1;
92 int channelsInDestinationBuffer=2;
93 int channelToWriteTo=0;
94 int length=receiveAudio0.getSamplesSrc(context->audioOut, context->audioFrames,
95 samplingRateRatio, channelsInDestinationBuffer, channelToWriteTo);
96 if(length!=context->audioFrames){
97 rt_printf("Length mismatch: %d\n", length);
98 }
91 // int readPointer1=receiveAudio1.getSamplesSrc(context->audioOut, context->audioFrames, 1, 2, 1); 99 // int readPointer1=receiveAudio1.getSamplesSrc(context->audioOut, context->audioFrames, 1, 2, 1);
100 }
101 for(int n=0; n<context->audioFrames; n++){
102 context->audioOut[n*2+1]=context->audioOut[n*2];
92 } 103 }
93 count++; 104 count++;
94 } 105 }
95 106
96 // cleanup_render() is called once at the end, after the audio has stopped. 107 // cleanup_render() is called once at the end, after the audio has stopped.