Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


FileWvIn.h
1 #ifndef STK_FILEWVIN_H
2 #define STK_FILEWVIN_H
3 
4 #include "WvIn.h"
5 #include "FileRead.h"
6 
7 namespace stk {
8 
9 /***************************************************/
40 /***************************************************/
41 
42 class FileWvIn : public WvIn
43 {
44 public:
46  FileWvIn( unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
47 
49 
53  FileWvIn( std::string fileName, bool raw = false, bool doNormalize = true,
54  unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
55 
57  ~FileWvIn( void );
58 
60 
69  virtual void openFile( std::string fileName, bool raw = false, bool doNormalize = true );
70 
72  virtual void closeFile( void );
73 
75  virtual void reset( void );
76 
78 
82  virtual void normalize( void );
83 
85 
89  virtual void normalize( StkFloat peak );
90 
92  virtual unsigned long getSize( void ) const { return file_.fileSize(); };
93 
95 
100  virtual StkFloat getFileRate( void ) const { return data_.dataRate(); };
101 
103  bool isOpen( void ) { return file_.isOpen(); };
104 
106  bool isFinished( void ) const { return finished_; };
107 
109 
112  virtual void setRate( StkFloat rate );
113 
115 
118  virtual void addTime( StkFloat time );
119 
121 
127  void setInterpolate( bool doInterpolate ) { interpolate_ = doInterpolate; };
128 
130 
139  StkFloat lastOut( unsigned int channel = 0 );
140 
142 
151  virtual StkFloat tick( unsigned int channel = 0 );
152 
154 
162  virtual StkFrames& tick( StkFrames& frames );
163 
164 protected:
165 
166  void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
167 
168  FileRead file_;
169  bool finished_;
170  bool interpolate_;
171  bool normalizing_;
172  bool chunking_;
173  StkFloat time_;
174  StkFloat rate_;
175  unsigned long chunkThreshold_;
176  unsigned long chunkSize_;
177  long chunkPointer_;
178 
179 };
180 
181 inline StkFloat FileWvIn :: lastOut( unsigned int channel )
182 {
183 #if defined(_STK_DEBUG_)
184  if ( channel >= data_.channels() ) {
185  oStream_ << "FileWvIn::lastOut(): channel argument and soundfile data are incompatible!";
186  handleError( StkError::FUNCTION_ARGUMENT );
187  }
188 #endif
189 
190  if ( finished_ ) return 0.0;
191  return lastFrame_[channel];
192 }
193 
194 } // stk namespace
195 
196 #endif

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