iso::synth::GranularUnit Class Reference

GranularUnit granular synthesis unit class. More...

#include <iso_synth_granular_unit.h>

Inherits iso::synth::ProcessUnit.

Inheritance diagram for iso::synth::GranularUnit:

Inheritance graph
[legend]
Collaboration diagram for iso::synth::GranularUnit:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GranularUnit ()
 default constructor
 GranularUnit (sample pMaxDelay)
 parameter based contructor
 GranularUnit (const String &pName, sample pMaxDelay=sMaxDelay)
 parameter based contructor
 GranularUnit (unsigned int pChannelCount, sample pMaxDelay)
 parameter based contructor
 GranularUnit (const String &pName, unsigned int pChannelCount, sample pMaxDelay=sMaxDelay)
 parameter based contructor
 GranularUnit (unsigned int pFrameCount, unsigned int pChannelCount, unsigned int pRate, sample pMaxDelay=sMaxDelay)
 parameter based contructor
 GranularUnit (const String &pName, unsigned int pFrameCount, unsigned int pChannelCount, unsigned int pRate, sample pMaxDelay=sMaxDelay)
 name and parameter based contructor
 GranularUnit (const GranularUnit &pUnit)
 copy constructor
 GranularUnit (const String &pName, const GranularUnit &pUnit)
 name & copy constructor
 GranularUnit (const data::Values &pValues) throw (SynthException)
 values based constructor
 ~GranularUnit ()
 destructor
void setGrainCount (unsigned int pMaxSimulGrains)
 set maximum number of simultaneously active grains
void setEnvelope (Frame pEnvelope)
 create new envelope
void setDelayCompensation (bool pDelayCompensation)
 set delay compensation
void setAmplitudeCompensation (bool pAmplitudeCompensation)
 set amplitude compensation
void setInterpolation (bool pInterpolation)
 set subsample interpolation
virtual void process (Buffer *pBuffer=NULL) throw (SynthException)
 processes buffer
virtual String info (bool pPropagate=false, bool pShowPorts=true) const
 obtain textual unit information

Static Public Attributes

static const String sClassName
 default name

Protected Member Functions

void init ()
 initializes switch ports
GraincreateGrain (Frame &pAmplitude, Frame &pDuration, Frame &pDelay, Frame &pPlayRate)
 create a grain

Protected Attributes

ControlPortmTrigger
 grain trigger control port
ControlPortmAmplitude
 amplitude control port
ControlPortmDuration
 duration control port
ControlPortmDelay
 duration control port
ControlPortmPlayRate
 duration play rate port
Frame mAmplitudeFrame
 amplitude frame
Frame mDurationFrame
 duration frame
Frame mDelayFrame
 delay frame
Frame mPlayRateFrame
 play rate frame
PointList mPointList
 grain amplitude envelope
RingBuffer mRingBuffer
 ring buffer
Buffer mGrainAudioBuffer
 temporary buffer for grain audio data
unsigned int mMaxSimulGrains
 maximum number of simultaneously active grains
bool mDelayCompensation
 grain delay compensation
bool mAmplitudeCompensation
 grain delay compensation
bool mInterpolation
 subsample interpolation
QVector< Grain * > mActiveGrains
 active grains
QVector< Grain * > mReserveGrains
 inactive grains
sample mPrevTriggerValue
 previous trigger value
Channel mAmplitudeCompensationChannel
 amplitude compensation channel

Static Protected Attributes

static unsigned int sUnitCount
 total number of units created so far
static sample sMaxDelay
 default maximum delay (in milisecs)
static unsigned int sMaxSimulGrains
 default maximum number of simultaneously active grains

Friends

std::ostream & operator<< (std::ostream &pOstream, const GranularUnit &pUnit)
 print unit information

Detailed Description

GranularUnit granular synthesis unit class.

unit class

A granular synthesis unit.
This unit converts any audio signal it receives at it audio input port in a trail of grains.
Grains are triggered by pulses received at the trigger control port.
This unit has extensive configuration capabilities.
The grain envelope is controlled by a pointlist.
The setEnvelope function allows to define new envelopes.
There exist control ports for the amplitude of grains,
the grain duration, the delay (in milisecs) of grains
(grain read their audio data from a ring buffer), and the play back rate of grains.
The playback rate of grains can be positive or negative and doesn't affect the grains envelope duration.
Furthermore, the grain delay may automatically be adjusted to take the start position of a grain within a audio buffer into account.
This option is essential to recreate the original audio input with sample accuracy (for example for pitch shifting effects). There is also an option to compensate for amplitude variations due to the number of grains and envelope shape.
This option produces only reasonable effects if the grain density is high (i.e. all grains overlap).
It shouldn't be active when some grains are non overlapping.
Finally, whenever the playback rate of grains is not 1.0, there is an option to create the grain's audio signal via interpolation.


ControlPorts
name: trigger defaultValue: 0.0
name: amplitude defaultValue: 1.0
name: duration defaultValue: 1.0
name: delay defaultValue: 0.0
name: playRate defaultValue: 1.0

SwitchPorts:
name: active channelCount: 1 defaultValue: 1.0 resizable: false function: setActive
name: grainCount channelCount: 1 defaultValue: 40.0 resizable: false function: setGrainCount
name: delayCompensation channelCount: 1 defaultValue: 1.0 resizable: false function: setDelayCompensation
name: amplitudeCompensation channelCount: 1 defaultValue: 0.0 resizable: false function: setAmplitudeCompensation
name: interpolation channelCount: 1 defaultValue: 0.0 resizable: false function: setInterpolation

Created by Daniel Bisig on 6/14/07.


Constructor & Destructor Documentation

GranularUnit::GranularUnit (  ) 

default constructor

GranularUnit::GranularUnit ( sample  pMaxDelay  ) 

parameter based contructor

Parameters:
pMaxDelay maximum delay (in milisecs)

GranularUnit::GranularUnit ( const String pName,
sample  pMaxDelay = sMaxDelay 
)

parameter based contructor

Parameters:
pName unit name
pMaxDelay maximum delay (in milisecs)

GranularUnit::GranularUnit ( unsigned int  pChannelCount,
sample  pMaxDelay 
)

parameter based contructor

Parameters:
pChannelCount number of channels
pMaxDelay maximum delay (in milisecs)

GranularUnit::GranularUnit ( const String pName,
unsigned int  pChannelCount,
sample  pMaxDelay = sMaxDelay 
)

parameter based contructor

Parameters:
pName unit name
pChannelCount number of channels
pMaxDelay maximum delay (in milisecs)

GranularUnit::GranularUnit ( unsigned int  pFrameCount,
unsigned int  pChannelCount,
unsigned int  pRate,
sample  pMaxDelay = sMaxDelay 
)

parameter based contructor

Parameters:
pFrameCount number of frames
pChannelCount number of channels
pRate samping rate
pMaxDelay maximum delay (in milisecs)

GranularUnit::GranularUnit ( const String pName,
unsigned int  pFrameCount,
unsigned int  pChannelCount,
unsigned int  pRate,
sample  pMaxDelay = sMaxDelay 
)

name and parameter based contructor

Parameters:
pName unit name
pFrameCount number of frames
pChannelCount number of channels
pRate samping rate
pMaxDelay maximum delay (in milisecs)

GranularUnit::GranularUnit ( const GranularUnit pUnit  ) 

copy constructor

Parameters:
pUnit unit to copy properties from

GranularUnit::GranularUnit ( const String pName,
const GranularUnit pUnit 
)

name & copy constructor

Parameters:
pName unit name
pUnit unit to copy properties from

GranularUnit::GranularUnit ( const data::Values &  pValues  )  throw (SynthException)

values based constructor

Parameters:
pValues unit values
Exceptions:
SynthException failed to create unit
pValues structure & data types: 0: const String& : unit name 1: unsigned int : number of frames 2: unsigned int : number of channels 3: unsigned int : samping rate 4: sample : max delay

GranularUnit::~GranularUnit (  ) 

destructor


Member Function Documentation

void GranularUnit::setGrainCount ( unsigned int  pMaxSimulGrains  ) 

set maximum number of simultaneously active grains

Parameters:
pMaxSimulGrains ( maximum number of simultaneously active grains )
define the maximum number of simultaneously active grains
takes only the value stored at channel 0 into account

void GranularUnit::setEnvelope ( Frame  pEnvelope  ) 

create new envelope

Parameters:
pEnvelope ( envelope data )
the supplied frame defines the new envelope type by interpreting every pair of successing channels in the frame as a new point

void GranularUnit::setDelayCompensation ( bool  pDelayCompensation  ) 

set delay compensation

Parameters:
pDelayCompensation ( true: delay compensation, false: no delay compensation )
adapt grain delay values depending on their trigger position within a audio buffer
this is essential for creating perfectly aligned grain buffers that recreate the original audio signal
turn this option on if you would like to use granular synthesis for pitch shifting effects
takes only the value stored at channel 0 into account

