A simple MultiLine envelope generator. More...
#include <MultiLine.h>
Public Member Functions | |
MultiLine () | |
Constructor. | |
void | update () |
Updates the internal controls of the MultiLine. More... | |
Q15n16 | next () |
Advances one step along the MultiLine and returns the level. More... | |
void | start () |
Start the target1 phase of the MultiLine. More... | |
void | stop () |
Start the target4 phase of the MultiLine. More... | |
void | setTarget1Level (Q15n16 value) |
Set the target1 level of the MultiLine. More... | |
void | setTarget2Level (Q15n16 value) |
Set the target2 level of the MultiLine. More... | |
void | setTarget3Level (Q15n16 value) |
Set the target3 level of the MultiLine. More... | |
void | setTarget4Level (Q15n16 value) |
Set the target4 level of the MultiLine. More... | |
void | setIdleLevel (Q15n16 value) |
void | setLevels (Q15n16 target1, Q15n16 target2, Q15n16 target3, Q15n16 target4) |
Set the target1, target2, target3 and target4 levels. More... | |
void | setTarget1Time (unsigned int msec) |
Set the target1 time of the MultiLine in milliseconds. More... | |
void | setTarget2Time (unsigned int msec) |
Set the target2 time of the MultiLine in milliseconds. More... | |
void | setTarget3Time (unsigned int msec) |
Set the target3 time of the MultiLine in milliseconds. More... | |
void | setTarget4Time (unsigned int msec) |
Set the target4 time of the MultiLine in milliseconds. More... | |
void | setIdleTime (unsigned int msec) |
void | setTimes (unsigned int target1_ms, unsigned int target2_ms, unsigned int target3_ms, unsigned int target4_ms) |
Set the target1, target2 and target4 times of the MultiLine in milliseconds. More... | |
void | setTarget1UpdateSteps (unsigned int steps) |
Set the target1 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target1 phase. More... | |
void | setTarget2UpdateSteps (unsigned int steps) |
Set the target2 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target2 phase. More... | |
void | setTarget3UpdateSteps (unsigned int steps) |
Set the target3 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target3 phase. More... | |
void | setTarget4UpdateSteps (unsigned int steps) |
Set the target4 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target4 phase. More... | |
void | setIdleUpdateSteps (unsigned int steps) |
void | setAllUpdateSteps (unsigned int target1_steps, unsigned int target2_steps, unsigned int target3_steps, unsigned int target4_steps) |
Set the target1, target2 and target4 times of the MultiLine, expressed in update steps (not MultiLine::next() interpolation steps). More... | |
bool | playing () |
Tells if the envelope is currently playing. More... | |
MultiLine () | |
Constructor. | |
void | update () |
Updates the internal controls of the MultiLine. More... | |
Q15n16 | next () |
Advances one step along the MultiLine and returns the level. More... | |
void | start () |
Start the target1 phase of the MultiLine. More... | |
void | stop () |
Start the target4 phase of the MultiLine. More... | |
void | setTargetLevel (uint8_t phase_num, Q15n16 value) |
Set the target1 level of the MultiLine. More... | |
void | setTargetTime (uint8_t phase_num, unsigned int msec) |
Set the target levels. More... | |
void | setTargetUpdateSteps (uint8_t phase_num, unsigned int steps) |
Set the target1, target2 and target4 times of the MultiLine in milliseconds. More... | |
bool | playing () |
Set the target1, target2 and target4 times of the MultiLine, expressed in update steps (not MultiLine::next() interpolation steps). More... | |
A simple MultiLine envelope generator.
This implementation has separate update() and next() methods, where next() interpolates values between each update(). The "normal" way to use this would be with update() in updateControl(), where it calculates a new internal state each control step, and then next() is in updateAudio(), called much more often, where it interpolates between the control values. This also allows the MultiLine updates to be made even more sparsely if desired, eg. every 3rd control update.
CONTROL_UPDATE_RATE | The frequency of control updates. Ordinarily this will be CONTROL_RATE, but an alternative (amongst others) is to set this as well as the LERP_RATE parameter to AUDIO_RATE, and call both update() and next() in updateAudio(). Such a use would allow accurate envelopes with finer resolution of the control points than CONTROL_RATE. |
LERP_RATE | Sets how often next() will be called, to interpolate between updates set by CONTROL_UPDATE_RATE. This will produce the smoothest results if it's set to AUDIO_RATE, but if you need to save processor time and your envelope changes slowly or controls something like a filter where there may not be problems with glitchy or clicking transitions, LERP_RATE could be set to CONTROL_RATE (for instance). Then update() and next() could both be called in updateControl(), greatly reducing the amount of processing required compared to calling next() in updateAudio(). |
This implementation has separate update() and next() methods, where next() interpolates values between each update(). The "normal" way to use this would be with update() in updateControl(), where it calculates a new internal state each control step, and then next() is in updateAudio(), called much more often, where it interpolates between the control values. This also allows the MultiLine updates to be made even more sparsely if desired, eg. every 3rd control update.
CONTROL_UPDATE_RATE | The frequency of control updates. Ordinarily this will be CONTROL_RATE, but an alternative (amongst others) is to set this as well as the LERP_RATE parameter to AUDIO_RATE, and call both update() and next() in updateAudio(). Such a use would allow accurate envelopes with finer resolution of the control points than CONTROL_RATE. |
LERP_RATE | Sets how often next() will be called, to interpolate between updates set by CONTROL_UPDATE_RATE. This will produce the smoothest results if it's set to AUDIO_RATE, but if you need to save processor time and your envelope changes slowly or controls something like a filter where there may not be problems with glitchy or clicking transitions, LERP_RATE could be set to CONTROL_RATE (for instance). Then update() and next() could both be called in updateControl(), greatly reducing the amount of processing required compared to calling next() in updateAudio(). |
Definition at line 45 of file MultiLine.h.
|
inline |
Advances one step along the MultiLine and returns the level.
Call this in updateAudio().
Definition at line 161 of file MultiLine.h.
|
inline |
Advances one step along the MultiLine and returns the level.
Call this in updateAudio().
Definition at line 172 of file MultiLine2.h.
|
inline |
Set the target1, target2 and target4 times of the MultiLine, expressed in update steps (not MultiLine::next() interpolation steps).
target1_steps | the number of update steps in the target1 phase |
target2_steps | the number of update steps in the target2 phase |
target3_steps | the number of update steps in the target3 phase |
target4_steps | the number of update steps in the target4 phase Tells if the envelope is currently playing. |
Definition at line 292 of file MultiLine2.h.
|
inline |
Tells if the envelope is currently playing.
Definition at line 403 of file MultiLine.h.
|
inline |
Set the target1, target2 and target4 times of the MultiLine, expressed in update steps (not MultiLine::next() interpolation steps).
target1_steps | the number of update steps in the target1 phase |
target2_steps | the number of update steps in the target2 phase |
target3_steps | the number of update steps in the target3 phase |
target4_steps | the number of update steps in the target4 phase |
Definition at line 388 of file MultiLine.h.
|
inline |
Set the target1, target2, target3 and target4 levels.
target1 | the new target1 level. |
target2 | the new target3 level. |
target1 | the new target3 level. |
target2 | the new target4 level. |
Definition at line 243 of file MultiLine.h.
|
inline |
Set the target1 level of the MultiLine.
value | the target1 level. |
Definition at line 191 of file MultiLine.h.
|
inline |
Set the target1 time of the MultiLine in milliseconds.
The actual time taken will be resolved within the resolution of CONTROL_RATE.
msec | the unsigned int target1 time in milliseconds. |
Definition at line 260 of file MultiLine.h.
|
inline |
Set the target1 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target1 phase.
steps | the number of times MultiLine::update() will be called in the target1 phase. |
Definition at line 339 of file MultiLine.h.
|
inline |
Set the target2 level of the MultiLine.
value | the target2 level. |
Definition at line 202 of file MultiLine.h.
|
inline |
Set the target2 time of the MultiLine in milliseconds.
The actual time taken will be resolved within the resolution of CONTROL_RATE.
msec | the unsigned int target2 time in milliseconds. |
Definition at line 273 of file MultiLine.h.
|
inline |
Set the target2 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target2 phase.
steps | the number of times MultiLine::update() will be called in the target2 phase. |
Definition at line 349 of file MultiLine.h.
|
inline |
Set the target3 level of the MultiLine.
value | the target3 level. Usually the same as the target2 level, for a steady target3ed note. |
Definition at line 213 of file MultiLine.h.
|
inline |
Set the target3 time of the MultiLine in milliseconds.
The actual time taken will be resolved within the resolution of CONTROL_RATE. The target3 phase will finish if the MultiLine recieves a stop().
msec | the unsigned int target3 time in milliseconds. |
Definition at line 287 of file MultiLine.h.
|
inline |
Set the target3 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target3 phase.
steps | the number of times MultiLine::update() will be called in the target3 phase. |
Definition at line 359 of file MultiLine.h.
|
inline |
Set the target4 level of the MultiLine.
Normally you'd make this 0, but you have the option of some other value.
value | the target4 level (usually 0). |
Definition at line 223 of file MultiLine.h.
|
inline |
Set the target4 time of the MultiLine in milliseconds.
The actual time taken will be resolved within the resolution of CONTROL_RATE.
msec | the unsigned int target4 time in milliseconds. |
Definition at line 301 of file MultiLine.h.
|
inline |
Set the target4 time of the MultiLine, expressed as the number of update steps (not MultiLine::next() interpolation steps) in the target4 phase.
steps | the number of times MultiLine::update() will be called in the target4 phase. |
Definition at line 369 of file MultiLine.h.
|
inline |
Set the target1 level of the MultiLine.
value | the target1 level. |
Definition at line 203 of file MultiLine2.h.
|
inline |
Set the target levels.
target1 | the new target1 level. |
target2 | the new target3 level. |
target1 | the new target3 level. |
target2 | the new target4 level. Set the target1 time of the MultiLine in milliseconds. The actual time taken will be resolved within the resolution of CONTROL_RATE. |
msec | the unsigned int target1 time in milliseconds. |
Definition at line 233 of file MultiLine2.h.
|
inline |
Set the target1, target2 and target4 times of the MultiLine in milliseconds.
The actual times will be resolved within the resolution of CONTROL_RATE.
target1_ms | the new target1 time in milliseconds. |
target2_ms | the new target2 time in milliseconds. |
target3_ms | the new target3 time in milliseconds. |
target4_ms | the new target4 time in milliseconds. |
steps | the number of times MultiLine::update() will be called in the target1 phase. |
Definition at line 264 of file MultiLine2.h.
|
inline |
Set the target1, target2 and target4 times of the MultiLine in milliseconds.
The actual times will be resolved within the resolution of CONTROL_RATE.
target1_ms | the new target1 time in milliseconds. |
target2_ms | the new target2 time in milliseconds. |
target3_ms | the new target3 time in milliseconds. |
target4_ms | the new target4 time in milliseconds. |
Definition at line 324 of file MultiLine.h.
|
inline |
Start the target1 phase of the MultiLine.
THis will restart the MultiLine no matter what phase it is up to.
Definition at line 171 of file MultiLine.h.
|
inline |
Start the target1 phase of the MultiLine.
THis will restart the MultiLine no matter what phase it is up to.
Definition at line 182 of file MultiLine2.h.
|
inline |
Start the target4 phase of the MultiLine.
Definition at line 181 of file MultiLine.h.
|
inline |
Start the target4 phase of the MultiLine.
Definition at line 193 of file MultiLine2.h.
|
inline |
Updates the internal controls of the MultiLine.
Call this in updateControl().
Definition at line 128 of file MultiLine.h.
|
inline |
Updates the internal controls of the MultiLine.
Call this in updateControl().
Definition at line 136 of file MultiLine2.h.