35 Granulate(
unsigned int nVoices, std::string fileName,
bool typeRaw =
false );
45 void openFile( std::string fileName,
bool typeRaw =
false );
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_;
174inline StkFloat Granulate :: lastOut(
unsigned int channel )
176#if defined(_STK_DEBUG_)
177 if ( channel >= lastFrame_.channels() ) {
178 oStream_ <<
"Granulate::lastOut(): channel argument is invalid!";
179 handleError( StkError::FUNCTION_ARGUMENT );
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!";
192 handleError( StkError::FUNCTION_ARGUMENT );
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];
STK abstract unit generator parent class.
Definition Generator.h:21
STK granular synthesis class.
Definition Granulate.h:29
void setRandomFactor(StkFloat randomness=0.1)
This factor is used when setting individual grain parameters (0.0 - 1.0).
StkFloat tick(unsigned int channel=0)
Compute one sample frame and return the specified channel value.
~Granulate(void)
Class destructor.
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition Granulate.h:174
void openFile(std::string fileName, bool typeRaw=false)
Load a monophonic soundfile to be "granulated".
void setVoices(unsigned int nVoices=1)
Set the number of simultaneous grain "voices" to use.
Granulate(void)
Default constructor.
void reset(void)
Reset the file pointer and all existing grains to the file start.
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).
Granulate(unsigned int nVoices, std::string fileName, bool typeRaw=false)
Constructor taking input audio file and number of voices arguments.
An STK class to handle vectorized audio data.
Definition Stk.h:279
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition Stk.h:416
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition Stk.h:419
The STK namespace.
Definition ADSR.h:6