📄 digital_audio.c
字号:
/* allpass.c - allpass reverberator with circular delay line */
double tap();
void cdelay();
double allpass(D, w, p, a, x) /* usage: y=allpass(D,w,&p,a,x); */
double *w, **p, a, x; /* \(p\) is passed by address */
int D;
{
double y, s0, sD;
sD = tap(D, w, *p, D); /* \(D\)th tap delay output */
s0 = x + a * sD;
y = -a * s0 + sD; /* filter output */
**p = s0; /* delay input */
cdelay(D, w, p); /* update delay line */
return y;
}
/* lowpass.c - lowpass reverberator with feedback filter G(z) */
double tap(), can();
void cdelay();
double lowpass(D, w, p, M, a, b, v, x)
double *w, **p, *a, *b, *v, x; /* \(v\) = state vector for \(G(z)\) */
int D; /* \(a,b,v\) are \((M+1)\)-dimensional */
{
double y, sD;
sD = tap(D, w, *p, D); /* delay output is \(G(z)\) input */
y = x + can(M, a, M, b, v, sD); /* reverb output */
**p = y; /* delay input */
cdelay(D, w, p); /* update delay line */
return y;
}
/* plain.c - plain reverberator with circular delay line */
double tap();
void cdelay();
double plain(D, w, p, a, x) /* usage: y=plain(D,w,&p,a,x); */
double *w, **p, a, x; /* \(p\) is passed by address */
int D;
{
double y, sD;
sD = tap(D, w, *p, D); /* \(D\)th tap delay output */
y = x + a * sD; /* filter output */
**p = y; /* delay input */
cdelay(D, w, p); /* update delay line */
return y;
}
/* tapi.c - interpolated tap output of a delay line */
double tap();
double tapi(D, w, p, d) /* usage: sd = tapi(D, w, p, d); */
double *w, *p, d; /* \(d\) = desired non-integer delay */
int D; /* \(p\) = circular pointer to \(w\) */
{
int i, j;
double si, sj;
i = (int) d; /* interpolate between \(s\sb{i}\) and \(s\sb{j}\) */
j = (i+1) % (D+1); /* if \(i=D\), then \(j=0\); otherwise, \(j=i+1\) */
si = tap(D, w, p, i); /* note, \(s\sb{i}(n) = x(n-i)\) */
sj = tap(D, w, p, j); /* note, \(s\sb{j}(n) = x(n-j)\) */
return si + (d - i) * (sj - si);
}
/* tapi2.c - interpolated tap output of a delay line */
double tap2();
double tapi2(D, w, q, d) /* usage: sd = tapi2(D, w, q, d); */
double *w, d; /* \(d\) = desired non-integer delay */
int D, q; /* \(q\) = circular offset index */
{
int i, j;
double si, sj;
i = (int) d; /* interpolate between \(s\sb{i}\) and \(s\sb{j}\) */
j = (i+1) % (D+1); /* if \(i=D\), then \(j=0\); otherwise, \(j=i+1\) */
si = tap2(D, w, q, i); /* note, \(s\sb{i}(n) = x(n-i)\) */
sj = tap2(D, w, q, j); /* note, \(s\sb{j}(n) = x(n-j)\) */
return si + (d - i) * (sj - si);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -