Mercurial > hg > beaglert
view 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 |
line wrap: on
line source
//scope.cpp #ifndef SCOPE_H_ #define SCOPE_H_ #ifdef USE_JUCE #else #include <BeagleRT.h> #include <rtdk.h> #include <cmath> #include <UdpClient.h> #include <vector> #endif /* USE_JUCE */ #define NETWORK_AUDIO_BUFFER_SIZE 302 struct NetworkBuffer{ int channelNumber; int activeBuffer; int index; float buffers[2][NETWORK_AUDIO_BUFFER_SIZE]; bool doneOnTime; bool readyToBeSent; static const int headerLength=2; }; #ifdef USE_JUCE class NetworkSend: public Thread { #else class NetworkSend { #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<NetworkSend *> 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 * * All sending on the same port (defaults to 9999) * All sending to the same server (defaults to 127.0.0.1) */ class Scope { std::vector<NetworkSend> channels; void deallocate(); public: Scope(int aNumChannels); ~Scope(); void log(int channel, float value); void setup(); void setup(float sampleRate, int aPort, const char* aServer); void sendData(); void setPort(int port); void setPort(int channel, int port); int getNumChannels(); }; #endif /* USE_JUCE */ #endif /* SCOPE_H */