我一直在嘗試調頻合成製作音頻文件,並使用ADSR包絡來塑造最終的聲音。 FM 表示調頻。ADSR 表示 Attack、Decay、Sustain 和 Release。 ADSR 描述了一條曲線,該曲線確定按下琴鍵時音符音量增加(起音)和減小(衰減)的速度、按住琴鍵時的持續音量以及鬆開琴鍵時音符音量的衰減方式。 ADSR 曲線的典型圖片有四條直線:
A, D, R are time; S is a levelA, D, R are time; S is a levelA, D, R are time; S is a levelA, D, R are time; S is a levelA、D、R為時間; S是一個級別
下面的波形沒有調製(所有的波峰和波谷都是等距的。)
如果您查看圖表中第一個週期的頂部,您會看到一個小故障。 由於我正在編寫代碼,所以我認為我犯了一個錯誤;縮放它會使它看起來像是一個可能會稍微影響聲音的重大錯誤。
Actually, two glitchesActually, two glitchesActually, two glitchesActually, two glitches其實有兩個漏洞
攻擊設置為 0.001 秒,衰減為 0.003;每秒 44,100 個樣本時,攻擊在樣本 44 處結束,衰減在樣本 176 附近結束。 我建立了一個數據表來製作一個簡化版本,最終發現毛刺是由 ADSR 曲線中的尖角引起的。 為了修復它,我將樣條擬合到 ADSR 曲線。 只要樣條線的張力足夠高,故障就非常微妙,不易察覺。 (這是簡化的數據,不是您在上面和下面聽到的數據。)
The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.The orange spline-based curves are hiding behind the purple curves; at this zoom they are nearly identical.橙色樣條曲線隱藏在紫色曲線後面;在此變焦下,它們幾乎完全相同。
在衰減和維持曲線之間的拐角處放大一點:
The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)The solid sine curve is rising, but slowing. The dotted purple decay curve is falling, but about to become flat (sustain.)實心正弦曲線正在上升,但正在放緩。 虛線紫色衰減曲線正在下降,但即將變平(持續)
橙色虛線是紫色虛線中各點的樣條插值。 橙色實線是原始正弦波乘以橙色包絡以按比例縮小。 紫色曲線的誤差似乎約為千分之一;我不確定那是否會被聽到。 在波形文件數據的 +/- 32767 範圍內,大約是 32、2^5,可能在 16 位數的第 5 位,可能降低 60 dB。 我認為用好的設備和年輕的耳朵應該可以聽到。
放大看,像很好地失真的正弦波。
The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.The glitch is gone. The leading part of the sine wave is flattened by the rising gain of the attack.故障消失了。 正弦波的前導部分因攻擊增益的上升而變平。
附上文件。 在 Windows 上,它使用多媒體 DLL 中的 PlaySound。 頂部有幾個開關。 它沒有使用任何 FM 代碼,我想得越多,它可能實現的是相位調製而不是頻率調製。 除了這個演示,它還沒有準備好。