History

added leak to ADSR

spiricom committed 6 years ago

Commit 8ea545c1 parent 6447d014 files · +15 −-2Browse files

Unified · Split

4 files
  1. .DS_Store +0 −0
  2. LEAF/.DS_Store +0 −0
  3. LEAF/Inc/leaf-envelopes.h +2 −0
  4. LEAF/Src/leaf-envelopes.c +15 −0
.DS_Store+0−0

Binary file not shown.

LEAF/.DS_Store+0−0

Binary file not shown.

LEAF/Inc/leaf-envelopes.h+2−0
@@ -104,6 +104,7 @@ extern "C" { · 103 unmodified lines
104104
105105 float attackPhase, decayPhase, releasePhase, rampPhase;
106106
107+ float leakFactor;
107108
108109
109110 } _tADSR;
@@ -120,6 +121,7 @@ extern "C" { · 10 unmodified lines
120121 void tADSR_setDecay (tADSR* const, float decay);
121122 void tADSR_setSustain (tADSR* const, float sustain);
122123 void tADSR_setRelease (tADSR* const, float release);
124+ void tADSR_setLeakFactor (tADSR* const, float leakFactor);
123125 void tADSR_on (tADSR* const, float velocity);
124126 void tADSR_off (tADSR* const);
125127
LEAF/Src/leaf-envelopes.c+15−0
@@ -309,6 +309,8 @@ void tADSR_init(tADSR* const adsrenv, float attack, float decay, float sustai · 308 unmodified lines
309309 adsr->releaseInc = adsr->inc_buff[releaseIndex];
310310 adsr->rampInc = adsr->inc_buff[rampIndex];
311311
312+ adsr->leakFactor = 1.0f;
313+
312314 }
313315
314316 void tADSR_free(tADSR* const adsrenv)
@@ -374,6 +376,7 @@ void tADSR_initToPool (tADSR* const adsrenv, float attack, float decay, fl · 59 unmodified lines
374376 adsr->releaseInc = adsr->inc_buff[releaseIndex];
375377 adsr->rampInc = adsr->inc_buff[rampIndex];
376378
379+ adsr->leakFactor = 1.0f;
377380 }
378381
379382 void tADSR_freeFromPool (tADSR* const adsrenv, tMempool* const mp)
@@ -443,7 +446,14 @@ void tADSR_setRelease(tADSR* const adsrenv, float release) · 63 unmodified lines
443446 adsr->releaseInc = adsr->inc_buff[releaseIndex];
444447 }
445448
449+// 0.999999 is slow leak, 0.9 is fast leak
450+void tADSR_setLeakFactor(tADSR* const adsrenv, float leakFactor)
451+{
452+ _tADSR* adsr = *adsrenv;
453+
446454
455+ adsr->leakFactor = leakFactor;
456+}
447457
448458 void tADSR_on(tADSR* const adsrenv, float velocity)
449459 {
@@ -545,6 +555,11 @@ float tADSR_tick(tADSR* const adsrenv) · 95 unmodified lines
545555 adsr->decayPhase += adsr->decayInc;
546556 }
547557
558+ if (adsr->inSustain)
559+ {
560+ adsr->next = adsr->next * adsr->leakFactor;
561+ }
562+
548563 if (adsr->inRelease)
549564 {
550565 // If release done, finish.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t