Paul Batchelorimporta901d566 years agoHistory
55 lines · 1.0 KB · C
RawDownload
/* This code is placed in the public domain. */ #include <stdlib.h>#include <math.h>#include "soundpipe.h" int sp_tenvx_create(sp_tenvx **p){    *p = malloc(sizeof(sp_tenvx));    return SP_OK;} int sp_tenvx_destroy(sp_tenvx **p){    free(*p);    return SP_OK;}  int sp_tenvx_init(sp_data *sp, sp_tenvx *p){    p->hold = 0.5;    p->atk = 0.5;    p->rel = 0.5;    p->a_a = p->b_a = 0;    p->a_r = p->b_r = 0;    p->y = 0;    p->count = (uint32_t) (p->hold * sp->sr);    return SP_OK;}  int sp_tenvx_compute(sp_data *sp, sp_tenvx *p, SPFLOAT *in, SPFLOAT *out){    *out = 0;     if(*in != 0) {        p->a_a = exp(-1.0/(p->atk * sp->sr));        p->b_a = 1.0 - p->a_a;        p->a_r = exp(-1.0/(p->rel * sp->sr));        p->b_r = 1.0 - p->a_r;        p->count = (uint32_t) (p->hold * sp->sr);    }     if(p->count > 0) {        *out = p->b_a + p->a_a * p->y;        p->y = *out;        p->count--;    } else {        *out = p->a_r * p->y;        p->y = *out;    }     return SP_OK;}

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