andrewm@71: //scope.cpp giuliomoro@109: #ifndef SCOPE_H_ giuliomoro@109: #define SCOPE_H_ giuliomoro@109: 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 giuliomoro@109: giuliomoro@109: struct NetworkBuffer{ andrewm@71: int timestamp; giuliomoro@109: int channelNumber; giuliomoro@109: int activeBuffer; andrewm@71: int index; andrewm@71: float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; giuliomoro@109: bool doneOnTime; giuliomoro@109: bool readyToBeSent; giuliomoro@109: int headerLength=2; andrewm@71: UdpClient udpClient; andrewm@71: }; andrewm@71: andrewm@71: #define NUM_SCOPE_CHANNELS 6 andrewm@71: giuliomoro@109: class NetworkIO { andrewm@71: int sampleCount; andrewm@71: float sampleRate; andrewm@71: AuxiliaryTask scopeTask; giuliomoro@109: int port; andrewm@71: public: giuliomoro@109: NetworkBuffer channel; giuliomoro@109: NetworkIO(); giuliomoro@109: ~NetworkIO(); giuliomoro@109: void setup(float aSampleRate); giuliomoro@109: void setup(float aSampleRate, int aChannelNumber); giuliomoro@109: void sendData(); giuliomoro@109: void log(float value); giuliomoro@109: void setPort(int aPort); giuliomoro@109: int getPort(); giuliomoro@109: void setChannelNumber(int aChannelNumber); giuliomoro@109: int getChannelNumber(); andrewm@71: }; andrewm@71: giuliomoro@109: class Scope { giuliomoro@109: NetworkIO *channels; giuliomoro@109: int numChannels; giuliomoro@109: void deallocate(); giuliomoro@109: public: giuliomoro@109: Scope(int aNumChannels); giuliomoro@109: ~Scope(); giuliomoro@109: void log(int channel, float value); giuliomoro@109: void setup(float sampleRate); giuliomoro@109: void sendData(); giuliomoro@109: }; giuliomoro@109: #endif /* SCOPE_H */