comparison include/Scope.h @ 93:8c7f537d0a21

edited Scope.h with ifdefs to be compatible with udpio plugin
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 21 Jul 2015 21:18:45 +0100
parents 53e57276ac1a
children 836052c86e1e
comparison
equal deleted inserted replaced
92:a55dcdcebdcd 93:8c7f537d0a21
2 #include <BeagleRT.h> 2 #include <BeagleRT.h>
3 #include <rtdk.h> 3 #include <rtdk.h>
4 #include <cmath> 4 #include <cmath>
5 #include <UdpClient.h> 5 #include <UdpClient.h>
6 6
7 #define NETWORK_AUDIO_BUFFER_SIZE 2048 7 #define NETWORK_AUDIO_BUFFER_SIZE 400
8 struct networkAudio{ 8 struct networkAudio{
9 int timestamp; 9 int timestamp;
10 int currentBuffer; 10 int currentBuffer;
11 int index; 11 int index;
12 float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; 12 float buffers[2][NETWORK_AUDIO_BUFFER_SIZE];
30 numChannels = NUM_SCOPE_CHANNELS; 30 numChannels = NUM_SCOPE_CHANNELS;
31 sampleCount = 0; 31 sampleCount = 0;
32 32
33 for(int n=0; n<numChannels; n++){ 33 for(int n=0; n<numChannels; n++){
34 channel[n].doneOnTime=1; 34 channel[n].doneOnTime=1;
35 channel[n].index=2; 35 channel[n].index=2; //leave space for the heading message (channel, timestamp)
36 channel[n].timestamp=0; 36 channel[n].timestamp=0;
37 channel[n].currentBuffer=0; 37 channel[n].currentBuffer=0;
38 channel[n].toBeSent=false; 38 channel[n].toBeSent=false;
39 #ifdef BUILD_FOR_UDPRECEIVE_PLUGIN
40 channel[n].udpClient.setPort(9999+n);
41 channel[n].udpClient.setServer("192.168.7.1");
42 #else
39 channel[n].udpClient.setPort(9999); 43 channel[n].udpClient.setPort(9999);
40 channel[n].udpClient.setServer("127.0.0.1"); 44 channel[n].udpClient.setServer("127.0.0.1");
45 #endif /* BUILD_FOR_UDPRECEIVE_PLUGIN */
41 } 46 }
42 } 47 }
43 void setup(float _sampleRate); 48 void setup(float _sampleRate);
44 void log(float channel1=0.0, float channel2=0.0, float channel3=0.0, float channel4=0.0, float channel5=0.0, float channel6=0.0){ 49 void log(float channel1=0.0, float channel2=0.0, float channel3=0.0, float channel4=0.0, float channel5=0.0, float channel6=0.0){
45 50
81 86
82 static void SendScopeData(){ 87 static void SendScopeData(){
83 for(int n=0; n<gOscilloscopeInstance->numChannels; n++){ 88 for(int n=0; n<gOscilloscopeInstance->numChannels; n++){
84 if(gOscilloscopeInstance->channel[n].toBeSent){ 89 if(gOscilloscopeInstance->channel[n].toBeSent){
85 gOscilloscopeInstance->channel[n].toBeSent=false; 90 gOscilloscopeInstance->channel[n].toBeSent=false;
86 gOscilloscopeInstance->channel[n].udpClient.send(gOscilloscopeInstance->channel[n].buffers[!gOscilloscopeInstance->channel[n].currentBuffer],NETWORK_AUDIO_BUFFER_SIZE*sizeof(float)); 91 gOscilloscopeInstance->channel[n].udpClient.send(
92 gOscilloscopeInstance->channel[n].buffers[!gOscilloscopeInstance->channel[n].currentBuffer],
93 NETWORK_AUDIO_BUFFER_SIZE*sizeof(float)
94 );
87 gOscilloscopeInstance->channel[n].doneOnTime=1; 95 gOscilloscopeInstance->channel[n].doneOnTime=1;
88 } 96 }
89 } 97 }
90 } 98 }