Home Information Classes Download Usage Mail List Requirements Links Tutorial

# WvOut.h

    00001 /***************************************************/
    00034 /***************************************************/
    00035
    00036 #if !defined(__WVOUT_H)
    00037 #define __WVOUT_H
    00038
    00039 #include "Stk.h"
    00040 #include <stdio.h>
    00041
    00042 #define BUFFER_SIZE 1024  // sample frames
    00043
    00044 class WvOut : public Stk
    00045 {
    00046  public:
    00047
    00048   typedef unsigned long FILE_TYPE;
    00049
    00050   static const FILE_TYPE WVOUT_RAW;
    00051   static const FILE_TYPE WVOUT_WAV;
    00052   static const FILE_TYPE WVOUT_SND;
    00053   static const FILE_TYPE WVOUT_AIF;
    00054   static const FILE_TYPE WVOUT_MAT;
    00056
    00057   WvOut();
    00058
    00060
    00063   WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
    00064
    00066   virtual ~WvOut();
    00067
    00069
    00072   void openFile( const char *fileName, unsigned int nChannels = 1,
    00073                  WvOut::FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
    00074
    00076   void closeFile( void );
    00077
    00079   unsigned long getFrames( void ) const;
    00080
    00082   MY_FLOAT getTime( void ) const;
    00083
    00085
    00088   virtual void tick(const MY_FLOAT sample);
    00089
    00091
    00094   virtual void tick(const MY_FLOAT *vector, unsigned int vectorSize);
    00095
    00097
    00100   virtual void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
    00101
    00102  protected:
    00103
    00104   // Initialize class variables.
    00105   void init( void );
    00106
    00107   // Write data to output file;
    00108   virtual void writeData( unsigned long frames );
    00109
    00110   // Write STK RAW file header.
    00111   bool setRawFile( const char *fileName );
    00112
    00113   // Write WAV file header.
    00114   bool setWavFile( const char *fileName );
    00115
    00116   // Close WAV file, updating the header.
    00117   void closeWavFile( void );
    00118
    00119   // Write SND (AU) file header.
    00120   bool setSndFile( const char *fileName );
    00121
    00122   // Close SND file, updating the header.
    00123   void closeSndFile( void );
    00124
    00125   // Write AIFF file header.
    00126   bool setAifFile( const char *fileName );
    00127
    00128   // Close AIFF file, updating the header.
    00129   void closeAifFile( void );
    00130
    00131   // Write MAT-file header.
    00132   bool setMatFile( const char *fileName );
    00133
    00134   // Close MAT-file, updating the header.
    00135   void closeMatFile( void );
    00136
    00137   char msg[256];
    00138   FILE *fd;
    00139   MY_FLOAT *data;
    00140   FILE_TYPE fileType;
    00141   STK_FORMAT dataType;
    00142   bool byteswap;
    00143   unsigned int channels;
    00144   unsigned long counter;
    00145   unsigned long totalCount;
    00146
    00147 };
    00148
    00149 #endif // defined(__WVOUT_H)

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