Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


FileRead.h
1 #ifndef STK_FILEREAD_H
2 #define STK_FILEREAD_H
3 
4 #include "Stk.h"
5 
6 namespace stk {
7 
8 /***************************************************/
39 /***************************************************/
40 
41 class FileRead : public Stk
42 {
43 public:
45  FileRead( void );
46 
48 
54  FileRead( std::string fileName, bool typeRaw = false, unsigned int nChannels = 1,
55  StkFormat format = STK_SINT16, StkFloat rate = 22050.0 );
56 
58  ~FileRead( void );
59 
61 
67  void open( std::string fileName, bool typeRaw = false, unsigned int nChannels = 1,
68  StkFormat format = STK_SINT16, StkFloat rate = 22050.0 );
69 
71  void close( void );
72 
74  bool isOpen( void );
75 
77  unsigned long fileSize( void ) const { return fileSize_; };
78 
80  unsigned int channels( void ) const { return channels_; };
81 
83  StkFormat format( void ) const { return dataType_; };
84 
86 
91  StkFloat fileRate( void ) const { return fileRate_; };
92 
94 
106  void read( StkFrames& buffer, unsigned long startFrame = 0, bool doNormalize = true );
107 
108 protected:
109 
110  // Get STK RAW file information.
111  bool getRawInfo( const char *fileName, unsigned int nChannels,
112  StkFormat format, StkFloat rate );
113 
114  // Get WAV file header information.
115  bool getWavInfo( const char *fileName );
116 
117  // Get SND (AU) file header information.
118  bool getSndInfo( const char *fileName );
119 
120  // Get AIFF file header information.
121  bool getAifInfo( const char *fileName );
122 
123  // Get MAT-file header information.
124  bool getMatInfo( const char *fileName );
125 
126  // Helper function for MAT-file parsing.
127  bool findNextMatArray( SINT32 *chunkSize, SINT32 *rows, SINT32 *columns, SINT32 *nametype );
128 
129  FILE *fd_;
130  bool byteswap_;
131  bool wavFile_;
132  unsigned long fileSize_;
133  unsigned long dataOffset_;
134  unsigned int channels_;
135  StkFormat dataType_;
136  StkFloat fileRate_;
137 };
138 
139 } // stk namespace
140 
141 #endif

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