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];
~Granulate(void)
Class destructor.
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
void reset(void)
Reset the file pointer and all existing grains to the file start.
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:407
STK granular synthesis class.
Definition: Granulate.h:28
void setGrainParameters(unsigned int duration=30, unsigned int rampPercent=50, int offset=0, unsigned int delay=0)
Set global grain parameters used to determine individual grain settings.
void setStretch(unsigned int stretchFactor=1)
Set the stretch factor used for grain playback (1 - 1000).
The STK namespace.
Definition: ADSR.h:6
StkFloat tick(unsigned int channel=0)
Compute one sample frame and return the specified channel value.
void setRandomFactor(StkFloat randomness=0.1)
This factor is used when setting individual grain parameters (0.0 - 1.0).
void openFile(std::string fileName, bool typeRaw=false)
Load a monophonic soundfile to be "granulated".
Granulate(void)
Default constructor.
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:404
STK abstract unit generator parent class.
Definition: Generator.h:20
An STK class to handle vectorized audio data.
Definition: Stk.h:275
STK noise generator.
Definition: Noise.h:21
void setVoices(unsigned int nVoices=1)
Set the number of simultaneous grain "voices" to use.
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition: Granulate.h:174