Mercurial > hg > beaglert
comparison projects/scope/render.cpp @ 118:26ad97b8aa9e scope-refactoring
Missing file from previous commit
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 21 Aug 2015 14:37:19 +0100 |
parents | ada68d50e56a |
children | c692827083e1 |
comparison
equal
deleted
inserted
replaced
117:ada68d50e56a | 118:26ad97b8aa9e |
---|---|
49 receiveAudio.startThread(); | 49 receiveAudio.startThread(); |
50 | 50 |
51 for(unsigned int n = 0; n < context->audioFrames; n++) { | 51 for(unsigned int n = 0; n < context->audioFrames; n++) { |
52 | 52 |
53 float chn0 = sinf(gPhase1); | 53 float chn0 = sinf(gPhase1); |
54 float chn1 = sinf(gPhase2); | 54 // float chn1 = sinf(gPhase2); |
55 | 55 |
56 float chn2 = context->audioIn[n*2 + 0]; | 56 // float chn2 = context->audioIn[n*2 + 0]; |
57 float chn3 = context->audioIn[n*2 + 1]; | 57 // float chn3 = context->audioIn[n*2 + 1]; |
58 | 58 |
59 float chn4 = context->analogIn[(int)n/2*8 + 0]; | 59 // float chn4 = context->analogIn[(int)n/2*8 + 0]; |
60 float chn5 = context->analogIn[(int)n/2*8 + 1]; | 60 // float chn5 = context->analogIn[(int)n/2*8 + 1]; |
61 scope.log(0, chn0); | 61 scope.log(0, chn0); |
62 scope.log(1, chn1); | 62 // scope.log(1, chn1); |
63 scope.log(2, chn2); | 63 // scope.log(2, chn2); |
64 scope.log(3, chn3); | 64 // scope.log(3, chn3); |
65 scope.log(4, chn4); | 65 // scope.log(4, chn4); |
66 scope.log(5, chn5); | 66 // scope.log(5, chn5); |
67 | 67 |
68 // scope.log(chn1, chn2, chn3, chn4, chn5, chn6); | 68 // scope.log(chn1, chn2, chn3, chn4, chn5, chn6); |
69 //call this once every audio frame | 69 //call this once every audio frame |
70 //takes six or fewer floats as parameters | 70 //takes six or fewer floats as parameters |
71 //first parameter becomes channel 1 etc | 71 //first parameter becomes channel 1 etc |
72 //to view, click the 'oscilloscope' button on the toolbar while BeagleRT is NOT running | 72 //to view, click the 'oscilloscope' button on the toolbar while BeagleRT is NOT running |
73 //then click the big red button on the toolbar on this page | 73 //then click the big red button on the toolbar on this page |
74 | 74 |
75 gPhase1 += 2.0 * M_PI * gFrequency1 * gInverseSampleRate * ((count&4095)/4096.0+1); | 75 gPhase1 += 2.0 * M_PI * gFrequency1 * gInverseSampleRate * ((count&4095)/4096.0+1); |
76 gPhase2 += 2.0 * M_PI * gFrequency2 * gInverseSampleRate; | 76 gPhase2 += 2.0 * M_PI * gFrequency2 * gInverseSampleRate; |
77 if(gPhase1 > 2.0 * M_PI) | 77 if(gPhase1 > 2.0 * M_PI) |
78 gPhase1 -= 2.0 * M_PI; | 78 gPhase1 -= 2.0 * M_PI; |
79 if(gPhase2 > 2.0 * M_PI) | 79 if(gPhase2 > 2.0 * M_PI) |
80 gPhase2 -= 2.0 * M_PI; | 80 gPhase2 -= 2.0 * M_PI; |
81 | 81 |
82 } | 82 } |
83 if(count>100) | 83 static float buffer[32]; //this should be context->audioFrames |
84 receiveAudio.getSamplesSrc(context->audioOut, context->audioFrames, 1); | 84 if(count==0){ |
85 for(int n=0; n<32; n++) | |
86 buffer[n]=0; | |
87 } | |
88 if(count>0){ | |
89 int readPointer=receiveAudio.getSamplesSrc(buffer, context->audioFrames, 1); | |
90 for(int n=0; n<context->audioFrames; n++){ | |
91 context->audioOut[n*2]=buffer[n]; | |
92 context->audioOut[n*2+1]=buffer[n]; | |
93 } | |
94 } | |
85 count++; | 95 count++; |
86 } | 96 } |
87 | 97 |
88 // cleanup_render() is called once at the end, after the audio has stopped. | 98 // cleanup_render() is called once at the end, after the audio has stopped. |
89 // Release any resources that were allocated in initialise_render(). | 99 // Release any resources that were allocated in initialise_render(). |