andrewm@71: //scope.cpp andrewm@71: #include andrewm@71: #include andrewm@71: #include andrewm@71: #include andrewm@71: giuliomoro@107: #define BUILD_FOR_UDPRECEIVE_PLUGIN giuliomoro@107: #define NETWORK_AUDIO_BUFFER_SIZE 302 andrewm@71: struct networkAudio{ andrewm@71: int timestamp; andrewm@71: int currentBuffer; andrewm@71: int index; andrewm@71: float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; andrewm@71: int doneOnTime; andrewm@71: bool toBeSent; andrewm@71: UdpClient udpClient; andrewm@71: }; andrewm@71: andrewm@71: #define NUM_SCOPE_CHANNELS 6 andrewm@71: andrewm@71: static void SendScopeData(); andrewm@71: andrewm@71: class Scope { andrewm@71: int sampleCount; andrewm@71: float sampleRate; andrewm@71: AuxiliaryTask scopeTask; andrewm@71: public: andrewm@71: int numChannels; andrewm@71: networkAudio channel[NUM_SCOPE_CHANNELS]; andrewm@71: Scope(){ andrewm@71: numChannels = NUM_SCOPE_CHANNELS; andrewm@71: sampleCount = 0; giuliomoro@107: #ifdef BUILD_FOR_UDPRECEIVE_PLUGIN giuliomoro@107: char server[]="192.168.7.1"; giuliomoro@107: #else giuliomoro@107: char server[]="127.0.0.1"; giuliomoro@107: #endif /* BUILD_FOR_UDPRECEIVE_PLUGIN */ giuliomoro@107: printf("Sending messages to : %s\n", server); andrewm@71: for(int n=0; nnumChannels; n++){ andrewm@71: if(gOscilloscopeInstance->channel[n].toBeSent){ andrewm@71: gOscilloscopeInstance->channel[n].toBeSent=false; giuliomoro@93: gOscilloscopeInstance->channel[n].udpClient.send( giuliomoro@93: gOscilloscopeInstance->channel[n].buffers[!gOscilloscopeInstance->channel[n].currentBuffer], giuliomoro@93: NETWORK_AUDIO_BUFFER_SIZE*sizeof(float) giuliomoro@93: ); andrewm@71: gOscilloscopeInstance->channel[n].doneOnTime=1; andrewm@71: } andrewm@71: } andrewm@71: }