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)
| 整個陣列 | 陣列特寫 |
|
|
|
| 無法播放此檔案?請參閱 媒體幫助。 | |
