ZynAddSubFX/PADsynth/输入和输出
外观
< ZynAddSubFX | PADsynth
输入
N - wavetable size. It's recomanded to be a power of 2.
This is, usually, a big number (like 262144)
samplerate - the samplerate (e.g. 44100)
f - frequency of the fundamental note (e.g. 440)
bw - bandwidth of first harmonic in cents (e.g. 50 cents)
must be greater than zero
number_harmonics - the number of harmonics.
Of course, number_harmonics<(samplerate/f)
A[1..number_harmonics] - amplitude of the harmonics
输出
smp[0..N-1]- the generated wavetable
内部变量
freq_amp[0..N/2-1] = {0,0,0,0,...,0}
freq_phase[0..N/2-1]
etc...
函数
RND() returns a random value between 0 and 1
IFFT() is the inverse fourier transform
normalize_sample() normalizes samples
profile(fi,bwi){
x=fi/bwi;
return exp(-x*x)/bwi;
};
步骤
FOR nh = 1 to number_harmonics
bw_Hz=(pow(2,bw/1200)-1.0)*f*nh;
bwi=bw_Hz/(2.0*samplerate);
fi=f*nh/samplerate;
FOR i=0 to N/2-1
hprofile=profile((i/N)-fi,bwi);
freq_amp[i]=freq_amp[i]+hprofile*A[nh];
ENDFOR
ENDFOR
FOR i=0 to N/2-1
freq_phase[i]=RND()*2*PI;
ENDFOR
smp=IFFT(N,freq_amp,freq_phase);
normalize_sample(N,smp);
OUTPUT smp
扩展算法与基本算法之间的差异很小:有一个额外的参数
- bwscale: 指定谐波带宽根据其频率增加的程度。
- 此外,还定义了一个名为 relF(N) 的函数,它返回第 N 个泛音的相对频率。它允许生成失谐的谐波,甚至金属声音(如钟声)。
基本算法的差异在于 bw_Hz 和 fi 的计算
bw_Hz=(pow(2.0,bw/1200.0)-1.0)*f*pow(relF(nh),bwscale); fi=f*relF(nh)/samplerate;
如果 relF(N) 函数返回 N 且 bwscale 等于 1,则此算法将等效于基本算法。
(基本算法) freq_amp 数组的图表,用于 N=262144、f=500 Hz、bw=100 厘、采样率=44.1 kHz 和 A[],其中 A[n]=1.0/sqrt(n)
| 整个数组 | 数组特写 |
|
|
|
| 无法播放此文件?请参阅 媒体帮助。 | |