void GranularUnit::setAmplitudeCompensation ( bool  pAmplitudeCompensation  ) 

set amplitude compensation

Parameters:
pAmplitudeCompensation ( true: amplitude compensation, false: no amplitude compensation )
normalize sample amplitudes based on grain envelopes

void GranularUnit::setInterpolation ( bool  pInterpolation  ) 

set subsample interpolation

Parameters:
pInterpolation ( true: subsample interpolation, false: no subsample interpolation )
turn on or off subsample interpolation
subsample interpolation has only an effect for play rates != 1.0

void GranularUnit::process ( Buffer pBuffer = NULL  )  throw (SynthException) [virtual]

processes buffer

Parameters:
pBuffer buffer to process

Reimplemented from iso::synth::ProcessUnit.

base::String GranularUnit::info ( bool  pPropagate = false,
bool  pShowPorts = true 
) const [virtual]

obtain textual unit information

Parameters:
pPropagate if true, the unit calls the info methods of its input ports
pShowPorts print port information
Returns:
String containing unit information

Reimplemented from iso::synth::ProcessUnit.

void GranularUnit::init (  )  [protected]

initializes switch ports

Grain * GranularUnit::createGrain ( Frame pAmplitude,
Frame pDuration,
Frame pDelay,
Frame pPlayRate 
) [protected]

create a grain

Parameters:
pAmplitude amplitude
pDuration duration (in milisecs)
pDelay (in milisecs)
pPlayRate play rate (1.0 : normal play rate)


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  pOstream,
const GranularUnit pUnit 
) [friend]

print unit information


Member Data Documentation

const base::String GranularUnit::sClassName [static]

default name

Reimplemented from iso::synth::ProcessUnit.

unsigned int GranularUnit::sUnitCount [static, protected]

total number of units created so far

Reimplemented from iso::synth::ProcessUnit.

sample GranularUnit::sMaxDelay [static, protected]

default maximum delay (in milisecs)

unsigned int GranularUnit::sMaxSimulGrains [static, protected]

default maximum number of simultaneously active grains

ControlPort* iso::synth::GranularUnit::mTrigger [protected]

grain trigger control port

ControlPort* iso::synth::GranularUnit::mAmplitude [protected]

amplitude control port

ControlPort* iso::synth::GranularUnit::mDuration [protected]

duration control port

ControlPort* iso::synth::GranularUnit::mDelay [protected]

duration control port

ControlPort* iso::synth::GranularUnit::mPlayRate [protected]

duration play rate port

Frame iso::synth::GranularUnit::mAmplitudeFrame [protected]

amplitude frame

helper frame for the creation of grains

Frame iso::synth::GranularUnit::mDurationFrame [protected]

duration frame

helper frame for the creation of grains

Frame iso::synth::GranularUnit::mDelayFrame [protected]

delay frame

helper frame for the creation of grains

Frame iso::synth::GranularUnit::mPlayRateFrame [protected]

play rate frame

helper frame for the creation of grains

PointList iso::synth::GranularUnit::mPointList [protected]

grain amplitude envelope

RingBuffer iso::synth::GranularUnit::mRingBuffer [protected]

ring buffer

Buffer iso::synth::GranularUnit::mGrainAudioBuffer [protected]

temporary buffer for grain audio data

unsigned int iso::synth::GranularUnit::mMaxSimulGrains [protected]

maximum number of simultaneously active grains

bool iso::synth::GranularUnit::mDelayCompensation [protected]

grain delay compensation

bool iso::synth::GranularUnit::mAmplitudeCompensation [protected]

grain delay compensation

bool iso::synth::GranularUnit::mInterpolation [protected]

subsample interpolation

QVector<Grain*> iso::synth::GranularUnit::mActiveGrains [protected]

active grains

QVector<Grain*> iso::synth::GranularUnit::mReserveGrains [protected]

inactive grains

sample iso::synth::GranularUnit::mPrevTriggerValue [protected]

previous trigger value

helper for detecting when a trigger just started

Channel iso::synth::GranularUnit::mAmplitudeCompensationChannel [protected]

amplitude compensation channel

channel containing sum of current grain envelopes
used for amplitude auto compensation


The documentation for this class was generated from the following files:
Generated on Fri Feb 25 14:18:45 2011 for synth by  doxygen 1.5.1