Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Granulate Class Reference

#include <Granulate.h>

Inheritance diagram for Granulate:

Generator Stk List of all members.

Detailed Description

STK granular synthesis class.

This class implements a real-time granular synthesis algorithm that operates on an input soundfile. Currently, only monophonic files are supported. Various functions are provided to allow control over voice and grain parameters.

The functionality of this class is based on the program MacPod by Chris Rolfe and Damian Keller, though there are likely to be a number of differences in the actual implementation.

by Gary Scavone, 2005.


Public Member Functions

 Granulate (void)
 Default constructor.
 Granulate (unsigned int nVoices, std::string fileName, bool typeRaw=false)
 Constructor taking input audio file and number of voices arguments.
 ~Granulate ()
 Class destructor.
void openFile (std::string fileName, bool typeRaw=false)
 Load a monophonic soundfile to be "granulated".
void reset ()
 Reset the file pointer and all existing grains to the file start.
void setVoices (unsigned int nVoices=1)
 Set the number of simultaneous grain "voices" to use.
void setStretch (unsigned int stretchFactor=1)
 Set the stretch factor used for grain playback (1 - 1000).
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 setRandomFactor (StkFloat randomness=0.1)
 This factor is used when setting individual grain parameters (0.0 - 1.0).


Member Function Documentation

void Granulate::openFile std::string  fileName,
bool  typeRaw = false
 

Load a monophonic soundfile to be "granulated".

An StkError will be thrown if the file is not found, its format is unknown or unsupported, or the file has more than one channel.

void Granulate::reset  ) 
 

Reset the file pointer and all existing grains to the file start.

Multiple grains are offset from one another in time by grain duration / nVoices.

void Granulate::setVoices unsigned int  nVoices = 1  ) 
 

Set the number of simultaneous grain "voices" to use.

Multiple grains are offset from one another in time by grain duration / nVoices. For this reason, it is best to set the grain parameters before calling this function (during initialization).

void Granulate::setStretch unsigned int  stretchFactor = 1  ) 
 

Set the stretch factor used for grain playback (1 - 1000).

Granular synthesis allows for time-stetching without affecting the original pitch of a sound. A stretch factor of 4 will produce a resulting sound of length 4 times the orignal sound. The default parameter of 1 produces no stretching.

void Granulate::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.

Each grain is defined as having a length of duration milliseconds which must be greater than zero. For values of rampPercent (0 - 100) greater than zero, a linear envelope will be applied to each grain. If rampPercent = 100, the resultant grain "window" is triangular while rampPercent = 50 produces a trapezoidal window. In addition, each grain can have a time delay of length delay and a grain pointer increment of length offset, which can be negative, before the next ramp onset (in milliseconds). The offset parameter controls grain pointer jumps between enveloped grain segments, while the delay parameter causes grain calculations to pause between grains. The actual values calculated for each grain will be randomized by a factor set using the setRandomFactor() function.

void Granulate::setRandomFactor StkFloat  randomness = 0.1  ) 
 

This factor is used when setting individual grain parameters (0.0 - 1.0).

This random factor is applied when all grain state durations are calculated. If set to 0.0, no randomness occurs. When randomness = 1.0, a grain segment of length duration will be randomly augmented by up to +- duration seconds (i.e., a 30 millisecond length will be augmented by an extra length of up to +30 or -30 milliseconds).


The documentation for this class was generated from the following file:
The Synthesis ToolKit in C++ (STK)
©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved.