Mercurial > hg > beaglert
annotate include/Scope.h @ 109:ad8a93cd7c39 scope-refactoring
Working for single-channel scope, or NetworkIO
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 18 Aug 2015 14:53:16 +0100 |
parents | 836052c86e1e |
children |
rev | line source |
---|---|
andrewm@71 | 1 //scope.cpp |
giuliomoro@109 | 2 #ifndef SCOPE_H_ |
giuliomoro@109 | 3 #define SCOPE_H_ |
giuliomoro@109 | 4 |
andrewm@71 | 5 #include <BeagleRT.h> |
andrewm@71 | 6 #include <rtdk.h> |
andrewm@71 | 7 #include <cmath> |
andrewm@71 | 8 #include <UdpClient.h> |
andrewm@71 | 9 |
giuliomoro@107 | 10 #define BUILD_FOR_UDPRECEIVE_PLUGIN |
giuliomoro@107 | 11 #define NETWORK_AUDIO_BUFFER_SIZE 302 |
giuliomoro@109 | 12 |
giuliomoro@109 | 13 struct NetworkBuffer{ |
andrewm@71 | 14 int timestamp; |
giuliomoro@109 | 15 int channelNumber; |
giuliomoro@109 | 16 int activeBuffer; |
andrewm@71 | 17 int index; |
andrewm@71 | 18 float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; |
giuliomoro@109 | 19 bool doneOnTime; |
giuliomoro@109 | 20 bool readyToBeSent; |
giuliomoro@109 | 21 int headerLength=2; |
andrewm@71 | 22 UdpClient udpClient; |
andrewm@71 | 23 }; |
andrewm@71 | 24 |
andrewm@71 | 25 #define NUM_SCOPE_CHANNELS 6 |
andrewm@71 | 26 |
giuliomoro@109 | 27 class NetworkIO { |
andrewm@71 | 28 int sampleCount; |
andrewm@71 | 29 float sampleRate; |
andrewm@71 | 30 AuxiliaryTask scopeTask; |
giuliomoro@109 | 31 int port; |
andrewm@71 | 32 public: |
giuliomoro@109 | 33 NetworkBuffer channel; |
giuliomoro@109 | 34 NetworkIO(); |
giuliomoro@109 | 35 ~NetworkIO(); |
giuliomoro@109 | 36 void setup(float aSampleRate); |
giuliomoro@109 | 37 void setup(float aSampleRate, int aChannelNumber); |
giuliomoro@109 | 38 void sendData(); |
giuliomoro@109 | 39 void log(float value); |
giuliomoro@109 | 40 void setPort(int aPort); |
giuliomoro@109 | 41 int getPort(); |
giuliomoro@109 | 42 void setChannelNumber(int aChannelNumber); |
giuliomoro@109 | 43 int getChannelNumber(); |
andrewm@71 | 44 }; |
andrewm@71 | 45 |
giuliomoro@109 | 46 class Scope { |
giuliomoro@109 | 47 NetworkIO *channels; |
giuliomoro@109 | 48 int numChannels; |
giuliomoro@109 | 49 void deallocate(); |
giuliomoro@109 | 50 public: |
giuliomoro@109 | 51 Scope(int aNumChannels); |
giuliomoro@109 | 52 ~Scope(); |
giuliomoro@109 | 53 void log(int channel, float value); |
giuliomoro@109 | 54 void setup(float sampleRate); |
giuliomoro@109 | 55 void sendData(); |
giuliomoro@109 | 56 }; |
giuliomoro@109 | 57 #endif /* SCOPE_H */ |