#include <iso_synth_granular_unit.h>
Inherits iso::synth::ProcessUnit.
Inheritance diagram for iso::synth::GranularUnit:
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 | |
Grain * | createGrain (Frame &pAmplitude, Frame &pDuration, Frame &pDelay, Frame &pPlayRate) |
create a grain | |
Protected Attributes | |
ControlPort * | mTrigger |
grain trigger control port | |
ControlPort * | mAmplitude |
amplitude control port | |
ControlPort * | mDuration |
duration control port | |
ControlPort * | mDelay |
duration control port | |
ControlPort * | mPlayRate |
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 |
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.
GranularUnit::GranularUnit | ( | ) |
default constructor
GranularUnit::GranularUnit | ( | sample | pMaxDelay | ) |
parameter based contructor
pMaxDelay | maximum delay (in milisecs) |
parameter based contructor
pName | unit name | |
pMaxDelay | maximum delay (in milisecs) |
GranularUnit::GranularUnit | ( | unsigned int | pChannelCount, | |
sample | pMaxDelay | |||
) |
parameter based contructor
pChannelCount | number of channels | |
pMaxDelay | maximum delay (in milisecs) |
GranularUnit::GranularUnit | ( | const String & | pName, | |
unsigned int | pChannelCount, | |||
sample | pMaxDelay = sMaxDelay | |||
) |
parameter based contructor
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
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
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
pUnit | unit to copy properties from |
GranularUnit::GranularUnit | ( | const String & | pName, | |
const GranularUnit & | pUnit | |||
) |
name & copy constructor
pName | unit name | |
pUnit | unit to copy properties from |
GranularUnit::GranularUnit | ( | const data::Values & | pValues | ) | throw (SynthException) |
values based constructor
pValues | unit values |
SynthException | failed to create unit |
GranularUnit::~GranularUnit | ( | ) |
destructor
void GranularUnit::setGrainCount | ( | unsigned int | pMaxSimulGrains | ) |
set maximum number of simultaneously active grains
pMaxSimulGrains | ( maximum number of simultaneously active grains ) |
void GranularUnit::setEnvelope | ( | Frame | pEnvelope | ) |
create new envelope
pEnvelope | ( envelope data ) |
void GranularUnit::setDelayCompensation | ( | bool | pDelayCompensation | ) |
set delay compensation
pDelayCompensation | ( true: delay compensation, false: no delay compensation ) |
void GranularUnit::setAmplitudeCompensation | ( | bool | pAmplitudeCompensation | ) |
set amplitude compensation
pAmplitudeCompensation | ( true: amplitude compensation, false: no amplitude compensation ) |
void GranularUnit::setInterpolation | ( | bool | pInterpolation | ) |
set subsample interpolation
pInterpolation | ( true: subsample interpolation, false: no subsample interpolation ) |
void GranularUnit::process | ( | Buffer * | pBuffer = NULL |
) | throw (SynthException) [virtual] |
base::String GranularUnit::info | ( | bool | pPropagate = false , |
|
bool | pShowPorts = true | |||
) | const [virtual] |
obtain textual unit information
pPropagate | if true, the unit calls the info methods of its input ports | |
pShowPorts | print port 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
pAmplitude | amplitude | |
pDuration | duration (in milisecs) | |
pDelay | (in milisecs) | |
pPlayRate | play rate (1.0 : normal play rate) |
std::ostream& operator<< | ( | std::ostream & | pOstream, | |
const GranularUnit & | pUnit | |||
) | [friend] |
print unit information
const base::String GranularUnit::sClassName [static] |
unsigned int GranularUnit::sUnitCount [static, protected] |
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
amplitude compensation channel
channel containing sum of current grain envelopes
used for amplitude auto compensation