comparison core/NetworkSend.cpp @ 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 cdd441a304a9
children ff28e56e5b7e
comparison
equal deleted inserted replaced
128:2696a7f00053 129:cce58e6ec2a2
1 //scope.cpp
2 #include <NetworkSend.h> 1 #include <NetworkSend.h>
3 2
4 #define BUILD_FOR_UDPRECEIVE_PLUGIN 3 #ifdef USE_JUCE
5 #define NETWORK_AUDIO_BUFFER_SIZE 302 4 #else
6
7 //initialize the static members of NetworkSend 5 //initialize the static members of NetworkSend
8 bool NetworkSend::staticConstructed=false; 6 bool NetworkSend::staticConstructed=false;
9 std::vector<NetworkSend*> NetworkSend::objAddrs(0); 7 std::vector<NetworkSend*> NetworkSend::objAddrs(0);
10 AuxiliaryTask NetworkSend::sendDataTask=NULL; 8 AuxiliaryTask NetworkSend::sendDataTask=NULL;
11 9
12 void transmitAudio(){ 10 void sendData(){
13 NetworkSend::sendAllData(); 11 NetworkSend::sendAllData();
14 } 12 }
15 13 void NetworkSend::staticConstructor(){
14 if(staticConstructed==true)
15 return;
16 staticConstructed=true;
17 sendDataTask = BeagleRT_createAuxiliaryTask(::sendData, 95, "sendDataTask"); //TODO: allow variable priority
18 }
16 void NetworkSend::sendAllData(){ 19 void NetworkSend::sendAllData(){
17 for(unsigned int n=0; n<NetworkSend::objAddrs.size(); n++){ 20 for(unsigned int n=0; n<NetworkSend::objAddrs.size(); n++){
18 NetworkSend::objAddrs[n]->sendData(); 21 NetworkSend::objAddrs[n]->sendData();
19 } 22 }
20 } 23 }
21 24 int NetworkSend::getNumInstances(){
22 void NetworkSend::staticConstructor(){ 25 return objAddrs.size();
23 if(staticConstructed==true) 26 }
24 return; 27 #endif /* USE_JUCE */
25 staticConstructed=true;
26 sendDataTask = BeagleRT_createAuxiliaryTask(transmitAudio, 95, "sendDataTask"); //TODO: allow variable priority
27 };
28 28
29 NetworkSend::NetworkSend() 29 NetworkSend::NetworkSend()
30 { 30 {
31 sampleCount = 0; 31 sampleCount = 0;
32 channel.doneOnTime=true; 32 channel.doneOnTime=true;
42 break; 42 break;
43 } 43 }
44 } 44 }
45 } 45 }
46 46
47 void NetworkSend::setup(float aSampleRate){ 47 void NetworkSend::setup(float aSampleRate){//TODO: remove this method
48 setup(aSampleRate, 0, 9999, "192.168.7.1");//channelNumber=0 48 setup(aSampleRate, 0, 9999, "192.168.7.1");//channelNumber=0
49 } 49 }
50
50 void NetworkSend::setup(float aSampleRate, int aChannelNumber, int aPort, const char *aServer){ 51 void NetworkSend::setup(float aSampleRate, int aChannelNumber, int aPort, const char *aServer){
51 staticConstructor(); //FIXME: ideally this should be in the constructor, but this is not currently possible 52 staticConstructor(); //FIXME: ideally this should be in the constructor, but this is not currently possible
52 //because of limitations in BeagleRT_createAuxiliaryTask() 53 //because of limitations in BeagleRT_createAuxiliaryTask()
53 //keep track of added active instances 54 //keep track of added active instances
54 objAddrs.push_back(this);//TODO: this line should be in the constructor, but something weird happens if 55 objAddrs.push_back(this);//TODO: this line should be in the constructor, but something weird happens if
110 ); 111 );
111 channel.doneOnTime=true; 112 channel.doneOnTime=true;
112 } 113 }
113 } 114 }
114 115
115 int NetworkSend::getNumInstances(){ 116 #ifdef USE_JUCE
116 return objAddrs.size(); 117 #else
117 };
118
119 Scope::Scope(int aNumChannels): 118 Scope::Scope(int aNumChannels):
120 channels(aNumChannels) 119 channels(aNumChannels)
121 {}; 120 {};
122 Scope::~Scope(){}; 121 Scope::~Scope(){};
123 122
152 } 151 }
153 152
154 void Scope::sendData(){ 153 void Scope::sendData(){
155 NetworkSend::sendAllData(); 154 NetworkSend::sendAllData();
156 } 155 }
156 #endif