Debian Codegraph @

lib-src/libnyquist/nyquist/nyqstk/include/WaveLoop.h

raw
1 /***************************************************/
2 /*! \class WaveLoop
3 \brief STK waveform oscillator class.
4
5 This class inherits from FileWvIn and provides audio file looping
6 functionality. Any audio file that can be loaded by FileRead can
7 be looped using this class.
8
9 WaveLoop supports multi-channel data. It is important to
10 distinguish the tick() methods, which return samples produced by
11 averaging across sample frames, from the tickFrame() methods,
12 which return references or pointers to multi-channel sample
13 frames.
14
15 by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
16 */
17 /***************************************************/
18
19 #ifndef STK_WAVELOOP_H
20 #define STK_WAVELOOP_H
21
22 #include "FileWvIn.h"
23
24 namespace Nyq
25 {
26
27 class WaveLoop : public FileWvIn
28 {
29 public:
30 //! Default constructor.
31 WaveLoop( unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
32
33 //! Class constructor that opens a specified file.
34 WaveLoop( std::string fileName, bool raw = false, bool doNormalize = true,
35 unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
36
37 //! Class destructor.
38 virtual ~WaveLoop();
39
40 //! Open the specified file and load its data.
41 /*!
42 Data from a previously opened file will be overwritten by this
43 function. An StkError will be thrown if the file is not found,
44 its format is unknown, or a read error occurs. If the file data
45 is to be loaded incrementally from disk and normalization is
46 specified, a scaling will be applied with respect to fixed-point
47 limits. If the data format is floating-point, no scaling is
48 performed.
49 */
50 void openFile( std::string fileName, bool raw = false, bool doNormalize = true );
51
52 //! Set the data read rate in samples. The rate can be negative.
53 /*!
54 If the rate value is negative, the data is read in reverse order.
55 */
56 void setRate( StkFloat rate );
57
58 //! Set the data interpolation rate based on a looping frequency.
59 /*!
60 This function determines the interpolation rate based on the file
61 size and the current Stk::sampleRate. The \e frequency value
62 corresponds to file cycles per second. The frequency can be
63 negative, in which case the loop is read in reverse order.
64 */
65 void setFrequency( StkFloat frequency );
66
67 //! Increment the read pointer by \e time samples, modulo file size.
68 void addTime( StkFloat time );
69
70 //! Increment current read pointer by \e angle, relative to a looping frequency.
71 /*!
72 This function increments the read pointer based on the file
73 size and the current Stk::sampleRate. The \e anAngle value
74 is a multiple of file size.
75 */
76 void addPhase( StkFloat angle );
77
78 //! Add a phase offset to the current read pointer.
79 /*!
80 This function determines a time offset based on the file
81 size and the current Stk::sampleRate. The \e angle value
82 is a multiple of file size.
83 */
84 void addPhaseOffset( StkFloat angle );
85
86 protected:
87
88 virtual void computeFrame( void );
89
90 StkFrames firstFrame_;
91 StkFloat phaseOffset_;
92
93 };
94
95 } // namespace Nyq
96
97 #endif