00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MARSYAS_AUDIOSOURCE_H
00020 #define MARSYAS_AUDIOSOURCE_H
00021
00022
00023
00024 #ifdef MARSYAS_AUDIOIO
00025 #include "RtAudio.h"
00026 #endif
00027
00028 #include "MarSystem.h"
00029
00030
00031 class RtAudio;
00032
00033 namespace Marsyas
00034 {
00055 class AudioSource:public MarSystem
00056 {
00057 private:
00058
00059
00060
00061 struct InputData
00062 {
00063 mrs_realvec* ringBuffer;
00064 unsigned int wp;
00065 unsigned int rp;
00066 unsigned int ringBufferSize;
00067 unsigned int high_watermark;
00068 unsigned int low_watermark;
00069 unsigned int samplesInBuffer;
00070
00071 AudioSource* myself;
00072 } idata;
00073
00074
00075
00076 unsigned int getSpaceAvailable();
00077 unsigned int getSamplesAvailable();
00078
00079
00080
00081 #ifdef MARSYAS_AUDIOIO
00082 RtAudio* audio_;
00083 #endif
00084 int bufferSize_;
00085 int nBuffers_;
00086 int rtSrate_;
00087 int rtChannels_;
00088
00089
00090 mrs_natural ri_;
00091 mrs_natural nChannels_;
00092 mrs_natural pnChannels_;
00093
00094 mrs_real *data_;
00095 realvec ringBuffer_;
00096 mrs_natural ringBufferSize_;
00097 mrs_natural pringBufferSize_;
00098 mrs_natural pinObservations_;
00099
00100 mrs_real gain_;
00101
00102 bool isInitialized_;
00103 bool stopped_;
00104
00105 void addControls();
00106 void myUpdate(MarControlPtr sender);
00107
00108 void initRtAudio();
00109
00110 void start();
00111 void stop();
00112
00113 void localActivate(bool state);
00114
00115 static int recordCallback(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, double streamTime, unsigned int status, void *userData);
00116
00117 public:
00118 AudioSource(std::string name);
00119 ~AudioSource();
00120 MarSystem* clone() const;
00121
00122 void myProcess(realvec& in, realvec& out);
00123 };
00124
00125 }
00126
00127
00128 #endif
00129
00130
00131
00132