Jamoma API  0.6.0.a19
TTAdsr Class Reference

TTAdsr is an attack-decay-sustain-release envelope generator. More...

#include <TTAdsr.h>

+ Inheritance diagram for TTAdsr:
+ Collaboration diagram for TTAdsr:

Protected Types

enum  eg_states {
  k_eg_inactive,
  k_eg_attack,
  k_eg_decay,
  k_eg_sustain,
  k_eg_release
}
 Enumerations tracking the state of the envelope. More...
 

Protected Member Functions

TTErr updateSampleRate (const TTValue &, TTValue &)
 This method must be called when the sample rate change. More...
 
TTErr dictionary (const TTValue &input, TTValue &output)
 Send a dictionary from Jamoma Graph to this object in order to pass a MidiNoteEvent or set attributes. More...
 
TTErr processAudioLinear (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
 The Linear audio processing method use linear amplitude curves for all parts of the envelope. More...
 
TTErr processAudioExponential (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
 The Exponential processing methods use exponential curves for all sections of the envelope. More...
 
TTErr processAudioHybrid (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
 The Hybrid processing method combines a linear attack with an exponential release. More...
 
TTErr setAttack (const TTValue &newValue)
 Set the attack time for the enevelope. More...
 
TTErr setDecay (const TTValue &newValue)
 Set the decay time for the envelope. More...
 
TTErr setSustainDb (const TTValue &newValue)
 Set the signal level to use for the sustain, expressed in decibels. More...
 
TTErr getSustainDb (TTValue &returnedValue)
 Get the signal level currently used for the sustain, measured in decibels. More...
 
TTErr setSustainAmp (const TTValue &newValue)
 Set the signal level to use for the sustain, expressed as linear amplitude. More...
 
TTErr setRelease (const TTValue &newValue)
 Set the release time in milliseconds. More...
 
TTErr setMode (const TTValue &newValue)
 Set the performance mode to use for the envelope. More...
 

Protected Attributes

TTFloat64 attack_ms
 Attack duration in milliseconds.
 
TTInt32 attack_samples
 Attack duration in total number of samples.
 
TTFloat64 attack_step
 Stepsize for each sample in the attack phase.
 
TTFloat64 attack_step_db
 Stepasize in decibels for each sample in the attack phase.
 
TTFloat64 decay_ms
 Decay duration in milliseconds.
 
TTInt32 decay_samples
 Decay duration in total number of samples.
 
TTFloat64 decay_step
 Stepsize for each sample during the decay phase.
 
TTFloat64 decay_step_db
 Stepsize in decibels for each sample during the decay phase.
 
TTFloat64 sustain_amp
 Sustain level as linear amplitude.
 
TTFloat64 sustain_db
 Sustain level as decibel value.
 
TTFloat64 release_ms
 Release duration in milliseconds.
 
TTInt32 release_samples
 Release duration in total number of samples.
 
TTFloat64 release_step
 Stepsize for each sample during the release phase.
 
TTFloat64 release_step_db
 Stepsize in decibels for each sample during the release phase.
 
TTSampleValue output
 Current envelope value as linear amplitude.
 
TTSampleValue output_db
 Current envelope value as decibel value.
 
TTInt16 eg_state
 The current state of the envelope. Tracks what envelope phase that we are currently in.
 

Detailed Description

TTAdsr is an attack-decay-sustain-release envelope generator.

Definition at line 25 of file TTAdsr.h.

Member Enumeration Documentation

enum TTAdsr::eg_states
protected

Enumerations tracking the state of the envelope.

ingroup enums

Enumerator
k_eg_inactive 

The envelope is currently inactive (not being executed).

k_eg_attack 

The envelope is currently in the attack phase.

k_eg_decay 

The envelope is currently in the decay phase.

k_eg_sustain 

The envelope is currently in the sustain phase.

k_eg_release 

The envelope is currently in the release phase.

Definition at line 115 of file TTAdsr.h.

Member Function Documentation

TTErr TTAdsr::dictionary ( const TTValue input,
TTValue output 
)
protected

Send a dictionary from Jamoma Graph to this object in order to pass a MidiNoteEvent or set attributes.

Sending a dictionary to this object may perform one of several functions.

  1. If the dictionary contains a MidiNoteEvent, then the midi note velocity (second item of the value array for the dictionary) is used to set the ADSR trigger as on or off.
  2. For setting attributes, etc., we rely on the external system (e.g. Jamoma Graph) to implement the infrastructure. By returning an error code if the dictionary is not a MidiNoteEvent, we indicate to the calling system that it is free to perform other tasks with the dictionary.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 52 of file TTAdsr.cpp.

References TTDictionary::getSchema(), TTDictionary::getValue(), kTTErrInvalidType, kTypeDictionary, and TT.

+ Here is the call graph for this function:

TTErr TTAdsr::getSustainDb ( TTValue returnedValue)
protected

Get the signal level currently used for the sustain, measured in decibels.

Parameters
returnedValueUsed to return the current sustain signal level in dB.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 143 of file TTAdsr.cpp.

References kTTErrNone, sustain_amp, and TTLinearGainToDecibels().

+ Here is the call graph for this function:

TTErr TTAdsr::processAudioExponential ( TTAudioSignalArrayPtr  inputs,
TTAudioSignalArrayPtr  outputs 
)
protected

The Exponential processing methods use exponential curves for all sections of the envelope.

Parameters
inputsThe input audio vector to process. For this unit generator this is basically ignored.
outputsThe returned processed audio.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 227 of file TTAdsr.cpp.

References attack_step_db, decay_step_db, eg_state, k_eg_attack, k_eg_decay, k_eg_inactive, k_eg_release, k_eg_sustain, kTTErrNone, TTAudioSignal::mSampleVectors, TTAudioSignalArray::numAudioSignals, output, output_db, release_step_db, sustain_amp, and TTDecibelsToLinearGain().

Referenced by setMode().

+ Here is the call graph for this function:

TTErr TTAdsr::processAudioHybrid ( TTAudioSignalArrayPtr  inputs,
TTAudioSignalArrayPtr  outputs 
)
protected

The Hybrid processing method combines a linear attack with an exponential release.

Parameters
inputsThe input audio vector to process. For this unit generator this is basically ignored.
outputsThe returned processed audio.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 295 of file TTAdsr.cpp.

References attack_step, decay_step_db, eg_state, k_eg_attack, k_eg_decay, k_eg_inactive, k_eg_release, k_eg_sustain, kTTErrNone, TTAudioSignal::mSampleVectors, TTAudioSignalArray::numAudioSignals, output, output_db, release_step_db, sustain_amp, TTDecibelsToLinearGain(), and TTLinearGainToDecibels().

Referenced by setMode().

+ Here is the call graph for this function:

TTErr TTAdsr::processAudioLinear ( TTAudioSignalArrayPtr  inputs,
TTAudioSignalArrayPtr  outputs 
)
protected

The Linear audio processing method use linear amplitude curves for all parts of the envelope.

Parameters
inputsThe input audio vector to process. For this unit generator this is basically ignored.
outputsThe returned processed audio.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 165 of file TTAdsr.cpp.

References attack_step, decay_step, eg_state, k_eg_attack, k_eg_decay, k_eg_inactive, k_eg_release, k_eg_sustain, kTTErrNone, TTAudioSignal::mSampleVectors, TTAudioSignalArray::numAudioSignals, output, release_step, and sustain_amp.

Referenced by setMode().

TTErr TTAdsr::setAttack ( const TTValue newValue)
protected

Set the attack time for the enevelope.

The maximum attack amplitude is normalised to 0 dB.

Parameters
newValueThe desired attack time in milliseconds.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 99 of file TTAdsr.cpp.

References attack_ms, attack_samples, attack_step, attack_step_db, kTTErrNone, and TTAudioObjectBase::sr.

Referenced by updateSampleRate().

TTErr TTAdsr::setDecay ( const TTValue newValue)
protected

Set the decay time for the envelope.

Parameters
newValueThe desired decay time in milliseconds.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 109 of file TTAdsr.cpp.

References decay_ms, decay_samples, decay_step, decay_step_db, kTTErrNone, and TTAudioObjectBase::sr.

Referenced by updateSampleRate().

TTErr TTAdsr::setMode ( const TTValue newValue)
protected

Set the performance mode to use for the envelope.

Possible options are 'exponential', 'linear' and 'hybrid'

Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 150 of file TTAdsr.cpp.

References kTTErrNone, processAudioExponential(), processAudioHybrid(), processAudioLinear(), setProcessMethod, and TT.

+ Here is the call graph for this function:

TTErr TTAdsr::setRelease ( const TTValue newValue)
protected

Set the release time in milliseconds.

param newValue The desired release time in milliseconds.

Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 119 of file TTAdsr.cpp.

References kTTErrNone, release_ms, release_samples, release_step, release_step_db, and TTAudioObjectBase::sr.

Referenced by updateSampleRate().

TTErr TTAdsr::setSustainAmp ( const TTValue newValue)
protected

Set the signal level to use for the sustain, expressed as linear amplitude.

Parameters
newValueThe desired sustain level in decibels.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 129 of file TTAdsr.cpp.

References kTTErrNone, sustain_amp, sustain_db, and TTLinearGainToDecibels().

+ Here is the call graph for this function:

TTErr TTAdsr::setSustainDb ( const TTValue newValue)
protected

Set the signal level to use for the sustain, expressed in decibels.

Parameters
newValueThe desired sustain level in decibels.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 136 of file TTAdsr.cpp.

References kTTErrNone, sustain_amp, sustain_db, and TTDecibelsToLinearGain().

+ Here is the call graph for this function:

TTErr TTAdsr::updateSampleRate ( const TTValue ,
TTValue  
)
protected

This method must be called when the sample rate change.

Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 82 of file TTAdsr.cpp.

References attack_ms, decay_ms, kTTErrNone, release_ms, setAttack(), setDecay(), and setRelease().

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: