Mercurial > hg > beaglert
comparison include/NetworkSend.h @ 129:cce58e6ec2a2 scope-refactoring
Added ifdefs USE_JUCE to NetworkSend. Juce part not added yet
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 24 Aug 2015 20:53:26 +0100 |
parents | c692827083e1 |
children | ff28e56e5b7e |
comparison
equal
deleted
inserted
replaced
128:2696a7f00053 | 129:cce58e6ec2a2 |
---|---|
1 //scope.cpp | 1 //scope.cpp |
2 #ifndef SCOPE_H_ | 2 #ifndef SCOPE_H_ |
3 #define SCOPE_H_ | 3 #define SCOPE_H_ |
4 | 4 |
5 #ifdef USE_JUCE | |
6 #else | |
5 #include <BeagleRT.h> | 7 #include <BeagleRT.h> |
6 #include <rtdk.h> | 8 #include <rtdk.h> |
7 #include <cmath> | 9 #include <cmath> |
8 #include <UdpClient.h> | 10 #include <UdpClient.h> |
9 #include <vector> | 11 #include <vector> |
12 #endif /* USE_JUCE */ | |
10 | 13 |
11 #define NETWORK_AUDIO_BUFFER_SIZE 302 | 14 #define NETWORK_AUDIO_BUFFER_SIZE 302 |
12 | 15 |
13 struct NetworkBuffer{ | 16 struct NetworkBuffer{ |
14 int channelNumber; | 17 int channelNumber; |
18 bool doneOnTime; | 21 bool doneOnTime; |
19 bool readyToBeSent; | 22 bool readyToBeSent; |
20 static const int headerLength=2; | 23 static const int headerLength=2; |
21 }; | 24 }; |
22 | 25 |
26 #ifdef USE_JUCE | |
27 class NetworkSend: public Thread { | |
28 #else | |
23 class NetworkSend { | 29 class NetworkSend { |
24 int sampleCount; | 30 #endif /* USE_JUCE */ |
25 float sampleRate; | 31 int sampleCount; |
32 float sampleRate; | |
33 #ifdef USE_JUCE | |
34 DatagramSocket udpClient; | |
35 #else | |
26 UdpClient udpClient; | 36 UdpClient udpClient; |
27 static bool staticConstructed; | 37 static bool staticConstructed; |
28 static void staticConstructor(); | 38 static void staticConstructor(); |
29 static AuxiliaryTask sendDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) | 39 static AuxiliaryTask sendDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) |
30 static std::vector<NetworkSend *> objAddrs; | 40 static std::vector<NetworkSend *> objAddrs; |
31 public: | 41 #endif /* USE_JUCE */ |
32 NetworkBuffer channel; | 42 public: |
33 NetworkSend(); | 43 NetworkBuffer channel; |
34 ~NetworkSend(); | 44 NetworkSend(); |
35 void setup(float aSampleRate); | 45 ~NetworkSend(); |
36 void setup(float aSampleRate, int aChannelNumber, int aPort, const char *aServer); | 46 void setup(float aSampleRate); |
37 void sendData(); | 47 void setup(float aSampleRate, int aChannelNumber, int aPort, const char *aServer); |
38 void log(float value); | 48 void sendData(); |
39 void setPort(int aPort); | 49 void log(float value); |
40 void setServer(const char* aServer); | 50 void setPort(int aPort); |
41 void setChannelNumber(int aChannelNumber); | 51 void setServer(const char* aServer); |
42 int getChannelNumber(); | 52 void setChannelNumber(int aChannelNumber); |
43 static int getNumInstances(); | 53 int getChannelNumber(); |
44 static void sendAllData(); | 54 #ifdef USE_JUCE |
55 void run(); | |
56 #else | |
57 static int getNumInstances(); | |
58 static void sendAllData(); | |
59 static void run(); | |
60 #endif /* USE_JUCE */ | |
45 }; | 61 }; |
46 | 62 |
63 #ifdef USE_JUCE | |
64 #else | |
47 /** | 65 /** |
48 * An array of NetworkSend objects with some default parameters | 66 * An array of NetworkSend objects with some default parameters |
49 * | 67 * |
50 * All sending on the same port (defaults to 9999) | 68 * All sending on the same port (defaults to 9999) |
51 * All sending to the same server (defaults to 127.0.0.1) | 69 * All sending to the same server (defaults to 127.0.0.1) |
62 void sendData(); | 80 void sendData(); |
63 void setPort(int port); | 81 void setPort(int port); |
64 void setPort(int channel, int port); | 82 void setPort(int channel, int port); |
65 int getNumChannels(); | 83 int getNumChannels(); |
66 }; | 84 }; |
85 #endif /* USE_JUCE */ | |
86 | |
67 #endif /* SCOPE_H */ | 87 #endif /* SCOPE_H */ |