1 #ifndef STK_GRANULATE_H
2 #define STK_GRANULATE_H
36 Granulate(
unsigned int nVoices, std::string fileName,
bool typeRaw =
false );
42 void openMemory(
MemoryFS &memoryFile);
49 void openFile( std::string fileName,
bool typeRaw =
false );
92 int offset = 0,
unsigned int delay = 0 );
114 StkFloat
lastOut(
unsigned int channel = 0 );
117 StkFloat
tick(
unsigned int channel = 0 );
141 unsigned long attackCount;
142 unsigned long sustainCount;
143 unsigned long decayCount;
144 unsigned long delayCount;
145 unsigned long counter;
148 unsigned long startPointer;
149 unsigned int repeats;
154 :eScaler(0.0), eRate(0.0), attackCount(0), sustainCount(0), decayCount(0),
155 delayCount(0), counter(0), pointer(0), startPointer(0), repeats(0), state(GRAIN_STOPPED) {}
158 void calculateGrain( Granulate::Grain& grain );
161 std::vector<Grain> grains_;
167 unsigned int gDuration_;
168 unsigned int gRampPercent_;
169 unsigned int gDelay_;
170 unsigned int gStretch_;
171 unsigned int stretchCounter_;
173 StkFloat gRandomFactor_;
180 #if defined(_STK_DEBUG_)
181 if ( channel >= lastFrame_.
channels() ) {
182 oStream_ <<
"Granulate::lastOut(): channel argument is invalid!";
187 return lastFrame_[channel];
192 unsigned int nChannels = lastFrame_.
channels();
193 #if defined(_STK_DEBUG_)
194 if ( channel > frames.
channels() - nChannels ) {
195 oStream_ <<
"Granulate::tick(): channel and StkFrames arguments are incompatible!";
200 StkFloat *samples = &frames[channel];
201 unsigned int j, hop = frames.
channels() - nChannels;
202 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
204 for ( j=1; j<nChannels; j++ )
205 *samples++ = lastFrame_[j];
STK abstract unit generator parent class.
Definition: Generator.h:21
STK granular synthesis class.
Definition: Granulate.h:30
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:178
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.
STK in memory File An instance is representing an individual memory array which can be registered wit...
Definition: MemoryFS.h:46
An STK class to handle vectorized audio data.
Definition: Stk.h:287
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:415
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:418
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
The STK namespace.
Definition: ADSR.h:8