PAIO.h

Go to the documentation of this file.
00001 //
00002 //  PAIO.h -- DAC IO using PortAudio
00003 //  See the copyright notice and acknowledgment of authors in the file COPYRIGHT
00004 //
00005 
00006 #ifndef CSL_PAIO_H
00007 #define CSL_PAIO_H
00008 
00009 #include "CSL_Core.h"
00010 #include "portaudio.h"  // the portaudio header file in /usr/local/include
00011 #include <string>
00012 #include <vector>       // we use the STL vector, map, and string classes
00013 
00014 using namespace std;
00015 
00016 namespace csl {
00017 
00021 class PADevice {
00022 public:                 
00023     PADevice(string name, unsigned index, unsigned maxIn, unsigned maxOut, bool isIn, bool isOut) :
00024         mName(name), mIndex(index), mMaxInputChannels(maxIn), mMaxOutputChannels(maxOut), 
00025         mIsDefaultIn(isIn), mIsDefaultOut(isOut) { /* no-op */ };
00026 
00028     string mName;                   
00029     unsigned mIndex;                
00030     unsigned mMaxInputChannels;     
00031     unsigned mMaxOutputChannels;    
00032     vector<float> mFrameRates;      
00033     bool mIsDefaultIn;              
00034     bool mIsDefaultOut;             
00035 };
00036 
00037 // IOs hold onto device vectors
00038 
00039 typedef vector<PADevice *> PADeviceVector;
00040 
00044 class PAIO : public IO {
00045 
00046 public:
00047     PAIO();         
00048 
00049     PAIO(unsigned s_rate, unsigned b_size);
00051     PAIO(int in_stream, int out_stream, unsigned in_chans, unsigned out_chans);
00053     PAIO(unsigned s_rate, unsigned b_size, PaDeviceIndex in_device, PaDeviceIndex out_device, unsigned in_chans, unsigned out_chans);
00054     ~PAIO();                    
00055 
00056     void open() throw(CException);          
00057     void start() throw(CException);         
00058     void stop() throw(CException);          
00059     void close() throw(CException);         
00060     void test() throw(CException);          
00061     
00062     Buffer & getInput() throw(CException);  
00063     Buffer & getInput(unsigned numFrames, unsigned numChannels) throw(CException);      
00064 
00065     PaStream * mStream;                 
00066     sample * mInputPointer;             
00067     unsigned *mChannelMap;
00068 
00069 protected:
00070     PaStreamParameters *mInputParameters;   
00071     PaStreamParameters *mOutputParameters;
00072     
00073     PaDeviceIndex mInDev, mOutDev;          
00074     PADeviceVector mDevices;
00076     void handleError(PaError result) throw(CException);
00078     void initialize(unsigned sr, unsigned bs, int is, int os, unsigned ic, unsigned oc);
00079 };
00080 
00081 }
00082 
00083 #endif

Generated on Fri Apr 6 20:18:12 2007 for CSL by  doxygen 1.4.5-20051010