Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# FileRead.h

    00001 #ifndef STK_FILEREAD_H
    00002 #define STK_FILEREAD_H
    00003
    00004 #include "Stk.h"
    00005
    00006 namespace stk {
    00007
    00008 /***************************************************/
    00039 /***************************************************/
    00040
    00041 class FileRead : public Stk
    00042 {
    00043 public:
    00045   FileRead( void );
    00046
    00048
    00054   FileRead( std::string fileName, bool typeRaw = false, unsigned int nChannels = 1,
    00055             StkFormat format = STK_SINT16, StkFloat rate = 22050.0 );
    00056
    00058   ~FileRead( void );
    00059
    00061
    00067   void open( std::string fileName, bool typeRaw = false, unsigned int nChannels = 1,
    00068              StkFormat format = STK_SINT16, StkFloat rate = 22050.0 );
    00069
    00071   void close( void );
    00072
    00074   bool isOpen( void );
    00075
    00077   unsigned long fileSize( void ) const { return fileSize_; };
    00078
    00080   unsigned int channels( void ) const { return channels_; };
    00081
    00083   StkFormat format( void ) const { return dataType_; };
    00084
    00086
    00091   StkFloat fileRate( void ) const { return fileRate_; };
    00092
    00094
    00106   void read( StkFrames& buffer, unsigned long startFrame = 0, bool doNormalize = true );
    00107
    00108 protected:
    00109
    00110   // Get STK RAW file information.
    00111   bool getRawInfo( const char *fileName, unsigned int nChannels,
    00112                    StkFormat format, StkFloat rate );
    00113
    00114   // Get WAV file header information.
    00115   bool getWavInfo( const char *fileName );
    00116
    00117   // Get SND (AU) file header information.
    00118   bool getSndInfo( const char *fileName );
    00119
    00120   // Get AIFF file header information.
    00121   bool getAifInfo( const char *fileName );
    00122
    00123   // Get MAT-file header information.
    00124   bool getMatInfo( const char *fileName );
    00125
    00126   // Helper function for MAT-file parsing.
    00127   bool findNextMatArray( SINT32 *chunkSize, SINT32 *rows, SINT32 *columns, SINT32 *nametype );
    00128
    00129   FILE *fd_;
    00130   bool byteswap_;
    00131   bool wavFile_;
    00132   unsigned long fileSize_;
    00133   unsigned long dataOffset_;
    00134   unsigned int channels_;
    00135   StkFormat dataType_;
    00136   StkFloat fileRate_;
    00137 };
    00138
    00139 } // stk namespace
    00140
    00141 #endif

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