# HG changeset patch # User Giulio Moro # Date 1440446006 -3600 # Node ID cce58e6ec2a2ae42f35fef271383c5948be90521 # Parent 2696a7f000532b0a9a97e58c45bf2dc8ad98b35e Added ifdefs USE_JUCE to NetworkSend. Juce part not added yet diff -r 2696a7f00053 -r cce58e6ec2a2 core/NetworkSend.cpp --- a/core/NetworkSend.cpp Mon Aug 24 18:55:19 2015 +0100 +++ b/core/NetworkSend.cpp Mon Aug 24 20:53:26 2015 +0100 @@ -1,30 +1,30 @@ -//scope.cpp #include -#define BUILD_FOR_UDPRECEIVE_PLUGIN -#define NETWORK_AUDIO_BUFFER_SIZE 302 - +#ifdef USE_JUCE +#else //initialize the static members of NetworkSend bool NetworkSend::staticConstructed=false; std::vector NetworkSend::objAddrs(0); AuxiliaryTask NetworkSend::sendDataTask=NULL; -void transmitAudio(){ +void sendData(){ NetworkSend::sendAllData(); } - +void NetworkSend::staticConstructor(){ + if(staticConstructed==true) + return; + staticConstructed=true; + sendDataTask = BeagleRT_createAuxiliaryTask(::sendData, 95, "sendDataTask"); //TODO: allow variable priority +} void NetworkSend::sendAllData(){ for(unsigned int n=0; nsendData(); } } - -void NetworkSend::staticConstructor(){ - if(staticConstructed==true) - return; - staticConstructed=true; - sendDataTask = BeagleRT_createAuxiliaryTask(transmitAudio, 95, "sendDataTask"); //TODO: allow variable priority -}; +int NetworkSend::getNumInstances(){ + return objAddrs.size(); +} +#endif /* USE_JUCE */ NetworkSend::NetworkSend() { @@ -44,9 +44,10 @@ } } -void NetworkSend::setup(float aSampleRate){ +void NetworkSend::setup(float aSampleRate){//TODO: remove this method setup(aSampleRate, 0, 9999, "192.168.7.1");//channelNumber=0 } + void NetworkSend::setup(float aSampleRate, int aChannelNumber, int aPort, const char *aServer){ staticConstructor(); //FIXME: ideally this should be in the constructor, but this is not currently possible //because of limitations in BeagleRT_createAuxiliaryTask() @@ -112,10 +113,8 @@ } } -int NetworkSend::getNumInstances(){ - return objAddrs.size(); -}; - +#ifdef USE_JUCE +#else Scope::Scope(int aNumChannels): channels(aNumChannels) {}; @@ -154,3 +153,4 @@ void Scope::sendData(){ NetworkSend::sendAllData(); } +#endif diff -r 2696a7f00053 -r cce58e6ec2a2 include/NetworkSend.h --- a/include/NetworkSend.h Mon Aug 24 18:55:19 2015 +0100 +++ b/include/NetworkSend.h Mon Aug 24 20:53:26 2015 +0100 @@ -2,11 +2,14 @@ #ifndef SCOPE_H_ #define SCOPE_H_ +#ifdef USE_JUCE +#else #include #include #include #include #include +#endif /* USE_JUCE */ #define NETWORK_AUDIO_BUFFER_SIZE 302 @@ -20,30 +23,45 @@ static const int headerLength=2; }; +#ifdef USE_JUCE +class NetworkSend: public Thread { +#else class NetworkSend { - int sampleCount; - float sampleRate; +#endif /* USE_JUCE */ + int sampleCount; + float sampleRate; +#ifdef USE_JUCE + DatagramSocket udpClient; +#else UdpClient udpClient; static bool staticConstructed; - static void staticConstructor(); - static AuxiliaryTask sendDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) - static std::vector objAddrs; - public: - NetworkBuffer channel; - NetworkSend(); - ~NetworkSend(); - void setup(float aSampleRate); - void setup(float aSampleRate, int aChannelNumber, int aPort, const char *aServer); - void sendData(); - void log(float value); - void setPort(int aPort); - void setServer(const char* aServer); - void setChannelNumber(int aChannelNumber); - int getChannelNumber(); - static int getNumInstances(); - static void sendAllData(); + static void staticConstructor(); + static AuxiliaryTask sendDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) + static std::vector objAddrs; +#endif /* USE_JUCE */ + public: + NetworkBuffer channel; + NetworkSend(); + ~NetworkSend(); + void setup(float aSampleRate); + void setup(float aSampleRate, int aChannelNumber, int aPort, const char *aServer); + void sendData(); + void log(float value); + void setPort(int aPort); + void setServer(const char* aServer); + void setChannelNumber(int aChannelNumber); + int getChannelNumber(); +#ifdef USE_JUCE + void run(); +#else + static int getNumInstances(); + static void sendAllData(); + static void run(); +#endif /* USE_JUCE */ }; +#ifdef USE_JUCE +#else /** * An array of NetworkSend objects with some default parameters * @@ -64,4 +82,6 @@ void setPort(int channel, int port); int getNumChannels(); }; +#endif /* USE_JUCE */ + #endif /* SCOPE_H */