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
104 104
105 float attackPhase, decayPhase, releasePhase, rampPhase;105 float attackPhase, decayPhase, releasePhase, rampPhase;
106 106
107 float leakFactor;
107 108
108 109
109 } _tADSR;110 } _tADSR;
@@ -120,6 +121,7 @@ extern "C" { · 10 unmodified lines
120 void tADSR_setDecay (tADSR* const, float decay);121 void tADSR_setDecay (tADSR* const, float decay);
121 void tADSR_setSustain (tADSR* const, float sustain);122 void tADSR_setSustain (tADSR* const, float sustain);
122 void tADSR_setRelease (tADSR* const, float release);123 void tADSR_setRelease (tADSR* const, float release);
124 void tADSR_setLeakFactor (tADSR* const, float leakFactor);
123 void tADSR_on (tADSR* const, float velocity);125 void tADSR_on (tADSR* const, float velocity);
124 void tADSR_off (tADSR* const);126 void tADSR_off (tADSR* const);
125 127
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
309 adsr->releaseInc = adsr->inc_buff[releaseIndex];309 adsr->releaseInc = adsr->inc_buff[releaseIndex];
310 adsr->rampInc = adsr->inc_buff[rampIndex];310 adsr->rampInc = adsr->inc_buff[rampIndex];
311 311
312 adsr->leakFactor = 1.0f;
313
312}314}
313 315
314void tADSR_free(tADSR* const adsrenv)316void tADSR_free(tADSR* const adsrenv)
@@ -374,6 +376,7 @@ void tADSR_initToPool (tADSR* const adsrenv, float attack, float decay, fl · 59 unmodified lines
374 adsr->releaseInc = adsr->inc_buff[releaseIndex];376 adsr->releaseInc = adsr->inc_buff[releaseIndex];
375 adsr->rampInc = adsr->inc_buff[rampIndex];377 adsr->rampInc = adsr->inc_buff[rampIndex];
376 378
379 adsr->leakFactor = 1.0f;
377}380}
378 381
379void tADSR_freeFromPool (tADSR* const adsrenv, tMempool* const mp)382void tADSR_freeFromPool (tADSR* const adsrenv, tMempool* const mp)
@@ -443,7 +446,14 @@ void tADSR_setRelease(tADSR* const adsrenv, float release) · 63 unmodified lines
443 adsr->releaseInc = adsr->inc_buff[releaseIndex];446 adsr->releaseInc = adsr->inc_buff[releaseIndex];
444}447}
445 448
449// 0.999999 is slow leak, 0.9 is fast leak
450void tADSR_setLeakFactor(tADSR* const adsrenv, float leakFactor)
451{
452 _tADSR* adsr = *adsrenv;
453
446 454
455 adsr->leakFactor = leakFactor;
456}
447 457
448void tADSR_on(tADSR* const adsrenv, float velocity)458void tADSR_on(tADSR* const adsrenv, float velocity)
449{459{
@@ -545,6 +555,11 @@ float tADSR_tick(tADSR* const adsrenv) · 95 unmodified lines
545 adsr->decayPhase += adsr->decayInc;555 adsr->decayPhase += adsr->decayInc;
546 }556 }
547 557
558 if (adsr->inSustain)
559 {
560 adsr->next = adsr->next * adsr->leakFactor;
561 }
562
548 if (adsr->inRelease)563 if (adsr->inRelease)
549 {564 {
550 // If release done, finish.565 // 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