00001 // 00002 // FileIO.h -- IO using a sound file for writing data to sound files 00003 // 00004 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT 00005 // 00006 00007 #ifndef CSL_FileIO_H 00008 #define CSL_FileIO_H 00009 00010 #include "CSL_Includes.h" 00011 #include "ThreadUtilities.h" // PThread utilities 00012 00013 namespace csl { 00014 00018 00019 class FileIO : public IO { 00020 public: 00022 FileIO(char *path = NULL); 00023 ~FileIO(); 00024 00025 bool mIsPlaying; 00026 bool mIsThreadRunning; 00027 unsigned mDuration; 00028 void open() throw(CException); 00032 void start(float seconds = 0) throw(CException); 00033 void stop() throw(CException); 00034 void close() throw(CException); 00035 void test() throw(CException) { }; 00036 00037 Buffer & getInput() throw(CException) { return mInBuffer; }; 00038 Buffer & getInput(unsigned numFrames, unsigned numChannels) throw(CException) { return mInBuffer; }; 00039 00040 protected: 00041 string mPath; // the output file name 00042 SoundFile * mFile; // the output sound file 00043 CThread * mThread; // the background thread 00044 static void *threadFunction(void *); // the background thread function 00045 00046 Buffer mInBuffer; // buffer we use for input 00047 Buffer mOutBuffer; // buffer we use for output 00048 void writeNextBuffer(); 00049 }; 00050 00051 } 00052 00053 #endif
1.4.5-20051010