Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


FileLoop.h
1 #ifndef STK_FILELOOP_H
2 #define STK_FILELOOP_H
3 
4 #include "FileWvIn.h"
5 
6 namespace stk {
7 
8 /***************************************************/
24 /***************************************************/
25 
26 class FileLoop : protected FileWvIn
27 {
28  public:
30  FileLoop( unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
31 
33  FileLoop( std::string fileName, bool raw = false, bool doNormalize = true,
34  unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
35 
37  ~FileLoop( void );
38 
40 
49  void openFile( std::string fileName, bool raw = false, bool doNormalize = true );
50 
52  void closeFile( void ) { FileWvIn::closeFile(); };
53 
55  void reset( void ) { FileWvIn::reset(); };
56 
58  unsigned int channelsOut( void ) const { return data_.channels(); };
59 
61 
65  void normalize( void ) { FileWvIn::normalize( 1.0 ); };
66 
68 
72  void normalize( StkFloat peak ) { FileWvIn::normalize( peak ); };
73 
75  unsigned long getSize( void ) const { return data_.frames(); };
76 
78 
83  StkFloat getFileRate( void ) const { return data_.dataRate(); };
84 
86 
89  void setRate( StkFloat rate );
90 
92 
98  void setFrequency( StkFloat frequency ) { this->setRate( file_.fileSize() * frequency / Stk::sampleRate() ); };
99 
101  void addTime( StkFloat time );
102 
104 
109  void addPhase( StkFloat angle );
110 
112 
117  void addPhaseOffset( StkFloat angle );
118 
120 
129  StkFloat lastOut( unsigned int channel = 0 ) { return FileWvIn::lastOut( channel ); };
130 
132 
141  StkFloat tick( unsigned int channel = 0 );
142 
144 
153  StkFrames& tick( StkFrames& frames );
154 
155  protected:
156 
157  StkFrames firstFrame_;
158  StkFloat phaseOffset_;
159 
160 };
161 
162 } // stk namespace
163 
164 #endif
StkFloat dataRate(void) const
Return the sample rate associated with the StkFrames data.
Definition: Stk.h:394
StkFloat getFileRate(void) const
Return the input file sample rate in Hz (not the data read rate).
Definition: FileLoop.h:83
void addTime(StkFloat time)
Increment the read pointer by time samples, modulo file size.
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition: FileWvIn.h:181
STK audio file input class.
Definition: FileWvIn.h:42
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:380
StkFloat tick(unsigned int channel=0)
Compute a sample frame and return the specified channel value.
The STK namespace.
Definition: ADSR.h:6
virtual void closeFile(void)
Close a file if one is open.
~FileLoop(void)
Class destructor.
STK file looping / oscillator class.
Definition: FileLoop.h:26
FileLoop(unsigned long chunkThreshold=1000000, unsigned long chunkSize=1024)
Default constructor.
void normalize(StkFloat peak)
Normalize data to a maximum of +-peak.
Definition: FileLoop.h:72
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition: FileLoop.h:129
void setFrequency(StkFloat frequency)
Set the data interpolation rate based on a looping frequency.
Definition: FileLoop.h:98
virtual void reset(void)
Clear outputs and reset time (file) pointer to zero.
void setRate(StkFloat rate)
Set the data read rate in samples. The rate can be negative.
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:377
static StkFloat sampleRate(void)
Static method that returns the current STK sample rate.
Definition: Stk.h:145
void reset(void)
Clear outputs and reset time (file) pointer to zero.
Definition: FileLoop.h:55
void addPhase(StkFloat angle)
Increment current read pointer by angle, relative to a looping frequency.
unsigned long getSize(void) const
Return the file size in sample frames.
Definition: FileLoop.h:75
An STK class to handle vectorized audio data.
Definition: Stk.h:272
void normalize(void)
Normalize data to a maximum of +-1.0.
Definition: FileLoop.h:65
virtual void normalize(void)
Normalize data to a maximum of +-1.0.
void openFile(std::string fileName, bool raw=false, bool doNormalize=true)
Open the specified file and load its data.
unsigned int channelsOut(void) const
Return the number of audio channels in the data or stream.
Definition: FileLoop.h:58
void addPhaseOffset(StkFloat angle)
Add a phase offset to the current read pointer.
unsigned long fileSize(void) const
Return the file size in sample frames.
Definition: FileRead.h:77
void closeFile(void)
Close a file if one is open.
Definition: FileLoop.h:52

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