Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


FileWrite.h

00001 /***************************************************/
00022 /***************************************************/
00023 
00024 #ifndef STK_FILEWRITE_H
00025 #define STK_FILEWRITE_H
00026 
00027 #include "Stk.h"
00028 
00029 class FileWrite : public Stk
00030 {
00031  public:
00032 
00033   typedef unsigned long FILE_TYPE;
00034 
00035   static const FILE_TYPE FILE_RAW; 
00036   static const FILE_TYPE FILE_WAV; 
00037   static const FILE_TYPE FILE_SND; 
00038   static const FILE_TYPE FILE_AIF; 
00039   static const FILE_TYPE FILE_MAT; 
00041 
00042   FileWrite();
00043 
00045 
00048   FileWrite( std::string fileName, unsigned int nChannels = 1, FILE_TYPE type = FILE_WAV, Stk::StkFormat format = STK_SINT16 );
00049 
00051   virtual ~FileWrite();
00052 
00054 
00057   void open( std::string fileName, unsigned int nChannels = 1,
00058              FileWrite::FILE_TYPE type = FILE_WAV, Stk::StkFormat format = STK_SINT16 );
00059 
00061   void close( void );
00062 
00064   bool isOpen( void );
00065 
00067 
00072   void write( StkFrames& buffer );
00073 
00074  protected:
00075 
00076   // Write STK RAW file header.
00077   bool setRawFile( const char *fileName );
00078 
00079   // Write WAV file header.
00080   bool setWavFile( const char *fileName );
00081 
00082   // Close WAV file, updating the header.
00083   void closeWavFile( void );
00084 
00085   // Write SND (AU) file header.
00086   bool setSndFile( const char *fileName );
00087 
00088   // Close SND file, updating the header.
00089   void closeSndFile( void );
00090 
00091   // Write AIFF file header.
00092   bool setAifFile( const char *fileName );
00093 
00094   // Close AIFF file, updating the header.
00095   void closeAifFile( void );
00096 
00097   // Write MAT-file header.
00098   bool setMatFile( const char *fileName );
00099 
00100   // Close MAT-file, updating the header.
00101   void closeMatFile( void );
00102 
00103   FILE *fd_;
00104   FILE_TYPE fileType_;
00105   StkFormat dataType_;
00106   unsigned int channels_;
00107   unsigned long frameCounter_;
00108   bool byteswap_;
00109 
00110 };
00111 
00112 #endif

The Synthesis ToolKit in C++ (STK)
©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved.