Mercurial > hg > beaglert
comparison include/ReceiveAudioThread.h @ 117:ada68d50e56a scope-refactoring
ReceiveAudioThread hs been ported to BBB. The scope project now is sending audio locally and receiving it at the same time
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 20 Aug 2015 16:37:15 +0100 |
parents | |
children | c692827083e1 |
comparison
equal
deleted
inserted
replaced
116:8341df5e404b | 117:ada68d50e56a |
---|---|
1 #ifndef RECEIVEAUDIOTHREAD_H_INCLUDED | |
2 #define RECEIVEAUDIOTHREAD_H_INCLUDED | |
3 #include <vector> | |
4 #include <iostream> | |
5 #include <UdpServer.h> | |
6 #include <BeagleRT.h> | |
7 #include <native/task.h> | |
8 | |
9 class ReceiveAudioThread{ | |
10 private: | |
11 // FILE *fd; //DEBUG | |
12 // FILE *fd2; //DEBUG | |
13 UdpServer socket; | |
14 //JUCE DatagramSocket socket; | |
15 bool listening; | |
16 bool bufferReady; | |
17 bool threadIsExiting; | |
18 bool threadRunning; | |
19 float *buffer; | |
20 float *stackBuffer; | |
21 int bufferLength; | |
22 float readPointer; | |
23 int writePointer; | |
24 int lastValidPointer; | |
25 int sleepTime; | |
26 int waitForSocketTime; | |
27 int payloadLength; //size of the payload of each datagram | |
28 int headerLength; //size of the header of each datagram | |
29 int bytesToRead; | |
30 int threadPriority; | |
31 void dealloc(); | |
32 void wrapWritePointer(); | |
33 void pushPayload(int startIndex); | |
34 void popPayload(int startIndex); | |
35 int readUdpToBuffer(); | |
36 bool threadShouldExit(); | |
37 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) | |
38 // static std::vector<NetworkReceive *> objAddrs; | |
39 public: | |
40 ReceiveAudioThread(); | |
41 ~ReceiveAudioThread(); | |
42 void init(int aSamplesPerBlock); | |
43 void setup(); | |
44 void bindToPort(int aPort); | |
45 bool isListening(); | |
46 float* getCurrentBuffer(int length); | |
47 int getSamplesSrc(float *destination, int length, float samplingRateRatio); | |
48 bool isBufferReady(); | |
49 void run(); | |
50 void startThread(); | |
51 void stopThread(); | |
52 // static int getNumInstances(); | |
53 // static void receiveAllData(); | |
54 }; | |
55 #endif // RECEIVEAUDIOTHREAD_H_INCLUDED |