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 bool doInt2FloatScaling = true );
36
38 ~FileLoop( void );
39
41
51 void openFile( std::string fileName, bool raw = false, bool doNormalize = true, bool doInt2FloatScaling = true );
52
54 void closeFile( void ) { FileWvIn::closeFile(); };
55
57 void reset( void ) { FileWvIn::reset(); };
58
60 unsigned int channelsOut( void ) const { return data_.channels(); };
61
63
67 void normalize( void ) { FileWvIn::normalize( 1.0 ); };
68
70
74 void normalize( StkFloat peak ) { FileWvIn::normalize( peak ); };
75
77 //unsigned long getSize( void ) const { return data_.frames(); };
78 unsigned long getSize( void ) const { return fileSize_; };
79
81
86 StkFloat getFileRate( void ) const { return data_.dataRate(); };
87
89
92 void setRate( StkFloat rate );
93
95
101 void setFrequency( StkFloat frequency ) { this->setRate( fileSize_ * frequency / Stk::sampleRate() ); };
102
104 void addTime( StkFloat time );
105
107
112 void addPhase( StkFloat angle );
113
115
120 void addPhaseOffset( StkFloat angle );
121
123
132 StkFloat lastOut( unsigned int channel = 0 ) { return FileWvIn::lastOut( channel ); };
133
135
144 StkFloat tick( unsigned int channel = 0 );
145
147
154 virtual StkFrames& tick( StkFrames& frames,unsigned int channel = 0 );
155
156 protected:
157
158 StkFrames firstFrame_;
159 StkFloat phaseOffset_;
160
161};
162
163} // stk namespace
164
165#endif
stk::FileLoop
STK file looping / oscillator class.
Definition FileLoop.h:27
stk::FileLoop::FileLoop
FileLoop(std::string fileName, bool raw=false, bool doNormalize=true, unsigned long chunkThreshold=1000000, unsigned long chunkSize=1024, bool doInt2FloatScaling=true)
Class constructor that opens a specified file.
stk::FileLoop::tick
StkFloat tick(unsigned int channel=0)
Compute a sample frame and return the specified channel value.
stk::FileLoop::FileLoop
FileLoop(unsigned long chunkThreshold=1000000, unsigned long chunkSize=1024)
Default constructor.
stk::FileLoop::setRate
void setRate(StkFloat rate)
Set the data read rate in samples. The rate can be negative.
stk::FileLoop::addTime
void addTime(StkFloat time)
Increment the read pointer by time samples, modulo file size.
stk::FileLoop::reset
void reset(void)
Clear outputs and reset time (file) pointer to zero.
Definition FileLoop.h:57
stk::FileLoop::channelsOut
unsigned int channelsOut(void) const
Return the number of audio channels in the data or stream.
Definition FileLoop.h:60
stk::FileLoop::closeFile
void closeFile(void)
Close a file if one is open.
Definition FileLoop.h:54
stk::FileLoop::getFileRate
StkFloat getFileRate(void) const
Return the input file sample rate in Hz (not the data read rate).
Definition FileLoop.h:86
stk::FileLoop::tick
virtual StkFrames & tick(StkFrames &frames, unsigned int channel=0)
Fill the StkFrames object with computed sample frames, starting at the specified channel and return t...
stk::FileLoop::normalize
void normalize(void)
Normalize data to a maximum of +-1.0.
Definition FileLoop.h:67
stk::FileLoop::lastOut
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition FileLoop.h:132
stk::FileLoop::openFile
void openFile(std::string fileName, bool raw=false, bool doNormalize=true, bool doInt2FloatScaling=true)
Open the specified file and load its data.
stk::FileLoop::addPhase
void addPhase(StkFloat angle)
Increment current read pointer by angle, relative to a looping frequency.
stk::FileLoop::normalize
void normalize(StkFloat peak)
Normalize data to a maximum of +-peak.
Definition FileLoop.h:74
stk::FileLoop::~FileLoop
~FileLoop(void)
Class destructor.
stk::FileLoop::getSize
unsigned long getSize(void) const
Return the file size in sample frames.
Definition FileLoop.h:78
stk::FileLoop::setFrequency
void setFrequency(StkFloat frequency)
Set the data interpolation rate based on a looping frequency.
Definition FileLoop.h:101
stk::FileLoop::addPhaseOffset
void addPhaseOffset(StkFloat angle)
Add a phase offset to the current read pointer.
stk::FileWvIn
STK audio file input class.
Definition FileWvIn.h:53
stk::FileWvIn::normalize
virtual void normalize(void)
Normalize data to a maximum of +-1.0.
stk::FileWvIn::reset
virtual void reset(void)
Clear outputs and reset time (file) pointer to zero.
stk::FileWvIn::lastOut
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition FileWvIn.h:193
stk::FileWvIn::closeFile
virtual void closeFile(void)
Close a file if one is open.
stk::StkFrames
An STK class to handle vectorized audio data.
Definition Stk.h:279
stk::StkFrames::channels
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition Stk.h:416
stk::StkFrames::dataRate
StkFloat dataRate(void) const
Return the sample rate associated with the StkFrames data.
Definition Stk.h:433
stk::Stk::sampleRate
static StkFloat sampleRate(void)
Static method that returns the current STK sample rate.
Definition Stk.h:148
stk
The STK namespace.
Definition ADSR.h:6

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