11 #ifndef LEAF_ENVELOPES_H_INCLUDED
12 #define LEAF_ENVELOPES_H_INCLUDED
20 #include "leaf-math.h"
21 #include "leaf-mempool.h"
22 #include "leaf-filters.h"
23 #include "leaf-delay.h"
24 #include "leaf-analysis.h"
25 #include "leaf-envelopes.h"
79 typedef struct _tEnvelope
84 const float *exp_buff;
85 const float *inc_buff;
90 float attackInc, decayInc, rampInc;
92 int inAttack, inDecay, inRamp;
98 float attackPhase, decayPhase, rampPhase;
102 typedef _tEnvelope* tEnvelope;
104 void tEnvelope_init (tEnvelope*
const,
float attack,
float decay,
int loop,
LEAF*
const leaf);
105 void tEnvelope_initToPool (tEnvelope*
const,
float attack,
float decay,
int loop, tMempool*
const);
163 typedef struct _tExpSmooth
167 float factor, oneminusfactor;
171 typedef _tExpSmooth* tExpSmooth;
244 typedef struct _tADSR
249 const float *exp_buff;
250 const float *inc_buff;
255 float attackInc, decayInc, releaseInc, rampInc;
257 int inAttack, inDecay, inSustain, inRelease, inRamp;
259 float sustain, gain, rampPeak, releasePeak;
261 float attackPhase, decayPhase, releasePhase, rampPhase;
266 typedef _tADSR* tADSR;
268 void tADSR_init (tADSR*
const adsrenv,
float attack,
float decay,
float sustain,
float release,
LEAF*
const leaf);
269 void tADSR_initToPool (tADSR*
const adsrenv,
float attack,
float decay,
float sustain,
float release, tMempool*
const mp);
278 void tADSR_on (tADSR*
const,
float velocity);
337 typedef struct _tADSR2
341 float sampleRateInMs;
351 float targetGainSquared;
353 float oneMinusFactor;
361 typedef _tADSR2* tADSR2;
363 void tADSR2_init (tADSR2*
const,
float attack,
float decay,
float sustain,
float release,
LEAF*
const leaf);
364 void tADSR2_initToPool (tADSR2*
const,
float attack,
float decay,
float sustain,
float release, tMempool*
const);
373 void tADSR2_on (tADSR2*
const,
float velocity);
442 typedef struct _tADSR3
446 float sampleRateInMs;
462 float targetGainSquared;
464 float oneMinusFactor;
469 typedef _tADSR3* tADSR3;
471 void tADSR3_init (tADSR3*
const,
float attack,
float decay,
float sustain,
float release,
LEAF*
const leaf);
472 void tADSR3_initToPool (tADSR3*
const,
float attack,
float decay,
float sustain,
float release, tMempool*
const);
481 void tADSR3_on (tADSR3*
const,
float velocity);
544 typedef struct _tADSR4
548 const float *exp_buff;
550 uint32_t buff_sizeMinusOne;
551 float bufferSizeDividedBySampleRateInMs;
554 float attackInc, decayInc, releaseInc, rampInc;
558 float sustain, gain, rampPeak, releasePeak;
560 float attackPhase, decayPhase, releasePhase, rampPhase;
565 typedef _tADSR4* tADSR4;
567 void tADSR4_init (tADSR4*
const,
float attack,
float decay,
float sustain,
float release,
float* expBuffer,
int bufferSize,
LEAF*
const leaf);
568 void tADSR4_initToPool (tADSR4*
const,
float attack,
float decay,
float sustain,
float release,
float* expBuffer,
int bufferSize, tMempool*
const);
578 void tADSR4_on (tADSR4*
const,
float velocity);
625 typedef struct _tRamp
635 int samples_per_tick;
638 typedef _tRamp* tRamp;
640 void tRamp_init (tRamp*
const,
float time,
int samplesPerTick,
LEAF*
const leaf);
641 void tRamp_initToPool (tRamp*
const,
float time,
int samplesPerTick, tMempool*
const);
696 typedef struct _tRampUpDown
707 int samples_per_tick;
710 typedef _tRampUpDown* tRampUpDown;
712 void tRampUpDown_init (tRampUpDown*
const,
float upTime,
float downTime,
int samplesPerTick,
LEAF*
const leaf);
713 void tRampUpDown_initToPool (tRampUpDown*
const,
float upTime,
float downTime,
int samplesPerTick, tMempool*
const);
767 typedef struct _tSlide
779 typedef _tSlide* tSlide;
781 void tSlide_init (tSlide*
const,
float upSlide,
float downSlide,
LEAF*
const leaf);
782 void tSlide_initToPool (tSlide*
const,
float upSlide,
float downSlide, tMempool*
const);
795 #endif // LEAF_ENVELOPES_H_INCLUDED
float tADSR4_tick(tADSR4 *const)
Definition: leaf-envelopes.c:949
void tRampUpDown_setDest(tRampUpDown *const, float dest)
Definition: leaf-envelopes.c:1338
float tRamp_tick(tRamp *const)
Definition: leaf-envelopes.c:1225
void tADSR2_init(tADSR2 *const, float attack, float decay, float sustain, float release, LEAF *const leaf)
Initialize a tADSR2 to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:502
void tSlide_setDownSlide(tSlide *const sl, float downSlide)
Definition: leaf-envelopes.c:1514
void tADSR4_setLeakFactor(tADSR4 *const, float leakFactor)
Definition: leaf-envelopes.c:905
void tADSR3_init(tADSR3 *const, float attack, float decay, float sustain, float release, LEAF *const leaf)
Initialize a tADSR3 to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:658
void tSlide_init(tSlide *const, float upSlide, float downSlide, LEAF *const leaf)
Initialize a tSlide to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:1473
void tADSR_setAttack(tADSR *const, float attack)
Definition: leaf-envelopes.c:292
void tADSR3_off(tADSR3 *const)
Definition: leaf-envelopes.c:754
void tADSR3_setRelease(tADSR3 *const, float release)
Definition: leaf-envelopes.c:730
void tExpSmooth_setValAndDest(tExpSmooth *const expsmooth, float val)
Definition: leaf-envelopes.c:1450
void tADSR4_setDecay(tADSR4 *const, float decay)
Definition: leaf-envelopes.c:873
void tADSR2_setRelease(tADSR2 *const, float release)
Definition: leaf-envelopes.c:576
void tADSR3_setLeakFactor(tADSR3 *const, float leakFactor)
Definition: leaf-envelopes.c:740
void tADSR_off(tADSR *const)
Definition: leaf-envelopes.c:385
void tADSR2_setLeakFactor(tADSR2 *const, float leakFactor)
Definition: leaf-envelopes.c:584
void tExpSmooth_setFactor(tExpSmooth *const, float factor)
Definition: leaf-envelopes.c:1426
void tSlide_initToPool(tSlide *const, float upSlide, float downSlide, tMempool *const)
Initialize a tSlide to a specified mempool.
Definition: leaf-envelopes.c:1478
void tRampUpDown_setUpTime(tRampUpDown *const, float upTime)
Definition: leaf-envelopes.c:1307
void tEnvelope_initToPool(tEnvelope *const, float attack, float decay, int loop, tMempool *const)
Initialize a tEnvelope to a specified mempool.
Definition: leaf-envelopes.c:33
void tADSR4_setAttack(tADSR4 *const, float attack)
Definition: leaf-envelopes.c:861
void tRampUpDown_setVal(tRampUpDown *const, float val)
Definition: leaf-envelopes.c:1346
void tADSR_setRelease(tADSR *const, float release)
Definition: leaf-envelopes.c:335
float tRamp_sample(tRamp *const)
Definition: leaf-envelopes.c:1240
float tADSR3_tick(tADSR3 *const)
Definition: leaf-envelopes.c:764
void tSlide_setUpSlide(tSlide *const sl, float upSlide)
Definition: leaf-envelopes.c:1508
float tExpSmooth_sample(tExpSmooth *const)
Definition: leaf-envelopes.c:1464
void tADSR2_free(tADSR2 *const)
Free a tADSR2 from its mempool.
Definition: leaf-envelopes.c:540
void tSlide_setDest(tSlide *const sl, float dest)
Definition: leaf-envelopes.c:1520
float tEnvelope_tick(tEnvelope *const)
Definition: leaf-envelopes.c:144
void tADSR_on(tADSR *const, float velocity)
Definition: leaf-envelopes.c:361
float tSlide_tickNoInput(tSlide *const sl)
Definition: leaf-envelopes.c:1526
void tADSR4_setSustain(tADSR4 *const, float sustain)
Definition: leaf-envelopes.c:884
void tRamp_init(tRamp *const, float time, int samplesPerTick, LEAF *const leaf)
Initialize a tRamp to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:1156
void tRampUpDown_init(tRampUpDown *const, float upTime, float downTime, int samplesPerTick, LEAF *const leaf)
Initialize a tRampUpDown to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:1259
void tADSR2_off(tADSR2 *const)
Definition: leaf-envelopes.c:601
void tRampUpDown_setDownTime(tRampUpDown *const, float downTime)
Definition: leaf-envelopes.c:1323
void tEnvelope_setDecay(tEnvelope *const, float decay)
Definition: leaf-envelopes.c:98
void tADSR4_init(tADSR4 *const, float attack, float decay, float sustain, float release, float *expBuffer, int bufferSize, LEAF *const leaf)
Initialize a tADSR4 to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:806
void tADSR2_setSustain(tADSR2 *const, float sustain)
Definition: leaf-envelopes.c:562
void tRamp_setVal(tRamp *const, float val)
Definition: leaf-envelopes.c:1218
void tRampUpDown_free(tRampUpDown *const)
Free a tRampUpDown from its mempool.
Definition: leaf-envelopes.c:1300
void tADSR_setDecay(tADSR *const, float decay)
Definition: leaf-envelopes.c:309
void tRamp_free(tRamp *const)
Free a tRamp from its mempool.
Definition: leaf-envelopes.c:1187
void tRamp_setTime(tRamp *const, float time)
Definition: leaf-envelopes.c:1194
void tADSR3_initToPool(tADSR3 *const, float attack, float decay, float sustain, float release, tMempool *const)
Initialize a tADSR3 to a specified mempool.
Definition: leaf-envelopes.c:663
void tADSR4_off(tADSR4 *const)
Definition: leaf-envelopes.c:934
void tEnvelope_setAttack(tEnvelope *const, float attack)
Definition: leaf-envelopes.c:81
void tADSR_init(tADSR *const adsrenv, float attack, float decay, float sustain, float release, LEAF *const leaf)
Initialize a tADSR to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:219
float tSlide_tick(tSlide *const, float in)
Definition: leaf-envelopes.c:1548
void tExpSmooth_setVal(tExpSmooth *const, float val)
Definition: leaf-envelopes.c:1444
void tRampUpDown_initToPool(tRampUpDown *const, float upTime, float downTime, int samplesPerTick, tMempool *const)
Initialize a tRampUpDown to a specified mempool.
Definition: leaf-envelopes.c:1264
float tRampUpDown_tick(tRampUpDown *const)
Definition: leaf-envelopes.c:1354
void tADSR3_setDecay(tADSR3 *const, float decay)
Definition: leaf-envelopes.c:713
void tADSR2_initToPool(tADSR2 *const, float attack, float decay, float sustain, float release, tMempool *const)
Initialize a tADSR2 to a specified mempool.
Definition: leaf-envelopes.c:507
float tADSR_tick(tADSR *const)
Definition: leaf-envelopes.c:399
void tADSR_setSustain(tADSR *const, float sustain)
Definition: leaf-envelopes.c:326
void tEnvelope_init(tEnvelope *const, float attack, float decay, int loop, LEAF *const leaf)
Initialize a tEnvelope to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:28
void tADSR_free(tADSR *const)
Free a tADSR from its mempool.
Definition: leaf-envelopes.c:286
void tADSR4_on(tADSR4 *const, float velocity)
Definition: leaf-envelopes.c:913
void tADSR3_free(tADSR3 *const)
Free a tADSR3 from its mempool.
Definition: leaf-envelopes.c:698
void tExpSmooth_initToPool(tExpSmooth *const, float val, float factor, tMempool *const)
Initialize a tExpSmooth to a specified mempool.
Definition: leaf-envelopes.c:1405
void tADSR_initToPool(tADSR *const adsrenv, float attack, float decay, float sustain, float release, tMempool *const mp)
Initialize a tADSR to a specified mempool.
Definition: leaf-envelopes.c:224
void tExpSmooth_setDest(tExpSmooth *const, float dest)
Definition: leaf-envelopes.c:1438
float tADSR2_tick(tADSR2 *const)
Definition: leaf-envelopes.c:608
void tADSR2_setAttack(tADSR2 *const, float attack)
Definition: leaf-envelopes.c:546
void tADSR2_setDecay(tADSR2 *const, float decay)
Definition: leaf-envelopes.c:554
void tRamp_setDest(tRamp *const, float dest)
Definition: leaf-envelopes.c:1211
void tEnvelope_free(tEnvelope *const)
Free a tEnvelope from its mempool.
Definition: leaf-envelopes.c:75
float tExpSmooth_tick(tExpSmooth *const)
Definition: leaf-envelopes.c:1457
void tADSR3_on(tADSR3 *const, float velocity)
Definition: leaf-envelopes.c:747
void tRamp_initToPool(tRamp *const, float time, int samplesPerTick, tMempool *const)
Initialize a tRamp to a specified mempool.
Definition: leaf-envelopes.c:1161
void tExpSmooth_init(tExpSmooth *const, float val, float factor, LEAF *const leaf)
Initialize a tExpSmooth to the default mempool of a LEAF instance.
Definition: leaf-envelopes.c:1400
void tADSR4_free(tADSR4 *const)
Free a tADSR4 from its mempool.
Definition: leaf-envelopes.c:855
void tADSR2_on(tADSR2 *const, float velocity)
Definition: leaf-envelopes.c:591
void tADSR4_initToPool(tADSR4 *const, float attack, float decay, float sustain, float release, float *expBuffer, int bufferSize, tMempool *const)
Initialize a tADSR4 to a specified mempool.
Definition: leaf-envelopes.c:813
void tADSR_setLeakFactor(tADSR *const, float leakFactor)
Definition: leaf-envelopes.c:353
void tADSR4_setRelease(tADSR4 *const, float release)
Definition: leaf-envelopes.c:893
void tEnvelope_loop(tEnvelope *const, int loop)
Definition: leaf-envelopes.c:115
float tRampUpDown_sample(tRampUpDown *const)
Definition: leaf-envelopes.c:1388
void tSlide_free(tSlide *const)
Free a tSlide from its mempool.
Definition: leaf-envelopes.c:1501
Struct for an instance of LEAF.
Definition: leaf-global.h:31
float tADSR4_tickNoInterp(tADSR4 *const adsrenv)
Definition: leaf-envelopes.c:1074
void tADSR3_setAttack(tADSR3 *const, float attack)
Definition: leaf-envelopes.c:704
void tEnvelope_on(tEnvelope *const, float velocity)
Definition: leaf-envelopes.c:122
void tADSR3_setSustain(tADSR3 *const, float sustain)
Definition: leaf-envelopes.c:722
void tExpSmooth_free(tExpSmooth *const)
Free a tExpSmooth from its mempool.
Definition: leaf-envelopes.c:1419