1 #ifndef STK_GRANULATE_H
2 #define STK_GRANULATE_H
35 Granulate(
unsigned int nVoices, std::string fileName,
bool typeRaw =
false );
45 void openFile( std::string fileName,
bool typeRaw =
false );
60 void setVoices(
unsigned int nVoices = 1 );
69 void setStretch(
unsigned int stretchFactor = 1 );
88 int offset = 0,
unsigned int delay = 0 );
110 StkFloat
lastOut(
unsigned int channel = 0 );
113 StkFloat
tick(
unsigned int channel = 0 );
137 unsigned long attackCount;
138 unsigned long sustainCount;
139 unsigned long decayCount;
140 unsigned long delayCount;
141 unsigned long counter;
144 unsigned long startPointer;
145 unsigned int repeats;
150 :eScaler(0.0), eRate(0.0), attackCount(0), sustainCount(0), decayCount(0),
151 delayCount(0), counter(0), pointer(0), startPointer(0), repeats(0), state(GRAIN_STOPPED) {}
154 void calculateGrain( Granulate::Grain& grain );
157 std::vector<Grain> grains_;
163 unsigned int gDuration_;
164 unsigned int gRampPercent_;
165 unsigned int gDelay_;
166 unsigned int gStretch_;
167 unsigned int stretchCounter_;
169 StkFloat gRandomFactor_;
176 #if defined(_STK_DEBUG_)
177 if ( channel >= lastFrame_.
channels() ) {
178 oStream_ <<
"Granulate::lastOut(): channel argument is invalid!";
183 return lastFrame_[channel];
188 unsigned int nChannels = lastFrame_.
channels();
189 #if defined(_STK_DEBUG_)
190 if ( channel > frames.
channels() - nChannels ) {
191 oStream_ <<
"Granulate::tick(): channel and StkFrames arguments are incompatible!";
196 StkFloat *samples = &frames[channel];
197 unsigned int j, hop = frames.
channels() - nChannels;
198 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
200 for ( j=1; j<nChannels; j++ )
201 *samples++ = lastFrame_[j];